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