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