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