Mercurial > geeqie.yaz
annotate src/layout.c @ 1333:bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
author | zas_ |
---|---|
date | Fri, 27 Feb 2009 23:25:31 +0000 |
parents | 4286f08079b6 |
children | f97450e632a1 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
3 * (C) 2006 John Ellis |
1284 | 4 * Copyright (C) 2008 - 2009 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
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! | |
11 */ | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "layout.h" |
15 | |
507 | 16 #include "color-man.h" |
586 | 17 #include "filedata.h" |
507 | 18 #include "histogram.h" |
9 | 19 #include "image.h" |
482 | 20 #include "image-overlay.h" |
9 | 21 #include "layout_config.h" |
22 #include "layout_image.h" | |
23 #include "layout_util.h" | |
24 #include "menu.h" | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
25 #include "pixbuf-renderer.h" |
9 | 26 #include "pixbuf_util.h" |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
27 #include "utilops.h" |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
28 #include "view_dir.h" |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
29 #include "view_file.h" |
9 | 30 #include "ui_fileops.h" |
31 #include "ui_menu.h" | |
32 #include "ui_misc.h" | |
33 #include "ui_tabcomp.h" | |
648
e34c1002e553
Move some functions from main.[ch] to new window.[ch].
zas_
parents:
632
diff
changeset
|
34 #include "window.h" |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1177
diff
changeset
|
35 #include "metadata.h" |
1309 | 36 #include "rcfile.h" |
37 #include "bar.h" | |
1320 | 38 #include "bar_sort.h" |
648
e34c1002e553
Move some functions from main.[ch] to new window.[ch].
zas_
parents:
632
diff
changeset
|
39 |
528 | 40 #ifdef HAVE_LIRC |
41 #include "lirc.h" | |
42 #endif | |
9 | 43 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
44 #define MAINWINDOW_DEF_WIDTH 700 |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
45 #define MAINWINDOW_DEF_HEIGHT 500 |
9 | 46 |
553
32cf2e7992fd
Change default positions of dividers since width of the main menu
zas_
parents:
531
diff
changeset
|
47 #define MAIN_WINDOW_DIV_HPOS (MAINWINDOW_DEF_WIDTH / 2) |
32cf2e7992fd
Change default positions of dividers since width of the main menu
zas_
parents:
531
diff
changeset
|
48 #define MAIN_WINDOW_DIV_VPOS (MAINWINDOW_DEF_HEIGHT / 2) |
9 | 49 |
50 #define TOOLWINDOW_DEF_WIDTH 260 | |
51 #define TOOLWINDOW_DEF_HEIGHT 450 | |
553
32cf2e7992fd
Change default positions of dividers since width of the main menu
zas_
parents:
531
diff
changeset
|
52 |
9 | 53 #define PROGRESS_WIDTH 150 |
54 #define ZOOM_LABEL_WIDTH 64 | |
55 | |
56 #define PANE_DIVIDER_SIZE 10 | |
57 | |
58 | |
59 GList *layout_window_list = NULL; | |
60 | |
61 | |
62 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle); | |
63 | |
64 | |
65 /* | |
66 *----------------------------------------------------------------------------- | |
67 * misc | |
68 *----------------------------------------------------------------------------- | |
69 */ | |
70 | |
71 gint layout_valid(LayoutWindow **lw) | |
72 { | |
73 if (*lw == NULL) | |
74 { | |
75 if (layout_window_list) *lw = layout_window_list->data; | |
76 return (*lw != NULL); | |
77 } | |
78 | |
79 return (g_list_find(layout_window_list, *lw) != NULL); | |
80 } | |
81 | |
82 LayoutWindow *layout_find_by_image(ImageWindow *imd) | |
83 { | |
84 GList *work; | |
85 | |
86 work = layout_window_list; | |
87 while (work) | |
88 { | |
89 LayoutWindow *lw = work->data; | |
90 work = work->next; | |
91 | |
92 if (lw->image == imd) return lw; | |
93 } | |
94 | |
95 return NULL; | |
96 } | |
97 | |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
98 LayoutWindow *layout_find_by_image_fd(ImageWindow *imd) |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
99 { |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
100 GList *work; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
101 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
102 work = layout_window_list; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
103 while (work) |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
104 { |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
105 LayoutWindow *lw = work->data; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
106 work = work->next; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
107 if (lw->image->image_fd == imd->image_fd) |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
108 return lw; |
442 | 109 |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
110 } |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
111 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
112 return NULL; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
113 } |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
114 |
9 | 115 /* |
116 *----------------------------------------------------------------------------- | |
117 * menu, toolbar, and dir view | |
118 *----------------------------------------------------------------------------- | |
119 */ | |
120 | |
121 static void layout_path_entry_changed_cb(GtkWidget *widget, gpointer data) | |
122 { | |
123 LayoutWindow *lw = data; | |
124 gchar *buf; | |
125 | |
126 if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) < 0) return; | |
127 | |
128 buf = g_strdup(gtk_entry_get_text(GTK_ENTRY(lw->path_entry))); | |
783 | 129 if (!buf || (lw->dir_fd && strcmp(buf, lw->dir_fd->path) == 0)) |
9 | 130 { |
131 g_free(buf); | |
132 return; | |
133 } | |
134 | |
135 layout_set_path(lw, buf); | |
136 | |
442 | 137 g_free(buf); |
9 | 138 } |
139 | |
140 static void layout_path_entry_tab_cb(const gchar *path, gpointer data) | |
141 { | |
142 LayoutWindow *lw = data; | |
143 gchar *buf; | |
144 gchar *base; | |
145 | |
146 buf = g_strdup(path); | |
147 parse_out_relatives(buf); | |
148 base = remove_level_from_path(buf); | |
149 | |
150 if (isdir(buf)) | |
151 { | |
783 | 152 if ((!lw->dir_fd || strcmp(lw->dir_fd->path, buf) != 0) && layout_set_path(lw, buf)) |
9 | 153 { |
154 gint pos = -1; | |
726 | 155 /* put the G_DIR_SEPARATOR back, if we are in tab completion for a dir and result was path change */ |
725 | 156 gtk_editable_insert_text(GTK_EDITABLE(lw->path_entry), G_DIR_SEPARATOR_S, -1, &pos); |
9 | 157 gtk_editable_set_position(GTK_EDITABLE(lw->path_entry), |
158 strlen(gtk_entry_get_text(GTK_ENTRY(lw->path_entry)))); | |
159 } | |
160 } | |
783 | 161 else if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0) |
9 | 162 { |
163 layout_list_scroll_to_subpart(lw, filename_from_path(buf)); | |
164 } | |
165 | |
166 g_free(base); | |
167 g_free(buf); | |
168 } | |
169 | |
170 static void layout_path_entry_cb(const gchar *path, gpointer data) | |
171 { | |
172 LayoutWindow *lw = data; | |
173 gchar *buf; | |
174 | |
175 buf = g_strdup(path); | |
176 parse_out_relatives(buf); | |
177 | |
178 layout_set_path(lw, buf); | |
179 | |
180 g_free(buf); | |
181 } | |
182 | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
183 static void layout_vd_select_cb(ViewDir *vd, const gchar *path, gpointer data) |
9 | 184 { |
185 LayoutWindow *lw = data; | |
186 | |
187 layout_set_path(lw, path); | |
188 } | |
189 | |
1167
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
190 static void layout_path_entry_tab_append_cb(const gchar *path, gpointer data, gint n) |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
191 { |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
192 LayoutWindow *lw = data; |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
193 |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
194 if (!lw || !lw->back_button) return; |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
195 if (!layout_valid(&lw)) return; |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
196 |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
197 if (n >= 2) |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
198 { |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
199 /* Enable back button */ |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
200 gtk_widget_set_sensitive(lw->back_button, TRUE); |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
201 } |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
202 else |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
203 { |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
204 /* Disable back button */ |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
205 gtk_widget_set_sensitive(lw->back_button, FALSE); |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
206 } |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
207 } |
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
208 |
9 | 209 static GtkWidget *layout_tool_setup(LayoutWindow *lw) |
210 { | |
211 GtkWidget *box; | |
212 GtkWidget *menu_bar; | |
213 GtkWidget *tabcomp; | |
214 | |
215 box = gtk_vbox_new(FALSE, 0); | |
216 | |
217 menu_bar = layout_actions_menu_bar(lw); | |
218 gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0); | |
219 gtk_widget_show(menu_bar); | |
220 | |
221 lw->toolbar = layout_button_bar(lw); | |
222 gtk_box_pack_start(GTK_BOX(box), lw->toolbar, FALSE, FALSE, 0); | |
1309 | 223 if (!lw->options.toolbar_hidden) gtk_widget_show(lw->toolbar); |
9 | 224 |
225 tabcomp = tab_completion_new_with_history(&lw->path_entry, NULL, "path_list", -1, | |
226 layout_path_entry_cb, lw); | |
227 tab_completion_add_tab_func(lw->path_entry, layout_path_entry_tab_cb, lw); | |
1167
e812b1a7adda
Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
zas_
parents:
1055
diff
changeset
|
228 tab_completion_add_append_func(lw->path_entry, layout_path_entry_tab_append_cb, lw); |
9 | 229 gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0); |
230 gtk_widget_show(tabcomp); | |
231 | |
232 g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed", | |
233 G_CALLBACK(layout_path_entry_changed_cb), lw); | |
234 | |
1309 | 235 lw->vd = vd_new(lw->options.dir_view_type, lw->dir_fd); |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
236 vd_set_layout(lw->vd, lw); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
237 vd_set_select_func(lw->vd, layout_vd_select_cb, lw); |
9 | 238 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
239 lw->dir_view = lw->vd->widget; |
9 | 240 |
241 gtk_box_pack_start(GTK_BOX(box), lw->dir_view, TRUE, TRUE, 0); | |
242 gtk_widget_show(lw->dir_view); | |
243 | |
244 gtk_widget_show(box); | |
245 | |
246 return box; | |
247 } | |
248 | |
249 /* | |
250 *----------------------------------------------------------------------------- | |
251 * sort button (and menu) | |
252 *----------------------------------------------------------------------------- | |
253 */ | |
254 | |
255 static void layout_sort_menu_cb(GtkWidget *widget, gpointer data) | |
256 { | |
257 LayoutWindow *lw; | |
258 SortType type; | |
259 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
260 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
261 |
9 | 262 lw = submenu_item_get_data(widget); |
263 if (!lw) return; | |
264 | |
265 type = (SortType)GPOINTER_TO_INT(data); | |
266 | |
267 layout_sort_set(lw, type, lw->sort_ascend); | |
268 } | |
269 | |
270 static void layout_sort_menu_ascend_cb(GtkWidget *widget, gpointer data) | |
271 { | |
272 LayoutWindow *lw = data; | |
273 | |
274 layout_sort_set(lw, lw->sort_method, !lw->sort_ascend); | |
275 } | |
276 | |
277 static void layout_sort_menu_hide_cb(GtkWidget *widget, gpointer data) | |
278 { | |
279 /* destroy the menu */ | |
1043 | 280 #if GTK_CHECK_VERSION(2,12,0) |
281 g_object_unref(widget); | |
282 #else | |
9 | 283 gtk_widget_unref(GTK_WIDGET(widget)); |
1043 | 284 #endif |
9 | 285 } |
286 | |
287 static void layout_sort_button_press_cb(GtkWidget *widget, gpointer data) | |
288 { | |
289 LayoutWindow *lw = data; | |
290 GtkWidget *menu; | |
291 GdkEvent *event; | |
292 guint32 etime; | |
293 | |
294 menu = submenu_add_sort(NULL, G_CALLBACK(layout_sort_menu_cb), lw, FALSE, FALSE, TRUE, lw->sort_method); | |
295 | |
88
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
296 /* take ownership of menu */ |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
297 #ifdef GTK_OBJECT_FLOATING |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
298 /* GTK+ < 2.10 */ |
9 | 299 g_object_ref(G_OBJECT(menu)); |
300 gtk_object_sink(GTK_OBJECT(menu)); | |
88
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
301 #else |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
302 /* GTK+ >= 2.10 */ |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
303 g_object_ref_sink(G_OBJECT(menu)); |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
304 #endif |
9 | 305 |
442 | 306 /* ascending option */ |
9 | 307 menu_item_add_divider(menu); |
308 menu_item_add_check(menu, _("Ascending"), lw->sort_ascend, G_CALLBACK(layout_sort_menu_ascend_cb), lw); | |
309 | |
310 g_signal_connect(G_OBJECT(menu), "selection_done", | |
311 G_CALLBACK(layout_sort_menu_hide_cb), NULL); | |
312 | |
313 event = gtk_get_current_event(); | |
314 if (event) | |
315 { | |
316 etime = gdk_event_get_time(event); | |
317 gdk_event_free(event); | |
318 } | |
319 else | |
320 { | |
321 etime = 0; | |
322 } | |
323 | |
324 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, etime); | |
325 } | |
326 | |
327 static GtkWidget *layout_sort_button(LayoutWindow *lw) | |
328 { | |
329 GtkWidget *button; | |
330 | |
331 button = gtk_button_new_with_label(sort_type_get_text(lw->sort_method)); | |
442 | 332 g_signal_connect(G_OBJECT(button), "clicked", |
9 | 333 G_CALLBACK(layout_sort_button_press_cb), lw); |
442 | 334 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9 | 335 |
442 | 336 return button; |
9 | 337 } |
338 | |
339 /* | |
340 *----------------------------------------------------------------------------- | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
341 * color profile button (and menu) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
342 *----------------------------------------------------------------------------- |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
343 */ |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
344 |
1006
45ce6c1f331e
Silent warnings about unused functions when lcms is not used.
zas_
parents:
995
diff
changeset
|
345 #ifdef HAVE_LCMS |
45ce6c1f331e
Silent warnings about unused functions when lcms is not used.
zas_
parents:
995
diff
changeset
|
346 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
347 static void layout_color_menu_enable_cb(GtkWidget *widget, gpointer data) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
348 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
349 LayoutWindow *lw = data; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
350 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
351 layout_image_color_profile_set_use(lw, (!layout_image_color_profile_get_use(lw))); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
352 layout_image_refresh(lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
353 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
354 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
355 static void layout_color_menu_use_image_cb(GtkWidget *widget, gpointer data) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
356 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
357 LayoutWindow *lw = data; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
358 gint input, screen, use_image; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
359 |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
360 if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
361 layout_image_color_profile_set(lw, input, screen, !use_image); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
362 layout_image_refresh(lw); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
363 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
364 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
365 #define COLOR_MENU_KEY "color_menu_key" |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
366 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
367 static void layout_color_menu_input_cb(GtkWidget *widget, gpointer data) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
368 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
369 LayoutWindow *lw = data; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
370 gint type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
371 gint input, screen, use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
372 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
373 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
374 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
375 type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), COLOR_MENU_KEY)); |
432 | 376 if (type < 0 || type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) return; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
377 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
378 if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
379 if (type == input) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
380 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
381 layout_image_color_profile_set(lw, type, screen, use_image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
382 layout_image_refresh(lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
383 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
384 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
385 static void layout_color_menu_screen_cb(GtkWidget *widget, gpointer data) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
386 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
387 LayoutWindow *lw = data; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
388 gint type; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
389 gint input, screen, use_image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
390 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
391 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
392 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
393 type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), COLOR_MENU_KEY)); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
394 if (type < 0 || type > 1) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
395 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
396 if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
397 if (type == screen) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
398 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
399 layout_image_color_profile_set(lw, input, type, use_image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
400 layout_image_refresh(lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
401 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
402 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
403 static gchar *layout_color_name_parse(const gchar *name) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
404 { |
1333
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
405 if (!name || !*name) return g_strdup(_("Empty")); |
269
dca6c0b9f862
Simplify layout_color_name_parse() using g_strdelimit().
zas_
parents:
268
diff
changeset
|
406 return g_strdelimit(g_strdup(name), "_", '-'); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
407 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
408 |
1006
45ce6c1f331e
Silent warnings about unused functions when lcms is not used.
zas_
parents:
995
diff
changeset
|
409 #endif /* HAVE_LCMS */ |
45ce6c1f331e
Silent warnings about unused functions when lcms is not used.
zas_
parents:
995
diff
changeset
|
410 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
411 static void layout_color_button_press_cb(GtkWidget *widget, gpointer data) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
412 { |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
413 #ifndef HAVE_LCMS |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
414 gchar *msg = g_strdup_printf(_("This installation of %s was not built with support for color profiles."), GQ_APPNAME); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
415 file_util_warning_dialog(_("Color profiles not supported"), |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
416 msg, |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
417 GTK_STOCK_DIALOG_INFO, widget); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
418 g_free(msg); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
419 return; |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
420 #else |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
421 LayoutWindow *lw = data; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
422 GtkWidget *menu; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
423 GtkWidget *item; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
424 gchar *buf; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
425 gint active; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
426 gint input = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
427 gint screen = 0; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
428 gint use_image = 0; |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
429 gint from_image = 0; |
1333
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
430 gint image_profile; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
431 gint i; |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
432 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
433 if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
434 |
1333
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
435 image_profile = layout_image_color_profile_get_from_image(lw); |
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
436 from_image = use_image && (image_profile != COLOR_PROFILE_NONE); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
437 menu = popup_menu_short_lived(); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
438 |
270 | 439 active = layout_image_color_profile_get_use(lw); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
440 menu_item_add_check(menu, _("Use _color profiles"), active, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
441 G_CALLBACK(layout_color_menu_enable_cb), lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
442 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
443 menu_item_add_divider(menu); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
444 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
445 item = menu_item_add_check(menu, _("Use profile from _image"), use_image, |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
446 G_CALLBACK(layout_color_menu_use_image_cb), lw); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
447 gtk_widget_set_sensitive(item, active); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
448 |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
449 for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++) |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
450 { |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
451 const gchar *label; |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
452 |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
453 switch (i) |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
454 { |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
455 case COLOR_PROFILE_SRGB: label = _("sRGB"); break; |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
456 case COLOR_PROFILE_ADOBERGB: label = _("AdobeRGB compatible"); break; |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
457 default: label = "fixme"; break; |
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
458 } |
1333
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
459 buf = g_strdup_printf(_("Input _%d: %s%s"), i, label, (i == image_profile) ? " *" : ""); |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
460 item = menu_item_add_radio(menu, (i == COLOR_PROFILE_SRGB) ? NULL : item, |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
461 buf, (input == i), |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
462 G_CALLBACK(layout_color_menu_input_cb), lw); |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
463 g_free(buf); |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
464 g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i)); |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
465 gtk_widget_set_sensitive(item, active && !from_image); |
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
466 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
467 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
468 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
|
469 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
470 const gchar *name; |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
471 gchar *end; |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
472 |
327 | 473 name = options->color_profile.input_name[i]; |
1332
4286f08079b6
Fix up color profiles menu: mark empty entries (but not NULL) as inactive.
zas_
parents:
1322
diff
changeset
|
474 if (!name || !name[0]) name = filename_from_path(options->color_profile.input_file[i]); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
475 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
476 end = layout_color_name_parse(name); |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
477 buf = g_strdup_printf(_("Input _%d: %s"), i + COLOR_PROFILE_FILE, end); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
478 g_free(end); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
479 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
480 item = menu_item_add_radio(menu, item, |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
481 buf, (i + COLOR_PROFILE_FILE == input), |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
482 G_CALLBACK(layout_color_menu_input_cb), lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
483 g_free(buf); |
426
9fe0ca1b5263
show the AdobeRGB profile in the menu, indicate input profile from image
nadvornik
parents:
390
diff
changeset
|
484 g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + COLOR_PROFILE_FILE)); |
1333
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
485 gtk_widget_set_sensitive(item, active && !from_image && options->color_profile.input_file[i] && options->color_profile.input_file[i][0]); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
486 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
487 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
488 menu_item_add_divider(menu); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
489 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
490 item = menu_item_add_radio(menu, NULL, |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
491 _("Screen sRGB"), (screen == 0), |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
492 G_CALLBACK(layout_color_menu_screen_cb), lw); |
878
1b14c0e177ad
layout_color_button_press_cb(): tidy up, drop useless memory allocations, improve i18n.
zas_
parents:
837
diff
changeset
|
493 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
494 g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(0)); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
495 gtk_widget_set_sensitive(item, active); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
496 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
497 item = menu_item_add_radio(menu, item, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
498 _("_Screen profile"), (screen == 1), |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
499 G_CALLBACK(layout_color_menu_screen_cb), lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
500 g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(1)); |
1333
bdc19836c33d
Really fix up color profiles options tests. Add an indicator of the embedded color profile when recognized (a * just after sRGB or AdobeRGB compatible).
zas_
parents:
1332
diff
changeset
|
501 gtk_widget_set_sensitive(item, active && options->color_profile.screen_file && options->color_profile.screen_file[0]); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
502 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
503 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
281
diff
changeset
|
504 #endif /* HAVE_LCMS */ |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
505 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
506 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
507 static GtkWidget *layout_color_button(LayoutWindow *lw) |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
508 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
509 GtkWidget *button; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
510 GtkWidget *image; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
511 gint enable; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
512 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
513 button = gtk_button_new(); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
514 image = gtk_image_new_from_stock(GTK_STOCK_SELECT_COLOR, GTK_ICON_SIZE_MENU); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
515 gtk_container_add(GTK_CONTAINER(button), image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
516 gtk_widget_show(image); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
517 g_signal_connect(G_OBJECT(button), "clicked", |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
518 G_CALLBACK(layout_color_button_press_cb), lw); |
268 | 519 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
520 |
268 | 521 #ifdef HAVE_LCMS |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
522 enable = (lw->image) ? lw->image->color_profile_enable : FALSE; |
268 | 523 #else |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
524 enable = FALSE; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
525 #endif |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
526 gtk_widget_set_sensitive(image, enable); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
527 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
528 return button; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
529 } |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
530 |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
531 /* |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
532 *----------------------------------------------------------------------------- |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
533 * write button |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
534 *----------------------------------------------------------------------------- |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
535 */ |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
536 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
537 static void layout_write_button_press_cb(GtkWidget *widget, gpointer data) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
538 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
539 metadata_write_queue_confirm(NULL, NULL); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
540 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
541 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
542 static GtkWidget *layout_write_button(LayoutWindow *lw) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
543 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
544 GtkWidget *button; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
545 GtkWidget *image; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
546 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
547 button = gtk_button_new(); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
548 image = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
549 gtk_container_add(GTK_CONTAINER(button), image); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
550 gtk_widget_show(image); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
551 g_signal_connect(G_OBJECT(button), "clicked", |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
552 G_CALLBACK(layout_write_button_press_cb), lw); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
553 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
554 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
555 gtk_widget_set_sensitive(button, metadata_queue_length() > 0); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
556 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
557 return button; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
558 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
559 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
560 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
561 /* |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
562 *----------------------------------------------------------------------------- |
9 | 563 * status bar |
564 *----------------------------------------------------------------------------- | |
565 */ | |
566 | |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
567 void layout_status_update_write(LayoutWindow *lw) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
568 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
569 if (!layout_valid(&lw)) return; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
570 if (!lw->info_write) return; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
571 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
572 gtk_widget_set_sensitive(lw->info_write, metadata_queue_length() > 0); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
573 /* FIXME: maybe show also the number of files */ |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
574 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
575 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
576 void layout_status_update_write_all(void) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
577 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
578 GList *work; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
579 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
580 work = layout_window_list; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
581 while (work) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
582 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
583 LayoutWindow *lw = work->data; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
584 work = work->next; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
585 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
586 layout_status_update_write(lw); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
587 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
588 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
589 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
590 |
9 | 591 void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text) |
592 { | |
593 if (!layout_valid(&lw)) return; | |
594 if (!lw->info_progress_bar) return; | |
595 | |
596 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(lw->info_progress_bar), val); | |
597 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(lw->info_progress_bar), (text) ? text : " "); | |
598 } | |
599 | |
600 void layout_status_update_info(LayoutWindow *lw, const gchar *text) | |
601 { | |
602 gchar *buf = NULL; | |
603 | |
604 if (!layout_valid(&lw)) return; | |
605 | |
606 if (!text) | |
607 { | |
736 | 608 guint n; |
9 | 609 gint64 n_bytes = 0; |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
610 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
611 n = layout_list_count(lw, &n_bytes); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
612 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
613 if (n) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
614 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
615 guint s; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
616 gint64 s_bytes = 0; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
617 const gchar *ss; |
9 | 618 |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
619 if (layout_image_slideshow_active(lw)) |
9 | 620 { |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
621 if (!layout_image_slideshow_paused(lw)) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
622 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
623 ss = _(" Slideshow"); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
624 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
625 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
626 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
627 ss = _(" Paused"); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
628 } |
9 | 629 } |
630 else | |
631 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
632 ss = ""; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
633 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
634 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
635 s = layout_selection_count(lw, &s_bytes); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
636 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
637 layout_bars_new_selection(lw, s); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
638 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
639 if (s > 0) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
640 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
641 gchar *b = text_from_size_abrev(n_bytes); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
642 gchar *sb = text_from_size_abrev(s_bytes); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
643 buf = g_strdup_printf(_("%s, %d files (%s, %d)%s"), b, n, sb, s, ss); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
644 g_free(b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
645 g_free(sb); |
9 | 646 } |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
647 else if (n > 0) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
648 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
649 gchar *b = text_from_size_abrev(n_bytes); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
650 buf = g_strdup_printf(_("%s, %d files%s"), b, n, ss); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
651 g_free(b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
652 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
653 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
654 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
655 buf = g_strdup_printf(_("%d files%s"), n, ss); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
656 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
657 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
658 text = buf; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
659 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
660 image_osd_update(lw->image); |
9 | 661 } |
662 else | |
663 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
664 text = ""; |
9 | 665 } |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
666 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
667 |
583
de3e2bc22336
Revert patch 675, and correctly fix gtk assertion failure.
zas_
parents:
574
diff
changeset
|
668 if (lw->info_status) gtk_label_set_text(GTK_LABEL(lw->info_status), text); |
9 | 669 g_free(buf); |
670 } | |
671 | |
672 void layout_status_update_image(LayoutWindow *lw) | |
673 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
674 guint64 n; |
9 | 675 |
676 if (!layout_valid(&lw) || !lw->image) return; | |
677 | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
678 n = layout_list_count(lw, NULL); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
679 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
680 if (!n) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
681 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
682 gtk_label_set_text(GTK_LABEL(lw->info_zoom), ""); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
683 gtk_label_set_text(GTK_LABEL(lw->info_details), ""); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
684 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
685 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
686 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
687 gchar *text; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
688 gchar *b; |
9 | 689 |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
690 text = image_zoom_get_as_text(lw->image); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
691 gtk_label_set_text(GTK_LABEL(lw->info_zoom), text); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
692 g_free(text); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
693 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
694 b = image_get_fd(lw->image) ? text_from_size(image_get_fd(lw->image)->size) : g_strdup("0"); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
695 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
696 if (lw->image->unknown) |
9 | 697 { |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
698 if (image_get_path(lw->image) && !access_file(image_get_path(lw->image), R_OK)) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
699 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
700 text = g_strdup_printf(_("(no read permission) %s bytes"), b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
701 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
702 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
703 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
704 text = g_strdup_printf(_("( ? x ? ) %s bytes"), b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
705 } |
9 | 706 } |
707 else | |
708 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
709 gint width, height; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
710 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
711 image_get_image_size(lw->image, &width, &height); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
712 text = g_strdup_printf(_("( %d x %d ) %s bytes"), |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
713 width, height, b); |
9 | 714 } |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
715 |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
716 g_free(b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
717 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
718 gtk_label_set_text(GTK_LABEL(lw->info_details), text); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
719 g_free(text); |
9 | 720 } |
721 } | |
722 | |
723 void layout_status_update_all(LayoutWindow *lw) | |
724 { | |
725 layout_status_update_progress(lw, 0.0, NULL); | |
726 layout_status_update_info(lw, NULL); | |
727 layout_status_update_image(lw); | |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
728 layout_status_update_write(lw); |
9 | 729 } |
730 | |
731 static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gint start, gint size, gint expand) | |
732 { | |
733 GtkWidget *label; | |
734 GtkWidget *frame; | |
735 | |
736 frame = gtk_frame_new(NULL); | |
737 if (size) gtk_widget_set_size_request(frame, size, -1); | |
738 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
739 if (start) | |
740 { | |
741 gtk_box_pack_start(GTK_BOX(box), frame, expand, expand, 0); | |
742 } | |
743 else | |
744 { | |
745 gtk_box_pack_end(GTK_BOX(box), frame, expand, expand, 0); | |
746 } | |
747 gtk_widget_show(frame); | |
748 | |
749 label = gtk_label_new(text ? text : ""); | |
750 gtk_container_add(GTK_CONTAINER(frame), label); | |
751 gtk_widget_show(label); | |
752 | |
753 return label; | |
754 } | |
755 | |
756 static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gint small_format) | |
757 { | |
758 GtkWidget *hbox; | |
759 | |
760 if (lw->info_box) return; | |
761 | |
762 if (small_format) | |
763 { | |
764 lw->info_box = gtk_vbox_new(FALSE, 0); | |
765 } | |
766 else | |
767 { | |
768 lw->info_box = gtk_hbox_new(FALSE, 0); | |
769 } | |
770 gtk_box_pack_end(GTK_BOX(box), lw->info_box, FALSE, FALSE, 0); | |
771 gtk_widget_show(lw->info_box); | |
772 | |
773 if (small_format) | |
774 { | |
775 hbox = gtk_hbox_new(FALSE, 0); | |
776 gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0); | |
777 gtk_widget_show(hbox); | |
778 } | |
779 else | |
780 { | |
781 hbox = lw->info_box; | |
782 } | |
783 lw->info_progress_bar = gtk_progress_bar_new(); | |
784 gtk_widget_set_size_request(lw->info_progress_bar, PROGRESS_WIDTH, -1); | |
785 gtk_box_pack_start(GTK_BOX(hbox), lw->info_progress_bar, FALSE, FALSE, 0); | |
786 gtk_widget_show(lw->info_progress_bar); | |
787 | |
788 lw->info_sort = layout_sort_button(lw); | |
789 gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0); | |
790 gtk_widget_show(lw->info_sort); | |
791 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
792 lw->info_color = layout_color_button(lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
793 gtk_widget_show(lw->info_color); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
794 |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
795 lw->info_write = layout_write_button(lw); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
796 gtk_widget_show(lw->info_write); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
797 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
798 if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
799 if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
800 |
9 | 801 lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format)); |
802 | |
803 if (small_format) | |
804 { | |
805 hbox = gtk_hbox_new(FALSE, 0); | |
806 gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0); | |
807 gtk_widget_show(hbox); | |
808 } | |
809 else | |
810 { | |
811 hbox = lw->info_box; | |
812 } | |
813 lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE); | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
814 if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
815 if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); |
9 | 816 lw->info_zoom = layout_status_label(NULL, hbox, FALSE, ZOOM_LABEL_WIDTH, FALSE); |
817 } | |
818 | |
819 /* | |
820 *----------------------------------------------------------------------------- | |
821 * views | |
822 *----------------------------------------------------------------------------- | |
823 */ | |
824 | |
825 static GtkWidget *layout_tools_new(LayoutWindow *lw) | |
826 { | |
827 lw->dir_view = layout_tool_setup(lw); | |
828 return lw->dir_view; | |
829 } | |
830 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
831 static void layout_list_status_cb(ViewFile *vf, gpointer data) |
9 | 832 { |
833 LayoutWindow *lw = data; | |
834 | |
835 layout_status_update_info(lw, NULL); | |
836 } | |
837 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
838 static void layout_list_thumb_cb(ViewFile *vf, gdouble val, const gchar *text, gpointer data) |
9 | 839 { |
840 LayoutWindow *lw = data; | |
841 | |
842 layout_status_update_progress(lw, val, text); | |
843 } | |
844 | |
845 static GtkWidget *layout_list_new(LayoutWindow *lw) | |
846 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
847 lw->vf = vf_new(lw->file_view_type, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
848 vf_set_layout(lw->vf, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
849 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
850 vf_set_status_func(lw->vf, layout_list_status_cb, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
851 vf_set_thumb_status_func(lw->vf, layout_list_thumb_cb, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
852 |
1309 | 853 vf_marks_set(lw->vf, lw->options.show_marks); |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
854 |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
855 switch (lw->file_view_type) |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
856 { |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
857 case FILEVIEW_ICON: |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
858 break; |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
859 case FILEVIEW_LIST: |
1309 | 860 vf_thumb_set(lw->vf, lw->options.show_thumbnails); |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
861 break; |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
862 } |
442 | 863 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
864 return lw->vf->widget; |
9 | 865 } |
866 | |
867 static void layout_list_sync_thumb(LayoutWindow *lw) | |
868 { | |
1309 | 869 if (lw->vf) vf_thumb_set(lw->vf, lw->options.show_thumbnails); |
9 | 870 } |
871 | |
132 | 872 static void layout_list_sync_marks(LayoutWindow *lw) |
873 { | |
1309 | 874 if (lw->vf) vf_marks_set(lw->vf, lw->options.show_marks); |
132 | 875 } |
876 | |
9 | 877 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle) |
878 { | |
879 if (!lw) return; | |
880 #if 0 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
881 if (lw->vf) vf_scroll_to_subpart(lw->vf, needle); |
9 | 882 #endif |
883 } | |
884 | |
885 GList *layout_list(LayoutWindow *lw) | |
886 { | |
887 if (!layout_valid(&lw)) return NULL; | |
888 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
889 if (lw->vf) return vf_get_list(lw->vf); |
9 | 890 |
891 return NULL; | |
892 } | |
893 | |
736 | 894 guint layout_list_count(LayoutWindow *lw, gint64 *bytes) |
9 | 895 { |
896 if (!layout_valid(&lw)) return 0; | |
897 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
898 if (lw->vf) return vf_count(lw->vf, bytes); |
9 | 899 |
900 return 0; | |
901 } | |
902 | |
138 | 903 FileData *layout_list_get_fd(LayoutWindow *lw, gint index) |
904 { | |
905 if (!layout_valid(&lw)) return NULL; | |
906 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
907 if (lw->vf) return vf_index_get_data(lw->vf, index); |
138 | 908 |
909 return NULL; | |
910 } | |
911 | |
783 | 912 gint layout_list_get_index(LayoutWindow *lw, FileData *fd) |
9 | 913 { |
783 | 914 if (!layout_valid(&lw) || !fd) return -1; |
9 | 915 |
783 | 916 if (lw->vf) return vf_index_by_path(lw->vf, fd->path); |
9 | 917 |
918 return -1; | |
919 } | |
920 | |
138 | 921 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd) |
9 | 922 { |
923 if (!layout_valid(&lw)) return; | |
924 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
925 if (lw->vf) vf_select_by_fd(lw->vf, fd); |
9 | 926 } |
927 | |
928 static void layout_list_sync_sort(LayoutWindow *lw) | |
929 { | |
930 if (!layout_valid(&lw)) return; | |
931 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
932 if (lw->vf) vf_sort_set(lw->vf, lw->sort_method, lw->sort_ascend); |
9 | 933 } |
934 | |
935 GList *layout_selection_list(LayoutWindow *lw) | |
936 { | |
937 if (!layout_valid(&lw)) return NULL; | |
938 | |
939 if (layout_image_get_collection(lw, NULL)) | |
940 { | |
138 | 941 FileData *fd; |
9 | 942 |
138 | 943 fd = layout_image_get_fd(lw); |
944 if (fd) return g_list_append(NULL, file_data_ref(fd)); | |
9 | 945 return NULL; |
946 } | |
947 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
948 if (lw->vf) return vf_selection_get_list(lw->vf); |
9 | 949 |
950 return NULL; | |
951 } | |
952 | |
953 GList *layout_selection_list_by_index(LayoutWindow *lw) | |
954 { | |
955 if (!layout_valid(&lw)) return NULL; | |
956 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
957 if (lw->vf) return vf_selection_get_list_by_index(lw->vf); |
9 | 958 |
959 return NULL; | |
960 } | |
961 | |
736 | 962 guint layout_selection_count(LayoutWindow *lw, gint64 *bytes) |
9 | 963 { |
964 if (!layout_valid(&lw)) return 0; | |
965 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
966 if (lw->vf) return vf_selection_count(lw->vf, bytes); |
9 | 967 |
968 return 0; | |
969 } | |
970 | |
971 void layout_select_all(LayoutWindow *lw) | |
972 { | |
973 if (!layout_valid(&lw)) return; | |
974 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
975 if (lw->vf) vf_select_all(lw->vf); |
9 | 976 } |
977 | |
978 void layout_select_none(LayoutWindow *lw) | |
979 { | |
980 if (!layout_valid(&lw)) return; | |
981 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
982 if (lw->vf) vf_select_none(lw->vf); |
9 | 983 } |
984 | |
601 | 985 void layout_select_invert(LayoutWindow *lw) |
986 { | |
987 if (!layout_valid(&lw)) return; | |
988 | |
989 if (lw->vf) vf_select_invert(lw->vf); | |
990 } | |
991 | |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
992 void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode) |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
993 { |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
994 if (!layout_valid(&lw)) return; |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
995 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
996 if (lw->vf) vf_mark_to_selection(lw->vf, mark, mode); |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
997 } |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
998 |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
999 void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode) |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
1000 { |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
1001 if (!layout_valid(&lw)) return; |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
1002 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1003 if (lw->vf) vf_selection_to_mark(lw->vf, mark, mode); |
442 | 1004 |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
1005 layout_status_update_info(lw, NULL); /* osd in fullscreen mode */ |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
1006 } |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
1007 |
9 | 1008 /* |
1009 *----------------------------------------------------------------------------- | |
1010 * access | |
1011 *----------------------------------------------------------------------------- | |
1012 */ | |
1013 | |
1014 const gchar *layout_get_path(LayoutWindow *lw) | |
1015 { | |
1016 if (!layout_valid(&lw)) return NULL; | |
783 | 1017 return lw->dir_fd ? lw->dir_fd->path : NULL; |
9 | 1018 } |
1019 | |
1020 static void layout_sync_path(LayoutWindow *lw) | |
1021 { | |
783 | 1022 if (!lw->dir_fd) return; |
9 | 1023 |
783 | 1024 if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path); |
1025 if (lw->vd) vd_set_fd(lw->vd, lw->dir_fd); | |
9 | 1026 |
783 | 1027 if (lw->vf) vf_set_fd(lw->vf, lw->dir_fd); |
9 | 1028 } |
1029 | |
1030 gint layout_set_path(LayoutWindow *lw, const gchar *path) | |
1031 { | |
959 | 1032 FileData *fd; |
1033 if (!path) return FALSE; | |
1034 fd = file_data_new_simple(path); | |
783 | 1035 gint ret = layout_set_fd(lw, fd); |
1036 file_data_unref(fd); | |
1037 return ret; | |
1038 } | |
1039 | |
1040 | |
1041 gint layout_set_fd(LayoutWindow *lw, FileData *fd) | |
1042 { | |
9 | 1043 gint have_file = FALSE; |
1044 | |
1045 if (!layout_valid(&lw)) return FALSE; | |
1046 | |
783 | 1047 if (!fd || !isname(fd->path)) return FALSE; |
1048 if (lw->dir_fd && fd == lw->dir_fd) | |
9 | 1049 { |
1050 return TRUE; | |
1051 } | |
1052 | |
783 | 1053 if (isdir(fd->path)) |
9 | 1054 { |
791 | 1055 if (lw->dir_fd) |
1056 { | |
1057 file_data_unregister_real_time_monitor(lw->dir_fd); | |
1058 file_data_unref(lw->dir_fd); | |
1059 } | |
783 | 1060 lw->dir_fd = file_data_ref(fd); |
791 | 1061 file_data_register_real_time_monitor(fd); |
9 | 1062 } |
1063 else | |
1064 { | |
1065 gchar *base; | |
1066 | |
783 | 1067 base = remove_level_from_path(fd->path); |
1068 if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0) | |
9 | 1069 { |
1070 g_free(base); | |
1071 } | |
1072 else if (isdir(base)) | |
1073 { | |
791 | 1074 if (lw->dir_fd) |
1075 { | |
1076 file_data_unregister_real_time_monitor(lw->dir_fd); | |
1077 file_data_unref(lw->dir_fd); | |
1078 } | |
783 | 1079 lw->dir_fd = file_data_new_simple(base); |
791 | 1080 file_data_register_real_time_monitor(lw->dir_fd); |
783 | 1081 g_free(base); |
9 | 1082 } |
1083 else | |
1084 { | |
1085 g_free(base); | |
1086 return FALSE; | |
1087 } | |
783 | 1088 if (isfile(fd->path)) have_file = TRUE; |
9 | 1089 } |
1090 | |
783 | 1091 if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->dir_fd->path); |
9 | 1092 layout_sync_path(lw); |
1301
8c47a4f521ad
Fix bug 2599857: file list sort order was wrong in many cases.
zas_
parents:
1296
diff
changeset
|
1093 layout_list_sync_sort(lw); |
8c47a4f521ad
Fix bug 2599857: file list sort order was wrong in many cases.
zas_
parents:
1296
diff
changeset
|
1094 |
9 | 1095 if (have_file) |
1096 { | |
1097 gint row; | |
1098 | |
783 | 1099 row = layout_list_get_index(lw, fd); |
9 | 1100 if (row >= 0) |
1101 { | |
1102 layout_image_set_index(lw, row); | |
1103 } | |
1104 else | |
1105 { | |
783 | 1106 layout_image_set_fd(lw, fd); |
9 | 1107 } |
1108 } | |
320 | 1109 else if (!options->lazy_image_sync) |
9 | 1110 { |
1111 layout_image_set_index(lw, 0); | |
1112 } | |
1113 | |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1177
diff
changeset
|
1114 if (options->metadata.confirm_on_dir_change) |
1231 | 1115 metadata_write_queue_confirm(NULL, NULL); |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1177
diff
changeset
|
1116 |
9 | 1117 return TRUE; |
1118 } | |
1119 | |
1120 static void layout_refresh_lists(LayoutWindow *lw) | |
1121 { | |
390 | 1122 if (lw->vd) vd_refresh(lw->vd); |
9 | 1123 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1124 if (lw->vf) vf_refresh(lw->vf); |
9 | 1125 } |
1126 | |
1127 void layout_refresh(LayoutWindow *lw) | |
1128 { | |
1129 if (!layout_valid(&lw)) return; | |
1130 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
501
diff
changeset
|
1131 DEBUG_1("layout refresh"); |
9 | 1132 |
1133 layout_refresh_lists(lw); | |
1134 | |
1135 if (lw->image) layout_image_refresh(lw); | |
1136 } | |
1137 | |
1138 void layout_thumb_set(LayoutWindow *lw, gint enable) | |
1139 { | |
1140 if (!layout_valid(&lw)) return; | |
1141 | |
1309 | 1142 if (lw->options.show_thumbnails == enable) return; |
1143 | |
1144 lw->options.show_thumbnails = enable; | |
9 | 1145 |
1146 layout_util_sync_thumb(lw); | |
1147 layout_list_sync_thumb(lw); | |
1148 } | |
1149 | |
132 | 1150 void layout_marks_set(LayoutWindow *lw, gint enable) |
1151 { | |
1152 if (!layout_valid(&lw)) return; | |
1153 | |
1309 | 1154 if (lw->options.show_marks == enable) return; |
1155 | |
1156 lw->options.show_marks = enable; | |
132 | 1157 |
268 | 1158 // layout_util_sync_marks(lw); |
1159 layout_list_sync_marks(lw); | |
132 | 1160 } |
1161 | |
9 | 1162 gint layout_thumb_get(LayoutWindow *lw) |
1163 { | |
1164 if (!layout_valid(&lw)) return FALSE; | |
1165 | |
1309 | 1166 return lw->options.show_thumbnails; |
9 | 1167 } |
1168 | |
433
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1169 gint layout_marks_get(LayoutWindow *lw) |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1170 { |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1171 if (!layout_valid(&lw)) return FALSE; |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1172 |
1309 | 1173 return lw->options.show_marks; |
433
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1174 } |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1175 |
9 | 1176 void layout_sort_set(LayoutWindow *lw, SortType type, gint ascend) |
1177 { | |
1178 if (!layout_valid(&lw)) return; | |
1179 if (lw->sort_method == type && lw->sort_ascend == ascend) return; | |
1180 | |
1181 lw->sort_method = type; | |
1182 lw->sort_ascend = ascend; | |
1183 | |
1184 if (lw->info_sort) gtk_label_set_text(GTK_LABEL(GTK_BIN(lw->info_sort)->child), | |
1185 sort_type_get_text(type)); | |
1186 layout_list_sync_sort(lw); | |
1187 } | |
1188 | |
1189 gint layout_sort_get(LayoutWindow *lw, SortType *type, gint *ascend) | |
1190 { | |
1191 if (!layout_valid(&lw)) return FALSE; | |
1192 | |
1193 if (type) *type = lw->sort_method; | |
1194 if (ascend) *ascend = lw->sort_ascend; | |
1195 | |
1196 return TRUE; | |
1197 } | |
1198 | |
1199 gint layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h) | |
1200 { | |
1201 if (!layout_valid(&lw)) return FALSE; | |
1202 | |
1203 gdk_window_get_root_origin(lw->window->window, x, y); | |
1204 gdk_drawable_get_size(lw->window->window, w, h); | |
1205 | |
1206 return TRUE; | |
1207 } | |
1208 | |
1209 gint layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v) | |
1210 { | |
1211 if (!layout_valid(&lw)) return FALSE; | |
1212 | |
1213 if (lw->h_pane && GTK_PANED(lw->h_pane)->child1->allocation.x >= 0) | |
1214 { | |
1215 *h = GTK_PANED(lw->h_pane)->child1->allocation.width; | |
1216 } | |
1309 | 1217 else if (h != &lw->options.main_window.hdivider_pos) |
9 | 1218 { |
1309 | 1219 *h = lw->options.main_window.hdivider_pos; |
9 | 1220 } |
1221 | |
1222 if (lw->v_pane && GTK_PANED(lw->v_pane)->child1->allocation.x >= 0) | |
1223 { | |
1224 *v = GTK_PANED(lw->v_pane)->child1->allocation.height; | |
1225 } | |
1309 | 1226 else if (v != &lw->options.main_window.vdivider_pos) |
9 | 1227 { |
1309 | 1228 *v = lw->options.main_window.vdivider_pos; |
9 | 1229 } |
1230 | |
1231 return TRUE; | |
1232 } | |
1233 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1234 void layout_views_set(LayoutWindow *lw, DirViewType dir_view_type, FileViewType file_view_type) |
9 | 1235 { |
1236 if (!layout_valid(&lw)) return; | |
1237 | |
1309 | 1238 if (lw->options.dir_view_type == dir_view_type && lw->file_view_type == file_view_type) return; |
1239 | |
1240 lw->options.dir_view_type = dir_view_type; | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1241 lw->file_view_type = file_view_type; |
9 | 1242 |
1243 layout_style_set(lw, -1, NULL); | |
1244 } | |
1245 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1246 gint layout_views_get(LayoutWindow *lw, DirViewType *dir_view_type, FileViewType *file_view_type) |
9 | 1247 { |
1248 if (!layout_valid(&lw)) return FALSE; | |
1249 | |
1309 | 1250 *dir_view_type = lw->options.dir_view_type; |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1251 *file_view_type = lw->file_view_type; |
9 | 1252 |
1253 return TRUE; | |
1254 } | |
1255 | |
1256 /* | |
1257 *----------------------------------------------------------------------------- | |
1258 * location utils | |
1259 *----------------------------------------------------------------------------- | |
1260 */ | |
1261 | |
1262 static gint layout_location_single(LayoutLocation l) | |
1263 { | |
1264 return (l == LAYOUT_LEFT || | |
1265 l == LAYOUT_RIGHT || | |
1266 l == LAYOUT_TOP || | |
1267 l == LAYOUT_BOTTOM); | |
1268 } | |
1269 | |
1270 static gint layout_location_vertical(LayoutLocation l) | |
1271 { | |
1272 return (l & LAYOUT_TOP || | |
1273 l & LAYOUT_BOTTOM); | |
1274 } | |
1275 | |
1276 static gint layout_location_first(LayoutLocation l) | |
1277 { | |
1278 return (l & LAYOUT_TOP || | |
1279 l & LAYOUT_LEFT); | |
1280 } | |
1281 | |
1282 static LayoutLocation layout_grid_compass(LayoutWindow *lw) | |
1283 { | |
1284 if (layout_location_single(lw->dir_location)) return lw->dir_location; | |
1285 if (layout_location_single(lw->file_location)) return lw->file_location; | |
1286 return lw->image_location; | |
1287 } | |
1288 | |
1289 static void layout_location_compute(LayoutLocation l1, LayoutLocation l2, | |
1290 GtkWidget *s1, GtkWidget *s2, | |
1291 GtkWidget **d1, GtkWidget **d2) | |
1292 { | |
1293 LayoutLocation l; | |
1294 | |
1295 l = l1 & l2; /* get common compass direction */ | |
1296 l = l1 - l; /* remove it */ | |
1297 | |
1298 if (layout_location_first(l)) | |
1299 { | |
1300 *d1 = s1; | |
1301 *d2 = s2; | |
1302 } | |
1303 else | |
1304 { | |
1305 *d1 = s2; | |
1306 *d2 = s1; | |
1307 } | |
1308 } | |
1309 | |
1310 /* | |
1311 *----------------------------------------------------------------------------- | |
1312 * tools window (for floating/hidden) | |
1313 *----------------------------------------------------------------------------- | |
1314 */ | |
1315 | |
1316 gint layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) | |
1317 { | |
1318 if (!layout_valid(&lw)) return FALSE; | |
1319 | |
1320 if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools)) | |
1321 { | |
1322 /* use the stored values (sort of breaks success return value) */ | |
1323 | |
1309 | 1324 *divider_pos = lw->options.float_window.vdivider_pos; |
9 | 1325 |
1326 return FALSE; | |
1327 } | |
1328 | |
1329 gdk_window_get_root_origin(lw->tools->window, x, y); | |
1330 gdk_drawable_get_size(lw->tools->window, w, h); | |
1331 | |
1332 if (GTK_IS_VPANED(lw->tools_pane)) | |
1333 { | |
1334 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height; | |
1335 } | |
1336 else | |
1337 { | |
1338 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width; | |
1339 } | |
1340 | |
1341 return TRUE; | |
1342 } | |
1343 | |
1344 static void layout_tools_geometry_sync(LayoutWindow *lw) | |
1345 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1346 layout_geometry_get_tools(lw, &options->layout.float_window.x, &options->layout.float_window.x, |
1309 | 1347 &options->layout.float_window.w, &options->layout.float_window.h, &lw->options.float_window.vdivider_pos); |
9 | 1348 } |
1349 | |
1350 static void layout_tools_hide(LayoutWindow *lw, gint hide) | |
1351 { | |
1352 if (!lw->tools) return; | |
1353 | |
1354 if (hide) | |
1355 { | |
1356 if (GTK_WIDGET_VISIBLE(lw->tools)) | |
1357 { | |
1358 layout_tools_geometry_sync(lw); | |
1359 gtk_widget_hide(lw->tools); | |
1360 } | |
1361 } | |
1362 else | |
1363 { | |
1364 if (!GTK_WIDGET_VISIBLE(lw->tools)) | |
1365 { | |
1366 gtk_widget_show(lw->tools); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1367 if (lw->vf) vf_refresh(lw->vf); |
9 | 1368 } |
1369 } | |
1370 | |
1309 | 1371 lw->options.tools_hidden = hide; |
9 | 1372 } |
1373 | |
1374 static gint layout_tools_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
1375 { | |
1376 LayoutWindow *lw = data; | |
1377 | |
1378 layout_tools_float_toggle(lw); | |
1379 | |
1380 return TRUE; | |
1381 } | |
1382 | |
1383 static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *files) | |
1384 { | |
1385 GtkWidget *vbox; | |
1386 GtkWidget *w1, *w2; | |
1387 gint vertical; | |
1388 gint new_window = FALSE; | |
1389 | |
1390 vertical = (layout_location_single(lw->image_location) && !layout_location_vertical(lw->image_location)) || | |
1391 (!layout_location_single(lw->image_location) && layout_location_vertical(layout_grid_compass(lw))); | |
1392 #if 0 | |
1393 layout_location_compute(lw->dir_location, lw->file_location, | |
1394 tools, files, &w1, &w2); | |
1395 #endif | |
1396 /* for now, tools/dir are always first in order */ | |
1397 w1 = tools; | |
1398 w2 = files; | |
1399 | |
1400 if (!lw->tools) | |
1401 { | |
1402 GdkGeometry geometry; | |
1403 GdkWindowHints hints; | |
1404 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
1405 lw->tools = window_new(GTK_WINDOW_TOPLEVEL, "tools", PIXBUF_INLINE_ICON_TOOLS, NULL, _("Tools")); |
9 | 1406 g_signal_connect(G_OBJECT(lw->tools), "delete_event", |
1407 G_CALLBACK(layout_tools_delete_cb), lw); | |
1408 layout_keyboard_init(lw, lw->tools); | |
1409 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1410 if (options->layout.save_window_positions) |
9 | 1411 { |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1412 hints = GDK_HINT_USER_POS; |
9 | 1413 } |
1414 else | |
1415 { | |
1416 hints = 0; | |
1417 } | |
1418 | |
1029
1a4b18c58556
Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents:
1006
diff
changeset
|
1419 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE; |
1a4b18c58556
Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents:
1006
diff
changeset
|
1420 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE; |
9 | 1421 geometry.base_width = TOOLWINDOW_DEF_WIDTH; |
1422 geometry.base_height = TOOLWINDOW_DEF_HEIGHT; | |
1423 gtk_window_set_geometry_hints(GTK_WINDOW(lw->tools), NULL, &geometry, | |
1424 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hints); | |
1425 | |
1426 | |
268 | 1427 gtk_window_set_resizable(GTK_WINDOW(lw->tools), TRUE); |
1428 gtk_container_set_border_width(GTK_CONTAINER(lw->tools), 0); | |
442 | 1429 |
9 | 1430 new_window = TRUE; |
1431 } | |
1432 else | |
1433 { | |
1434 layout_tools_geometry_sync(lw); | |
1435 /* dump the contents */ | |
1436 gtk_widget_destroy(GTK_BIN(lw->tools)->child); | |
1437 } | |
1438 | |
1439 layout_actions_add_window(lw, lw->tools); | |
1440 | |
1441 vbox = gtk_vbox_new(FALSE, 0); | |
1442 gtk_container_add(GTK_CONTAINER(lw->tools), vbox); | |
1443 gtk_widget_show(vbox); | |
1444 | |
1445 layout_status_setup(lw, vbox, TRUE); | |
1446 | |
1447 if (vertical) | |
1448 { | |
1449 lw->tools_pane = gtk_vpaned_new(); | |
1450 } | |
1451 else | |
1452 { | |
1453 lw->tools_pane = gtk_hpaned_new(); | |
1454 } | |
1455 gtk_box_pack_start(GTK_BOX(vbox), lw->tools_pane, TRUE, TRUE, 0); | |
1456 gtk_widget_show(lw->tools_pane); | |
1457 | |
1458 gtk_paned_pack1(GTK_PANED(lw->tools_pane), w1, FALSE, TRUE); | |
1459 gtk_paned_pack2(GTK_PANED(lw->tools_pane), w2, TRUE, TRUE); | |
1460 | |
1461 gtk_widget_show(tools); | |
1462 gtk_widget_show(files); | |
1463 | |
1464 if (new_window) | |
1465 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1466 if (options->layout.save_window_positions) |
9 | 1467 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1468 gtk_window_set_default_size(GTK_WINDOW(lw->tools), options->layout.float_window.w, options->layout.float_window.h); |
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1469 gtk_window_move(GTK_WINDOW(lw->tools), options->layout.float_window.x, options->layout.float_window.y); |
268 | 1470 } |
9 | 1471 else |
1472 { | |
1473 if (vertical) | |
1474 { | |
1475 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1476 TOOLWINDOW_DEF_WIDTH, TOOLWINDOW_DEF_HEIGHT); | |
1477 } | |
1478 else | |
1479 { | |
1480 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1481 TOOLWINDOW_DEF_HEIGHT, TOOLWINDOW_DEF_WIDTH); | |
1482 } | |
1483 } | |
1484 } | |
1485 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1486 if (!options->layout.save_window_positions) |
9 | 1487 { |
1488 if (vertical) | |
1489 { | |
1309 | 1490 lw->options.float_window.vdivider_pos = MAIN_WINDOW_DIV_VPOS; |
9 | 1491 } |
1492 else | |
1493 { | |
1309 | 1494 lw->options.float_window.vdivider_pos = MAIN_WINDOW_DIV_HPOS; |
9 | 1495 } |
1496 } | |
1497 | |
1309 | 1498 gtk_paned_set_position(GTK_PANED(lw->tools_pane), lw->options.float_window.vdivider_pos); |
9 | 1499 } |
1500 | |
1501 /* | |
1502 *----------------------------------------------------------------------------- | |
1503 * glue (layout arrangement) | |
1504 *----------------------------------------------------------------------------- | |
1505 */ | |
1506 | |
1507 static void layout_grid_compute(LayoutWindow *lw, | |
1508 GtkWidget *image, GtkWidget *tools, GtkWidget *files, | |
1509 GtkWidget **w1, GtkWidget **w2, GtkWidget **w3) | |
1510 { | |
1511 /* heh, this was fun */ | |
1512 | |
1513 if (layout_location_single(lw->dir_location)) | |
1514 { | |
1515 if (layout_location_first(lw->dir_location)) | |
1516 { | |
1517 *w1 = tools; | |
1518 layout_location_compute(lw->file_location, lw->image_location, files, image, w2, w3); | |
1519 } | |
1520 else | |
1521 { | |
1522 *w3 = tools; | |
1523 layout_location_compute(lw->file_location, lw->image_location, files, image, w1, w2); | |
1524 } | |
1525 } | |
1526 else if (layout_location_single(lw->file_location)) | |
1527 { | |
1528 if (layout_location_first(lw->file_location)) | |
1529 { | |
1530 *w1 = files; | |
1531 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w2, w3); | |
1532 } | |
1533 else | |
1534 { | |
1535 *w3 = files; | |
1536 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w1, w2); | |
1537 } | |
1538 } | |
1539 else | |
1540 { | |
1541 /* image */ | |
1542 if (layout_location_first(lw->image_location)) | |
1543 { | |
1544 *w1 = image; | |
1545 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w2, w3); | |
1546 } | |
1547 else | |
1548 { | |
1549 *w3 = image; | |
1550 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w1, w2); | |
1551 } | |
1552 } | |
1553 } | |
1554 | |
127 | 1555 void layout_split_change(LayoutWindow *lw, ImageSplitMode mode) |
1556 { | |
1557 GtkWidget *image; | |
1558 gint i; | |
268 | 1559 |
1560 for (i = 0; i < MAX_SPLIT_IMAGES; i++) | |
127 | 1561 { |
1562 if (lw->split_images[i]) | |
1563 { | |
1564 gtk_widget_hide(lw->split_images[i]->widget); | |
442 | 1565 if (lw->split_images[i]->widget->parent != lw->utility_box) |
127 | 1566 gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); |
1567 } | |
1568 } | |
1569 gtk_container_remove(GTK_CONTAINER(lw->utility_box), lw->split_image_widget); | |
1570 | |
1571 image = layout_image_setup_split(lw, mode); | |
1572 | |
1573 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); | |
1574 gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0); | |
1575 gtk_widget_show(image); | |
1576 } | |
1577 | |
9 | 1578 static void layout_grid_setup(LayoutWindow *lw) |
1579 { | |
1580 gint priority_location; | |
1581 GtkWidget *h; | |
1582 GtkWidget *v; | |
1583 GtkWidget *w1, *w2, *w3; | |
1584 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1585 GtkWidget *image_sb; /* image together with sidebars in utility box */ |
9 | 1586 GtkWidget *tools; |
1587 GtkWidget *files; | |
1588 | |
1589 layout_actions_setup(lw); | |
1590 layout_actions_add_window(lw, lw->window); | |
1591 | |
1592 lw->group_box = gtk_vbox_new(FALSE, 0); | |
1593 gtk_box_pack_start(GTK_BOX(lw->main_box), lw->group_box, TRUE, TRUE, 0); | |
1594 gtk_widget_show(lw->group_box); | |
1595 | |
1596 priority_location = layout_grid_compass(lw); | |
1597 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1598 if (lw->utility_box) |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1599 { |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1600 image_sb = lw->utility_box; |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1601 } |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1602 else |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1603 { |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1604 GtkWidget *image; /* image or split images together */ |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1605 image = layout_image_setup_split(lw, lw->split_mode); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1606 image_sb = layout_bars_prepare(lw, image); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1607 } |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1608 |
9 | 1609 tools = layout_tools_new(lw); |
1610 files = layout_list_new(lw); | |
1611 | |
1612 | |
1309 | 1613 if (lw->options.tools_float || lw->options.tools_hidden) |
9 | 1614 { |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1615 gtk_box_pack_start(GTK_BOX(lw->group_box), image_sb, TRUE, TRUE, 0); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1616 gtk_widget_show(image_sb); |
9 | 1617 |
1618 layout_tools_setup(lw, tools, files); | |
1619 | |
1620 gtk_widget_grab_focus(lw->image->widget); | |
1621 | |
1622 return; | |
1623 } | |
1624 else if (lw->tools) | |
1625 { | |
1626 layout_tools_geometry_sync(lw); | |
1627 gtk_widget_destroy(lw->tools); | |
1628 lw->tools = NULL; | |
1629 lw->tools_pane = NULL; | |
1630 } | |
1631 | |
1632 layout_status_setup(lw, lw->group_box, FALSE); | |
1633 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1634 layout_grid_compute(lw, image_sb, tools, files, &w1, &w2, &w3); |
9 | 1635 |
1636 v = lw->v_pane = gtk_vpaned_new(); | |
1637 | |
1638 h = lw->h_pane = gtk_hpaned_new(); | |
1639 | |
1640 if (!layout_location_vertical(priority_location)) | |
1641 { | |
1642 GtkWidget *tmp; | |
1643 | |
1644 tmp = v; | |
1645 v = h; | |
1646 h = tmp; | |
1647 } | |
1648 | |
1649 gtk_box_pack_start(GTK_BOX(lw->group_box), v, TRUE, TRUE, 0); | |
1650 | |
1651 if (!layout_location_first(priority_location)) | |
1652 { | |
1653 gtk_paned_pack1(GTK_PANED(v), h, FALSE, TRUE); | |
1654 gtk_paned_pack2(GTK_PANED(v), w3, TRUE, TRUE); | |
1655 | |
1656 gtk_paned_pack1(GTK_PANED(h), w1, FALSE, TRUE); | |
1657 gtk_paned_pack2(GTK_PANED(h), w2, TRUE, TRUE); | |
1658 } | |
1659 else | |
1660 { | |
1661 gtk_paned_pack1(GTK_PANED(v), w1, FALSE, TRUE); | |
1662 gtk_paned_pack2(GTK_PANED(v), h, TRUE, TRUE); | |
1663 | |
1664 gtk_paned_pack1(GTK_PANED(h), w2, FALSE, TRUE); | |
1665 gtk_paned_pack2(GTK_PANED(h), w3, TRUE, TRUE); | |
1666 } | |
1667 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1668 gtk_widget_show(image_sb); |
9 | 1669 gtk_widget_show(tools); |
1670 gtk_widget_show(files); | |
1671 | |
1672 gtk_widget_show(v); | |
1673 gtk_widget_show(h); | |
1674 | |
1675 /* fix to have image pane visible when it is left and priority widget */ | |
1309 | 1676 if (lw->options.main_window.hdivider_pos == -1 && |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1677 w1 == image_sb && |
9 | 1678 !layout_location_vertical(priority_location) && |
1679 layout_location_first(priority_location)) | |
1680 { | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1681 gtk_widget_set_size_request(image_sb, 200, -1); |
9 | 1682 } |
1683 | |
1309 | 1684 gtk_paned_set_position(GTK_PANED(lw->h_pane), lw->options.main_window.hdivider_pos); |
1685 gtk_paned_set_position(GTK_PANED(lw->v_pane), lw->options.main_window.vdivider_pos); | |
9 | 1686 |
1687 gtk_widget_grab_focus(lw->image->widget); | |
1688 } | |
1689 | |
1690 void layout_style_set(LayoutWindow *lw, gint style, const gchar *order) | |
1691 { | |
783 | 1692 FileData *dir_fd; |
9 | 1693 |
1694 if (!layout_valid(&lw)) return; | |
1695 | |
1696 if (style != -1) | |
1697 { | |
1698 LayoutLocation d, f, i; | |
1699 | |
1700 layout_config_parse(style, order, &d, &f, &i); | |
1701 | |
1702 if (lw->dir_location == d && | |
1703 lw->file_location == f && | |
1704 lw->image_location == i) return; | |
1705 | |
1706 lw->dir_location = d; | |
1707 lw->file_location = f; | |
1708 lw->image_location = i; | |
1709 } | |
1710 | |
1711 /* remember state */ | |
1712 | |
1713 layout_image_slideshow_stop(lw); | |
1714 layout_image_full_screen_stop(lw); | |
1715 | |
783 | 1716 dir_fd = lw->dir_fd; |
960
37fdfe8f2ab1
fixed crash with float file list and geeqie --blank
nadvornik
parents:
959
diff
changeset
|
1717 if (dir_fd) file_data_unregister_real_time_monitor(dir_fd); |
783 | 1718 lw->dir_fd = NULL; |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1719 |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1720 /* lw->image is preserved together with lw->utility_box */ |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1721 if (lw->utility_box) |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1722 { |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1723 /* preserve utility_box (image + sidebars) to be reused later in layout_grid_setup */ |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1724 gtk_widget_hide(lw->utility_box); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1725 g_object_ref(lw->utility_box); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1726 gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1727 } |
9 | 1728 |
1309 | 1729 layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos); |
9 | 1730 |
1731 /* clear it all */ | |
1732 | |
1733 lw->h_pane = NULL; | |
1734 lw->v_pane = NULL; | |
1735 | |
1736 lw->toolbar = NULL; | |
1737 lw->thumb_button = NULL; | |
1738 lw->path_entry = NULL; | |
1739 lw->dir_view = NULL; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
1740 lw->vd = NULL; |
9 | 1741 |
1742 lw->file_view = NULL; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1743 lw->vf = NULL; |
9 | 1744 |
1745 lw->info_box = NULL; | |
1746 lw->info_progress_bar = NULL; | |
1747 lw->info_sort = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1748 lw->info_color = NULL; |
9 | 1749 lw->info_status = NULL; |
1750 lw->info_details = NULL; | |
1751 lw->info_zoom = NULL; | |
1752 | |
1753 if (lw->ui_manager) g_object_unref(lw->ui_manager); | |
1754 lw->ui_manager = NULL; | |
1755 lw->action_group = NULL; | |
1279
6248faa9e829
do not translate already translated texts from desktop files
nadvornik
parents:
1249
diff
changeset
|
1756 lw->action_group_external = NULL; |
9 | 1757 |
1758 gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box); | |
1759 lw->group_box = NULL; | |
1760 | |
1761 /* re-fill */ | |
1762 | |
1763 layout_grid_setup(lw); | |
1309 | 1764 layout_tools_hide(lw, lw->options.tools_hidden); |
9 | 1765 |
1766 layout_util_sync(lw); | |
1767 layout_status_update_all(lw); | |
1768 | |
1769 /* sync */ | |
1770 | |
783 | 1771 if (image_get_fd(lw->image)) |
9 | 1772 { |
783 | 1773 layout_set_fd(lw, image_get_fd(lw->image)); |
9 | 1774 } |
1775 else | |
1776 { | |
783 | 1777 layout_set_fd(lw, dir_fd); |
9 | 1778 } |
1309 | 1779 image_top_window_set_sync(lw->image, (lw->options.tools_float || lw->options.tools_hidden)); |
9 | 1780 |
1781 /* clean up */ | |
1782 | |
783 | 1783 file_data_unref(dir_fd); |
9 | 1784 } |
1785 | |
1786 void layout_styles_update(void) | |
1787 { | |
1788 GList *work; | |
1789 | |
1790 work = layout_window_list; | |
1791 while (work) | |
1792 { | |
1793 LayoutWindow *lw = work->data; | |
1794 work = work->next; | |
1795 | |
327 | 1796 layout_style_set(lw, options->layout.style, options->layout.order); |
9 | 1797 } |
1798 } | |
1799 | |
1800 void layout_colors_update(void) | |
1801 { | |
1802 GList *work; | |
1803 | |
1804 work = layout_window_list; | |
1805 while (work) | |
1806 { | |
1807 LayoutWindow *lw = work->data; | |
1808 work = work->next; | |
442 | 1809 |
208
fa0e05f985c3
set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents:
196
diff
changeset
|
1810 if (!lw->image) continue; |
339
de1c2cd06fce
Rename user_specified_window_background and window_background_color
zas_
parents:
338
diff
changeset
|
1811 image_background_set_color(lw->image, options->image.use_custom_border_color ? &options->image.border_color : NULL); |
9 | 1812 } |
1813 } | |
1814 | |
1815 void layout_tools_float_toggle(LayoutWindow *lw) | |
1816 { | |
1817 gint popped; | |
1818 | |
1819 if (!lw) return; | |
1820 | |
1309 | 1821 if (!lw->options.tools_hidden) |
9 | 1822 { |
1309 | 1823 popped = !lw->options.tools_float; |
9 | 1824 } |
1825 else | |
1826 { | |
1827 popped = TRUE; | |
1828 } | |
1829 | |
1309 | 1830 if (lw->options.tools_float == popped) |
9 | 1831 { |
1309 | 1832 if (popped && lw->options.tools_hidden) |
9 | 1833 { |
1834 layout_tools_float_set(lw, popped, FALSE); | |
1835 } | |
1836 } | |
1837 else | |
1838 { | |
1309 | 1839 if (lw->options.tools_float) |
9 | 1840 { |
1841 layout_tools_float_set(lw, FALSE, FALSE); | |
1842 } | |
1843 else | |
1844 { | |
1845 layout_tools_float_set(lw, TRUE, FALSE); | |
1846 } | |
1847 } | |
1848 } | |
1849 | |
1850 void layout_tools_hide_toggle(LayoutWindow *lw) | |
1851 { | |
1852 if (!lw) return; | |
1853 | |
1309 | 1854 layout_tools_float_set(lw, lw->options.tools_float, !lw->options.tools_hidden); |
9 | 1855 } |
1856 | |
1857 void layout_tools_float_set(LayoutWindow *lw, gint popped, gint hidden) | |
1858 { | |
1859 if (!layout_valid(&lw)) return; | |
1860 | |
1309 | 1861 if (lw->options.tools_float == popped && lw->options.tools_hidden == hidden) return; |
1862 | |
1863 if (lw->options.tools_float == popped && lw->options.tools_float && lw->tools) | |
9 | 1864 { |
1865 layout_tools_hide(lw, hidden); | |
1866 return; | |
1867 } | |
1868 | |
1309 | 1869 lw->options.tools_float = popped; |
1870 lw->options.tools_hidden = hidden; | |
9 | 1871 |
1872 layout_style_set(lw, -1, NULL); | |
1873 } | |
1874 | |
1875 gint layout_tools_float_get(LayoutWindow *lw, gint *popped, gint *hidden) | |
1876 { | |
1877 if (!layout_valid(&lw)) return FALSE; | |
1878 | |
1309 | 1879 *popped = lw->options.tools_float; |
1880 *hidden = lw->options.tools_hidden; | |
9 | 1881 |
1882 return TRUE; | |
1883 } | |
1884 | |
1885 void layout_toolbar_toggle(LayoutWindow *lw) | |
1886 { | |
1887 if (!layout_valid(&lw)) return; | |
1888 if (!lw->toolbar) return; | |
1889 | |
1309 | 1890 lw->options.toolbar_hidden = !lw->options.toolbar_hidden; |
1891 | |
1892 if (lw->options.toolbar_hidden) | |
9 | 1893 { |
1894 if (GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_hide(lw->toolbar); | |
1895 } | |
1896 else | |
1897 { | |
1898 if (!GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_show(lw->toolbar); | |
1899 } | |
1900 } | |
1901 | |
1902 gint layout_toolbar_hidden(LayoutWindow *lw) | |
1903 { | |
1904 if (!layout_valid(&lw)) return TRUE; | |
1905 | |
1309 | 1906 return lw->options.toolbar_hidden; |
9 | 1907 } |
1908 | |
1909 /* | |
1910 *----------------------------------------------------------------------------- | |
1911 * base | |
1912 *----------------------------------------------------------------------------- | |
1913 */ | |
1914 | |
1309 | 1915 void layout_sync_options_with_current_state(LayoutWindow *lw) |
1916 { | |
1917 if (!layout_valid(&lw)) return; | |
1918 | |
1919 lw->options.main_window.maximized = window_maximized(lw->window); | |
1920 if (!lw->options.main_window.maximized) | |
1921 { | |
1922 layout_geometry_get(lw, &lw->options.main_window.x, &lw->options.main_window.y, | |
1923 &lw->options.main_window.w, &lw->options.main_window.h); | |
1924 } | |
1925 | |
1926 layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos); | |
1927 | |
1928 // layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending); | |
1929 | |
1930 layout_geometry_get_tools(lw, &lw->options.float_window.x, &lw->options.float_window.y, | |
1931 &lw->options.float_window.w, &lw->options.float_window.h, &lw->options.float_window.vdivider_pos); | |
1932 | |
1933 // if (options->startup.restore_path && options->startup.use_last_path) | |
1934 // { | |
1935 // g_free(options->startup.path); | |
1936 // options->startup.path = g_strdup(layout_get_path(NULL)); | |
1937 // } | |
1938 } | |
1939 | |
1940 | |
9 | 1941 void layout_close(LayoutWindow *lw) |
1942 { | |
1943 if (layout_window_list && layout_window_list->next) | |
1944 { | |
1945 layout_free(lw); | |
1946 } | |
1947 else | |
1948 { | |
278 | 1949 exit_program(); |
9 | 1950 } |
1951 } | |
1952 | |
1953 void layout_free(LayoutWindow *lw) | |
1954 { | |
1955 if (!lw) return; | |
1956 | |
1957 layout_window_list = g_list_remove(layout_window_list, lw); | |
1958 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1291
diff
changeset
|
1959 if (lw->exif_window) g_signal_handlers_disconnect_matched(G_OBJECT(lw->exif_window), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, lw); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1291
diff
changeset
|
1960 |
9 | 1961 layout_bars_close(lw); |
1962 | |
1963 gtk_widget_destroy(lw->window); | |
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
820
diff
changeset
|
1964 |
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
820
diff
changeset
|
1965 if (lw->split_image_sizegroup) g_object_unref(lw->split_image_sizegroup); |
442 | 1966 |
796 | 1967 file_data_unregister_notify_func(layout_image_notify_cb, lw); |
1968 | |
995 | 1969 if (lw->dir_fd) |
791 | 1970 { |
1971 file_data_unregister_real_time_monitor(lw->dir_fd); | |
1972 file_data_unref(lw->dir_fd); | |
1973 } | |
9 | 1974 |
1309 | 1975 free_layout_options_content(&lw->options); |
9 | 1976 g_free(lw); |
1977 } | |
1978 | |
1979 static gint layout_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
1980 { | |
1981 LayoutWindow *lw = data; | |
1982 | |
1983 layout_close(lw); | |
1984 return TRUE; | |
1985 } | |
1986 | |
1309 | 1987 LayoutWindow *layout_new(FileData *dir_fd, LayoutOptions *lop) |
9 | 1988 { |
1309 | 1989 return layout_new_with_geometry(dir_fd, lop, NULL); |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1990 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1991 |
1309 | 1992 LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop, |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1993 const gchar *geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1994 { |
9 | 1995 LayoutWindow *lw; |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1996 GdkGeometry hint; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1997 GdkWindowHints hint_mask; |
9 | 1998 |
1999 lw = g_new0(LayoutWindow, 1); | |
2000 | |
1309 | 2001 if (lop) |
2002 copy_layout_options(&lw->options, lop); | |
2003 else | |
2004 copy_layout_options(&lw->options, &options->layout); | |
2005 | |
9 | 2006 lw->sort_method = SORT_NAME; |
2007 lw->sort_ascend = TRUE; | |
2008 | |
1309 | 2009 // lw->options.tools_float = popped; |
2010 // lw->options.tools_hidden = hidden; | |
9 | 2011 |
2012 lw->utility_box = NULL; | |
2013 lw->bar_sort = NULL; | |
1309 | 2014 // lw->bar_sort_enabled = options->panels.sort.enabled; |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
482
diff
changeset
|
2015 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
1287
diff
changeset
|
2016 lw->bar = NULL; |
1309 | 2017 // lw->bar_enabled = options->panels.info.enabled; |
9 | 2018 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1291
diff
changeset
|
2019 lw->exif_window = NULL; |
9 | 2020 /* default layout */ |
2021 | |
1309 | 2022 layout_config_parse(lw->options.style, lw->options.order, |
9 | 2023 &lw->dir_location, &lw->file_location, &lw->image_location); |
1309 | 2024 if (lw->options.dir_view_type >= VIEW_DIR_TYPES_COUNT) lw->options.dir_view_type = 0; |
2025 if (lw->options.file_view_type >= VIEW_FILE_TYPES_COUNT) lw->options.file_view_type = 0; | |
9 | 2026 |
2027 /* divider positions */ | |
2028 | |
1309 | 2029 if (!lw->options.save_window_positions) |
9 | 2030 { |
1309 | 2031 lw->options.main_window.hdivider_pos = MAIN_WINDOW_DIV_HPOS; |
2032 lw->options.main_window.vdivider_pos = MAIN_WINDOW_DIV_VPOS; | |
2033 lw->options.float_window.vdivider_pos = MAIN_WINDOW_DIV_VPOS; | |
9 | 2034 } |
2035 | |
2036 /* window */ | |
2037 | |
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:
1167
diff
changeset
|
2038 lw->window = window_new(GTK_WINDOW_TOPLEVEL, GQ_APPNAME_LC, NULL, NULL, NULL); |
9 | 2039 gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE); |
2040 gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0); | |
2041 | |
1309 | 2042 if (lw->options.save_window_positions) |
9 | 2043 { |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2044 hint_mask = GDK_HINT_USER_POS; |
9 | 2045 } |
2046 else | |
2047 { | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2048 hint_mask = 0; |
9 | 2049 } |
2050 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2051 hint.min_width = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2052 hint.min_height = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2053 hint.base_width = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2054 hint.base_height = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2055 gtk_window_set_geometry_hints(GTK_WINDOW(lw->window), NULL, &hint, |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2056 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hint_mask); |
9 | 2057 |
1309 | 2058 if (lw->options.save_window_positions) |
9 | 2059 { |
1309 | 2060 gtk_window_set_default_size(GTK_WINDOW(lw->window), lw->options.main_window.w, lw->options.main_window.h); |
2061 // if (!layout_window_list) | |
2062 // { | |
2063 gtk_window_move(GTK_WINDOW(lw->window), lw->options.main_window.x, lw->options.main_window.y); | |
2064 if (lw->options.main_window.maximized) gtk_window_maximize(GTK_WINDOW(lw->window)); | |
2065 // } | |
9 | 2066 } |
2067 else | |
2068 { | |
2069 gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT); | |
2070 } | |
2071 | |
2072 g_signal_connect(G_OBJECT(lw->window), "delete_event", | |
2073 G_CALLBACK(layout_delete_cb), lw); | |
2074 | |
2075 layout_keyboard_init(lw, lw->window); | |
2076 | |
528 | 2077 #ifdef HAVE_LIRC |
2078 layout_image_lirc_init(lw); | |
2079 #endif | |
2080 | |
9 | 2081 lw->main_box = gtk_vbox_new(FALSE, 0); |
2082 gtk_container_add(GTK_CONTAINER(lw->window), lw->main_box); | |
2083 gtk_widget_show(lw->main_box); | |
2084 | |
2085 layout_grid_setup(lw); | |
1309 | 2086 image_top_window_set_sync(lw->image, (lw->options.tools_float || lw->options.tools_hidden)); |
9 | 2087 |
2088 layout_util_sync(lw); | |
2089 layout_status_update_all(lw); | |
2090 | |
783 | 2091 if (dir_fd) |
9 | 2092 { |
783 | 2093 layout_set_fd(lw, dir_fd); |
9 | 2094 } |
2095 else | |
2096 { | |
2097 GdkPixbuf *pixbuf; | |
2098 | |
2099 pixbuf = pixbuf_inline(PIXBUF_INLINE_LOGO); | |
1287
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2100 |
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2101 /* FIXME: the zoom value set here is the value, which is then copied again and again |
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2102 in "Leave Zoom at previous setting" mode. This is not ideal. */ |
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2103 image_change_pixbuf(lw->image, pixbuf, 0.0, FALSE); |
1043 | 2104 g_object_unref(pixbuf); |
9 | 2105 } |
2106 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2107 if (geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2108 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2109 if (!gtk_window_parse_geometry(GTK_WINDOW(lw->window), geometry)) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2110 { |
694 | 2111 log_printf("%s", _("Invalid geometry\n")); |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2112 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2113 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2114 |
9 | 2115 gtk_widget_show(lw->window); |
1309 | 2116 layout_tools_hide(lw, lw->options.tools_hidden); |
9 | 2117 |
1313 | 2118 image_osd_set(lw->image, options->image_overlay.common.state | (options->image_overlay.common.show_at_startup ? OSD_SHOW_INFO : OSD_SHOW_NOTHING)); |
2119 | |
9 | 2120 layout_window_list = g_list_append(layout_window_list, lw); |
2121 | |
796 | 2122 file_data_register_notify_func(layout_image_notify_cb, lw, NOTIFY_PRIORITY_LOW); |
2123 | |
9 | 2124 return lw; |
2125 } | |
2126 | |
1309 | 2127 void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent) |
2128 { | |
2129 WRITE_INT(*layout, style); | |
2130 WRITE_CHAR(*layout, order); | |
2131 WRITE_UINT(*layout, dir_view_type); | |
2132 WRITE_UINT(*layout, file_view_type); | |
2133 WRITE_BOOL(*layout, show_marks); | |
2134 WRITE_BOOL(*layout, show_thumbnails); | |
2135 WRITE_BOOL(*layout, show_directory_date); | |
2136 WRITE_CHAR(*layout, home_path); | |
2137 WRITE_SEPARATOR(); | |
2138 | |
2139 WRITE_BOOL(*layout, save_window_positions); | |
2140 WRITE_SEPARATOR(); | |
2141 | |
2142 WRITE_INT(*layout, main_window.x); | |
2143 WRITE_INT(*layout, main_window.y); | |
2144 WRITE_INT(*layout, main_window.w); | |
2145 WRITE_INT(*layout, main_window.h); | |
2146 WRITE_BOOL(*layout, main_window.maximized); | |
2147 WRITE_INT(*layout, main_window.hdivider_pos); | |
2148 WRITE_INT(*layout, main_window.vdivider_pos); | |
2149 WRITE_SEPARATOR(); | |
2150 | |
2151 WRITE_INT(*layout, float_window.x); | |
2152 WRITE_INT(*layout, float_window.y); | |
2153 WRITE_INT(*layout, float_window.w); | |
2154 WRITE_INT(*layout, float_window.h); | |
2155 WRITE_INT(*layout, float_window.vdivider_pos); | |
2156 WRITE_SEPARATOR(); | |
2157 | |
2158 WRITE_INT(*layout, properties_window.w); | |
2159 WRITE_INT(*layout, properties_window.h); | |
2160 WRITE_SEPARATOR(); | |
2161 | |
2162 WRITE_BOOL(*layout, tools_float); | |
2163 WRITE_BOOL(*layout, tools_hidden); | |
2164 WRITE_BOOL(*layout, tools_restore_state); | |
2165 WRITE_SEPARATOR(); | |
2166 | |
2167 WRITE_BOOL(*layout, toolbar_hidden); | |
2168 } | |
2169 | |
2170 | |
2171 void layout_write_config(LayoutWindow *lw, GString *outstr, gint indent) | |
2172 { | |
2173 layout_sync_options_with_current_state(lw); | |
1314 | 2174 WRITE_STRING("<layout\n"); |
1309 | 2175 layout_write_attributes(&lw->options, outstr, indent + 1); |
1314 | 2176 WRITE_STRING(">\n"); |
1309 | 2177 |
1320 | 2178 bar_sort_write_config(lw->bar_sort, outstr, indent + 1); |
1309 | 2179 bar_write_config(lw->bar, outstr, indent + 1); |
2180 | |
1314 | 2181 WRITE_STRING("</layout>\n"); |
1309 | 2182 } |
2183 | |
2184 void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names, const gchar **attribute_values) | |
2185 { | |
2186 | |
2187 while (*attribute_names) | |
2188 { | |
2189 const gchar *option = *attribute_names++; | |
2190 const gchar *value = *attribute_values++; | |
2191 | |
2192 /* layout options */ | |
2193 | |
1315 | 2194 if (READ_INT(*layout, style)) continue; |
2195 if (READ_CHAR(*layout, order)) continue; | |
1309 | 2196 |
1315 | 2197 if (READ_UINT(*layout, dir_view_type)) continue; |
2198 if (READ_UINT(*layout, file_view_type)) continue; | |
2199 if (READ_BOOL(*layout, show_marks)) continue; | |
2200 if (READ_BOOL(*layout, show_thumbnails)) continue; | |
2201 if (READ_BOOL(*layout, show_directory_date)) continue; | |
2202 if (READ_CHAR(*layout, home_path)) continue; | |
1309 | 2203 |
2204 /* window positions */ | |
2205 | |
1315 | 2206 if (READ_BOOL(*layout, save_window_positions)) continue; |
2207 | |
2208 if (READ_INT(*layout, main_window.x)) continue; | |
2209 if (READ_INT(*layout, main_window.y)) continue; | |
2210 if (READ_INT(*layout, main_window.w)) continue; | |
2211 if (READ_INT(*layout, main_window.h)) continue; | |
2212 if (READ_BOOL(*layout, main_window.maximized)) continue; | |
2213 if (READ_INT(*layout, main_window.hdivider_pos)) continue; | |
2214 if (READ_INT(*layout, main_window.vdivider_pos)) continue; | |
2215 | |
2216 if (READ_INT(*layout, float_window.x)) continue; | |
2217 if (READ_INT(*layout, float_window.y)) continue; | |
2218 if (READ_INT(*layout, float_window.w)) continue; | |
2219 if (READ_INT(*layout, float_window.h)) continue; | |
2220 if (READ_INT(*layout, float_window.vdivider_pos)) continue; | |
1309 | 2221 |
1315 | 2222 if (READ_INT(*layout, properties_window.w)) continue; |
2223 if (READ_INT(*layout, properties_window.h)) continue; | |
2224 | |
2225 if (READ_BOOL(*layout, tools_float)) continue; | |
2226 if (READ_BOOL(*layout, tools_hidden)) continue; | |
2227 if (READ_BOOL(*layout, tools_restore_state)) continue; | |
2228 if (READ_BOOL(*layout, toolbar_hidden)) continue; | |
1309 | 2229 |
2230 DEBUG_1("unknown attribute %s = %s", option, value); | |
2231 } | |
2232 | |
2233 } | |
2234 | |
1313 | 2235 static void layout_config_commandline(LayoutOptions *lop, gchar **path) |
2236 { | |
2237 if (command_line->startup_blank) | |
2238 { | |
2239 *path = NULL; | |
2240 } | |
2241 else if (command_line->file) | |
2242 { | |
2243 *path = g_strdup(command_line->file); | |
2244 } | |
2245 else if (command_line->path) | |
2246 { | |
2247 *path = g_strdup(command_line->path); | |
2248 } | |
2249 else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path)) | |
2250 { | |
2251 *path = g_strdup(options->startup.path); | |
2252 } | |
2253 else | |
2254 { | |
2255 *path = get_current_dir(); | |
2256 } | |
2257 | |
2258 if (command_line->tools_show) | |
2259 { | |
2260 lop->tools_float = FALSE; | |
2261 lop->tools_hidden = FALSE; | |
2262 } | |
2263 else if (command_line->tools_hide) | |
2264 { | |
2265 lop->tools_hidden = TRUE; | |
2266 } | |
2267 } | |
2268 | |
2269 LayoutWindow *layout_new_from_config(const gchar **attribute_names, const gchar **attribute_values, gboolean use_commandline) | |
1309 | 2270 { |
2271 LayoutOptions lop; | |
2272 LayoutWindow *lw; | |
1313 | 2273 gchar *path = NULL; |
2274 | |
1309 | 2275 memset(&lop, 0, sizeof(LayoutOptions)); |
2276 copy_layout_options(&lop, &options->layout); | |
2277 | |
1313 | 2278 if (attribute_names) layout_load_attributes(&lop, attribute_names, attribute_values); |
2279 | |
2280 if (use_commandline) | |
2281 { | |
2282 layout_config_commandline(&lop, &path); | |
2283 } | |
2284 else if (options->startup.restore_path && options->startup.path && isdir(options->startup.path)) | |
2285 { | |
2286 path = g_strdup(options->startup.path); | |
2287 } | |
2288 else | |
2289 { | |
2290 path = get_current_dir(); | |
2291 } | |
2292 | |
2293 lw = layout_new_with_geometry(NULL, &lop, use_commandline ? command_line->geometry : NULL); | |
1309 | 2294 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); |
1313 | 2295 layout_set_path(lw, path); |
2296 | |
2297 if (use_commandline && command_line->startup_full_screen) layout_image_full_screen_start(lw); | |
2298 if (use_commandline && command_line->startup_in_slideshow) layout_image_slideshow_start(lw); | |
2299 | |
2300 | |
2301 g_free(path); | |
1309 | 2302 free_layout_options_content(&lop); |
2303 return lw; | |
2304 } | |
2305 | |
2306 | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1045
diff
changeset
|
2307 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |