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