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