Support multiple filenames on command line.

Should work fine, although I doubt anyone would use it.
This commit is contained in:
Přemysl Eric Janouch 2012-10-09 18:03:28 +02:00
parent f21395779a
commit 0066917014
3 changed files with 25 additions and 7 deletions

View File

@ -7,7 +7,7 @@ GenericName[sk]=Editor schém
GenericName[pl]=Edytor schematów GenericName[pl]=Edytor schematów
GenericName[de]=Schema Editor GenericName[de]=Schema Editor
Icon=logdiag Icon=logdiag
Exec=logdiag %f Exec=logdiag %F
StartupNotify=true StartupNotify=true
MimeType=application/x-logdiag-diagram; MimeType=application/x-logdiag-diagram;
Categories=Graphics;VectorGraphics;Electricity;Engineering;GTK; Categories=Graphics;VectorGraphics;Electricity;Engineering;GTK;

View File

@ -316,7 +316,6 @@ ld_window_main_init (LdWindowMain *self)
gtk_container_add (GTK_CONTAINER (self), priv->vbox); gtk_container_add (GTK_CONTAINER (self), priv->vbox);
/* Configure the window. */ /* 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); g_signal_connect (self, "delete-event", G_CALLBACK (on_delete), NULL);
gtk_window_add_accel_group (GTK_WINDOW (self), gtk_window_add_accel_group (GTK_WINDOW (self),

View File

@ -76,14 +76,33 @@ get_utf8_args_fail:
} }
#endif #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 int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
gchar **files = NULL; gchar **iter, **files = NULL;
GOptionEntry option_entries[] = GOptionEntry option_entries[] =
{ {
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &files, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
NULL, N_("[FILE]")}, NULL, N_("[FILE...]")},
{NULL} {NULL}
}; };
@ -142,14 +161,14 @@ main (int argc, char *argv[])
gtk_window_set_default_icon_name (PROJECT_NAME); gtk_window_set_default_icon_name (PROJECT_NAME);
/* TODO: Be able to open multiple files. */
if (files) if (files)
{ {
ld_window_main_new (files[0]); for (iter = files; *iter; iter++)
window_create (*iter);
g_strfreev (files); g_strfreev (files);
} }
else else
ld_window_main_new (NULL); window_create (NULL);
gtk_main (); gtk_main ();
return 0; return 0;