Browse Source

Support multiple filenames on command line.

Should work fine, although I doubt anyone would use it.
Přemysl Janouch 6 years ago
parent
commit
0066917014
3 changed files with 25 additions and 7 deletions
  1. 1
    1
      share/logdiag.desktop
  2. 0
    1
      src/ld-window-main.c
  3. 24
    5
      src/logdiag.c

+ 1
- 1
share/logdiag.desktop View File

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

+ 0
- 1
src/ld-window-main.c View File

@@ -316,7 +316,6 @@ ld_window_main_init (LdWindowMain *self)
316 316
 	gtk_container_add (GTK_CONTAINER (self), priv->vbox);
317 317
 
318 318
 	/* Configure the window. */
319
-	g_signal_connect (self, "destroy", G_CALLBACK (gtk_main_quit), NULL);
320 319
 	g_signal_connect (self, "delete-event", G_CALLBACK (on_delete), NULL);
321 320
 
322 321
 	gtk_window_add_accel_group (GTK_WINDOW (self),

+ 24
- 5
src/logdiag.c View File

@@ -76,14 +76,33 @@ get_utf8_args_fail:
76 76
 }
77 77
 #endif
78 78
 
79
+static gint ld_active_windows = 0;
80
+
81
+static void
82
+window_on_destroyed (GtkObject *object, gpointer user_data)
83
+{
84
+	if (--ld_active_windows <= 0)
85
+		gtk_main_quit ();
86
+}
87
+
88
+static void
89
+window_create (const gchar *file)
90
+{
91
+	GtkWidget *wm;
92
+
93
+	wm = ld_window_main_new (file);
94
+	g_signal_connect (wm, "destroy", G_CALLBACK (window_on_destroyed), NULL);
95
+	ld_active_windows++;
96
+}
97
+
79 98
 int
80 99
 main (int argc, char *argv[])
81 100
 {
82
-	gchar **files = NULL;
101
+	gchar **iter, **files = NULL;
83 102
 	GOptionEntry option_entries[] =
84 103
 	{
85 104
 		{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
86
-			NULL, N_("[FILE]")},
105
+			NULL, N_("[FILE...]")},
87 106
 		{NULL}
88 107
 	};
89 108
 
@@ -142,14 +161,14 @@ main (int argc, char *argv[])
142 161
 
143 162
 	gtk_window_set_default_icon_name (PROJECT_NAME);
144 163
 
145
-	/* TODO: Be able to open multiple files. */
146 164
 	if (files)
147 165
 	{
148
-		ld_window_main_new (files[0]);
166
+		for (iter = files; *iter; iter++)
167
+			window_create (*iter);
149 168
 		g_strfreev (files);
150 169
 	}
151 170
 	else
152
-		ld_window_main_new (NULL);
171
+		window_create (NULL);
153 172
 
154 173
 	gtk_main ();
155 174
 	return 0;

Loading…
Cancel
Save