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