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