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