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