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