Mercurial > geeqie
annotate src/main.c @ 1032:7c87b324b9bb
dropped IMAGE_THROTTLE_LARGER_IMAGES code
author | nadvornik |
---|---|
date | Wed, 03 Sep 2008 19:58:21 +0000 |
parents | 9962b24b6b43 |
children | 1646720364cf |
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" | |
586 | 19 #include "filedata.h" |
20 #include "filefilter.h" | |
902 | 21 #include "history_list.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 "layout.h" |
24 #include "layout_image.h" | |
1019 | 25 #include "options.h" |
9 | 26 #include "remote.h" |
27 #include "similar.h" | |
28 #include "ui_fileops.h" | |
29 #include "ui_utildlg.h" | |
793 | 30 #include "cache_maint.h" |
877 | 31 #include "thumb.h" |
9 | 32 |
1 | 33 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
34 | |
9 | 35 |
36 #include <math.h> | |
653 | 37 #ifdef G_OS_UNIX |
38 #include <pwd.h> | |
39 #endif | |
9 | 40 |
41 | |
279 | 42 static RemoteConnection *remote_connection = NULL; |
9 | 43 |
1 | 44 |
45 /* | |
46 *----------------------------------------------------------------------------- | |
47 * keyboard functions | |
48 *----------------------------------------------------------------------------- | |
49 */ | |
50 | |
51 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event) | |
52 { | |
53 static gint delta = 0; | |
54 static guint32 time_old = 0; | |
55 static guint keyval_old = 0; | |
56 | |
9 | 57 if (event->state & GDK_CONTROL_MASK) |
58 { | |
59 if (*x < 0) *x = G_MININT / 2; | |
60 if (*x > 0) *x = G_MAXINT / 2; | |
61 if (*y < 0) *y = G_MININT / 2; | |
62 if (*y > 0) *y = G_MAXINT / 2; | |
63 | |
64 return; | |
65 } | |
66 | |
318 | 67 if (options->progressive_key_scrolling) |
1 | 68 { |
69 guint32 time_diff; | |
70 | |
71 time_diff = event->time - time_old; | |
72 | |
73 /* key pressed within 125ms ? (1/8 second) */ | |
74 if (time_diff > 125 || event->keyval != keyval_old) delta = 0; | |
75 | |
76 time_old = event->time; | |
77 keyval_old = event->keyval; | |
78 | |
79 delta += 2; | |
80 } | |
81 else | |
82 { | |
83 delta = 8; | |
84 } | |
85 | |
86 *x = *x * delta; | |
87 *y = *y * delta; | |
88 } | |
89 | |
9 | 90 |
1 | 91 |
92 /* | |
93 *----------------------------------------------------------------------------- | |
3 | 94 * command line parser (private) hehe, who needs popt anyway? |
1 | 95 *----------------------------------------------------------------------------- |
442 | 96 */ |
1 | 97 |
9 | 98 static gint startup_blank = FALSE; |
3 | 99 static gint startup_full_screen = FALSE; |
100 static gint startup_in_slideshow = FALSE; | |
9 | 101 static gint startup_command_line_collection = FALSE; |
3 | 102 |
9 | 103 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
104 static void parse_command_line_add_file(const gchar *file_path, gchar **path, gchar **file, |
442 | 105 GList **list, GList **collection_list) |
1 | 106 { |
9 | 107 gchar *path_parsed; |
108 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
109 path_parsed = g_strdup(file_path); |
9 | 110 parse_out_relatives(path_parsed); |
111 | |
781
2d2cca2bceb0
Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents:
780
diff
changeset
|
112 if (file_extension_match(path_parsed, GQ_COLLECTION_EXT)) |
9 | 113 { |
114 *collection_list = g_list_append(*collection_list, path_parsed); | |
115 } | |
116 else | |
117 { | |
118 if (!*path) *path = remove_level_from_path(path_parsed); | |
119 if (!*file) *file = g_strdup(path_parsed); | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
120 *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
|
121 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
122 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
123 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
124 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
|
125 GList **list) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
126 { |
780
44128da39e13
Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents:
767
diff
changeset
|
127 GList *files; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
128 gchar *path_parsed; |
783 | 129 FileData *dir_fd; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
130 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
131 path_parsed = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
132 parse_out_relatives(path_parsed); |
783 | 133 dir_fd = file_data_new_simple(path_parsed); |
134 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
135 |
783 | 136 if (filelist_read(dir_fd, &files, NULL)) |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
137 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
138 GList *work; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
139 |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
140 files = filelist_filter(files, FALSE); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
141 files = filelist_sort_path(files); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
142 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
143 work = files; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
144 while (work) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
145 { |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
146 FileData *fd = work->data; |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
147 if (!*path) *path = remove_level_from_path(fd->path); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
148 if (!*file) *file = g_strdup(fd->path); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
149 *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
|
150 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
151 work = work->next; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
152 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
153 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
154 g_list_free(files); |
9 | 155 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
156 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
157 g_free(path_parsed); |
783 | 158 file_data_unref(dir_fd); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
159 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
160 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
161 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
|
162 GList **list, gchar **first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
163 { |
442 | 164 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
165 if (!*list && !*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
166 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
167 *first_dir = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
168 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
169 else |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
170 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
171 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
172 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
173 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
|
174 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
175 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
176 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
177 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
|
178 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
179 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
180 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
181 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
|
182 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
|
183 { |
442 | 184 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
185 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
186 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
187 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
|
188 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
189 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
190 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
191 parse_command_line_add_file(file_path, path, file, list, collection_list); |
9 | 192 } |
193 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
194 static void parse_command_line(gint argc, gchar *argv[], gchar **path, gchar **file, |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
195 GList **cmd_list, GList **collection_list, |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
196 gchar **geometry) |
9 | 197 { |
198 GList *list = NULL; | |
199 GList *remote_list = NULL; | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
200 GList *remote_errors = NULL; |
9 | 201 gint remote_do = FALSE; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
202 gchar *first_dir = NULL; |
9 | 203 |
1 | 204 if (argc > 1) |
205 { | |
206 gint i; | |
207 gchar *base_dir = get_current_dir(); | |
208 i = 1; | |
209 while (i < argc) | |
210 { | |
9 | 211 const gchar *cmd_line = argv[i]; |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
694
diff
changeset
|
212 gchar *cmd_all = g_build_filename(base_dir, cmd_line, NULL); |
1 | 213 |
726 | 214 if (cmd_line[0] == G_DIR_SEPARATOR && isdir(cmd_line)) |
1 | 215 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
216 parse_command_line_process_dir(cmd_line, path, file, &list, &first_dir); |
1 | 217 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
218 else if (isdir(cmd_all)) |
1 | 219 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
220 parse_command_line_process_dir(cmd_all, path, file, &list, &first_dir); |
1 | 221 } |
726 | 222 else if (cmd_line[0] == G_DIR_SEPARATOR && isfile(cmd_line)) |
1 | 223 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
224 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
|
225 &list, collection_list, &first_dir); |
1 | 226 } |
9 | 227 else if (isfile(cmd_all)) |
1 | 228 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
229 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
|
230 &list, collection_list, &first_dir); |
1 | 231 } |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
232 else if (strncmp(cmd_line, "--debug", 7) == 0 && (cmd_line[7] == '\0' || cmd_line[7] == '=')) |
1 | 233 { |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
234 /* do nothing but do not produce warnings */ |
1 | 235 } |
236 else if (strcmp(cmd_line, "+t") == 0 || | |
3 | 237 strcmp(cmd_line, "--with-tools") == 0) |
1 | 238 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
239 options->layout.tools_float = FALSE; |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
240 options->layout.tools_hidden = FALSE; |
9 | 241 |
242 remote_list = g_list_append(remote_list, "+t"); | |
1 | 243 } |
244 else if (strcmp(cmd_line, "-t") == 0 || | |
3 | 245 strcmp(cmd_line, "--without-tools") == 0) |
1 | 246 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
247 options->layout.tools_hidden = TRUE; |
9 | 248 |
249 remote_list = g_list_append(remote_list, "-t"); | |
1 | 250 } |
3 | 251 else if (strcmp(cmd_line, "-f") == 0 || |
252 strcmp(cmd_line, "--fullscreen") == 0) | |
253 { | |
254 startup_full_screen = TRUE; | |
255 } | |
256 else if (strcmp(cmd_line, "-s") == 0 || | |
257 strcmp(cmd_line, "--slideshow") == 0) | |
258 { | |
259 startup_in_slideshow = TRUE; | |
260 } | |
9 | 261 else if (strcmp(cmd_line, "-l") == 0 || |
262 strcmp(cmd_line, "--list") == 0) | |
263 { | |
264 startup_command_line_collection = TRUE; | |
265 } | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
266 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
|
267 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
268 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
|
269 } |
9 | 270 else if (strcmp(cmd_line, "-r") == 0 || |
271 strcmp(cmd_line, "--remote") == 0) | |
272 { | |
273 if (!remote_do) | |
274 { | |
275 remote_do = TRUE; | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
276 remote_list = remote_build_list(remote_list, argc - i, &argv[i], &remote_errors); |
9 | 277 } |
278 } | |
279 else if (strcmp(cmd_line, "-rh") == 0 || | |
280 strcmp(cmd_line, "--remote-help") == 0) | |
281 { | |
279 | 282 remote_help(); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
283 exit(0); |
9 | 284 } |
285 else if (strcmp(cmd_line, "--blank") == 0) | |
286 { | |
287 startup_blank = TRUE; | |
288 } | |
289 else if (strcmp(cmd_line, "-v") == 0 || | |
290 strcmp(cmd_line, "--version") == 0) | |
291 { | |
694 | 292 printf_term("%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
|
293 exit(0); |
9 | 294 } |
295 else if (strcmp(cmd_line, "--alternate") == 0) | |
296 { | |
297 /* enable faster experimental algorithm */ | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
298 log_printf("Alternate similarity algorithm enabled\n"); |
9 | 299 image_sim_alternate_set(TRUE); |
300 } | |
3 | 301 else if (strcmp(cmd_line, "-h") == 0 || |
302 strcmp(cmd_line, "--help") == 0) | |
1 | 303 { |
694 | 304 printf_term("%s %s\n", GQ_APPNAME, VERSION); |
403 | 305 printf_term(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC); |
9 | 306 print_term(_("valid options are:\n")); |
307 print_term(_(" +t, --with-tools force show of tools\n")); | |
308 print_term(_(" -t, --without-tools force hide of tools\n")); | |
309 print_term(_(" -f, --fullscreen start in full screen mode\n")); | |
310 print_term(_(" -s, --slideshow start in slideshow mode\n")); | |
311 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
|
312 print_term(_(" --geometry=GEOMETRY set main window location\n")); |
9 | 313 print_term(_(" -r, --remote send following commands to open window\n")); |
314 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
|
315 #ifdef DEBUG |
379 | 316 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
|
317 #endif |
9 | 318 print_term(_(" -v, --version print version info\n")); |
319 print_term(_(" -h, --help show this message\n\n")); | |
442 | 320 |
9 | 321 #if 0 |
322 /* these options are not officially supported! | |
323 * only for testing new features, no need to translate them */ | |
324 print_term( " --alternate use alternate similarity algorithm\n"); | |
325 #endif | |
442 | 326 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
327 exit(0); |
1 | 328 } |
9 | 329 else if (!remote_do) |
1 | 330 { |
403 | 331 printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); |
1 | 332 } |
9 | 333 |
1 | 334 g_free(cmd_all); |
335 i++; | |
336 } | |
337 g_free(base_dir); | |
338 parse_out_relatives(*path); | |
339 parse_out_relatives(*file); | |
340 } | |
9 | 341 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
342 list = g_list_reverse(list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
343 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
344 if (!*path && first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
345 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
346 *path = first_dir; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
347 first_dir = NULL; |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
348 |
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
349 parse_out_relatives(*path); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
350 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
351 g_free(first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
352 |
9 | 353 if (remote_do) |
354 { | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
355 if (remote_errors) |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
356 { |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
357 GList *work = remote_errors; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
358 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
359 printf_term(_("Invalid or ignored remote options: ")); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
360 while (work) |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
361 { |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
362 gchar *opt = work->data; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
363 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
364 printf_term("%s%s", (work == remote_errors) ? "" : ", ", opt); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
365 work = work->next; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
366 } |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
367 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
368 printf_term(_("\nUse --remote-help for valid remote options.\n")); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
369 } |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
370 |
279 | 371 remote_control(argv[0], remote_list, *path, list, *collection_list); |
9 | 372 } |
373 g_list_free(remote_list); | |
374 | |
375 if (list && list->next) | |
376 { | |
377 *cmd_list = list; | |
378 } | |
379 else | |
380 { | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
381 filelist_free(list); |
9 | 382 *cmd_list = NULL; |
383 } | |
1 | 384 } |
385 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
386 static void parse_command_line_for_debug_option(gint argc, gchar *argv[]) |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
387 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
388 #ifdef DEBUG |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
389 const gchar *debug_option = "--debug"; |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
390 gint len = strlen(debug_option); |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
391 |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
392 if (argc > 1) |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
393 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
394 gint i; |
442 | 395 |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
396 for (i = 1; i < argc; i++) |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
397 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
398 const gchar *cmd_line = argv[i]; |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
399 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
|
400 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
401 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
|
402 |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
403 /* 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
|
404 if (cmd_line_len == len) |
507 | 405 debug_level_add(1); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
406 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
|
407 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
408 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
|
409 if (n < 0) n = 1; |
507 | 410 debug_level_add(n); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
411 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
412 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
413 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
414 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
415 |
507 | 416 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
|
417 #endif |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
418 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
419 |
1 | 420 /* |
421 *----------------------------------------------------------------------------- | |
422 * startup, init, and exit | |
423 *----------------------------------------------------------------------------- | |
442 | 424 */ |
1 | 425 |
9 | 426 #define RC_HISTORY_NAME "history" |
427 | |
428 static void keys_load(void) | |
429 { | |
430 gchar *path; | |
431 | |
714 | 432 path = g_build_filename(homedir(), GQ_RC_DIR, RC_HISTORY_NAME, NULL); |
9 | 433 history_list_load(path); |
434 g_free(path); | |
435 } | |
436 | |
437 static void keys_save(void) | |
438 { | |
439 gchar *path; | |
440 | |
714 | 441 path = g_build_filename(homedir(), GQ_RC_DIR, RC_HISTORY_NAME, NULL); |
9 | 442 history_list_save(path); |
443 g_free(path); | |
444 } | |
445 | |
446 static void check_for_home_path(gchar *path) | |
1 | 447 { |
9 | 448 gchar *buf; |
449 | |
714 | 450 buf = g_build_filename(homedir(), path, NULL); |
9 | 451 if (!isdir(buf)) |
452 { | |
694 | 453 log_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, buf); |
442 | 454 |
9 | 455 if (!mkdir_utf8(buf, 0755)) |
456 { | |
694 | 457 log_printf(_("Could not create dir:%s\n"), buf); |
9 | 458 } |
459 } | |
460 g_free(buf); | |
461 } | |
462 | |
1017 | 463 static void accel_map_save(void) |
464 { | |
465 gchar *path; | |
466 gchar *pathl; | |
467 | |
468 path = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL); | |
469 pathl = path_from_utf8(path); | |
470 gtk_accel_map_save(pathl); | |
471 g_free(pathl); | |
472 g_free(path); | |
473 } | |
474 | |
475 static void accel_map_load(void) | |
476 { | |
477 gchar *path; | |
478 gchar *pathl; | |
479 | |
480 path = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL); | |
481 pathl = path_from_utf8(path); | |
482 gtk_accel_map_load(pathl); | |
483 g_free(pathl); | |
484 g_free(path); | |
485 } | |
486 | |
487 static void gtkrc_load(void) | |
488 { | |
489 gchar *path; | |
490 gchar *pathl; | |
491 | |
492 /* If a gtkrc file exists in the rc directory, add it to the | |
493 * list of files to be parsed at the end of gtk_init() */ | |
494 path = g_build_filename(homedir(), GQ_RC_DIR, "gtkrc", NULL); | |
495 pathl = path_from_utf8(path); | |
496 if (access(pathl, R_OK) == 0) | |
497 gtk_rc_add_default_file(pathl); | |
498 g_free(pathl); | |
499 g_free(path); | |
500 } | |
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
501 |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
502 static void exit_program_final(void) |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
503 { |
840 | 504 LayoutWindow *lw = NULL; |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
505 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
506 remote_close(remote_connection); |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
507 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
508 collect_manager_flush(); |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
509 |
742
a336b5545af6
Pass ConfOptions * to save_options() and load_options().
zas_
parents:
740
diff
changeset
|
510 save_options(options); |
9 | 511 keys_save(); |
1017 | 512 accel_map_save(); |
1 | 513 |
840 | 514 if (layout_valid(&lw)) |
515 { | |
516 layout_free(lw); | |
517 } | |
518 | |
1 | 519 gtk_main_quit(); |
520 } | |
521 | |
9 | 522 static GenericDialog *exit_dialog = NULL; |
523 | |
524 static void exit_confirm_cancel_cb(GenericDialog *gd, gpointer data) | |
525 { | |
526 exit_dialog = NULL; | |
527 generic_dialog_close(gd); | |
528 } | |
529 | |
530 static void exit_confirm_exit_cb(GenericDialog *gd, gpointer data) | |
531 { | |
532 exit_dialog = NULL; | |
533 generic_dialog_close(gd); | |
278 | 534 exit_program_final(); |
9 | 535 } |
536 | |
537 static gint exit_confirm_dlg(void) | |
538 { | |
539 GtkWidget *parent; | |
540 LayoutWindow *lw; | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
541 gchar *msg; |
9 | 542 |
543 if (exit_dialog) | |
544 { | |
545 gtk_window_present(GTK_WINDOW(exit_dialog->dialog)); | |
546 return TRUE; | |
547 } | |
548 | |
549 if (!collection_window_modified_exists()) return FALSE; | |
550 | |
551 parent = NULL; | |
552 lw = NULL; | |
553 if (layout_valid(&lw)) | |
554 { | |
555 parent = lw->window; | |
556 } | |
557 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
558 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
|
559 exit_dialog = generic_dialog_new(msg, |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
227
diff
changeset
|
560 GQ_WMCLASS, "exit", parent, FALSE, |
9 | 561 exit_confirm_cancel_cb, NULL); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
562 g_free(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
563 msg = g_strdup_printf(_("Quit %s"), GQ_APPNAME); |
9 | 564 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
|
565 msg, _("Collections have been modified. Quit anyway?")); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
566 g_free(msg); |
9 | 567 generic_dialog_add_button(exit_dialog, GTK_STOCK_QUIT, NULL, exit_confirm_exit_cb, TRUE); |
568 | |
569 gtk_widget_show(exit_dialog->dialog); | |
570 | |
571 return TRUE; | |
572 } | |
573 | |
278 | 574 void exit_program(void) |
9 | 575 { |
576 layout_image_full_screen_stop(NULL); | |
577 | |
578 if (exit_confirm_dlg()) return; | |
579 | |
278 | 580 exit_program_final(); |
9 | 581 } |
582 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
583 gint main(gint argc, gchar *argv[]) |
1 | 584 { |
9 | 585 LayoutWindow *lw; |
586 gchar *path = NULL; | |
1 | 587 gchar *cmd_path = NULL; |
588 gchar *cmd_file = NULL; | |
9 | 589 GList *cmd_list = NULL; |
590 GList *collection_list = NULL; | |
591 CollectionData *first_collection = NULL; | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
592 gchar *geometry = NULL; |
9 | 593 gchar *buf; |
649 | 594 CollectionData *cd = NULL; |
1 | 595 |
1015 | 596 #ifdef HAVE_GTHREAD |
597 g_thread_init (NULL); | |
1020 | 598 gdk_threads_init(); |
599 gdk_threads_enter(); | |
1015 | 600 #endif |
601 | |
509 | 602 /* init execution time counter (debug only) */ |
603 init_exec_time(); | |
442 | 604 |
1 | 605 /* setup locale, i18n */ |
606 gtk_set_locale(); | |
686 | 607 |
687 | 608 #ifdef ENABLE_NLS |
609 bindtextdomain(PACKAGE, GQ_LOCALEDIR); | |
10 | 610 bind_textdomain_codeset(PACKAGE, "UTF-8"); |
611 textdomain(PACKAGE); | |
686 | 612 #endif |
995 | 613 |
1 | 614 /* setup random seed for random slideshow */ |
442 | 615 srand(time(NULL)); |
1 | 616 |
21
56866f205a68
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
10
diff
changeset
|
617 #if 1 |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
618 log_printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION); |
9 | 619 #endif |
793 | 620 |
621 /* register global notify functions */ | |
622 file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); | |
877 | 623 file_data_register_notify_func(thumb_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); |
799 | 624 file_data_register_notify_func(collect_manager_notify_cb, NULL, NOTIFY_PRIORITY_LOW); |
793 | 625 |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
626 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
|
627 |
318 | 628 options = init_options(NULL); |
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
739
diff
changeset
|
629 setup_default_options(options); |
742
a336b5545af6
Pass ConfOptions * to save_options() and load_options().
zas_
parents:
740
diff
changeset
|
630 load_options(options); |
1 | 631 |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
632 parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list, &geometry); |
9 | 633 |
1017 | 634 gtkrc_load(); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
635 gtk_init(&argc, &argv); |
9 | 636 |
637 if (gtk_major_version < GTK_MAJOR_VERSION || | |
638 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) | |
639 { | |
694 | 640 log_printf("!!! This is a friendly warning.\n"); |
641 log_printf("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); | |
642 log_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); | |
643 log_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); | |
644 log_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); | |
9 | 645 } |
646 | |
283 | 647 check_for_home_path(GQ_RC_DIR); |
648 check_for_home_path(GQ_RC_DIR_COLLECTIONS); | |
649 check_for_home_path(GQ_CACHE_RC_THUMB); | |
650 check_for_home_path(GQ_CACHE_RC_METADATA); | |
9 | 651 |
652 keys_load(); | |
653 filter_add_defaults(); | |
654 filter_rebuild(); | |
442 | 655 |
1017 | 656 accel_map_load(); |
1 | 657 |
9 | 658 if (startup_blank) |
659 { | |
660 g_free(cmd_path); | |
661 cmd_path = NULL; | |
662 g_free(cmd_file); | |
663 cmd_file = NULL; | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
664 filelist_free(cmd_list); |
9 | 665 cmd_list = NULL; |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
666 string_list_free(collection_list); |
9 | 667 collection_list = NULL; |
668 | |
669 path = NULL; | |
670 } | |
671 else if (cmd_path) | |
672 { | |
673 path = g_strdup(cmd_path); | |
674 } | |
629 | 675 else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path)) |
9 | 676 { |
629 | 677 path = g_strdup(options->startup.path); |
9 | 678 } |
1 | 679 else |
9 | 680 { |
681 path = get_current_dir(); | |
682 } | |
683 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
684 lw = layout_new_with_geometry(NULL, options->layout.tools_float, options->layout.tools_hidden, geometry); |
329 | 685 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); |
9 | 686 |
687 if (collection_list && !startup_command_line_collection) | |
688 { | |
689 GList *work; | |
690 | |
691 work = collection_list; | |
692 while (work) | |
693 { | |
694 CollectWindow *cw; | |
695 const gchar *path; | |
1 | 696 |
9 | 697 path = work->data; |
698 work = work->next; | |
699 | |
700 cw = collection_window_new(path); | |
701 if (!first_collection && cw) first_collection = cw->cd; | |
702 } | |
703 } | |
704 | |
705 if (cmd_list || | |
706 (startup_command_line_collection && collection_list)) | |
707 { | |
708 GList *work; | |
709 | |
710 if (startup_command_line_collection) | |
711 { | |
712 CollectWindow *cw; | |
713 | |
714 cw = collection_window_new(""); | |
715 cd = cw->cd; | |
716 } | |
717 else | |
718 { | |
719 cd = collection_new(""); /* if we pass NULL, untitled counter is falsely increm. */ | |
720 } | |
721 | |
722 g_free(cd->path); | |
723 cd->path = NULL; | |
724 g_free(cd->name); | |
725 cd->name = g_strdup(_("Command line")); | |
726 | |
727 collection_path_changed(cd); | |
1 | 728 |
9 | 729 work = cmd_list; |
730 while (work) | |
731 { | |
138 | 732 collection_add(cd, file_data_new_simple((gchar *)work->data), FALSE); |
9 | 733 work = work->next; |
734 } | |
735 | |
736 work = collection_list; | |
737 while (work) | |
738 { | |
358 | 739 collection_load(cd, (gchar *)work->data, COLLECTION_LOAD_APPEND); |
9 | 740 work = work->next; |
741 } | |
742 | |
743 layout_set_path(lw, path); | |
744 if (cd->list) layout_image_set_collection(lw, cd, cd->list->data); | |
1 | 745 |
9 | 746 /* mem leak, we never unref this collection when !startup_command_line_collection |
747 * (the image view of the main window does not hold a ref to the collection) | |
748 * this is sort of unavoidable, for if it did hold a ref, next/back | |
749 * may not work as expected when closing collection windows. | |
750 * | |
751 * collection_unref(cd); | |
752 */ | |
753 | |
754 } | |
755 else if (cmd_file) | |
756 { | |
757 layout_set_path(lw, cmd_file); | |
758 } | |
759 else | |
760 { | |
761 layout_set_path(lw, path); | |
762 if (first_collection) | |
763 { | |
764 layout_image_set_collection(lw, first_collection, | |
765 collection_get_first(first_collection)); | |
766 } | |
767 } | |
614 | 768 |
638
8cc9f349c670
Rename option image_overlay.common.enabled to image_overlay.common.state
zas_
parents:
630
diff
changeset
|
769 image_osd_set(lw->image, options->image_overlay.common.state | (options->image_overlay.common.show_at_startup ? OSD_SHOW_INFO : OSD_SHOW_NOTHING)); |
1 | 770 |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
771 g_free(geometry); |
1 | 772 g_free(cmd_path); |
773 g_free(cmd_file); | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
774 filelist_free(cmd_list); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
775 string_list_free(collection_list); |
9 | 776 g_free(path); |
1 | 777 |
9 | 778 if (startup_full_screen) layout_image_full_screen_start(lw); |
779 if (startup_in_slideshow) layout_image_slideshow_start(lw); | |
780 | |
714 | 781 buf = g_build_filename(homedir(), GQ_RC_DIR, ".command", NULL); |
649 | 782 remote_connection = remote_server_init(buf, cd); |
9 | 783 g_free(buf); |
1020 | 784 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
785 gtk_main(); |
1020 | 786 #ifdef HAVE_GTHREAD |
787 gdk_threads_leave(); | |
788 #endif | |
1 | 789 return 0; |
790 } |