Mercurial > geeqie.yaz
annotate src/main.c @ 1753:c4d37e0fc841 default tip
installation fix
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 29 Jan 2010 19:22:50 +0900 |
parents | 808dd5257146 |
children |
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 |
1284 | 4 * Copyright (C) 2008 - 2009 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 | |
1685
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
13 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
14 #ifdef HAVE_LIBCHAMPLAIN |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
15 #ifdef HAVE_LIBCHAMPLAIN_GTK |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
16 #include <clutter-gtk/gtk-clutter-embed.h> |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
17 #endif |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
18 #endif |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
19 |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
20 #include <signal.h> |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
21 #include <sys/mman.h> |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
22 |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
23 #include <math.h> |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
24 #ifdef G_OS_UNIX |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
25 #include <pwd.h> |
babd4142523f
Some systems (BSD,MacOsX,HP-UX,...) define MAP_ANON and not MAP_ANONYMOUS. Make each an alias of other to be sure. issue reported by Martin Proetzsch.
zas_
parents:
1647
diff
changeset
|
26 #endif |
9 | 27 |
281 | 28 #include "main.h" |
9 | 29 |
30 #include "cache.h" | |
31 #include "collect.h" | |
32 #include "collect-io.h" | |
586 | 33 #include "filedata.h" |
34 #include "filefilter.h" | |
902 | 35 #include "history_list.h" |
218
f4a0555794a9
Customizable info overlay in fullscreen, based on the patch posted to gqview-devel list by Timo on 2007-09-10.
zas_
parents:
214
diff
changeset
|
36 #include "image-overlay.h" |
9 | 37 #include "layout.h" |
38 #include "layout_image.h" | |
1019 | 39 #include "options.h" |
9 | 40 #include "remote.h" |
1061 | 41 #include "secure_save.h" |
9 | 42 #include "similar.h" |
43 #include "ui_fileops.h" | |
44 #include "ui_utildlg.h" | |
793 | 45 #include "cache_maint.h" |
877 | 46 #include "thumb.h" |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1174
diff
changeset
|
47 #include "metadata.h" |
1272 | 48 #include "editors.h" |
1288 | 49 #include "exif.h" |
1294 | 50 #include "histogram.h" |
1334 | 51 #include "pixbuf_util.h" |
9 | 52 |
53 | |
1506
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1463
diff
changeset
|
54 gboolean thumb_format_changed = FALSE; |
279 | 55 static RemoteConnection *remote_connection = NULL; |
9 | 56 |
1 | 57 /* |
58 *----------------------------------------------------------------------------- | |
59 * keyboard functions | |
60 *----------------------------------------------------------------------------- | |
61 */ | |
62 | |
63 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event) | |
64 { | |
65 static gint delta = 0; | |
66 static guint32 time_old = 0; | |
67 static guint keyval_old = 0; | |
68 | |
9 | 69 if (event->state & GDK_CONTROL_MASK) |
70 { | |
71 if (*x < 0) *x = G_MININT / 2; | |
72 if (*x > 0) *x = G_MAXINT / 2; | |
73 if (*y < 0) *y = G_MININT / 2; | |
74 if (*y > 0) *y = G_MAXINT / 2; | |
75 | |
76 return; | |
77 } | |
78 | |
318 | 79 if (options->progressive_key_scrolling) |
1 | 80 { |
81 guint32 time_diff; | |
82 | |
83 time_diff = event->time - time_old; | |
84 | |
85 /* key pressed within 125ms ? (1/8 second) */ | |
86 if (time_diff > 125 || event->keyval != keyval_old) delta = 0; | |
87 | |
88 time_old = event->time; | |
89 keyval_old = event->keyval; | |
90 | |
91 delta += 2; | |
92 } | |
93 else | |
94 { | |
95 delta = 8; | |
96 } | |
97 | |
98 *x = *x * delta; | |
99 *y = *y * delta; | |
100 } | |
101 | |
9 | 102 |
1 | 103 |
104 /* | |
105 *----------------------------------------------------------------------------- | |
3 | 106 * command line parser (private) hehe, who needs popt anyway? |
1 | 107 *----------------------------------------------------------------------------- |
442 | 108 */ |
1 | 109 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
110 static void parse_command_line_add_file(const gchar *file_path, gchar **path, gchar **file, |
442 | 111 GList **list, GList **collection_list) |
1 | 112 { |
9 | 113 gchar *path_parsed; |
114 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
115 path_parsed = g_strdup(file_path); |
9 | 116 parse_out_relatives(path_parsed); |
117 | |
781
2d2cca2bceb0
Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents:
780
diff
changeset
|
118 if (file_extension_match(path_parsed, GQ_COLLECTION_EXT)) |
9 | 119 { |
120 *collection_list = g_list_append(*collection_list, path_parsed); | |
121 } | |
122 else | |
123 { | |
124 if (!*path) *path = remove_level_from_path(path_parsed); | |
125 if (!*file) *file = g_strdup(path_parsed); | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
126 *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
|
127 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
128 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
129 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
130 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
|
131 GList **list) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
132 { |
1727
548fddf5070a
ignored multiple directories specified on commandline
nadvornik
parents:
1702
diff
changeset
|
133 #if 0 |
548fddf5070a
ignored multiple directories specified on commandline
nadvornik
parents:
1702
diff
changeset
|
134 /* This is broken because file filter is not initialized yet. |
548fddf5070a
ignored multiple directories specified on commandline
nadvornik
parents:
1702
diff
changeset
|
135 */ |
780
44128da39e13
Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents:
767
diff
changeset
|
136 GList *files; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
137 gchar *path_parsed; |
783 | 138 FileData *dir_fd; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
139 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
140 path_parsed = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
141 parse_out_relatives(path_parsed); |
783 | 142 dir_fd = file_data_new_simple(path_parsed); |
143 | |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
144 |
783 | 145 if (filelist_read(dir_fd, &files, NULL)) |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
146 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
147 GList *work; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
148 |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
149 files = filelist_filter(files, FALSE); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
150 files = filelist_sort_path(files); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
151 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
152 work = files; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
153 while (work) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
154 { |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
155 FileData *fd = work->data; |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
156 if (!*path) *path = remove_level_from_path(fd->path); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
157 if (!*file) *file = g_strdup(fd->path); |
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
158 *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
|
159 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
160 work = work->next; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
161 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
162 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
163 g_list_free(files); |
9 | 164 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
165 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
166 g_free(path_parsed); |
783 | 167 file_data_unref(dir_fd); |
1727
548fddf5070a
ignored multiple directories specified on commandline
nadvornik
parents:
1702
diff
changeset
|
168 #else |
548fddf5070a
ignored multiple directories specified on commandline
nadvornik
parents:
1702
diff
changeset
|
169 DEBUG_1("multiple directories specified, ignoring: %s", dir); |
548fddf5070a
ignored multiple directories specified on commandline
nadvornik
parents:
1702
diff
changeset
|
170 #endif |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
171 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
172 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
173 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
|
174 GList **list, gchar **first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
175 { |
442 | 176 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
177 if (!*list && !*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
178 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
179 *first_dir = g_strdup(dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
180 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
181 else |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
182 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
183 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
184 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
185 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
|
186 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
187 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
188 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
189 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
|
190 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
191 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
192 |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
193 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
|
194 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
|
195 { |
442 | 196 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
197 if (*first_dir) |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
198 { |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
199 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
|
200 g_free(*first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
201 *first_dir = NULL; |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
202 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
203 parse_command_line_add_file(file_path, path, file, list, collection_list); |
9 | 204 } |
205 | |
1313 | 206 static void parse_command_line(gint argc, gchar *argv[]) |
9 | 207 { |
208 GList *list = NULL; | |
209 GList *remote_list = NULL; | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
210 GList *remote_errors = NULL; |
1437 | 211 gboolean remote_do = FALSE; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
212 gchar *first_dir = NULL; |
1313 | 213 |
214 command_line = g_new0(CommandLine, 1); | |
215 | |
216 command_line->argc = argc; | |
217 command_line->argv = argv; | |
9 | 218 |
1 | 219 if (argc > 1) |
220 { | |
221 gint i; | |
222 gchar *base_dir = get_current_dir(); | |
223 i = 1; | |
224 while (i < argc) | |
225 { | |
1507 | 226 gchar *cmd_line = path_to_utf8(argv[i]); |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
694
diff
changeset
|
227 gchar *cmd_all = g_build_filename(base_dir, cmd_line, NULL); |
1 | 228 |
726 | 229 if (cmd_line[0] == G_DIR_SEPARATOR && isdir(cmd_line)) |
1 | 230 { |
1313 | 231 parse_command_line_process_dir(cmd_line, &command_line->path, &command_line->file, &list, &first_dir); |
1 | 232 } |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
233 else if (isdir(cmd_all)) |
1 | 234 { |
1313 | 235 parse_command_line_process_dir(cmd_all, &command_line->path, &command_line->file, &list, &first_dir); |
1 | 236 } |
726 | 237 else if (cmd_line[0] == G_DIR_SEPARATOR && isfile(cmd_line)) |
1 | 238 { |
1313 | 239 parse_command_line_process_file(cmd_line, &command_line->path, &command_line->file, |
240 &list, &command_line->collection_list, &first_dir); | |
1 | 241 } |
9 | 242 else if (isfile(cmd_all)) |
1 | 243 { |
1313 | 244 parse_command_line_process_file(cmd_all, &command_line->path, &command_line->file, |
245 &list, &command_line->collection_list, &first_dir); | |
1 | 246 } |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
247 else if (strncmp(cmd_line, "--debug", 7) == 0 && (cmd_line[7] == '\0' || cmd_line[7] == '=')) |
1 | 248 { |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
249 /* do nothing but do not produce warnings */ |
1 | 250 } |
251 else if (strcmp(cmd_line, "+t") == 0 || | |
3 | 252 strcmp(cmd_line, "--with-tools") == 0) |
1 | 253 { |
1313 | 254 command_line->tools_show = TRUE; |
9 | 255 |
256 remote_list = g_list_append(remote_list, "+t"); | |
1 | 257 } |
258 else if (strcmp(cmd_line, "-t") == 0 || | |
3 | 259 strcmp(cmd_line, "--without-tools") == 0) |
1 | 260 { |
1313 | 261 command_line->tools_hide = TRUE; |
9 | 262 |
263 remote_list = g_list_append(remote_list, "-t"); | |
1 | 264 } |
3 | 265 else if (strcmp(cmd_line, "-f") == 0 || |
266 strcmp(cmd_line, "--fullscreen") == 0) | |
267 { | |
1313 | 268 command_line->startup_full_screen = TRUE; |
3 | 269 } |
270 else if (strcmp(cmd_line, "-s") == 0 || | |
271 strcmp(cmd_line, "--slideshow") == 0) | |
272 { | |
1313 | 273 command_line->startup_in_slideshow = TRUE; |
3 | 274 } |
9 | 275 else if (strcmp(cmd_line, "-l") == 0 || |
276 strcmp(cmd_line, "--list") == 0) | |
277 { | |
1313 | 278 command_line->startup_command_line_collection = TRUE; |
9 | 279 } |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
280 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
|
281 { |
1313 | 282 if (!command_line->geometry) command_line->geometry = g_strdup(cmd_line + 11); |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
283 } |
9 | 284 else if (strcmp(cmd_line, "-r") == 0 || |
285 strcmp(cmd_line, "--remote") == 0) | |
286 { | |
287 if (!remote_do) | |
288 { | |
289 remote_do = TRUE; | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
290 remote_list = remote_build_list(remote_list, argc - i, &argv[i], &remote_errors); |
9 | 291 } |
292 } | |
293 else if (strcmp(cmd_line, "-rh") == 0 || | |
294 strcmp(cmd_line, "--remote-help") == 0) | |
295 { | |
279 | 296 remote_help(); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
297 exit(0); |
9 | 298 } |
299 else if (strcmp(cmd_line, "--blank") == 0) | |
300 { | |
1313 | 301 command_line->startup_blank = TRUE; |
9 | 302 } |
303 else if (strcmp(cmd_line, "-v") == 0 || | |
304 strcmp(cmd_line, "--version") == 0) | |
305 { | |
694 | 306 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
|
307 exit(0); |
9 | 308 } |
309 else if (strcmp(cmd_line, "--alternate") == 0) | |
310 { | |
311 /* enable faster experimental algorithm */ | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
312 log_printf("Alternate similarity algorithm enabled\n"); |
9 | 313 image_sim_alternate_set(TRUE); |
314 } | |
3 | 315 else if (strcmp(cmd_line, "-h") == 0 || |
316 strcmp(cmd_line, "--help") == 0) | |
1 | 317 { |
694 | 318 printf_term("%s %s\n", GQ_APPNAME, VERSION); |
403 | 319 printf_term(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC); |
9 | 320 print_term(_("valid options are:\n")); |
321 print_term(_(" +t, --with-tools force show of tools\n")); | |
322 print_term(_(" -t, --without-tools force hide of tools\n")); | |
323 print_term(_(" -f, --fullscreen start in full screen mode\n")); | |
324 print_term(_(" -s, --slideshow start in slideshow mode\n")); | |
325 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
|
326 print_term(_(" --geometry=GEOMETRY set main window location\n")); |
9 | 327 print_term(_(" -r, --remote send following commands to open window\n")); |
328 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
|
329 #ifdef DEBUG |
379 | 330 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
|
331 #endif |
9 | 332 print_term(_(" -v, --version print version info\n")); |
333 print_term(_(" -h, --help show this message\n\n")); | |
442 | 334 |
9 | 335 #if 0 |
336 /* these options are not officially supported! | |
337 * only for testing new features, no need to translate them */ | |
338 print_term( " --alternate use alternate similarity algorithm\n"); | |
339 #endif | |
442 | 340 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
341 exit(0); |
1 | 342 } |
9 | 343 else if (!remote_do) |
1 | 344 { |
403 | 345 printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); |
1 | 346 } |
9 | 347 |
1 | 348 g_free(cmd_all); |
1507 | 349 g_free(cmd_line); |
1 | 350 i++; |
351 } | |
352 g_free(base_dir); | |
1313 | 353 parse_out_relatives(command_line->path); |
354 parse_out_relatives(command_line->file); | |
1 | 355 } |
9 | 356 |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
357 list = g_list_reverse(list); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
358 |
1313 | 359 if (!command_line->path && first_dir) |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
360 { |
1313 | 361 command_line->path = first_dir; |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
362 first_dir = NULL; |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
76
diff
changeset
|
363 |
1313 | 364 parse_out_relatives(command_line->path); |
76
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
365 } |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
366 g_free(first_dir); |
07773a3c5b29
Sun Oct 15 04:03:41 2006 John Ellis <johne@verizon.net>
gqview
parents:
21
diff
changeset
|
367 |
9 | 368 if (remote_do) |
369 { | |
652
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
370 if (remote_errors) |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
371 { |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
372 GList *work = remote_errors; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
373 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
374 printf_term(_("Invalid or ignored remote options: ")); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
375 while (work) |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
376 { |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
377 gchar *opt = work->data; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
378 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
379 printf_term("%s%s", (work == remote_errors) ? "" : ", ", opt); |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
380 work = work->next; |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
381 } |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
382 |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
383 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
|
384 } |
9bcfd6d7a902
Display a message when invalid remote options are used.
zas_
parents:
649
diff
changeset
|
385 |
1313 | 386 remote_control(argv[0], remote_list, command_line->path, list, command_line->collection_list); |
9 | 387 } |
388 g_list_free(remote_list); | |
389 | |
390 if (list && list->next) | |
391 { | |
1313 | 392 command_line->cmd_list = list; |
9 | 393 } |
394 else | |
395 { | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
556
diff
changeset
|
396 filelist_free(list); |
1313 | 397 command_line->cmd_list = NULL; |
398 } | |
399 | |
400 if (command_line->startup_blank) | |
401 { | |
402 g_free(command_line->path); | |
403 command_line->path = NULL; | |
404 g_free(command_line->file); | |
405 command_line->file = NULL; | |
406 filelist_free(command_line->cmd_list); | |
407 command_line->cmd_list = NULL; | |
408 string_list_free(command_line->collection_list); | |
409 command_line->collection_list = NULL; | |
9 | 410 } |
1 | 411 } |
412 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
413 static void parse_command_line_for_debug_option(gint argc, gchar *argv[]) |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
414 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
415 #ifdef DEBUG |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
416 const gchar *debug_option = "--debug"; |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
417 gint len = strlen(debug_option); |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
418 |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
419 if (argc > 1) |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
420 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
421 gint i; |
442 | 422 |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
423 for (i = 1; i < argc; i++) |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
424 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
425 const gchar *cmd_line = argv[i]; |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
426 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
|
427 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
428 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
|
429 |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
430 /* 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
|
431 if (cmd_line_len == len) |
507 | 432 debug_level_add(1); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
433 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
|
434 { |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
435 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
|
436 if (n < 0) n = 1; |
507 | 437 debug_level_add(n); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
438 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
439 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
440 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
441 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
442 |
507 | 443 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
|
444 #endif |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
445 } |
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
446 |
1 | 447 /* |
448 *----------------------------------------------------------------------------- | |
449 * startup, init, and exit | |
450 *----------------------------------------------------------------------------- | |
442 | 451 */ |
1 | 452 |
9 | 453 #define RC_HISTORY_NAME "history" |
454 | |
1636 | 455 static void setup_env_path(void) |
456 { | |
457 const gchar *old_path = g_getenv("PATH"); | |
458 gchar *path = g_strconcat(GQ_BIN_DIR, ":", old_path, NULL); | |
459 g_setenv("PATH", path, TRUE); | |
460 g_free(path); | |
461 } | |
462 | |
9 | 463 static void keys_load(void) |
464 { | |
465 gchar *path; | |
466 | |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
467 path = g_build_filename(get_rc_dir(), RC_HISTORY_NAME, NULL); |
9 | 468 history_list_load(path); |
469 g_free(path); | |
470 } | |
471 | |
472 static void keys_save(void) | |
473 { | |
474 gchar *path; | |
475 | |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
476 path = g_build_filename(get_rc_dir(), RC_HISTORY_NAME, NULL); |
9 | 477 history_list_save(path); |
478 g_free(path); | |
479 } | |
480 | |
1146
11b93d0791db
Rename check_for_home_path() to mkdir_if_not_exists().
zas_
parents:
1145
diff
changeset
|
481 static void mkdir_if_not_exists(const gchar *path) |
1 | 482 { |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
483 if (isdir(path)) return; |
9 | 484 |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
485 log_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, path); |
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
486 |
1148
95860439070b
Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents:
1146
diff
changeset
|
487 if (!recursive_mkdir_if_not_exists(path, 0755)) |
9 | 488 { |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
489 log_printf(_("Could not create dir:%s\n"), path); |
9 | 490 } |
491 } | |
492 | |
1061 | 493 |
494 /* We add to duplicate and modify gtk_accel_map_print() and gtk_accel_map_save() | |
495 * to improve the reliability in special cases (especially when disk is full) | |
496 * These functions are now using secure saving stuff. | |
497 */ | |
498 static void gq_accel_map_print( | |
499 gpointer data, | |
500 const gchar *accel_path, | |
501 guint accel_key, | |
502 GdkModifierType accel_mods, | |
503 gboolean changed) | |
504 { | |
505 GString *gstring = g_string_new(changed ? NULL : "; "); | |
506 SecureSaveInfo *ssi = data; | |
507 gchar *tmp, *name; | |
508 | |
509 g_string_append(gstring, "(gtk_accel_path \""); | |
510 | |
511 tmp = g_strescape(accel_path, NULL); | |
512 g_string_append(gstring, tmp); | |
513 g_free(tmp); | |
514 | |
515 g_string_append(gstring, "\" \""); | |
516 | |
517 name = gtk_accelerator_name(accel_key, accel_mods); | |
518 tmp = g_strescape(name, NULL); | |
519 g_free(name); | |
520 g_string_append(gstring, tmp); | |
521 g_free(tmp); | |
522 | |
523 g_string_append(gstring, "\")\n"); | |
524 | |
525 secure_fwrite(gstring->str, sizeof(*gstring->str), gstring->len, ssi); | |
526 | |
527 g_string_free(gstring, TRUE); | |
528 } | |
529 | |
530 static gboolean gq_accel_map_save(const gchar *path) | |
531 { | |
532 gchar *pathl; | |
533 SecureSaveInfo *ssi; | |
534 GString *gstring; | |
535 | |
536 pathl = path_from_utf8(path); | |
537 ssi = secure_open(pathl); | |
538 g_free(pathl); | |
539 if (!ssi) | |
540 { | |
541 log_printf(_("error saving file: %s\n"), path); | |
542 return FALSE; | |
543 } | |
544 | |
545 gstring = g_string_new("; "); | |
546 if (g_get_prgname()) | |
547 g_string_append(gstring, g_get_prgname()); | |
548 g_string_append(gstring, " GtkAccelMap rc-file -*- scheme -*-\n"); | |
549 g_string_append(gstring, "; this file is an automated accelerator map dump\n"); | |
550 g_string_append(gstring, ";\n"); | |
551 | |
552 secure_fwrite(gstring->str, sizeof(*gstring->str), gstring->len, ssi); | |
553 | |
554 g_string_free(gstring, TRUE); | |
555 | |
556 gtk_accel_map_foreach((gpointer) ssi, gq_accel_map_print); | |
557 | |
558 if (secure_close(ssi)) | |
559 { | |
560 log_printf(_("error saving file: %s\nerror: %s\n"), path, | |
561 secsave_strerror(secsave_errno)); | |
562 return FALSE; | |
563 } | |
564 | |
565 return TRUE; | |
566 } | |
567 | |
568 static gchar *accep_map_filename(void) | |
569 { | |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
570 return g_build_filename(get_rc_dir(), "accels", NULL); |
1061 | 571 } |
572 | |
1017 | 573 static void accel_map_save(void) |
574 { | |
575 gchar *path; | |
576 | |
1061 | 577 path = accep_map_filename(); |
578 gq_accel_map_save(path); | |
1017 | 579 g_free(path); |
580 } | |
581 | |
582 static void accel_map_load(void) | |
583 { | |
584 gchar *path; | |
585 gchar *pathl; | |
586 | |
1061 | 587 path = accep_map_filename(); |
1017 | 588 pathl = path_from_utf8(path); |
589 gtk_accel_map_load(pathl); | |
590 g_free(pathl); | |
591 g_free(path); | |
592 } | |
593 | |
594 static void gtkrc_load(void) | |
595 { | |
596 gchar *path; | |
597 gchar *pathl; | |
598 | |
599 /* If a gtkrc file exists in the rc directory, add it to the | |
600 * list of files to be parsed at the end of gtk_init() */ | |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
601 path = g_build_filename(get_rc_dir(), "gtkrc", NULL); |
1017 | 602 pathl = path_from_utf8(path); |
603 if (access(pathl, R_OK) == 0) | |
604 gtk_rc_add_default_file(pathl); | |
605 g_free(pathl); | |
606 g_free(path); | |
607 } | |
630
83d3ded39e49
An option to save and restore the last path used was added.
zas_
parents:
629
diff
changeset
|
608 |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
609 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
|
610 { |
840 | 611 LayoutWindow *lw = NULL; |
739
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
612 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
613 remote_close(remote_connection); |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
614 |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
615 collect_manager_flush(); |
3296f8d3a79b
Move code from exit_program_final() to new sync_options_with_current_state().
zas_
parents:
738
diff
changeset
|
616 |
742
a336b5545af6
Pass ConfOptions * to save_options() and load_options().
zas_
parents:
740
diff
changeset
|
617 save_options(options); |
9 | 618 keys_save(); |
1017 | 619 accel_map_save(); |
1 | 620 |
840 | 621 if (layout_valid(&lw)) |
622 { | |
623 layout_free(lw); | |
624 } | |
625 | |
1 | 626 gtk_main_quit(); |
627 } | |
628 | |
9 | 629 static GenericDialog *exit_dialog = NULL; |
630 | |
631 static void exit_confirm_cancel_cb(GenericDialog *gd, gpointer data) | |
632 { | |
633 exit_dialog = NULL; | |
634 generic_dialog_close(gd); | |
635 } | |
636 | |
637 static void exit_confirm_exit_cb(GenericDialog *gd, gpointer data) | |
638 { | |
639 exit_dialog = NULL; | |
640 generic_dialog_close(gd); | |
278 | 641 exit_program_final(); |
9 | 642 } |
643 | |
644 static gint exit_confirm_dlg(void) | |
645 { | |
646 GtkWidget *parent; | |
647 LayoutWindow *lw; | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
648 gchar *msg; |
9 | 649 |
650 if (exit_dialog) | |
651 { | |
652 gtk_window_present(GTK_WINDOW(exit_dialog->dialog)); | |
653 return TRUE; | |
654 } | |
655 | |
656 if (!collection_window_modified_exists()) return FALSE; | |
657 | |
658 parent = NULL; | |
659 lw = NULL; | |
660 if (layout_valid(&lw)) | |
661 { | |
662 parent = lw->window; | |
663 } | |
664 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
665 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
|
666 exit_dialog = generic_dialog_new(msg, |
1174
0bea79d87065
Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents:
1148
diff
changeset
|
667 "exit", parent, FALSE, |
9 | 668 exit_confirm_cancel_cb, NULL); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
669 g_free(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
670 msg = g_strdup_printf(_("Quit %s"), GQ_APPNAME); |
9 | 671 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
|
672 msg, _("Collections have been modified. Quit anyway?")); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
673 g_free(msg); |
9 | 674 generic_dialog_add_button(exit_dialog, GTK_STOCK_QUIT, NULL, exit_confirm_exit_cb, TRUE); |
675 | |
676 gtk_widget_show(exit_dialog->dialog); | |
677 | |
678 return TRUE; | |
679 } | |
680 | |
1231 | 681 static void exit_program_write_metadata_cb(gint success, const gchar *dest_path, gpointer data) |
682 { | |
683 if (success) exit_program(); | |
684 } | |
685 | |
278 | 686 void exit_program(void) |
9 | 687 { |
688 layout_image_full_screen_stop(NULL); | |
689 | |
1231 | 690 if (metadata_write_queue_confirm(exit_program_write_metadata_cb, NULL)) return; |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1174
diff
changeset
|
691 |
9 | 692 if (exit_confirm_dlg()) return; |
693 | |
278 | 694 exit_program_final(); |
9 | 695 } |
696 | |
1266 | 697 /* This code is supposed to handle situation when a file mmaped by image_loader |
698 * or by exif loader is truncated by some other process. | |
699 * This is probably not completely correct according to posix, because | |
700 * mmap is not in the list of calls that can be used safely in signal handler, | |
701 * but anyway, the handler is called in situation when the application would | |
702 * crash otherwise. | |
703 * Ideas for improvement are welcome ;) | |
704 */ | |
705 /* FIXME: this probably needs some better ifdefs. Please report any compilation problems */ | |
706 | |
1738
808dd5257146
Some systems do not have SA_SIGINFO (siginfo_t), like GNU/Hurd, so just test if defined or not. Patch by Michal ªiha«Ú (Bug ID: 2894271).
zas_
parents:
1733
diff
changeset
|
707 #if defined(SIGBUS) && defined(SA_SIGINFO) |
1266 | 708 static void sigbus_handler_cb(int signum, siginfo_t *info, void *context) |
709 { | |
710 unsigned long pagesize = sysconf(_SC_PAGE_SIZE); | |
711 DEBUG_1("SIGBUS %p", info->si_addr); | |
712 mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | |
713 } | |
714 #endif | |
715 | |
716 static void setup_sigbus_handler(void) | |
717 { | |
1738
808dd5257146
Some systems do not have SA_SIGINFO (siginfo_t), like GNU/Hurd, so just test if defined or not. Patch by Michal ªiha«Ú (Bug ID: 2894271).
zas_
parents:
1733
diff
changeset
|
718 #if defined(SIGBUS) && defined(SA_SIGINFO) |
1266 | 719 struct sigaction sigbus_action; |
720 sigfillset(&sigbus_action.sa_mask); | |
721 sigbus_action.sa_sigaction = sigbus_handler_cb; | |
722 sigbus_action.sa_flags = SA_SIGINFO; | |
723 | |
724 sigaction(SIGBUS, &sigbus_action, NULL); | |
725 #endif | |
726 } | |
727 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
728 gint main(gint argc, gchar *argv[]) |
1 | 729 { |
9 | 730 CollectionData *first_collection = NULL; |
731 gchar *buf; | |
649 | 732 CollectionData *cd = NULL; |
1 | 733 |
1015 | 734 #ifdef HAVE_GTHREAD |
1346
c9949c19a6d0
No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents:
1334
diff
changeset
|
735 g_thread_init(NULL); |
1020 | 736 gdk_threads_init(); |
737 gdk_threads_enter(); | |
1015 | 738 #endif |
739 | |
509 | 740 /* init execution time counter (debug only) */ |
741 init_exec_time(); | |
442 | 742 |
1 | 743 /* setup locale, i18n */ |
744 gtk_set_locale(); | |
686 | 745 |
687 | 746 #ifdef ENABLE_NLS |
747 bindtextdomain(PACKAGE, GQ_LOCALEDIR); | |
10 | 748 bind_textdomain_codeset(PACKAGE, "UTF-8"); |
749 textdomain(PACKAGE); | |
686 | 750 #endif |
995 | 751 |
1288 | 752 exif_init(); |
753 | |
1 | 754 /* setup random seed for random slideshow */ |
442 | 755 srand(time(NULL)); |
1 | 756 |
1647
24360823aa6a
hide pointless version warning.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1636
diff
changeset
|
757 #if 0 |
24360823aa6a
hide pointless version warning.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1636
diff
changeset
|
758 log_printf("%s %s, This is a beta release.\n", GQ_APPNAME, VERSION); |
9 | 759 #endif |
793 | 760 |
1266 | 761 setup_sigbus_handler(); |
762 | |
793 | 763 /* register global notify functions */ |
764 file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); | |
877 | 765 file_data_register_notify_func(thumb_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); |
1294 | 766 file_data_register_notify_func(histogram_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); |
799 | 767 file_data_register_notify_func(collect_manager_notify_cb, NULL, NOTIFY_PRIORITY_LOW); |
1702 | 768 file_data_register_notify_func(metadata_notify_cb, NULL, NOTIFY_PRIORITY_LOW); |
769 | |
793 | 770 |
1313 | 771 gtkrc_load(); |
1602 | 772 |
773 #ifdef HAVE_LIBCHAMPLAIN | |
774 #ifdef HAVE_LIBCHAMPLAIN_GTK | |
1733 | 775 if (gtk_clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) |
776 { | |
777 log_printf("Can't initialize clutter-gtk.\n"); | |
778 exit(1); | |
779 } | |
1602 | 780 #else |
1313 | 781 gtk_init(&argc, &argv); |
1602 | 782 #endif |
783 #else | |
784 gtk_init(&argc, &argv); | |
785 #endif | |
1313 | 786 |
787 if (gtk_major_version < GTK_MAJOR_VERSION || | |
788 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) | |
789 { | |
790 log_printf("!!! This is a friendly warning.\n"); | |
791 log_printf("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); | |
792 log_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); | |
793 log_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); | |
794 log_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); | |
795 } | |
796 | |
1334 | 797 pixbuf_inline_register_stock_icons(); |
798 | |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
799 parse_command_line_for_debug_option(argc, argv); |
1313 | 800 parse_command_line(argc, argv); |
378
f1bdbbdb73ba
Parse command line for --debug option as soon as possible and allow
zas_
parents:
367
diff
changeset
|
801 |
1462 | 802 /* these functions don't depend on config file */ |
803 mkdir_if_not_exists(get_rc_dir()); | |
804 mkdir_if_not_exists(get_collections_dir()); | |
805 mkdir_if_not_exists(get_thumbnails_cache_dir()); | |
806 mkdir_if_not_exists(get_metadata_cache_dir()); | |
807 | |
1636 | 808 setup_env_path(); |
809 | |
1462 | 810 keys_load(); |
811 accel_map_load(); | |
812 | |
813 /* restore session from the config file */ | |
814 | |
318 | 815 options = init_options(NULL); |
740
9b0ac8d58c89
Move setup_default_options() and sync_options_with_current_state() to options.[ch].
zas_
parents:
739
diff
changeset
|
816 setup_default_options(options); |
1 | 817 |
1463
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
818 if (!load_options(options)) |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
819 { |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
820 /* load_options calls these functions after it parses global options, we have to call it here if it fails */ |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
821 filter_add_defaults(); |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
822 filter_rebuild(); |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
823 |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
824 editor_load_descriptions(); |
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1462
diff
changeset
|
825 } |
9 | 826 |
1462 | 827 /* handle missing config file and commandline additions*/ |
1309 | 828 if (!layout_window_list) |
9 | 829 { |
1313 | 830 /* broken or no config file */ |
831 layout_new_from_config(NULL, NULL, TRUE); | |
9 | 832 } |
833 | |
1313 | 834 if (command_line->collection_list && !command_line->startup_command_line_collection) |
9 | 835 { |
836 GList *work; | |
837 | |
1313 | 838 work = command_line->collection_list; |
9 | 839 while (work) |
840 { | |
841 CollectWindow *cw; | |
842 const gchar *path; | |
1 | 843 |
9 | 844 path = work->data; |
845 work = work->next; | |
846 | |
847 cw = collection_window_new(path); | |
848 if (!first_collection && cw) first_collection = cw->cd; | |
849 } | |
850 } | |
851 | |
1313 | 852 if (command_line->cmd_list || |
853 (command_line->startup_command_line_collection && command_line->collection_list)) | |
9 | 854 { |
855 GList *work; | |
856 | |
1313 | 857 if (command_line->startup_command_line_collection) |
9 | 858 { |
859 CollectWindow *cw; | |
860 | |
861 cw = collection_window_new(""); | |
862 cd = cw->cd; | |
863 } | |
864 else | |
865 { | |
866 cd = collection_new(""); /* if we pass NULL, untitled counter is falsely increm. */ | |
867 } | |
868 | |
869 g_free(cd->path); | |
870 cd->path = NULL; | |
871 g_free(cd->name); | |
872 cd->name = g_strdup(_("Command line")); | |
873 | |
874 collection_path_changed(cd); | |
1 | 875 |
1313 | 876 work = command_line->cmd_list; |
9 | 877 while (work) |
878 { | |
1617 | 879 collection_add(cd, (FileData *)work->data, FALSE); |
9 | 880 work = work->next; |
881 } | |
882 | |
1313 | 883 work = command_line->collection_list; |
9 | 884 while (work) |
885 { | |
358 | 886 collection_load(cd, (gchar *)work->data, COLLECTION_LOAD_APPEND); |
9 | 887 work = work->next; |
888 } | |
889 | |
1313 | 890 if (cd->list) layout_image_set_collection(NULL, cd, cd->list->data); |
1 | 891 |
9 | 892 /* mem leak, we never unref this collection when !startup_command_line_collection |
893 * (the image view of the main window does not hold a ref to the collection) | |
894 * this is sort of unavoidable, for if it did hold a ref, next/back | |
895 * may not work as expected when closing collection windows. | |
896 * | |
897 * collection_unref(cd); | |
898 */ | |
899 | |
900 } | |
1313 | 901 else if (first_collection) |
9 | 902 { |
1313 | 903 layout_image_set_collection(NULL, first_collection, |
904 collection_get_first(first_collection)); | |
9 | 905 } |
614 | 906 |
1145
3a7af6a8cd5f
Use functions to return directories instead of constants.
zas_
parents:
1089
diff
changeset
|
907 buf = g_build_filename(get_rc_dir(), ".command", NULL); |
649 | 908 remote_connection = remote_server_init(buf, cd); |
9 | 909 g_free(buf); |
1020 | 910 |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
509
diff
changeset
|
911 gtk_main(); |
1020 | 912 #ifdef HAVE_GTHREAD |
913 gdk_threads_leave(); | |
914 #endif | |
1 | 915 return 0; |
916 } | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1022
diff
changeset
|
917 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |