summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2012-10-09 18:03:28 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2012-10-09 18:03:28 +0200
commit0066917014d32f80b70982b927ee5a6859b0cbd5 (patch)
tree7264ae4b166d4b6f625971148567c677a20f8026 /src
parentf21395779af8b93bd4f3a03d492319819580527c (diff)
downloadlogdiag-0066917014d32f80b70982b927ee5a6859b0cbd5.tar.gz
logdiag-0066917014d32f80b70982b927ee5a6859b0cbd5.tar.xz
logdiag-0066917014d32f80b70982b927ee5a6859b0cbd5.zip
Support multiple filenames on command line.
Should work fine, although I doubt anyone would use it.
Diffstat (limited to 'src')
-rw-r--r--src/ld-window-main.c1
-rw-r--r--src/logdiag.c29
2 files changed, 24 insertions, 6 deletions
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index 8b83852..da84244 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -316,7 +316,6 @@ ld_window_main_init (LdWindowMain *self)
gtk_container_add (GTK_CONTAINER (self), priv->vbox);
/* Configure the window. */
- g_signal_connect (self, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (self, "delete-event", G_CALLBACK (on_delete), NULL);
gtk_window_add_accel_group (GTK_WINDOW (self),
diff --git a/src/logdiag.c b/src/logdiag.c
index f6132c4..563ada2 100644
--- a/src/logdiag.c
+++ b/src/logdiag.c
@@ -76,14 +76,33 @@ get_utf8_args_fail:
}
#endif
+static gint ld_active_windows = 0;
+
+static void
+window_on_destroyed (GtkObject *object, gpointer user_data)
+{
+ if (--ld_active_windows <= 0)
+ gtk_main_quit ();
+}
+
+static void
+window_create (const gchar *file)
+{
+ GtkWidget *wm;
+
+ wm = ld_window_main_new (file);
+ g_signal_connect (wm, "destroy", G_CALLBACK (window_on_destroyed), NULL);
+ ld_active_windows++;
+}
+
int
main (int argc, char *argv[])
{
- gchar **files = NULL;
+ gchar **iter, **files = NULL;
GOptionEntry option_entries[] =
{
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
- NULL, N_("[FILE]")},
+ NULL, N_("[FILE...]")},
{NULL}
};
@@ -142,14 +161,14 @@ main (int argc, char *argv[])
gtk_window_set_default_icon_name (PROJECT_NAME);
- /* TODO: Be able to open multiple files. */
if (files)
{
- ld_window_main_new (files[0]);
+ for (iter = files; *iter; iter++)
+ window_create (*iter);
g_strfreev (files);
}
else
- ld_window_main_new (NULL);
+ window_create (NULL);
gtk_main ();
return 0;