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