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