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