Mercurial > geeqie.yaz
annotate src/main.c @ 739:3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
author | zas_ |
---|---|
date | Thu, 22 May 2008 22:49:07 +0000 |
parents | ff8b802eac58 |
children | 9b0ac8d58c89 |
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 |
738
ff8b802eac58
Separate path building code from options loading code.
zas_
parents:
737
diff
changeset
|
16 #include "bar_exif.h" |
9 | 17 #include "cache.h" |
18 #include "collect.h" | |
19 #include "collect-io.h" | |
20 #include "dnd.h" | |
21 #include "editors.h" | |
586 | 22 #include "filedata.h" |
23 #include "filefilter.h" | |
354
5c82855feba7
Add a button to reset fullscreen info string to default value.
zas_
parents:
341
diff
changeset
|
24 #include "fullscreen.h" |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
214
diff
changeset
|
25 #include "image-overlay.h" |
9 | 26 #include "img-view.h" |
684 | 27 #include "info.h" |
9 | 28 #include "layout.h" |
29 #include "layout_image.h" | |
30 #include "menu.h" | |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
31 #include "pixbuf_util.h" |
9 | 32 #include "preferences.h" |
33 #include "rcfile.h" | |
34 #include "remote.h" | |
35 #include "similar.h" | |
36 #include "slideshow.h" | |
37 #include "utilops.h" | |
38 #include "ui_bookmark.h" | |
39 #include "ui_help.h" | |
40 #include "ui_fileops.h" | |
41 #include "ui_tabcomp.h" | |
42 #include "ui_utildlg.h" | |
648
e34c1002e553
Move some functions from main.[ch] to new window.[ch].
zas_
parents:
645
diff
changeset
|
43 #include "window.h" |
9 | 44 |
1 | 45 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
46 | |
9 | 47 |
48 #include <math.h> | |
653 | 49 #ifdef G_OS_UNIX |
50 #include <pwd.h> | |
51 #endif | |
9 | 52 |
53 | |
279 | 54 static RemoteConnection *remote_connection = NULL; |
9 | 55 |
1 | 56 |
57 /* | |
58 *----------------------------------------------------------------------------- | |
9 | 59 * misc (public) |
1 | 60 *----------------------------------------------------------------------------- |
442 | 61 */ |
1 | 62 |
9 | 63 |
64 gdouble get_zoom_increment(void) | |
65 { | |
334 | 66 return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0); |
1 | 67 } |
68 | |
645
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
69 gchar *utf8_validate_or_convert(gchar *text) |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
70 { |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
71 gint len; |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
72 |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
73 if (!text) return NULL; |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
74 |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
75 len = strlen(text); |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
76 if (!g_utf8_validate(text, len, NULL)) |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
77 { |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
78 gchar *conv_text; |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
79 |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
80 conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
81 g_free(text); |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
82 text = conv_text; |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
83 } |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
84 |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
85 return text; |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
86 } |
b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
zas_
parents:
638
diff
changeset
|
87 |
653 | 88 /* Borrowed from gtkfilesystemunix.c */ |
89 gchar *expand_tilde(const gchar *filename) | |
90 { | |
91 #ifndef G_OS_UNIX | |
92 return g_strdup(filename); | |
93 #else | |
94 const char *notilde; | |
95 const char *slash; | |
96 const char *home; | |
97 | |
98 if (filename[0] != '~') | |
99 return g_strdup(filename); | |
100 | |
101 notilde = filename + 1; | |
102 slash = strchr(notilde, G_DIR_SEPARATOR); | |
103 if (slash == notilde || !*notilde) | |
104 { | |
105 home = g_get_home_dir(); | |
106 if (!home) | |
107 return g_strdup(filename); | |
108 } | |
109 else | |
110 { | |
111 gchar *username; | |
112 struct passwd *passwd; | |
113 | |
114 if (slash) | |
115 username = g_strndup(notilde, slash - notilde); | |
116 else | |
117 username = g_strdup(notilde); | |
118 | |
119 passwd = getpwnam(username); | |
120 g_free(username); | |
121 | |
122 if (!passwd) | |
123 return g_strdup(filename); | |
124 | |
125 home = passwd->pw_dir; | |
126 } | |
127 | |
128 if (slash) | |
129 return g_build_filename(home, G_DIR_SEPARATOR_S, slash + 1, NULL); | |
130 else | |
131 return g_build_filename(home, G_DIR_SEPARATOR_S, NULL); | |
132 #endif | |
133 } | |
134 | |
135 | |
1 | 136 /* |
137 *----------------------------------------------------------------------------- | |
138 * keyboard functions | |
139 *----------------------------------------------------------------------------- | |
140 */ | |
141 | |
142 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event) | |
143 { | |
144 static gint delta = 0; | |
145 static guint32 time_old = 0; | |
146 static guint keyval_old = 0; | |
147 | |
9 | 148 if (event->state & GDK_CONTROL_MASK) |
149 { | |
150 if (*x < 0) *x = G_MININT / 2; | |
151 if (*x > 0) *x = G_MAXINT / 2; | |
152 if (*y < 0) *y = G_MININT / 2; | |
153 if (*y > 0) *y = G_MAXINT / 2; | |
154 | |
155 return; | |
156 } | |
157 | |
318 | 158 if (options->progressive_key_scrolling) |
1 | 159 { |
160 guint32 time_diff; | |
161 | |
162 time_diff = event->time - time_old; | |
163 | |
164 /* key pressed within 125ms ? (1/8 second) */ | |
165 if (time_diff > 125 || event->keyval != keyval_old) delta = 0; | |
166 | |
167 time_old = event->time; | |
168 keyval_old = event->keyval; | |
169 | |
170 delta += 2; | |
171 } | |
172 else | |
173 { | |
174 delta = 8; | |
175 } | |
176 | |
177 *x = *x * delta; | |
178 *y = *y * delta; | |
179 } | |
180 | |
9 | 181 |
1 | 182 |
183 /* | |
184 *----------------------------------------------------------------------------- | |
3 | 185 * command line parser (private) hehe, who needs popt anyway? |
1 | 186 *----------------------------------------------------------------------------- |
442 | 187 */ |
1 | 188 |
9 | 189 static gint startup_blank = FALSE; |
3 | 190 static gint startup_full_screen = FALSE; |
191 static gint startup_in_slideshow = FALSE; | |
9 | 192 static gint startup_command_line_collection = FALSE; |
3 | 193 |
9 | 194 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
195 static void parse_command_line_add_file(const gchar *file_path, gchar **path, gchar **file, |
442 | 196 GList **list, GList **collection_list) |
1 | 197 { |
9 | 198 gchar *path_parsed; |
199 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
200 path_parsed = g_strdup(file_path); |
9 | 201 parse_out_relatives(path_parsed); |
202 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
203 if (file_extension_match(path_parsed, ".gqv")) |
9 | 204 { |
205 *collection_list = g_list_append(*collection_list, path_parsed); | |
206 } | |
207 else | |
208 { | |
209 if (!*path) *path = remove_level_from_path(path_parsed); | |
210 if (!*file) *file = g_strdup(path_parsed); | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
211 *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
|
212 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
213 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
214 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
215 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
|
216 GList **list) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
217 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
218 GList *files = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
219 gchar *path_parsed; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
220 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
221 path_parsed = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
222 parse_out_relatives(path_parsed); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
223 |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
224 if (filelist_read(path_parsed, &files, NULL)) |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
225 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
226 GList *work; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
227 |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
228 files = filelist_filter(files, FALSE); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
229 files = filelist_sort_path(files); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
230 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
231 work = files; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
232 while (work) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
233 { |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
234 FileData *fd = work->data; |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
235 if (!*path) *path = remove_level_from_path(fd->path); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
236 if (!*file) *file = g_strdup(fd->path); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
237 *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
|
238 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
239 work = work->next; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
240 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
241 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
242 g_list_free(files); |
9 | 243 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
244 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
245 g_free(path_parsed); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
246 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
247 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
248 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
|
249 GList **list, gchar **first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
250 { |
442 | 251 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
252 if (!*list && !*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
253 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
254 *first_dir = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
255 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
256 else |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
257 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
258 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
259 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
260 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
|
261 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
262 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
263 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
264 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
|
265 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
266 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
267 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
268 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
|
269 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
|
270 { |
442 | 271 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
272 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
273 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
274 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
|
275 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
276 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
277 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
278 parse_command_line_add_file(file_path, path, file, list, collection_list); |
9 | 279 } |
280 | |
281 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
|
282 GList **cmd_list, GList **collection_list, |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
283 gchar **geometry) |
9 | 284 { |
285 GList *list = NULL; | |
286 GList *remote_list = NULL; | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
287 GList *remote_errors = NULL; |
9 | 288 gint remote_do = FALSE; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
289 gchar *first_dir = NULL; |
9 | 290 |
1 | 291 if (argc > 1) |
292 { | |
293 gint i; | |
294 gchar *base_dir = get_current_dir(); | |
295 i = 1; | |
296 while (i < argc) | |
297 { | |
9 | 298 const gchar *cmd_line = argv[i]; |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
694
diff
changeset
|
299 gchar *cmd_all = g_build_filename(base_dir, cmd_line, NULL); |
1 | 300 |
726 | 301 if (cmd_line[0] == G_DIR_SEPARATOR && isdir(cmd_line)) |
1 | 302 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
303 parse_command_line_process_dir(cmd_line, path, file, &list, &first_dir); |
1 | 304 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
305 else if (isdir(cmd_all)) |
1 | 306 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
307 parse_command_line_process_dir(cmd_all, path, file, &list, &first_dir); |
1 | 308 } |
726 | 309 else if (cmd_line[0] == G_DIR_SEPARATOR && isfile(cmd_line)) |
1 | 310 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
311 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
|
312 &list, collection_list, &first_dir); |
1 | 313 } |
9 | 314 else if (isfile(cmd_all)) |
1 | 315 { |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
316 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
|
317 &list, collection_list, &first_dir); |
1 | 318 } |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
319 else if (strncmp(cmd_line, "--debug", 7) == 0 && (cmd_line[7] == '\0' || cmd_line[7] == '=')) |
1 | 320 { |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
321 /* do nothing but do not produce warnings */ |
1 | 322 } |
323 else if (strcmp(cmd_line, "+t") == 0 || | |
3 | 324 strcmp(cmd_line, "--with-tools") == 0) |
1 | 325 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
326 options->layout.tools_float = FALSE; |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
327 options->layout.tools_hidden = FALSE; |
9 | 328 |
329 remote_list = g_list_append(remote_list, "+t"); | |
1 | 330 } |
331 else if (strcmp(cmd_line, "-t") == 0 || | |
3 | 332 strcmp(cmd_line, "--without-tools") == 0) |
1 | 333 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
334 options->layout.tools_hidden = TRUE; |
9 | 335 |
336 remote_list = g_list_append(remote_list, "-t"); | |
1 | 337 } |
3 | 338 else if (strcmp(cmd_line, "-f") == 0 || |
339 strcmp(cmd_line, "--fullscreen") == 0) | |
340 { | |
341 startup_full_screen = TRUE; | |
342 } | |
343 else if (strcmp(cmd_line, "-s") == 0 || | |
344 strcmp(cmd_line, "--slideshow") == 0) | |
345 { | |
346 startup_in_slideshow = TRUE; | |
347 } | |
9 | 348 else if (strcmp(cmd_line, "-l") == 0 || |
349 strcmp(cmd_line, "--list") == 0) | |
350 { | |
351 startup_command_line_collection = TRUE; | |
352 } | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
353 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
|
354 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
355 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
|
356 } |
9 | 357 else if (strcmp(cmd_line, "-r") == 0 || |
358 strcmp(cmd_line, "--remote") == 0) | |
359 { | |
360 if (!remote_do) | |
361 { | |
362 remote_do = TRUE; | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
363 remote_list = remote_build_list(remote_list, argc - i, &argv[i], &remote_errors); |
9 | 364 } |
365 } | |
366 else if (strcmp(cmd_line, "-rh") == 0 || | |
367 strcmp(cmd_line, "--remote-help") == 0) | |
368 { | |
279 | 369 remote_help(); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
370 exit(0); |
9 | 371 } |
372 else if (strcmp(cmd_line, "--blank") == 0) | |
373 { | |
374 startup_blank = TRUE; | |
375 } | |
376 else if (strcmp(cmd_line, "-v") == 0 || | |
377 strcmp(cmd_line, "--version") == 0) | |
378 { | |
694 | 379 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
|
380 exit(0); |
9 | 381 } |
382 else if (strcmp(cmd_line, "--alternate") == 0) | |
383 { | |
384 /* enable faster experimental algorithm */ | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
385 log_printf("Alternate similarity algorithm enabled\n"); |
9 | 386 image_sim_alternate_set(TRUE); |
387 } | |
3 | 388 else if (strcmp(cmd_line, "-h") == 0 || |
389 strcmp(cmd_line, "--help") == 0) | |
1 | 390 { |
694 | 391 printf_term("%s %s\n", GQ_APPNAME, VERSION); |
403 | 392 printf_term(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC); |
9 | 393 print_term(_("valid options are:\n")); |
394 print_term(_(" +t, --with-tools force show of tools\n")); | |
395 print_term(_(" -t, --without-tools force hide of tools\n")); | |
396 print_term(_(" -f, --fullscreen start in full screen mode\n")); | |
397 print_term(_(" -s, --slideshow start in slideshow mode\n")); | |
398 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
|
399 print_term(_(" --geometry=GEOMETRY set main window location\n")); |
9 | 400 print_term(_(" -r, --remote send following commands to open window\n")); |
401 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
|
402 #ifdef DEBUG |
379 | 403 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
|
404 #endif |
9 | 405 print_term(_(" -v, --version print version info\n")); |
406 print_term(_(" -h, --help show this message\n\n")); | |
442 | 407 |
9 | 408 #if 0 |
409 /* these options are not officially supported! | |
410 * only for testing new features, no need to translate them */ | |
411 print_term( " --alternate use alternate similarity algorithm\n"); | |
412 #endif | |
442 | 413 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
414 exit(0); |
1 | 415 } |
9 | 416 else if (!remote_do) |
1 | 417 { |
403 | 418 printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); |
1 | 419 } |
9 | 420 |
1 | 421 g_free(cmd_all); |
422 i++; | |
423 } | |
424 g_free(base_dir); | |
425 parse_out_relatives(*path); | |
426 parse_out_relatives(*file); | |
427 } | |
9 | 428 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
429 list = g_list_reverse(list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
430 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
431 if (!*path && first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
432 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
433 *path = first_dir; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
434 first_dir = NULL; |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
435 |
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
436 parse_out_relatives(*path); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
437 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
438 g_free(first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
439 |
9 | 440 if (remote_do) |
441 { | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
442 if (remote_errors) |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
443 { |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
444 GList *work = remote_errors; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
445 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
446 printf_term(_("Invalid or ignored remote options: ")); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
447 while (work) |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
448 { |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
449 gchar *opt = work->data; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
450 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
451 printf_term("%s%s", (work == remote_errors) ? "" : ", ", opt); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
452 work = work->next; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
453 } |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
454 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
455 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
|
456 } |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
457 |
279 | 458 remote_control(argv[0], remote_list, *path, list, *collection_list); |
9 | 459 } |
460 g_list_free(remote_list); | |
461 | |
462 if (list && list->next) | |
463 { | |
464 *cmd_list = list; | |
465 } | |
466 else | |
467 { | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
468 filelist_free(list); |
9 | 469 *cmd_list = NULL; |
470 } | |
1 | 471 } |
472 | |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
473 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
|
474 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
475 #ifdef DEBUG |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
476 const gchar *debug_option = "--debug"; |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
477 gint len = strlen(debug_option); |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
478 |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
479 if (argc > 1) |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
480 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
481 gint i; |
442 | 482 |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
483 for (i = 1; i < argc; i++) |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
484 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
485 const gchar *cmd_line = argv[i]; |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
486 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
|
487 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
488 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
|
489 |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
490 /* 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
|
491 if (cmd_line_len == len) |
507 | 492 debug_level_add(1); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
493 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
|
494 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
495 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
|
496 if (n < 0) n = 1; |
507 | 497 debug_level_add(n); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
498 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
499 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
500 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
501 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
502 |
507 | 503 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
|
504 #endif |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
505 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
506 |
1 | 507 /* |
508 *----------------------------------------------------------------------------- | |
509 * startup, init, and exit | |
510 *----------------------------------------------------------------------------- | |
442 | 511 */ |
1 | 512 |
9 | 513 #define RC_HISTORY_NAME "history" |
514 | |
515 static void keys_load(void) | |
516 { | |
517 gchar *path; | |
518 | |
714 | 519 path = g_build_filename(homedir(), GQ_RC_DIR, RC_HISTORY_NAME, NULL); |
9 | 520 history_list_load(path); |
521 g_free(path); | |
522 } | |
523 | |
524 static void keys_save(void) | |
525 { | |
526 gchar *path; | |
527 | |
714 | 528 path = g_build_filename(homedir(), GQ_RC_DIR, RC_HISTORY_NAME, NULL); |
9 | 529 history_list_save(path); |
530 g_free(path); | |
531 } | |
532 | |
533 static void check_for_home_path(gchar *path) | |
1 | 534 { |
9 | 535 gchar *buf; |
536 | |
714 | 537 buf = g_build_filename(homedir(), path, NULL); |
9 | 538 if (!isdir(buf)) |
539 { | |
694 | 540 log_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, buf); |
442 | 541 |
9 | 542 if (!mkdir_utf8(buf, 0755)) |
543 { | |
694 | 544 log_printf(_("Could not create dir:%s\n"), buf); |
9 | 545 } |
546 } | |
547 g_free(buf); | |
548 } | |
549 | |
550 static void setup_default_options(void) | |
551 { | |
552 gchar *path; | |
1 | 553 gint i; |
554 | |
283 | 555 for (i = 0; i < GQ_EDITOR_SLOTS; i++) |
1 | 556 { |
730 | 557 options->editor[i].name = NULL; |
558 options->editor[i].command = NULL; | |
1 | 559 } |
560 | |
9 | 561 editor_reset_defaults(); |
1 | 562 |
9 | 563 bookmark_add_default(_("Home"), homedir()); |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
694
diff
changeset
|
564 path = g_build_filename(homedir(), "Desktop", NULL); |
9 | 565 bookmark_add_default(_("Desktop"), path); |
566 g_free(path); | |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
694
diff
changeset
|
567 path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL); |
9 | 568 bookmark_add_default(_("Collections"), path); |
569 g_free(path); | |
1 | 570 |
341
15c6b94545a2
Move safe_delete* and in place rename options to file_ops
zas_
parents:
340
diff
changeset
|
571 g_free(options->file_ops.safe_delete_path); |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
694
diff
changeset
|
572 options->file_ops.safe_delete_path = g_build_filename(homedir(), GQ_RC_DIR_TRASH, NULL); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
573 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
574 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
|
575 { |
327 | 576 options->color_profile.input_file[i] = NULL; |
577 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
|
578 } |
189
deea9e11f1d4
fixed reading sidecar extensions from config file
nadvornik
parents:
145
diff
changeset
|
579 |
733
57f759d012c7
Modify set_default_image_overlay_template_string() to accept the pointer to
zas_
parents:
730
diff
changeset
|
580 set_default_image_overlay_template_string(&options->image_overlay.common.template_string); |
189
deea9e11f1d4
fixed reading sidecar extensions from config file
nadvornik
parents:
145
diff
changeset
|
581 sidecar_ext_add_defaults(); |
367
3556cc825e59
Move layout.order default init to setup_default_options().
zas_
parents:
358
diff
changeset
|
582 options->layout.order = g_strdup("123"); |
684 | 583 options->properties.tabs_order = g_strdup(info_tab_default_order()); |
737
8a8873e7a552
Make shell command and its option rc file options instead of hardcoded strings.
zas_
parents:
733
diff
changeset
|
584 |
8a8873e7a552
Make shell command and its option rc file options instead of hardcoded strings.
zas_
parents:
733
diff
changeset
|
585 options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH); |
8a8873e7a552
Make shell command and its option rc file options instead of hardcoded strings.
zas_
parents:
733
diff
changeset
|
586 options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS); |
738
ff8b802eac58
Separate path building code from options loading code.
zas_
parents:
737
diff
changeset
|
587 |
ff8b802eac58
Separate path building code from options loading code.
zas_
parents:
737
diff
changeset
|
588 for (i = 0; ExifUIList[i].key; i++) |
ff8b802eac58
Separate path building code from options loading code.
zas_
parents:
737
diff
changeset
|
589 ExifUIList[i].current = ExifUIList[i].default_value; |
1 | 590 } |
591 | |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
592 static void sync_options_with_current_state(void) |
1 | 593 { |
9 | 594 LayoutWindow *lw = NULL; |
595 | |
596 if (layout_valid(&lw)) | |
597 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
598 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
|
599 if (!options->layout.main_window.maximized) |
9 | 600 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
601 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
|
602 &options->layout.main_window.w, &options->layout.main_window.h); |
9 | 603 } |
618
b1a922a32d9c
Save full OSD state to rc file and restore it on startup.
zas_
parents:
614
diff
changeset
|
604 |
638
8cc9f349c670
Rename option image_overlay.common.enabled to image_overlay.common.state
zas_
parents:
630
diff
changeset
|
605 options->image_overlay.common.state = image_osd_get(lw->image); |
9 | 606 } |
1 | 607 |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
608 layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos); |
9 | 609 |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
512
diff
changeset
|
610 layout_views_get(NULL, &options->layout.dir_view_type, &options->layout.file_view_type); |
9 | 611 |
340
77103f3f2cb1
Rename option thumbnails.enabled to layout.show_thumbnails as it makes
zas_
parents:
338
diff
changeset
|
612 options->layout.show_thumbnails = layout_thumb_get(NULL); |
433
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
412
diff
changeset
|
613 options->layout.show_marks = layout_marks_get(NULL); |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
412
diff
changeset
|
614 |
329 | 615 layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending); |
9 | 616 |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
617 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
|
618 &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
|
619 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
|
620 options->layout.toolbar_hidden = layout_toolbar_hidden(NULL); |
9 | 621 |
327 | 622 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
|
623 layout_image_color_profile_get(NULL, |
327 | 624 &options->color_profile.input_type, |
625 &options->color_profile.screen_type, | |
626 &options->color_profile.use_image); | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
627 |
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
628 if (options->startup.restore_path && options->startup.use_last_path) |
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
629 { |
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
630 g_free(options->startup.path); |
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
631 options->startup.path = g_strdup(layout_get_path(NULL)); |
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
632 } |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
633 } |
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
634 |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
635 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
|
636 { |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
637 gchar *path; |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
638 gchar *pathl; |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
639 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
640 remote_close(remote_connection); |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
641 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
642 collect_manager_flush(); |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
643 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
644 sync_options_with_current_state(); |
1 | 645 save_options(); |
9 | 646 keys_save(); |
647 | |
714 | 648 path = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL); |
9 | 649 pathl = path_from_utf8(path); |
650 gtk_accel_map_save(pathl); | |
651 g_free(pathl); | |
652 g_free(path); | |
1 | 653 |
654 gtk_main_quit(); | |
655 } | |
656 | |
9 | 657 static GenericDialog *exit_dialog = NULL; |
658 | |
659 static void exit_confirm_cancel_cb(GenericDialog *gd, gpointer data) | |
660 { | |
661 exit_dialog = NULL; | |
662 generic_dialog_close(gd); | |
663 } | |
664 | |
665 static void exit_confirm_exit_cb(GenericDialog *gd, gpointer data) | |
666 { | |
667 exit_dialog = NULL; | |
668 generic_dialog_close(gd); | |
278 | 669 exit_program_final(); |
9 | 670 } |
671 | |
672 static gint exit_confirm_dlg(void) | |
673 { | |
674 GtkWidget *parent; | |
675 LayoutWindow *lw; | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
676 gchar *msg; |
9 | 677 |
678 if (exit_dialog) | |
679 { | |
680 gtk_window_present(GTK_WINDOW(exit_dialog->dialog)); | |
681 return TRUE; | |
682 } | |
683 | |
684 if (!collection_window_modified_exists()) return FALSE; | |
685 | |
686 parent = NULL; | |
687 lw = NULL; | |
688 if (layout_valid(&lw)) | |
689 { | |
690 parent = lw->window; | |
691 } | |
692 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
693 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
|
694 exit_dialog = generic_dialog_new(msg, |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
227
diff
changeset
|
695 GQ_WMCLASS, "exit", parent, FALSE, |
9 | 696 exit_confirm_cancel_cb, NULL); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
697 g_free(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
698 msg = g_strdup_printf(_("Quit %s"), GQ_APPNAME); |
9 | 699 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
|
700 msg, _("Collections have been modified. Quit anyway?")); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
701 g_free(msg); |
9 | 702 generic_dialog_add_button(exit_dialog, GTK_STOCK_QUIT, NULL, exit_confirm_exit_cb, TRUE); |
703 | |
704 gtk_widget_show(exit_dialog->dialog); | |
705 | |
706 return TRUE; | |
707 } | |
708 | |
278 | 709 void exit_program(void) |
9 | 710 { |
711 layout_image_full_screen_stop(NULL); | |
712 | |
713 if (exit_confirm_dlg()) return; | |
714 | |
278 | 715 exit_program_final(); |
9 | 716 } |
717 | |
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
718 int main(int argc, char *argv[]) |
1 | 719 { |
9 | 720 LayoutWindow *lw; |
721 gchar *path = NULL; | |
1 | 722 gchar *cmd_path = NULL; |
723 gchar *cmd_file = NULL; | |
9 | 724 GList *cmd_list = NULL; |
725 GList *collection_list = NULL; | |
726 CollectionData *first_collection = NULL; | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
727 gchar *geometry = NULL; |
9 | 728 gchar *buf; |
729 gchar *bufl; | |
649 | 730 CollectionData *cd = NULL; |
1 | 731 |
509 | 732 /* init execution time counter (debug only) */ |
733 init_exec_time(); | |
442 | 734 |
1 | 735 /* setup locale, i18n */ |
736 gtk_set_locale(); | |
686 | 737 |
687 | 738 #ifdef ENABLE_NLS |
739 bindtextdomain(PACKAGE, GQ_LOCALEDIR); | |
10 | 740 bind_textdomain_codeset(PACKAGE, "UTF-8"); |
741 textdomain(PACKAGE); | |
686 | 742 #endif |
743 | |
1 | 744 /* setup random seed for random slideshow */ |
442 | 745 srand(time(NULL)); |
1 | 746 |
21
56866f205a68
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
10
diff
changeset
|
747 #if 1 |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
748 log_printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION); |
9 | 749 #endif |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
750 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
|
751 |
318 | 752 options = init_options(NULL); |
1 | 753 setup_default_options(); |
754 load_options(); | |
755 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
756 parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list, &geometry); |
9 | 757 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
758 gtk_init(&argc, &argv); |
9 | 759 |
760 if (gtk_major_version < GTK_MAJOR_VERSION || | |
761 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) | |
762 { | |
694 | 763 log_printf("!!! This is a friendly warning.\n"); |
764 log_printf("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); | |
765 log_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); | |
766 log_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); | |
767 log_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); | |
9 | 768 } |
769 | |
283 | 770 check_for_home_path(GQ_RC_DIR); |
771 check_for_home_path(GQ_RC_DIR_COLLECTIONS); | |
772 check_for_home_path(GQ_CACHE_RC_THUMB); | |
773 check_for_home_path(GQ_CACHE_RC_METADATA); | |
9 | 774 |
775 keys_load(); | |
776 filter_add_defaults(); | |
777 filter_rebuild(); | |
442 | 778 |
714 | 779 buf = g_build_filename(homedir(), GQ_RC_DIR, "accels", NULL); |
9 | 780 bufl = path_from_utf8(buf); |
781 gtk_accel_map_load(bufl); | |
782 g_free(bufl); | |
783 g_free(buf); | |
1 | 784 |
9 | 785 if (startup_blank) |
786 { | |
787 g_free(cmd_path); | |
788 cmd_path = NULL; | |
789 g_free(cmd_file); | |
790 cmd_file = NULL; | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
791 filelist_free(cmd_list); |
9 | 792 cmd_list = NULL; |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
793 string_list_free(collection_list); |
9 | 794 collection_list = NULL; |
795 | |
796 path = NULL; | |
797 } | |
798 else if (cmd_path) | |
799 { | |
800 path = g_strdup(cmd_path); | |
801 } | |
629 | 802 else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path)) |
9 | 803 { |
629 | 804 path = g_strdup(options->startup.path); |
9 | 805 } |
1 | 806 else |
9 | 807 { |
808 path = get_current_dir(); | |
809 } | |
810 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
334
diff
changeset
|
811 lw = layout_new_with_geometry(NULL, options->layout.tools_float, options->layout.tools_hidden, geometry); |
329 | 812 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); |
9 | 813 |
814 if (collection_list && !startup_command_line_collection) | |
815 { | |
816 GList *work; | |
817 | |
818 work = collection_list; | |
819 while (work) | |
820 { | |
821 CollectWindow *cw; | |
822 const gchar *path; | |
1 | 823 |
9 | 824 path = work->data; |
825 work = work->next; | |
826 | |
827 cw = collection_window_new(path); | |
828 if (!first_collection && cw) first_collection = cw->cd; | |
829 } | |
830 } | |
831 | |
832 if (cmd_list || | |
833 (startup_command_line_collection && collection_list)) | |
834 { | |
835 GList *work; | |
836 | |
837 if (startup_command_line_collection) | |
838 { | |
839 CollectWindow *cw; | |
840 | |
841 cw = collection_window_new(""); | |
842 cd = cw->cd; | |
843 } | |
844 else | |
845 { | |
846 cd = collection_new(""); /* if we pass NULL, untitled counter is falsely increm. */ | |
847 } | |
848 | |
849 g_free(cd->path); | |
850 cd->path = NULL; | |
851 g_free(cd->name); | |
852 cd->name = g_strdup(_("Command line")); | |
853 | |
854 collection_path_changed(cd); | |
1 | 855 |
9 | 856 work = cmd_list; |
857 while (work) | |
858 { | |
138 | 859 collection_add(cd, file_data_new_simple((gchar *)work->data), FALSE); |
9 | 860 work = work->next; |
861 } | |
862 | |
863 work = collection_list; | |
864 while (work) | |
865 { | |
358 | 866 collection_load(cd, (gchar *)work->data, COLLECTION_LOAD_APPEND); |
9 | 867 work = work->next; |
868 } | |
869 | |
870 layout_set_path(lw, path); | |
871 if (cd->list) layout_image_set_collection(lw, cd, cd->list->data); | |
1 | 872 |
9 | 873 /* mem leak, we never unref this collection when !startup_command_line_collection |
874 * (the image view of the main window does not hold a ref to the collection) | |
875 * this is sort of unavoidable, for if it did hold a ref, next/back | |
876 * may not work as expected when closing collection windows. | |
877 * | |
878 * collection_unref(cd); | |
879 */ | |
880 | |
881 } | |
882 else if (cmd_file) | |
883 { | |
884 layout_set_path(lw, cmd_file); | |
885 } | |
886 else | |
887 { | |
888 layout_set_path(lw, path); | |
889 if (first_collection) | |
890 { | |
891 layout_image_set_collection(lw, first_collection, | |
892 collection_get_first(first_collection)); | |
893 } | |
894 } | |
614 | 895 |
638
8cc9f349c670
Rename option image_overlay.common.enabled to image_overlay.common.state
zas_
parents:
630
diff
changeset
|
896 image_osd_set(lw->image, options->image_overlay.common.state | (options->image_overlay.common.show_at_startup ? OSD_SHOW_INFO : OSD_SHOW_NOTHING)); |
1 | 897 |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
898 g_free(geometry); |
1 | 899 g_free(cmd_path); |
900 g_free(cmd_file); | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
901 filelist_free(cmd_list); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
902 string_list_free(collection_list); |
9 | 903 g_free(path); |
1 | 904 |
9 | 905 if (startup_full_screen) layout_image_full_screen_start(lw); |
906 if (startup_in_slideshow) layout_image_slideshow_start(lw); | |
907 | |
714 | 908 buf = g_build_filename(homedir(), GQ_RC_DIR, ".command", NULL); |
649 | 909 remote_connection = remote_server_init(buf, cd); |
9 | 910 g_free(buf); |
3 | 911 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
912 gtk_main(); |
1 | 913 return 0; |
914 } |