Mercurial > geeqie.yaz
annotate src/main.c @ 377:9efefd85684a
Cleanup read/write of image.zoom_mode option.
author | zas_ |
---|---|
date | Tue, 15 Apr 2008 21:06:00 +0000 |
parents | 3556cc825e59 |
children | f1bdbbdb73ba |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
9 | 12 |
281 | 13 #include "main.h" |
9 | 14 |
15 #include "cache.h" | |
16 #include "collect.h" | |
17 #include "collect-io.h" | |
18 #include "dnd.h" | |
19 #include "editors.h" | |
20 #include "filelist.h" | |
354
5c82855feba7
Add a button to reset fullscreen info string to default value.
zas_
parents:
341
diff
changeset
|
21 #include "fullscreen.h" |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
214
diff
changeset
|
22 #include "image-overlay.h" |
9 | 23 #include "img-view.h" |
24 #include "layout.h" | |
25 #include "layout_image.h" | |
26 #include "menu.h" | |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
27 #include "pixbuf_util.h" |
9 | 28 #include "preferences.h" |
29 #include "rcfile.h" | |
30 #include "remote.h" | |
31 #include "similar.h" | |
32 #include "slideshow.h" | |
33 #include "utilops.h" | |
34 #include "ui_bookmark.h" | |
35 #include "ui_help.h" | |
36 #include "ui_fileops.h" | |
37 #include "ui_tabcomp.h" | |
38 #include "ui_utildlg.h" | |
39 | |
1 | 40 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
41 | |
9 | 42 |
43 #include <math.h> | |
44 | |
45 | |
279 | 46 static RemoteConnection *remote_connection = NULL; |
47 static CollectionData *command_collection = NULL; | |
9 | 48 |
1 | 49 |
50 /* | |
51 *----------------------------------------------------------------------------- | |
9 | 52 * misc (public) |
1 | 53 *----------------------------------------------------------------------------- |
54 */ | |
55 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
56 GtkWidget *window_new(GtkWindowType type, const gchar *name, const gchar *icon, |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
57 const gchar *icon_file, const gchar *subtitle) |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
58 { |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
59 gchar *title; |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
60 GtkWidget *window; |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
61 |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
62 window = gtk_window_new(type); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
63 if (!window) return NULL; |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
64 |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
65 if (subtitle) |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
66 { |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
67 title = g_strdup_printf("%s - %s", subtitle, GQ_APPNAME); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
68 } |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
69 else |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
70 { |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
71 title = g_strdup_printf("%s", GQ_APPNAME); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
72 } |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
73 |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
74 gtk_window_set_title(GTK_WINDOW(window), title); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
75 g_free(title); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
76 |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
77 window_set_icon(window, icon, icon_file); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
78 gtk_window_set_role(GTK_WINDOW(window), name); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
79 gtk_window_set_wmclass(GTK_WINDOW(window), name, GQ_WMCLASS); |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
80 |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
81 return window; |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
82 } |
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
83 |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
84 void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file) |
1 | 85 { |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
86 if (!icon && !file) icon = PIXBUF_INLINE_ICON; |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
87 |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
88 if (icon) |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
89 { |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
90 GdkPixbuf *pixbuf; |
1 | 91 |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
92 pixbuf = pixbuf_inline(icon); |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
93 if (pixbuf) |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
94 { |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
95 gtk_window_set_icon(GTK_WINDOW(window), pixbuf); |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
96 g_object_unref(pixbuf); |
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
97 } |
9 | 98 } |
99 else | |
100 { | |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
101 gtk_window_set_icon_from_file(GTK_WINDOW(window), file, NULL); |
9 | 102 } |
103 } | |
1 | 104 |
9 | 105 gint window_maximized(GtkWidget *window) |
106 { | |
107 GdkWindowState state; | |
108 | |
109 if (!window || !window->window) return FALSE; | |
110 | |
111 state = gdk_window_get_state(window->window); | |
112 return (state & GDK_WINDOW_STATE_MAXIMIZED); | |
113 } | |
114 | |
115 gdouble get_zoom_increment(void) | |
116 { | |
334 | 117 return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0); |
1 | 118 } |
119 | |
120 /* | |
121 *----------------------------------------------------------------------------- | |
9 | 122 * Open browser with the help Documentation |
123 *----------------------------------------------------------------------------- | |
124 */ | |
125 | |
126 static gchar *command_result(const gchar *binary, const gchar *command) | |
127 { | |
128 gchar *result = NULL; | |
129 FILE *f; | |
130 char buf[2048]; | |
131 int l; | |
132 | |
133 if (!binary) return NULL; | |
134 if (!file_in_path(binary)) return NULL; | |
135 | |
136 if (!command) return g_strdup(binary); | |
137 if (command[0] == '!') return g_strdup(command + 1); | |
138 | |
139 f = popen(command, "r"); | |
140 if (!f) return NULL; | |
141 | |
142 while ((l = fread(buf, sizeof(char), sizeof(buf), f)) > 0) | |
143 { | |
144 if (!result) | |
145 { | |
146 int n = 0; | |
147 | |
148 while (n < l && buf[n] != '\n' && buf[n] != '\r') n++; | |
149 if (n > 0) result = g_strndup(buf, n); | |
150 } | |
151 } | |
152 | |
153 pclose(f); | |
154 | |
155 return result; | |
156 } | |
157 | |
158 static void help_browser_command(const gchar *command, const gchar *path) | |
159 { | |
160 gchar *result; | |
161 gchar *buf; | |
162 gchar *begin; | |
163 gchar *end; | |
164 | |
165 if (!command || !path) return; | |
166 | |
167 if (debug) printf("Help command pre \"%s\", \"%s\"\n", command, path); | |
168 | |
169 buf = g_strdup(command); | |
170 begin = strstr(buf, "%s"); | |
171 if (begin) | |
172 { | |
173 *begin = '\0'; | |
174 end = begin + 2; | |
175 begin = buf; | |
176 | |
177 result = g_strdup_printf("%s%s%s &", begin, path, end); | |
178 } | |
179 else | |
180 { | |
181 result = g_strdup_printf("%s \"%s\" &", command, path); | |
182 } | |
183 g_free(buf); | |
184 | |
185 if (debug) printf("Help command post [%s]\n", result); | |
186 | |
187 system(result); | |
188 | |
189 g_free(result); | |
190 } | |
191 | |
192 /* | |
193 * each set of 2 strings is one browser: | |
194 * the 1st is the binary to look for in the path | |
195 * the 2nd has 3 capabilities: | |
196 * NULL exec binary with html file path as command line | |
197 * string exec string and use results for command line | |
198 * !string use text following ! as command line, replacing optional %s with html file path | |
199 */ | |
200 static gchar *html_browsers[] = | |
201 { | |
202 /* Redhat has a nifty htmlview script to start the user's preferred browser */ | |
203 "htmlview", NULL, | |
204 /* GNOME 2 */ | |
205 "gconftool-2", "gconftool-2 -g /desktop/gnome/url-handlers/http/command", | |
206 /* KDE */ | |
207 "kfmclient", "!kfmclient exec \"%s\"", | |
208 /* use fallbacks */ | |
209 "firefox", NULL, | |
210 "mozilla", NULL, | |
211 "konqueror", NULL, | |
212 "netscape", NULL, | |
213 NULL, NULL | |
214 }; | |
215 | |
216 static void help_browser_run(void) | |
217 { | |
218 gchar *result = NULL; | |
219 gint i; | |
220 | |
221 i = 0; | |
222 while (!result && html_browsers[i]) | |
223 { | |
224 result = command_result(html_browsers[i], html_browsers[i+1]); | |
225 i += 2; | |
226 } | |
227 | |
228 if (!result) | |
229 { | |
230 printf("Unable to detect an installed browser.\n"); | |
231 return; | |
232 } | |
233 | |
283 | 234 help_browser_command(result, GQ_HTMLDIR "/index.html"); |
9 | 235 |
236 g_free(result); | |
237 } | |
238 | |
239 /* | |
240 *----------------------------------------------------------------------------- | |
241 * help window | |
1 | 242 *----------------------------------------------------------------------------- |
243 */ | |
244 | |
9 | 245 static GtkWidget *help_window = NULL; |
246 | |
247 static void help_window_destroy_cb(GtkWidget *window, gpointer data) | |
1 | 248 { |
9 | 249 help_window = NULL; |
1 | 250 } |
251 | |
9 | 252 void help_window_show(const gchar *key) |
1 | 253 { |
9 | 254 if (key && strcmp(key, "html_contents") == 0) |
255 { | |
256 help_browser_run(); | |
257 return; | |
258 } | |
259 | |
260 if (help_window) | |
1 | 261 { |
9 | 262 gtk_window_present(GTK_WINDOW(help_window)); |
263 if (key) help_window_set_key(help_window, key); | |
264 return; | |
1 | 265 } |
9 | 266 |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
267 { |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
268 gchar *title = g_strdup_printf("%s - %s", _("Help"), GQ_APPNAME); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
269 help_window = help_window_new(title, GQ_WMCLASS, "help", |
283 | 270 GQ_HELPDIR "/README", key); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
271 g_free(title); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
272 } |
9 | 273 g_signal_connect(G_OBJECT(help_window), "destroy", |
274 G_CALLBACK(help_window_destroy_cb), NULL); | |
1 | 275 } |
276 | |
9 | 277 |
1 | 278 /* |
279 *----------------------------------------------------------------------------- | |
280 * keyboard functions | |
281 *----------------------------------------------------------------------------- | |
282 */ | |
283 | |
284 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event) | |
285 { | |
286 static gint delta = 0; | |
287 static guint32 time_old = 0; | |
288 static guint keyval_old = 0; | |
289 | |
9 | 290 if (event->state & GDK_CONTROL_MASK) |
291 { | |
292 if (*x < 0) *x = G_MININT / 2; | |
293 if (*x > 0) *x = G_MAXINT / 2; | |
294 if (*y < 0) *y = G_MININT / 2; | |
295 if (*y > 0) *y = G_MAXINT / 2; | |
296 | |
297 return; | |
298 } | |
299 | |
318 | 300 if (options->progressive_key_scrolling) |
1 | 301 { |
302 guint32 time_diff; | |
303 | |
304 time_diff = event->time - time_old; | |
305 | |
306 /* key pressed within 125ms ? (1/8 second) */ | |
307 if (time_diff > 125 || event->keyval != keyval_old) delta = 0; | |
308 | |
309 time_old = event->time; | |
310 keyval_old = event->keyval; | |
311 | |
312 delta += 2; | |
313 } | |
314 else | |
315 { | |
316 delta = 8; | |
317 } | |
318 | |
319 *x = *x * delta; | |
320 *y = *y * delta; | |
321 } | |
322 | |
9 | 323 |
324 /* | |
325 *----------------------------------------------------------------------------- | |
326 * remote functions | |
327 *----------------------------------------------------------------------------- | |
328 */ | |
329 | |
330 static void gr_image_next(const gchar *text, gpointer data) | |
331 { | |
332 layout_image_next(NULL); | |
333 } | |
334 | |
335 static void gr_image_prev(const gchar *text, gpointer data) | |
336 { | |
337 layout_image_prev(NULL); | |
338 } | |
339 | |
340 static void gr_image_first(const gchar *text, gpointer data) | |
341 { | |
342 layout_image_first(NULL); | |
343 } | |
344 | |
345 static void gr_image_last(const gchar *text, gpointer data) | |
346 { | |
347 layout_image_last(NULL); | |
348 } | |
349 | |
350 static void gr_fullscreen_toggle(const gchar *text, gpointer data) | |
351 { | |
352 layout_image_full_screen_toggle(NULL); | |
353 } | |
354 | |
355 static void gr_fullscreen_start(const gchar *text, gpointer data) | |
1 | 356 { |
9 | 357 layout_image_full_screen_start(NULL); |
358 } | |
359 | |
360 static void gr_fullscreen_stop(const gchar *text, gpointer data) | |
361 { | |
362 layout_image_full_screen_stop(NULL); | |
363 } | |
364 | |
365 static void gr_slideshow_start_rec(const gchar *text, gpointer data) | |
366 { | |
367 GList *list; | |
368 | |
369 list = path_list_recursive(text); | |
370 if (!list) return; | |
214 | 371 //printf("length: %d\n", g_list_length(list)); |
9 | 372 layout_image_slideshow_stop(NULL); |
373 layout_image_slideshow_start_from_list(NULL, list); | |
374 } | |
1 | 375 |
9 | 376 static void gr_slideshow_toggle(const gchar *text, gpointer data) |
377 { | |
378 layout_image_slideshow_toggle(NULL); | |
379 } | |
380 | |
381 static void gr_slideshow_start(const gchar *text, gpointer data) | |
382 { | |
383 layout_image_slideshow_start(NULL); | |
384 } | |
385 | |
386 static void gr_slideshow_stop(const gchar *text, gpointer data) | |
387 { | |
388 layout_image_slideshow_stop(NULL); | |
389 } | |
390 | |
391 static void gr_slideshow_delay(const gchar *text, gpointer data) | |
392 { | |
393 gdouble n; | |
394 | |
395 n = strtod(text, NULL); | |
396 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS) | |
1 | 397 { |
9 | 398 gchar *buf; |
399 | |
400 buf = g_strdup_printf("Remote slideshow delay out of range (%.1f to %.1f)\n", | |
401 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS); | |
402 print_term(buf); | |
403 g_free(buf); | |
404 | |
405 return; | |
406 } | |
326 | 407 options->slideshow.delay = (gint)(n * 10.0 + 0.01); |
9 | 408 } |
409 | |
410 static void gr_tools_show(const gchar *text, gpointer data) | |
411 { | |
412 gint popped; | |
413 gint hidden; | |
414 | |
415 if (layout_tools_float_get(NULL, &popped, &hidden) && hidden) | |
416 { | |
417 layout_tools_float_set(NULL, popped, FALSE); | |
1 | 418 } |
9 | 419 } |
1 | 420 |
9 | 421 static void gr_tools_hide(const gchar *text, gpointer data) |
422 { | |
423 gint popped; | |
424 gint hidden; | |
425 | |
426 if (layout_tools_float_get(NULL, &popped, &hidden) && !hidden) | |
1 | 427 { |
9 | 428 layout_tools_float_set(NULL, popped, TRUE); |
429 } | |
430 } | |
431 | |
432 static gint gr_quit_idle_cb(gpointer data) | |
433 { | |
278 | 434 exit_program(); |
9 | 435 |
436 return FALSE; | |
437 } | |
438 | |
439 static void gr_quit(const gchar *text, gpointer data) | |
440 { | |
441 /* schedule exit when idle, if done from within a | |
442 * remote handler remote_close will crash | |
443 */ | |
444 g_idle_add(gr_quit_idle_cb, NULL); | |
445 } | |
446 | |
447 static void gr_file_load(const gchar *text, gpointer data) | |
448 { | |
449 if (isfile(text)) | |
450 { | |
451 if (file_extension_match(text, ".gqv")) | |
1 | 452 { |
9 | 453 collection_window_new(text); |
454 } | |
455 else | |
456 { | |
457 layout_set_path(NULL, text); | |
1 | 458 } |
459 } | |
9 | 460 else if (isdir(text)) |
461 { | |
462 layout_set_path(NULL, text); | |
463 } | |
464 else | |
465 { | |
466 printf("remote sent filename that does not exist:\"%s\"\n", text); | |
467 } | |
468 } | |
469 | |
470 static void gr_file_view(const gchar *text, gpointer data) | |
471 { | |
138 | 472 view_window_new(file_data_new_simple(text)); |
9 | 473 } |
474 | |
475 static void gr_list_clear(const gchar *text, gpointer data) | |
476 { | |
279 | 477 if (command_collection) collection_unref(command_collection); |
478 command_collection = NULL; | |
9 | 479 } |
480 | |
481 static void gr_list_add(const gchar *text, gpointer data) | |
482 { | |
483 gint new = TRUE; | |
484 | |
279 | 485 if (!command_collection) |
9 | 486 { |
487 CollectionData *cd; | |
488 | |
489 cd = collection_new(""); | |
490 | |
491 g_free(cd->path); | |
492 cd->path = NULL; | |
493 g_free(cd->name); | |
494 cd->name = g_strdup(_("Command line")); | |
495 | |
279 | 496 command_collection = cd; |
9 | 497 } |
498 else | |
499 { | |
279 | 500 new = (!collection_get_first(command_collection)); |
9 | 501 } |
1 | 502 |
279 | 503 if (collection_add(command_collection, file_data_new_simple(text), FALSE) && new) |
9 | 504 { |
279 | 505 layout_image_set_collection(NULL, command_collection, |
506 collection_get_first(command_collection)); | |
9 | 507 } |
508 } | |
509 | |
510 static void gr_raise(const gchar *text, gpointer data) | |
511 { | |
512 LayoutWindow *lw = NULL; | |
513 | |
514 if (layout_valid(&lw)) | |
515 { | |
516 gtk_window_present(GTK_WINDOW(lw->window)); | |
517 } | |
518 } | |
519 | |
520 typedef struct _RemoteCommandEntry RemoteCommandEntry; | |
521 struct _RemoteCommandEntry { | |
522 gchar *opt_s; | |
523 gchar *opt_l; | |
524 void (*func)(const gchar *text, gpointer data); | |
525 gint needs_extra; | |
526 gint prefer_command_line; | |
527 gchar *description; | |
528 }; | |
529 | |
530 static RemoteCommandEntry remote_commands[] = { | |
531 /* short, long callback, extra, prefer,description */ | |
532 { "-n", "--next", gr_image_next, FALSE, FALSE, N_("next image") }, | |
533 { "-b", "--back", gr_image_prev, FALSE, FALSE, N_("previous image") }, | |
534 { NULL, "--first", gr_image_first, FALSE, FALSE, N_("first image") }, | |
535 { NULL, "--last", gr_image_last, FALSE, FALSE, N_("last image") }, | |
536 { "-f", "--fullscreen", gr_fullscreen_toggle, FALSE, TRUE, N_("toggle full screen") }, | |
537 { "-fs","--fullscreen-start", gr_fullscreen_start, FALSE, FALSE, N_("start full screen") }, | |
538 { "-fS","--fullscreen-stop", gr_fullscreen_stop, FALSE, FALSE, N_("stop full screen") }, | |
539 { "-s", "--slideshow", gr_slideshow_toggle, FALSE, TRUE, N_("toggle slide show") }, | |
540 { "-ss","--slideshow-start", gr_slideshow_start, FALSE, FALSE, N_("start slide show") }, | |
541 { "-sS","--slideshow-stop", gr_slideshow_stop, FALSE, FALSE, N_("stop slide show") }, | |
542 { "-sr","--slideshow-recurse", gr_slideshow_start_rec, TRUE, FALSE, N_("start recursive slide show") }, | |
543 { "-d", "--delay=", gr_slideshow_delay, TRUE, FALSE, N_("set slide show delay in seconds") }, | |
544 { "+t", "--tools-show", gr_tools_show, FALSE, TRUE, N_("show tools") }, | |
545 { "-t", "--tools-hide", gr_tools_hide, FALSE, TRUE, N_("hide tools") }, | |
546 { "-q", "--quit", gr_quit, FALSE, FALSE, N_("quit") }, | |
547 { NULL, "file:", gr_file_load, TRUE, FALSE, N_("open file") }, | |
548 { NULL, "view:", gr_file_view, TRUE, FALSE, N_("open file in new window") }, | |
549 { NULL, "--list-clear", gr_list_clear, FALSE, FALSE, NULL }, | |
550 { NULL, "--list-add:", gr_list_add, TRUE, FALSE, NULL }, | |
551 { NULL, "raise", gr_raise, FALSE, FALSE, NULL }, | |
552 { NULL, NULL, NULL, FALSE, FALSE, NULL } | |
553 }; | |
554 | |
279 | 555 static RemoteCommandEntry *remote_command_find(const gchar *text, const gchar **offset) |
9 | 556 { |
557 gint match = FALSE; | |
558 gint i; | |
559 | |
560 i = 0; | |
561 while (!match && remote_commands[i].func != NULL) | |
1 | 562 { |
9 | 563 if (remote_commands[i].needs_extra) |
564 { | |
565 if (remote_commands[i].opt_s && | |
566 strncmp(remote_commands[i].opt_s, text, strlen(remote_commands[i].opt_s)) == 0) | |
567 { | |
568 if (offset) *offset = text + strlen(remote_commands[i].opt_s); | |
569 return &remote_commands[i]; | |
570 } | |
571 else if (remote_commands[i].opt_l && | |
572 strncmp(remote_commands[i].opt_l, text, strlen(remote_commands[i].opt_l)) == 0) | |
573 { | |
574 if (offset) *offset = text + strlen(remote_commands[i].opt_l); | |
575 return &remote_commands[i]; | |
576 } | |
577 } | |
578 else | |
579 { | |
580 if ((remote_commands[i].opt_s && strcmp(remote_commands[i].opt_s, text) == 0) || | |
581 (remote_commands[i].opt_l && strcmp(remote_commands[i].opt_l, text) == 0)) | |
1 | 582 { |
9 | 583 if (offset) *offset = text; |
584 return &remote_commands[i]; | |
1 | 585 } |
9 | 586 } |
587 | |
588 i++; | |
589 } | |
590 | |
591 return NULL; | |
592 } | |
593 | |
279 | 594 static void remote_cb(RemoteConnection *rc, const gchar *text, gpointer data) |
9 | 595 { |
596 RemoteCommandEntry *entry; | |
597 const gchar *offset; | |
598 | |
279 | 599 entry = remote_command_find(text, &offset); |
9 | 600 if (entry && entry->func) |
601 { | |
602 entry->func(offset, data); | |
603 } | |
604 else | |
605 { | |
606 printf("unknown remote command:%s\n", text); | |
607 } | |
608 } | |
609 | |
279 | 610 static void remote_help(void) |
9 | 611 { |
612 gint i; | |
613 | |
614 print_term(_("Remote command list:\n")); | |
615 | |
616 i = 0; | |
617 while (remote_commands[i].func != NULL) | |
618 { | |
619 if (remote_commands[i].description) | |
620 { | |
621 gchar *buf; | |
622 | |
623 buf = g_strdup_printf(" %-3s%s %-20s %s\n", | |
624 (remote_commands[i].opt_s) ? remote_commands[i].opt_s : "", | |
625 (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ", | |
626 (remote_commands[i].opt_l) ? remote_commands[i].opt_l : "", | |
627 _(remote_commands[i].description)); | |
628 | |
629 print_term(buf); | |
630 g_free(buf); | |
631 } | |
632 i++; | |
633 } | |
634 } | |
635 | |
279 | 636 static GList *remote_build_list(GList *list, int argc, char *argv[]) |
9 | 637 { |
638 gint i; | |
639 | |
640 i = 1; | |
641 while (i < argc) | |
642 { | |
643 RemoteCommandEntry *entry; | |
644 | |
279 | 645 entry = remote_command_find(argv[i], NULL); |
9 | 646 if (entry) |
647 { | |
648 list = g_list_append(list, argv[i]); | |
649 } | |
650 i++; | |
1 | 651 } |
652 | |
9 | 653 return list; |
654 } | |
655 | |
279 | 656 static void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path, |
9 | 657 GList *cmd_list, GList *collection_list) |
658 { | |
659 RemoteConnection *rc; | |
660 gint started = FALSE; | |
661 gchar *buf; | |
662 | |
283 | 663 buf = g_strconcat(homedir(), "/", GQ_RC_DIR, "/.command", NULL); |
9 | 664 rc = remote_client_open(buf); |
665 if (!rc) | |
666 { | |
667 GString *command; | |
668 GList *work; | |
669 gint retry_count = 12; | |
670 gint blank = FALSE; | |
671 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
672 { |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
673 gchar *msg = g_strdup_printf(_("Remote %s not running, starting..."), GQ_APPNAME); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
674 print_term(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
675 g_free(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
676 } |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
677 |
9 | 678 command = g_string_new(arg_exec); |
679 | |
680 work = remote_list; | |
681 while (work) | |
682 { | |
683 gchar *text; | |
684 RemoteCommandEntry *entry; | |
685 | |
686 text = work->data; | |
687 work = work->next; | |
688 | |
279 | 689 entry = remote_command_find(text, NULL); |
9 | 690 if (entry) |
691 { | |
692 if (entry->prefer_command_line) | |
693 { | |
694 remote_list = g_list_remove(remote_list, text); | |
695 g_string_append(command, " "); | |
696 g_string_append(command, text); | |
697 } | |
698 if (entry->opt_l && strcmp(entry->opt_l, "file:") == 0) | |
699 { | |
700 blank = TRUE; | |
701 } | |
702 } | |
703 } | |
704 | |
705 if (blank || cmd_list || path) g_string_append(command, " --blank"); | |
706 if (debug) g_string_append(command, " --debug"); | |
707 | |
708 g_string_append(command, " &"); | |
709 system(command->str); | |
710 g_string_free(command, TRUE); | |
711 | |
712 while (!rc && retry_count > 0) | |
713 { | |
714 usleep((retry_count > 10) ? 500000 : 1000000); | |
715 rc = remote_client_open(buf); | |
716 if (!rc) print_term("."); | |
717 retry_count--; | |
718 } | |
719 | |
720 print_term("\n"); | |
721 | |
722 started = TRUE; | |
723 } | |
724 g_free(buf); | |
725 | |
726 if (rc) | |
1 | 727 { |
9 | 728 GList *work; |
729 const gchar *prefix; | |
730 gint use_path = TRUE; | |
731 gint sent = FALSE; | |
732 | |
733 work = remote_list; | |
734 while (work) | |
735 { | |
736 gchar *text; | |
737 RemoteCommandEntry *entry; | |
738 | |
739 text = work->data; | |
740 work = work->next; | |
741 | |
279 | 742 entry = remote_command_find(text, NULL); |
9 | 743 if (entry && |
744 entry->opt_l && | |
745 strcmp(entry->opt_l, "file:") == 0) use_path = FALSE; | |
746 | |
747 remote_client_send(rc, text); | |
748 | |
749 sent = TRUE; | |
750 } | |
751 | |
752 if (cmd_list && cmd_list->next) | |
753 { | |
754 prefix = "--list-add:"; | |
755 remote_client_send(rc, "--list-clear"); | |
756 } | |
757 else | |
758 { | |
759 prefix = "file:"; | |
760 } | |
761 | |
762 work = cmd_list; | |
763 while (work) | |
764 { | |
765 const gchar *name; | |
766 gchar *text; | |
767 | |
768 name = work->data; | |
769 work = work->next; | |
770 | |
771 text = g_strconcat(prefix, name, NULL); | |
772 remote_client_send(rc, text); | |
773 g_free(text); | |
774 | |
775 sent = TRUE; | |
776 } | |
777 | |
778 if (path && !cmd_list && use_path) | |
779 { | |
780 gchar *text; | |
781 | |
782 text = g_strdup_printf("file:%s", path); | |
783 remote_client_send(rc, text); | |
784 g_free(text); | |
785 | |
786 sent = TRUE; | |
787 } | |
788 | |
789 work = collection_list; | |
790 while (work) | |
791 { | |
792 const gchar *name; | |
793 gchar *text; | |
794 | |
795 name = work->data; | |
796 work = work->next; | |
797 | |
798 text = g_strdup_printf("file:%s", name); | |
799 remote_client_send(rc, text); | |
800 g_free(text); | |
801 | |
802 sent = TRUE; | |
803 } | |
804 | |
805 if (!started && !sent) | |
806 { | |
807 remote_client_send(rc, "raise"); | |
808 } | |
809 } | |
810 else | |
811 { | |
812 print_term(_("Remote not available\n")); | |
1 | 813 } |
814 | |
9 | 815 _exit(0); |
1 | 816 } |
817 | |
818 /* | |
819 *----------------------------------------------------------------------------- | |
3 | 820 * command line parser (private) hehe, who needs popt anyway? |
1 | 821 *----------------------------------------------------------------------------- |
822 */ | |
823 | |
9 | 824 static gint startup_blank = FALSE; |
3 | 825 static gint startup_full_screen = FALSE; |
826 static gint startup_in_slideshow = FALSE; | |
9 | 827 static gint startup_command_line_collection = FALSE; |
3 | 828 |
9 | 829 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
830 static void parse_command_line_add_file(const gchar *file_path, gchar **path, gchar **file, |
9 | 831 GList **list, GList **collection_list) |
1 | 832 { |
9 | 833 gchar *path_parsed; |
834 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
835 path_parsed = g_strdup(file_path); |
9 | 836 parse_out_relatives(path_parsed); |
837 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
838 if (file_extension_match(path_parsed, ".gqv")) |
9 | 839 { |
840 *collection_list = g_list_append(*collection_list, path_parsed); | |
841 } | |
842 else | |
843 { | |
844 if (!*path) *path = remove_level_from_path(path_parsed); | |
845 if (!*file) *file = g_strdup(path_parsed); | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
846 *list = g_list_prepend(*list, path_parsed); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
847 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
848 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
849 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
850 static void parse_command_line_add_dir(const gchar *dir, gchar **path, gchar **file, |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
851 GList **list) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
852 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
853 GList *files = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
854 gchar *path_parsed; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
855 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
856 path_parsed = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
857 parse_out_relatives(path_parsed); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
858 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
859 if (path_list(path_parsed, &files, NULL)) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
860 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
861 GList *work; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
862 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
863 files = path_list_filter(files, FALSE); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
864 files = path_list_sort(files); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
865 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
866 work = files; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
867 while (work) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
868 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
869 gchar *p; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
870 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
871 p = work->data; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
872 if (!*path) *path = remove_level_from_path(p); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
873 if (!*file) *file = g_strdup(p); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
874 *list = g_list_prepend(*list, p); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
875 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
876 work = work->next; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
877 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
878 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
879 g_list_free(files); |
9 | 880 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
881 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
882 g_free(path_parsed); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
883 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
884 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
885 static void parse_command_line_process_dir(const gchar *dir, gchar **path, gchar **file, |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
886 GList **list, gchar **first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
887 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
888 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
889 if (!*list && !*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
890 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
891 *first_dir = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
892 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
893 else |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
894 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
895 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
896 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
897 parse_command_line_add_dir(*first_dir, path, file, list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
898 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
899 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
900 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
901 parse_command_line_add_dir(dir, path, file, list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
902 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
903 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
904 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
905 static void parse_command_line_process_file(const gchar *file_path, gchar **path, gchar **file, |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
906 GList **list, GList **collection_list, gchar **first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
907 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
908 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
909 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
910 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
911 parse_command_line_add_dir(*first_dir, path, file, list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
912 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
913 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
914 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
915 parse_command_line_add_file(file_path, path, file, list, collection_list); |
9 | 916 } |
917 | |
918 static void parse_command_line(int argc, char *argv[], gchar **path, gchar **file, | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
919 GList **cmd_list, GList **collection_list, |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
920 gchar **geometry) |
9 | 921 { |
922 GList *list = NULL; | |
923 GList *remote_list = NULL; | |
924 gint remote_do = FALSE; | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
925 gchar *first_dir = NULL; |
9 | 926 |
1 | 927 if (argc > 1) |
928 { | |
929 gint i; | |
930 gchar *base_dir = get_current_dir(); | |
931 i = 1; | |
932 while (i < argc) | |
933 { | |
9 | 934 const gchar *cmd_line = argv[i]; |
935 gchar *cmd_all = concat_dir_and_file(base_dir, cmd_line); | |
1 | 936 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
937 if (cmd_line[0] == '/' && isdir(cmd_line)) |
1 | 938 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
939 parse_command_line_process_dir(cmd_line, path, file, &list, &first_dir); |
1 | 940 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
941 else if (isdir(cmd_all)) |
1 | 942 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
943 parse_command_line_process_dir(cmd_all, path, file, &list, &first_dir); |
1 | 944 } |
9 | 945 else if (cmd_line[0] == '/' && isfile(cmd_line)) |
1 | 946 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
947 parse_command_line_process_file(cmd_line, path, file, |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
948 &list, collection_list, &first_dir); |
1 | 949 } |
9 | 950 else if (isfile(cmd_all)) |
1 | 951 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
952 parse_command_line_process_file(cmd_all, path, file, |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
953 &list, collection_list, &first_dir); |
1 | 954 } |
227
41fc4bfc8b25
Add a debug level spinner at the end of Preferences > Advanced.
zas_
parents:
218
diff
changeset
|
955 #ifdef DEBUG |
3 | 956 else if (strcmp(cmd_line, "--debug") == 0) |
1 | 957 { |
9 | 958 /* we now increment the debug state for verbosity */ |
959 debug++; | |
960 printf("debugging output enabled (level %d)\n", debug); | |
1 | 961 } |
227
41fc4bfc8b25
Add a debug level spinner at the end of Preferences > Advanced.
zas_
parents:
218
diff
changeset
|
962 #endif |
1 | 963 else if (strcmp(cmd_line, "+t") == 0 || |
3 | 964 strcmp(cmd_line, "--with-tools") == 0) |
1 | 965 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
966 options->layout.tools_float = FALSE; |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
967 options->layout.tools_hidden = FALSE; |
9 | 968 |
969 remote_list = g_list_append(remote_list, "+t"); | |
1 | 970 } |
971 else if (strcmp(cmd_line, "-t") == 0 || | |
3 | 972 strcmp(cmd_line, "--without-tools") == 0) |
1 | 973 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
974 options->layout.tools_hidden = TRUE; |
9 | 975 |
976 remote_list = g_list_append(remote_list, "-t"); | |
1 | 977 } |
3 | 978 else if (strcmp(cmd_line, "-f") == 0 || |
979 strcmp(cmd_line, "--fullscreen") == 0) | |
980 { | |
981 startup_full_screen = TRUE; | |
982 } | |
983 else if (strcmp(cmd_line, "-s") == 0 || | |
984 strcmp(cmd_line, "--slideshow") == 0) | |
985 { | |
986 startup_in_slideshow = TRUE; | |
987 } | |
9 | 988 else if (strcmp(cmd_line, "-l") == 0 || |
989 strcmp(cmd_line, "--list") == 0) | |
990 { | |
991 startup_command_line_collection = TRUE; | |
992 } | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
993 else if (strncmp(cmd_line, "--geometry=", 11) == 0) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
994 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
995 if (!*geometry) *geometry = g_strdup(cmd_line + 11); |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
996 } |
9 | 997 else if (strcmp(cmd_line, "-r") == 0 || |
998 strcmp(cmd_line, "--remote") == 0) | |
999 { | |
1000 if (!remote_do) | |
1001 { | |
1002 remote_do = TRUE; | |
279 | 1003 remote_list = remote_build_list(remote_list, argc, argv); |
9 | 1004 } |
1005 } | |
1006 else if (strcmp(cmd_line, "-rh") == 0 || | |
1007 strcmp(cmd_line, "--remote-help") == 0) | |
1008 { | |
279 | 1009 remote_help(); |
9 | 1010 exit (0); |
1011 } | |
1012 else if (strcmp(cmd_line, "--blank") == 0) | |
1013 { | |
1014 startup_blank = TRUE; | |
1015 } | |
1016 else if (strcmp(cmd_line, "-v") == 0 || | |
1017 strcmp(cmd_line, "--version") == 0) | |
1018 { | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1019 printf("%s %s\n", GQ_APPNAME, VERSION); |
9 | 1020 exit (0); |
1021 } | |
1022 else if (strcmp(cmd_line, "--alternate") == 0) | |
1023 { | |
1024 /* enable faster experimental algorithm */ | |
1025 printf("Alternate similarity algorithm enabled\n"); | |
1026 image_sim_alternate_set(TRUE); | |
1027 } | |
3 | 1028 else if (strcmp(cmd_line, "-h") == 0 || |
1029 strcmp(cmd_line, "--help") == 0) | |
1 | 1030 { |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1031 gchar *usage = g_strdup_printf(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1032 printf("%s %s\n", GQ_APPNAME, VERSION); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1033 print_term(usage); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1034 g_free(usage); |
9 | 1035 print_term(_("valid options are:\n")); |
1036 print_term(_(" +t, --with-tools force show of tools\n")); | |
1037 print_term(_(" -t, --without-tools force hide of tools\n")); | |
1038 print_term(_(" -f, --fullscreen start in full screen mode\n")); | |
1039 print_term(_(" -s, --slideshow start in slideshow mode\n")); | |
1040 print_term(_(" -l, --list open collection window for command line\n")); | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
1041 print_term(_(" --geometry=GEOMETRY set main window location\n")); |
9 | 1042 print_term(_(" -r, --remote send following commands to open window\n")); |
1043 print_term(_(" -rh,--remote-help print remote command list\n")); | |
227
41fc4bfc8b25
Add a debug level spinner at the end of Preferences > Advanced.
zas_
parents:
218
diff
changeset
|
1044 #ifdef DEBUG |
9 | 1045 print_term(_(" --debug turn on debug output\n")); |
227
41fc4bfc8b25
Add a debug level spinner at the end of Preferences > Advanced.
zas_
parents:
218
diff
changeset
|
1046 #endif |
9 | 1047 print_term(_(" -v, --version print version info\n")); |
1048 print_term(_(" -h, --help show this message\n\n")); | |
1049 | |
1050 #if 0 | |
1051 /* these options are not officially supported! | |
1052 * only for testing new features, no need to translate them */ | |
1053 print_term( " --alternate use alternate similarity algorithm\n"); | |
1054 #endif | |
1055 | |
1 | 1056 exit (0); |
1057 } | |
9 | 1058 else if (!remote_do) |
1 | 1059 { |
9 | 1060 gchar *buf; |
1061 | |
1062 buf = g_strdup_printf(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); | |
1063 print_term(buf); | |
1064 g_free(buf); | |
1 | 1065 } |
9 | 1066 |
1 | 1067 g_free(cmd_all); |
1068 i++; | |
1069 } | |
1070 g_free(base_dir); | |
1071 parse_out_relatives(*path); | |
1072 parse_out_relatives(*file); | |
1073 } | |
9 | 1074 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1075 list = g_list_reverse(list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1076 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1077 if (!*path && first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1078 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1079 *path = first_dir; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1080 first_dir = NULL; |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
1081 |
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
1082 parse_out_relatives(*path); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1083 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1084 g_free(first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
1085 |
9 | 1086 if (remote_do) |
1087 { | |
279 | 1088 remote_control(argv[0], remote_list, *path, list, *collection_list); |
9 | 1089 } |
1090 g_list_free(remote_list); | |
1091 | |
1092 if (list && list->next) | |
1093 { | |
1094 *cmd_list = list; | |
1095 } | |
1096 else | |
1097 { | |
1098 path_list_free(list); | |
1099 *cmd_list = NULL; | |
1100 } | |
1 | 1101 } |
1102 | |
1103 /* | |
1104 *----------------------------------------------------------------------------- | |
1105 * startup, init, and exit | |
1106 *----------------------------------------------------------------------------- | |
1107 */ | |
1108 | |
9 | 1109 #define RC_HISTORY_NAME "history" |
1110 | |
1111 static void keys_load(void) | |
1112 { | |
1113 gchar *path; | |
1114 | |
283 | 1115 path = g_strconcat(homedir(), "/", GQ_RC_DIR, "/", RC_HISTORY_NAME, NULL); |
9 | 1116 history_list_load(path); |
1117 g_free(path); | |
1118 } | |
1119 | |
1120 static void keys_save(void) | |
1121 { | |
1122 gchar *path; | |
1123 | |
283 | 1124 path = g_strconcat(homedir(), "/", GQ_RC_DIR, "/", RC_HISTORY_NAME, NULL); |
9 | 1125 history_list_save(path); |
1126 g_free(path); | |
1127 } | |
1128 | |
1129 static void check_for_home_path(gchar *path) | |
1 | 1130 { |
9 | 1131 gchar *buf; |
1132 | |
1133 buf = g_strconcat(homedir(), "/", path, NULL); | |
1134 if (!isdir(buf)) | |
1135 { | |
1136 gchar *tmp; | |
1137 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1138 tmp = g_strdup_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, buf); |
9 | 1139 print_term(tmp); |
1140 g_free(tmp); | |
1141 | |
1142 if (!mkdir_utf8(buf, 0755)) | |
1143 { | |
1144 tmp = g_strdup_printf(_("Could not create dir:%s\n"), buf); | |
1145 print_term(tmp); | |
1146 g_free(tmp); | |
1147 } | |
1148 } | |
1149 g_free(buf); | |
1150 } | |
1151 | |
1152 static void setup_default_options(void) | |
1153 { | |
1154 gchar *path; | |
1 | 1155 gint i; |
1156 | |
283 | 1157 for (i = 0; i < GQ_EDITOR_SLOTS; i++) |
1 | 1158 { |
318 | 1159 options->editor_name[i] = NULL; |
1160 options->editor_command[i] = NULL; | |
1 | 1161 } |
1162 | |
9 | 1163 editor_reset_defaults(); |
1 | 1164 |
9 | 1165 bookmark_add_default(_("Home"), homedir()); |
1166 path = concat_dir_and_file(homedir(), "Desktop"); | |
1167 bookmark_add_default(_("Desktop"), path); | |
1168 g_free(path); | |
283 | 1169 path = concat_dir_and_file(homedir(), GQ_RC_DIR_COLLECTIONS); |
9 | 1170 bookmark_add_default(_("Collections"), path); |
1171 g_free(path); | |
1 | 1172 |
341
15c6b94545a2
Move safe_delete* and in place rename options to file_ops
zas_
parents:
340
diff
changeset
|
1173 g_free(options->file_ops.safe_delete_path); |
15c6b94545a2
Move safe_delete* and in place rename options to file_ops
zas_
parents:
340
diff
changeset
|
1174 options->file_ops.safe_delete_path = concat_dir_and_file(homedir(), GQ_RC_DIR_TRASH); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1175 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1176 for (i = 0; i < COLOR_PROFILE_INPUTS; i++) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1177 { |
327 | 1178 options->color_profile.input_file[i] = NULL; |
1179 options->color_profile.input_name[i] = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1180 } |
189
deea9e11f1d4
fixed reading sidecar extensions from config file
nadvornik
parents:
145
diff
changeset
|
1181 |
354
5c82855feba7
Add a button to reset fullscreen info string to default value.
zas_
parents:
341
diff
changeset
|
1182 set_default_fullscreen_info(options); |
189
deea9e11f1d4
fixed reading sidecar extensions from config file
nadvornik
parents:
145
diff
changeset
|
1183 sidecar_ext_add_defaults(); |
367
3556cc825e59
Move layout.order default init to setup_default_options().
zas_
parents:
358
diff
changeset
|
1184 options->layout.order = g_strdup("123"); |
1 | 1185 } |
1186 | |
278 | 1187 static void exit_program_final(void) |
1 | 1188 { |
9 | 1189 gchar *path; |
1190 gchar *pathl; | |
1191 LayoutWindow *lw = NULL; | |
1192 | |
279 | 1193 remote_close(remote_connection); |
9 | 1194 |
1195 collect_manager_flush(); | |
1 | 1196 |
9 | 1197 if (layout_valid(&lw)) |
1198 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1199 options->layout.main_window.maximized = window_maximized(lw->window); |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1200 if (!options->layout.main_window.maximized) |
9 | 1201 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1202 layout_geometry_get(NULL, &options->layout.main_window.x, &options->layout.main_window.y, |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1203 &options->layout.main_window.w, &options->layout.main_window.h); |
9 | 1204 } |
322 | 1205 options->fullscreen.show_info = image_osd_get(lw->image, NULL, NULL); |
9 | 1206 } |
1 | 1207 |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1208 layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos); |
9 | 1209 |
327 | 1210 layout_views_get(NULL, &options->layout.view_as_tree, &options->layout.view_as_icons); |
9 | 1211 |
340
77103f3f2cb1
Rename option thumbnails.enabled to layout.show_thumbnails as it makes
zas_
parents:
338
diff
changeset
|
1212 options->layout.show_thumbnails = layout_thumb_get(NULL); |
329 | 1213 layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending); |
9 | 1214 |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1215 layout_geometry_get_tools(NULL, &options->layout.float_window.x, &options->layout.float_window.y, |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1216 &options->layout.float_window.w, &options->layout.float_window.h, &options->layout.float_window.vdivider_pos); |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1217 layout_tools_float_get(NULL, &options->layout.tools_float, &options->layout.tools_hidden); |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1218 options->layout.toolbar_hidden = layout_toolbar_hidden(NULL); |
9 | 1219 |
327 | 1220 options->color_profile.enabled = layout_image_color_profile_get_use(NULL); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1221 layout_image_color_profile_get(NULL, |
327 | 1222 &options->color_profile.input_type, |
1223 &options->color_profile.screen_type, | |
1224 &options->color_profile.use_image); | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1225 |
1 | 1226 save_options(); |
9 | 1227 keys_save(); |
1228 | |
283 | 1229 path = g_strconcat(homedir(), "/", GQ_RC_DIR, "/accels", NULL); |
9 | 1230 pathl = path_from_utf8(path); |
1231 gtk_accel_map_save(pathl); | |
1232 g_free(pathl); | |
1233 g_free(path); | |
1 | 1234 |
1235 gtk_main_quit(); | |
1236 } | |
1237 | |
9 | 1238 static GenericDialog *exit_dialog = NULL; |
1239 | |
1240 static void exit_confirm_cancel_cb(GenericDialog *gd, gpointer data) | |
1241 { | |
1242 exit_dialog = NULL; | |
1243 generic_dialog_close(gd); | |
1244 } | |
1245 | |
1246 static void exit_confirm_exit_cb(GenericDialog *gd, gpointer data) | |
1247 { | |
1248 exit_dialog = NULL; | |
1249 generic_dialog_close(gd); | |
278 | 1250 exit_program_final(); |
9 | 1251 } |
1252 | |
1253 static gint exit_confirm_dlg(void) | |
1254 { | |
1255 GtkWidget *parent; | |
1256 LayoutWindow *lw; | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1257 gchar *msg; |
9 | 1258 |
1259 if (exit_dialog) | |
1260 { | |
1261 gtk_window_present(GTK_WINDOW(exit_dialog->dialog)); | |
1262 return TRUE; | |
1263 } | |
1264 | |
1265 if (!collection_window_modified_exists()) return FALSE; | |
1266 | |
1267 parent = NULL; | |
1268 lw = NULL; | |
1269 if (layout_valid(&lw)) | |
1270 { | |
1271 parent = lw->window; | |
1272 } | |
1273 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1274 msg = g_strdup_printf("%s - %s", GQ_APPNAME, _("exit")); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1275 exit_dialog = generic_dialog_new(msg, |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
227
diff
changeset
|
1276 GQ_WMCLASS, "exit", parent, FALSE, |
9 | 1277 exit_confirm_cancel_cb, NULL); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1278 g_free(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1279 msg = g_strdup_printf(_("Quit %s"), GQ_APPNAME); |
9 | 1280 generic_dialog_add_message(exit_dialog, GTK_STOCK_DIALOG_QUESTION, |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1281 msg, _("Collections have been modified. Quit anyway?")); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1282 g_free(msg); |
9 | 1283 generic_dialog_add_button(exit_dialog, GTK_STOCK_QUIT, NULL, exit_confirm_exit_cb, TRUE); |
1284 | |
1285 gtk_widget_show(exit_dialog->dialog); | |
1286 | |
1287 return TRUE; | |
1288 } | |
1289 | |
278 | 1290 void exit_program(void) |
9 | 1291 { |
1292 layout_image_full_screen_stop(NULL); | |
1293 | |
1294 if (exit_confirm_dlg()) return; | |
1295 | |
278 | 1296 exit_program_final(); |
9 | 1297 } |
1298 | |
1 | 1299 int main (int argc, char *argv[]) |
1300 { | |
9 | 1301 LayoutWindow *lw; |
1302 gchar *path = NULL; | |
1 | 1303 gchar *cmd_path = NULL; |
1304 gchar *cmd_file = NULL; | |
9 | 1305 GList *cmd_list = NULL; |
1306 GList *collection_list = NULL; | |
1307 CollectionData *first_collection = NULL; | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
1308 gchar *geometry = NULL; |
9 | 1309 gchar *buf; |
1310 gchar *bufl; | |
1 | 1311 |
1312 /* setup locale, i18n */ | |
1313 gtk_set_locale(); | |
283 | 1314 bindtextdomain(PACKAGE, GQ_LOCALEDIR); |
10 | 1315 bind_textdomain_codeset(PACKAGE, "UTF-8"); |
1316 textdomain(PACKAGE); | |
1 | 1317 |
1318 /* setup random seed for random slideshow */ | |
9 | 1319 srand(time(NULL)); |
1 | 1320 |
21
56866f205a68
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
10
diff
changeset
|
1321 #if 1 |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1322 printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION); |
9 | 1323 #endif |
318 | 1324 options = init_options(NULL); |
1 | 1325 setup_default_options(); |
1326 load_options(); | |
1327 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
1328 parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list, &geometry); |
9 | 1329 |
1330 gtk_init (&argc, &argv); | |
1331 | |
1332 if (gtk_major_version < GTK_MAJOR_VERSION || | |
1333 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) | |
1334 { | |
1335 gchar *msg; | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1336 |
9 | 1337 print_term("!!! This is a friendly warning.\n"); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1338 msg = g_strdup_printf("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1339 print_term(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1340 g_free(msg); |
9 | 1341 msg = g_strdup_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); |
1342 print_term(msg); | |
1343 g_free(msg); | |
1344 msg = g_strdup_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); | |
1345 print_term(msg); | |
1346 g_free(msg); | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1347 msg = g_strdup_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1348 print_term(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1349 g_free(msg); |
9 | 1350 } |
1351 | |
283 | 1352 check_for_home_path(GQ_RC_DIR); |
1353 check_for_home_path(GQ_RC_DIR_COLLECTIONS); | |
1354 check_for_home_path(GQ_CACHE_RC_THUMB); | |
1355 check_for_home_path(GQ_CACHE_RC_METADATA); | |
9 | 1356 |
1357 keys_load(); | |
1358 filter_add_defaults(); | |
1359 filter_rebuild(); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
138
diff
changeset
|
1360 |
283 | 1361 buf = g_strconcat(homedir(), "/", GQ_RC_DIR, "/accels", NULL); |
9 | 1362 bufl = path_from_utf8(buf); |
1363 gtk_accel_map_load(bufl); | |
1364 g_free(bufl); | |
1365 g_free(buf); | |
1 | 1366 |
9 | 1367 if (startup_blank) |
1368 { | |
1369 g_free(cmd_path); | |
1370 cmd_path = NULL; | |
1371 g_free(cmd_file); | |
1372 cmd_file = NULL; | |
1373 path_list_free(cmd_list); | |
1374 cmd_list = NULL; | |
1375 path_list_free(collection_list); | |
1376 collection_list = NULL; | |
1377 | |
1378 path = NULL; | |
1379 } | |
1380 else if (cmd_path) | |
1381 { | |
1382 path = g_strdup(cmd_path); | |
1383 } | |
318 | 1384 else if (options->startup_path_enable && options->startup_path && isdir(options->startup_path)) |
9 | 1385 { |
318 | 1386 path = g_strdup(options->startup_path); |
9 | 1387 } |
1 | 1388 else |
9 | 1389 { |
1390 path = get_current_dir(); | |
1391 } | |
1392 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
1393 lw = layout_new_with_geometry(NULL, options->layout.tools_float, options->layout.tools_hidden, geometry); |
329 | 1394 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); |
9 | 1395 |
1396 if (collection_list && !startup_command_line_collection) | |
1397 { | |
1398 GList *work; | |
1399 | |
1400 work = collection_list; | |
1401 while (work) | |
1402 { | |
1403 CollectWindow *cw; | |
1404 const gchar *path; | |
1 | 1405 |
9 | 1406 path = work->data; |
1407 work = work->next; | |
1408 | |
1409 cw = collection_window_new(path); | |
1410 if (!first_collection && cw) first_collection = cw->cd; | |
1411 } | |
1412 } | |
1413 | |
1414 if (cmd_list || | |
1415 (startup_command_line_collection && collection_list)) | |
1416 { | |
1417 CollectionData *cd; | |
1418 GList *work; | |
1419 | |
1420 if (startup_command_line_collection) | |
1421 { | |
1422 CollectWindow *cw; | |
1423 | |
1424 cw = collection_window_new(""); | |
1425 cd = cw->cd; | |
1426 } | |
1427 else | |
1428 { | |
1429 cd = collection_new(""); /* if we pass NULL, untitled counter is falsely increm. */ | |
279 | 1430 command_collection = cd; |
9 | 1431 } |
1432 | |
1433 g_free(cd->path); | |
1434 cd->path = NULL; | |
1435 g_free(cd->name); | |
1436 cd->name = g_strdup(_("Command line")); | |
1437 | |
1438 collection_path_changed(cd); | |
1 | 1439 |
9 | 1440 work = cmd_list; |
1441 while (work) | |
1442 { | |
138 | 1443 collection_add(cd, file_data_new_simple((gchar *)work->data), FALSE); |
9 | 1444 work = work->next; |
1445 } | |
1446 | |
1447 work = collection_list; | |
1448 while (work) | |
1449 { | |
358 | 1450 collection_load(cd, (gchar *)work->data, COLLECTION_LOAD_APPEND); |
9 | 1451 work = work->next; |
1452 } | |
1453 | |
1454 layout_set_path(lw, path); | |
1455 if (cd->list) layout_image_set_collection(lw, cd, cd->list->data); | |
1 | 1456 |
9 | 1457 /* mem leak, we never unref this collection when !startup_command_line_collection |
1458 * (the image view of the main window does not hold a ref to the collection) | |
1459 * this is sort of unavoidable, for if it did hold a ref, next/back | |
1460 * may not work as expected when closing collection windows. | |
1461 * | |
1462 * collection_unref(cd); | |
1463 */ | |
1464 | |
1465 } | |
1466 else if (cmd_file) | |
1467 { | |
1468 layout_set_path(lw, cmd_file); | |
1469 } | |
1470 else | |
1471 { | |
1472 layout_set_path(lw, path); | |
1473 if (first_collection) | |
1474 { | |
1475 layout_image_set_collection(lw, first_collection, | |
1476 collection_get_first(first_collection)); | |
1477 } | |
1478 } | |
322 | 1479 image_osd_set(lw->image, FALSE, options->fullscreen.show_info); |
1 | 1480 |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
1481 g_free(geometry); |
1 | 1482 g_free(cmd_path); |
1483 g_free(cmd_file); | |
9 | 1484 path_list_free(cmd_list); |
1485 path_list_free(collection_list); | |
1486 g_free(path); | |
1 | 1487 |
9 | 1488 if (startup_full_screen) layout_image_full_screen_start(lw); |
1489 if (startup_in_slideshow) layout_image_slideshow_start(lw); | |
1490 | |
283 | 1491 buf = g_strconcat(homedir(), "/", GQ_RC_DIR, "/.command", NULL); |
279 | 1492 remote_connection = remote_server_open(buf); |
1493 remote_server_subscribe(remote_connection, remote_cb, NULL); | |
9 | 1494 g_free(buf); |
3 | 1495 |
1 | 1496 gtk_main (); |
1497 return 0; | |
1498 } | |
1499 |