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