Mercurial > geeqie
annotate src/layout.c @ 159:436376b60867
moved some actions to menu and accels
author | nadvornik |
---|---|
date | Mon, 17 Dec 2007 21:42:24 +0000 |
parents | 71e1ebee420e |
children | 1a42a2451575 |
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); | |
751 | |
752 return lw->vfi->widget; | |
753 } | |
754 | |
755 lw->vfl = vflist_new(NULL, lw->thumbs_enabled); | |
756 vflist_set_layout(lw->vfl, lw); | |
757 | |
758 vflist_set_status_func(lw->vfl, layout_list_status_cb, lw); | |
759 vflist_set_thumb_status_func(lw->vfl, layout_list_thumb_cb, lw); | |
760 | |
761 return lw->vfl->widget; | |
762 } | |
763 | |
764 static void layout_list_sync_thumb(LayoutWindow *lw) | |
765 { | |
766 if (lw->vfl) vflist_thumb_set(lw->vfl, lw->thumbs_enabled); | |
767 } | |
768 | |
132 | 769 static void layout_list_sync_marks(LayoutWindow *lw) |
770 { | |
771 if (lw->vfl) vflist_marks_set(lw->vfl, lw->marks_enabled); | |
772 } | |
773 | |
9 | 774 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle) |
775 { | |
776 if (!lw) return; | |
777 #if 0 | |
778 if (lw->vfl) vflist_scroll_to_subpart(lw->vfl, needle); | |
779 if (lw->vfi) vficon_scroll_to_subpart(lw->vfi, needle); | |
780 #endif | |
781 } | |
782 | |
783 GList *layout_list(LayoutWindow *lw) | |
784 { | |
785 if (!layout_valid(&lw)) return NULL; | |
786 | |
787 if (lw->vfl) return vflist_get_list(lw->vfl); | |
788 if (lw->vfi) return vficon_get_list(lw->vfi); | |
789 | |
790 return NULL; | |
791 } | |
792 | |
793 gint layout_list_count(LayoutWindow *lw, gint64 *bytes) | |
794 { | |
795 if (!layout_valid(&lw)) return 0; | |
796 | |
797 if (lw->vfl) return vflist_count(lw->vfl, bytes); | |
798 if (lw->vfi) return vficon_count(lw->vfi, bytes); | |
799 | |
800 return 0; | |
801 } | |
802 | |
803 const gchar *layout_list_get_path(LayoutWindow *lw, gint index) | |
804 { | |
805 if (!layout_valid(&lw)) return NULL; | |
806 | |
807 if (lw->vfl) return vflist_index_get_path(lw->vfl, index); | |
808 if (lw->vfi) return vficon_index_get_path(lw->vfi, index); | |
809 | |
810 return NULL; | |
811 } | |
812 | |
138 | 813 FileData *layout_list_get_fd(LayoutWindow *lw, gint index) |
814 { | |
815 if (!layout_valid(&lw)) return NULL; | |
816 | |
817 if (lw->vfl) return vflist_index_get_data(lw->vfl, index); | |
818 if (lw->vfi) return vficon_index_get_data(lw->vfi, index); | |
819 | |
820 return NULL; | |
821 } | |
822 | |
9 | 823 gint layout_list_get_index(LayoutWindow *lw, const gchar *path) |
824 { | |
825 if (!layout_valid(&lw)) return -1; | |
826 | |
827 if (lw->vfl) return vflist_index_by_path(lw->vfl, path); | |
828 if (lw->vfi) return vficon_index_by_path(lw->vfi, path); | |
829 | |
830 return -1; | |
831 } | |
832 | |
138 | 833 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd) |
9 | 834 { |
835 if (!layout_valid(&lw)) return; | |
836 | |
138 | 837 if (lw->vfl) vflist_select_by_fd(lw->vfl, fd); |
838 if (lw->vfi) vficon_select_by_fd(lw->vfi, fd); | |
9 | 839 } |
840 | |
841 static void layout_list_sync_sort(LayoutWindow *lw) | |
842 { | |
843 if (!layout_valid(&lw)) return; | |
844 | |
845 if (lw->vfl) vflist_sort_set(lw->vfl, lw->sort_method, lw->sort_ascend); | |
846 if (lw->vfi) vficon_sort_set(lw->vfi, lw->sort_method, lw->sort_ascend); | |
847 } | |
848 | |
849 GList *layout_selection_list(LayoutWindow *lw) | |
850 { | |
851 if (!layout_valid(&lw)) return NULL; | |
852 | |
853 if (layout_image_get_collection(lw, NULL)) | |
854 { | |
138 | 855 FileData *fd; |
9 | 856 |
138 | 857 fd = layout_image_get_fd(lw); |
858 if (fd) return g_list_append(NULL, file_data_ref(fd)); | |
9 | 859 return NULL; |
860 } | |
861 | |
862 if (lw->vfl) return vflist_selection_get_list(lw->vfl); | |
863 if (lw->vfi) return vficon_selection_get_list(lw->vfi); | |
864 | |
865 return NULL; | |
866 } | |
867 | |
868 GList *layout_selection_list_by_index(LayoutWindow *lw) | |
869 { | |
870 if (!layout_valid(&lw)) return NULL; | |
871 | |
872 if (lw->vfl) return vflist_selection_get_list_by_index(lw->vfl); | |
873 if (lw->vfi) return vficon_selection_get_list_by_index(lw->vfi); | |
874 | |
875 return NULL; | |
876 } | |
877 | |
878 gint layout_selection_count(LayoutWindow *lw, gint64 *bytes) | |
879 { | |
880 if (!layout_valid(&lw)) return 0; | |
881 | |
882 if (lw->vfl) return vflist_selection_count(lw->vfl, bytes); | |
883 if (lw->vfi) return vficon_selection_count(lw->vfi, bytes); | |
884 | |
885 return 0; | |
886 } | |
887 | |
888 void layout_select_all(LayoutWindow *lw) | |
889 { | |
890 if (!layout_valid(&lw)) return; | |
891 | |
892 if (lw->vfl) vflist_select_all(lw->vfl); | |
893 if (lw->vfi) vficon_select_all(lw->vfi); | |
894 } | |
895 | |
896 void layout_select_none(LayoutWindow *lw) | |
897 { | |
898 if (!layout_valid(&lw)) return; | |
899 | |
900 if (lw->vfl) vflist_select_none(lw->vfl); | |
901 if (lw->vfi) vficon_select_none(lw->vfi); | |
902 } | |
903 | |
904 /* | |
905 *----------------------------------------------------------------------------- | |
906 * access | |
907 *----------------------------------------------------------------------------- | |
908 */ | |
909 | |
910 const gchar *layout_get_path(LayoutWindow *lw) | |
911 { | |
912 if (!layout_valid(&lw)) return NULL; | |
913 return lw->path; | |
914 } | |
915 | |
916 static void layout_sync_path(LayoutWindow *lw) | |
917 { | |
918 if (!lw->path) return; | |
919 | |
920 lw->last_time = filetime(lw->path); | |
921 | |
922 gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path); | |
923 if (lw->vdl) vdlist_set_path(lw->vdl, lw->path); | |
924 if (lw->vdt) vdtree_set_path(lw->vdt, lw->path); | |
925 | |
926 if (lw->vfl) vflist_set_path(lw->vfl, lw->path); | |
927 if (lw->vfi) vficon_set_path(lw->vfi, lw->path); | |
928 } | |
929 | |
930 gint layout_set_path(LayoutWindow *lw, const gchar *path) | |
931 { | |
932 gint have_file = FALSE; | |
933 | |
934 if (!layout_valid(&lw)) return FALSE; | |
935 | |
936 if (!path || !isname(path)) return FALSE; | |
937 if (lw->path && path && strcmp(path, lw->path) == 0) | |
938 { | |
939 return TRUE; | |
940 } | |
941 | |
942 if (isdir(path)) | |
943 { | |
944 g_free(lw->path); | |
945 lw->path = g_strdup(path); | |
946 } | |
947 else | |
948 { | |
949 gchar *base; | |
950 | |
951 base = remove_level_from_path(path); | |
952 if (lw->path && strcmp(lw->path, base) == 0) | |
953 { | |
954 g_free(base); | |
955 } | |
956 else if (isdir(base)) | |
957 { | |
958 g_free(lw->path); | |
959 lw->path = base; | |
960 } | |
961 else | |
962 { | |
963 g_free(base); | |
964 return FALSE; | |
965 } | |
966 if (isfile(path)) have_file = TRUE; | |
967 } | |
968 | |
969 if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->path); | |
970 layout_sync_path(lw); | |
971 | |
972 if (have_file) | |
973 { | |
974 gint row; | |
975 | |
976 row = layout_list_get_index(lw, path); | |
977 if (row >= 0) | |
978 { | |
979 layout_image_set_index(lw, row); | |
980 } | |
981 else | |
982 { | |
138 | 983 layout_image_set_fd(lw, file_data_new_simple(path)); |
9 | 984 } |
985 } | |
986 else if (!lazy_image_sync) | |
987 { | |
988 layout_image_set_index(lw, 0); | |
989 } | |
990 | |
991 return TRUE; | |
992 } | |
993 | |
994 static void layout_refresh_lists(LayoutWindow *lw) | |
995 { | |
996 if (lw->path) lw->last_time = filetime(lw->path); | |
997 | |
998 if (lw->vdl) vdlist_refresh(lw->vdl); | |
999 if (lw->vdt) vdtree_refresh(lw->vdt); | |
1000 | |
1001 if (lw->vfl) vflist_refresh(lw->vfl); | |
1002 if (lw->vfi) vficon_refresh(lw->vfi); | |
1003 } | |
1004 | |
1005 static void layout_refresh_by_time(LayoutWindow *lw) | |
1006 { | |
1007 layout_refresh_lists(lw); | |
1008 | |
1009 if (lw->image && filetime(layout_image_get_path(lw)) >= lw->last_time) | |
1010 { | |
1011 layout_image_refresh(lw); | |
1012 } | |
1013 } | |
1014 | |
1015 void layout_refresh(LayoutWindow *lw) | |
1016 { | |
1017 if (!layout_valid(&lw)) return; | |
1018 | |
1019 if (debug) printf("layout refresh\n"); | |
1020 | |
1021 layout_refresh_lists(lw); | |
1022 | |
1023 if (lw->image) layout_image_refresh(lw); | |
1024 } | |
1025 | |
1026 static gint layout_check_for_update_cb(gpointer data) | |
1027 { | |
1028 LayoutWindow *lw = data; | |
1029 | |
1030 if (!update_on_time_change) return TRUE; | |
1031 | |
1032 if (lw->path) | |
1033 { | |
1034 time_t new_time; | |
1035 | |
1036 new_time = filetime(lw->path); | |
1037 | |
1038 if (new_time > 0 && new_time > lw->last_time) | |
1039 { | |
1040 if (debug) printf("layout path time changed, refreshing...\n"); | |
1041 layout_refresh_by_time(lw); | |
1042 } | |
1043 } | |
1044 | |
1045 return TRUE; | |
1046 } | |
1047 | |
1048 void layout_thumb_set(LayoutWindow *lw, gint enable) | |
1049 { | |
1050 if (!layout_valid(&lw)) return; | |
1051 | |
1052 if (lw->thumbs_enabled == enable) return; | |
1053 | |
1054 lw->thumbs_enabled = enable; | |
1055 | |
1056 layout_util_sync_thumb(lw); | |
1057 layout_list_sync_thumb(lw); | |
1058 } | |
1059 | |
132 | 1060 void layout_marks_set(LayoutWindow *lw, gint enable) |
1061 { | |
1062 if (!layout_valid(&lw)) return; | |
1063 | |
1064 if (lw->marks_enabled == enable) return; | |
1065 | |
1066 lw->marks_enabled = enable; | |
1067 | |
1068 // layout_util_sync_marks(lw); | |
1069 layout_list_sync_marks(lw); | |
1070 | |
1071 } | |
1072 | |
9 | 1073 gint layout_thumb_get(LayoutWindow *lw) |
1074 { | |
1075 if (!layout_valid(&lw)) return FALSE; | |
1076 | |
1077 return lw->thumbs_enabled; | |
1078 } | |
1079 | |
1080 void layout_sort_set(LayoutWindow *lw, SortType type, gint ascend) | |
1081 { | |
1082 if (!layout_valid(&lw)) return; | |
1083 if (lw->sort_method == type && lw->sort_ascend == ascend) return; | |
1084 | |
1085 lw->sort_method = type; | |
1086 lw->sort_ascend = ascend; | |
1087 | |
1088 if (lw->info_sort) gtk_label_set_text(GTK_LABEL(GTK_BIN(lw->info_sort)->child), | |
1089 sort_type_get_text(type)); | |
1090 layout_list_sync_sort(lw); | |
1091 } | |
1092 | |
1093 gint layout_sort_get(LayoutWindow *lw, SortType *type, gint *ascend) | |
1094 { | |
1095 if (!layout_valid(&lw)) return FALSE; | |
1096 | |
1097 if (type) *type = lw->sort_method; | |
1098 if (ascend) *ascend = lw->sort_ascend; | |
1099 | |
1100 return TRUE; | |
1101 } | |
1102 | |
1103 gint layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h) | |
1104 { | |
1105 if (!layout_valid(&lw)) return FALSE; | |
1106 | |
1107 gdk_window_get_root_origin(lw->window->window, x, y); | |
1108 gdk_drawable_get_size(lw->window->window, w, h); | |
1109 | |
1110 return TRUE; | |
1111 } | |
1112 | |
1113 gint layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v) | |
1114 { | |
1115 if (!layout_valid(&lw)) return FALSE; | |
1116 | |
1117 if (lw->h_pane && GTK_PANED(lw->h_pane)->child1->allocation.x >= 0) | |
1118 { | |
1119 *h = GTK_PANED(lw->h_pane)->child1->allocation.width; | |
1120 } | |
1121 else if (h != &lw->div_h) | |
1122 { | |
1123 *h = lw->div_h; | |
1124 } | |
1125 | |
1126 if (lw->v_pane && GTK_PANED(lw->v_pane)->child1->allocation.x >= 0) | |
1127 { | |
1128 *v = GTK_PANED(lw->v_pane)->child1->allocation.height; | |
1129 } | |
1130 else if (v != &lw->div_v) | |
1131 { | |
1132 *v = lw->div_v; | |
1133 } | |
1134 | |
1135 return TRUE; | |
1136 } | |
1137 | |
1138 void layout_views_set(LayoutWindow *lw, gint tree, gint icons) | |
1139 { | |
1140 if (!layout_valid(&lw)) return; | |
1141 | |
1142 if (lw->tree_view == tree && lw->icon_view == icons) return; | |
1143 | |
1144 lw->tree_view = tree; | |
1145 lw->icon_view = icons; | |
1146 | |
1147 layout_style_set(lw, -1, NULL); | |
1148 } | |
1149 | |
1150 gint layout_views_get(LayoutWindow *lw, gint *tree, gint *icons) | |
1151 { | |
1152 if (!layout_valid(&lw)) return FALSE; | |
1153 | |
1154 *tree = lw->tree_view; | |
1155 *icons = lw->icon_view; | |
1156 | |
1157 return TRUE; | |
1158 } | |
1159 | |
1160 /* | |
1161 *----------------------------------------------------------------------------- | |
1162 * location utils | |
1163 *----------------------------------------------------------------------------- | |
1164 */ | |
1165 | |
1166 static gint layout_location_single(LayoutLocation l) | |
1167 { | |
1168 return (l == LAYOUT_LEFT || | |
1169 l == LAYOUT_RIGHT || | |
1170 l == LAYOUT_TOP || | |
1171 l == LAYOUT_BOTTOM); | |
1172 } | |
1173 | |
1174 static gint layout_location_vertical(LayoutLocation l) | |
1175 { | |
1176 return (l & LAYOUT_TOP || | |
1177 l & LAYOUT_BOTTOM); | |
1178 } | |
1179 | |
1180 static gint layout_location_first(LayoutLocation l) | |
1181 { | |
1182 return (l & LAYOUT_TOP || | |
1183 l & LAYOUT_LEFT); | |
1184 } | |
1185 | |
1186 static LayoutLocation layout_grid_compass(LayoutWindow *lw) | |
1187 { | |
1188 if (layout_location_single(lw->dir_location)) return lw->dir_location; | |
1189 if (layout_location_single(lw->file_location)) return lw->file_location; | |
1190 return lw->image_location; | |
1191 } | |
1192 | |
1193 static void layout_location_compute(LayoutLocation l1, LayoutLocation l2, | |
1194 GtkWidget *s1, GtkWidget *s2, | |
1195 GtkWidget **d1, GtkWidget **d2) | |
1196 { | |
1197 LayoutLocation l; | |
1198 | |
1199 l = l1 & l2; /* get common compass direction */ | |
1200 l = l1 - l; /* remove it */ | |
1201 | |
1202 if (layout_location_first(l)) | |
1203 { | |
1204 *d1 = s1; | |
1205 *d2 = s2; | |
1206 } | |
1207 else | |
1208 { | |
1209 *d1 = s2; | |
1210 *d2 = s1; | |
1211 } | |
1212 } | |
1213 | |
1214 /* | |
1215 *----------------------------------------------------------------------------- | |
1216 * tools window (for floating/hidden) | |
1217 *----------------------------------------------------------------------------- | |
1218 */ | |
1219 | |
1220 gint layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) | |
1221 { | |
1222 if (!layout_valid(&lw)) return FALSE; | |
1223 | |
1224 if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools)) | |
1225 { | |
1226 /* use the stored values (sort of breaks success return value) */ | |
1227 | |
1228 *divider_pos = lw->div_float; | |
1229 | |
1230 return FALSE; | |
1231 } | |
1232 | |
1233 gdk_window_get_root_origin(lw->tools->window, x, y); | |
1234 gdk_drawable_get_size(lw->tools->window, w, h); | |
1235 | |
1236 if (GTK_IS_VPANED(lw->tools_pane)) | |
1237 { | |
1238 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height; | |
1239 } | |
1240 else | |
1241 { | |
1242 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width; | |
1243 } | |
1244 | |
1245 return TRUE; | |
1246 } | |
1247 | |
1248 static void layout_tools_geometry_sync(LayoutWindow *lw) | |
1249 { | |
1250 layout_geometry_get_tools(lw, &float_window_x, &float_window_x, | |
1251 &float_window_w, &float_window_h, &lw->div_float); | |
1252 } | |
1253 | |
1254 static void layout_tools_hide(LayoutWindow *lw, gint hide) | |
1255 { | |
1256 if (!lw->tools) return; | |
1257 | |
1258 if (hide) | |
1259 { | |
1260 if (GTK_WIDGET_VISIBLE(lw->tools)) | |
1261 { | |
1262 layout_tools_geometry_sync(lw); | |
1263 gtk_widget_hide(lw->tools); | |
1264 } | |
1265 } | |
1266 else | |
1267 { | |
1268 if (!GTK_WIDGET_VISIBLE(lw->tools)) | |
1269 { | |
1270 gtk_widget_show(lw->tools); | |
1271 if (lw->vfi) vficon_refresh(lw->vfi); | |
1272 } | |
1273 } | |
1274 | |
1275 lw->tools_hidden = hide; | |
1276 } | |
1277 | |
1278 static gint layout_tools_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
1279 { | |
1280 LayoutWindow *lw = data; | |
1281 | |
1282 layout_tools_float_toggle(lw); | |
1283 | |
1284 return TRUE; | |
1285 } | |
1286 | |
1287 static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *files) | |
1288 { | |
1289 GtkWidget *vbox; | |
1290 GtkWidget *w1, *w2; | |
1291 gint vertical; | |
1292 gint new_window = FALSE; | |
1293 | |
1294 vertical = (layout_location_single(lw->image_location) && !layout_location_vertical(lw->image_location)) || | |
1295 (!layout_location_single(lw->image_location) && layout_location_vertical(layout_grid_compass(lw))); | |
1296 #if 0 | |
1297 layout_location_compute(lw->dir_location, lw->file_location, | |
1298 tools, files, &w1, &w2); | |
1299 #endif | |
1300 /* for now, tools/dir are always first in order */ | |
1301 w1 = tools; | |
1302 w2 = files; | |
1303 | |
1304 if (!lw->tools) | |
1305 { | |
1306 GdkGeometry geometry; | |
1307 GdkWindowHints hints; | |
1308 | |
1309 lw->tools = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1310 g_signal_connect(G_OBJECT(lw->tools), "delete_event", | |
1311 G_CALLBACK(layout_tools_delete_cb), lw); | |
1312 layout_keyboard_init(lw, lw->tools); | |
1313 | |
1314 if (save_window_positions) | |
1315 { | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1316 hints = GDK_HINT_USER_POS; |
9 | 1317 } |
1318 else | |
1319 { | |
1320 hints = 0; | |
1321 } | |
1322 | |
1323 geometry.min_width = 32; | |
1324 geometry.min_height = 32; | |
1325 geometry.base_width = TOOLWINDOW_DEF_WIDTH; | |
1326 geometry.base_height = TOOLWINDOW_DEF_HEIGHT; | |
1327 gtk_window_set_geometry_hints(GTK_WINDOW(lw->tools), NULL, &geometry, | |
1328 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hints); | |
1329 | |
1330 | |
1331 gtk_window_set_resizable(GTK_WINDOW(lw->tools), TRUE); | |
1332 gtk_window_set_title(GTK_WINDOW(lw->tools), _("GQview Tools")); | |
1333 gtk_window_set_wmclass(GTK_WINDOW(lw->tools), "tools", "GQview"); | |
1334 gtk_container_set_border_width(GTK_CONTAINER(lw->tools), 0); | |
1335 | |
91
d063f97503b7
Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
88
diff
changeset
|
1336 window_set_icon(lw->tools, PIXBUF_INLINE_ICON_TOOLS, NULL); |
9 | 1337 |
1338 new_window = TRUE; | |
1339 } | |
1340 else | |
1341 { | |
1342 layout_tools_geometry_sync(lw); | |
1343 /* dump the contents */ | |
1344 gtk_widget_destroy(GTK_BIN(lw->tools)->child); | |
1345 } | |
1346 | |
1347 layout_actions_add_window(lw, lw->tools); | |
1348 | |
1349 vbox = gtk_vbox_new(FALSE, 0); | |
1350 gtk_container_add(GTK_CONTAINER(lw->tools), vbox); | |
1351 gtk_widget_show(vbox); | |
1352 | |
1353 layout_status_setup(lw, vbox, TRUE); | |
1354 | |
1355 if (vertical) | |
1356 { | |
1357 lw->tools_pane = gtk_vpaned_new(); | |
1358 } | |
1359 else | |
1360 { | |
1361 lw->tools_pane = gtk_hpaned_new(); | |
1362 } | |
1363 gtk_box_pack_start(GTK_BOX(vbox), lw->tools_pane, TRUE, TRUE, 0); | |
1364 gtk_widget_show(lw->tools_pane); | |
1365 | |
1366 gtk_paned_pack1(GTK_PANED(lw->tools_pane), w1, FALSE, TRUE); | |
1367 gtk_paned_pack2(GTK_PANED(lw->tools_pane), w2, TRUE, TRUE); | |
1368 | |
1369 gtk_widget_show(tools); | |
1370 gtk_widget_show(files); | |
1371 | |
1372 if (new_window) | |
1373 { | |
1374 if (save_window_positions) | |
1375 { | |
1376 gtk_window_set_default_size(GTK_WINDOW(lw->tools), float_window_w, float_window_h); | |
1377 gtk_window_move(GTK_WINDOW(lw->tools), float_window_x, float_window_y); | |
1378 } | |
1379 else | |
1380 { | |
1381 if (vertical) | |
1382 { | |
1383 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1384 TOOLWINDOW_DEF_WIDTH, TOOLWINDOW_DEF_HEIGHT); | |
1385 } | |
1386 else | |
1387 { | |
1388 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1389 TOOLWINDOW_DEF_HEIGHT, TOOLWINDOW_DEF_WIDTH); | |
1390 } | |
1391 } | |
1392 } | |
1393 | |
1394 if (!save_window_positions) | |
1395 { | |
1396 if (vertical) | |
1397 { | |
1398 lw->div_float = MAIN_WINDOW_DIV_VPOS; | |
1399 } | |
1400 else | |
1401 { | |
1402 lw->div_float = MAIN_WINDOW_DIV_HPOS; | |
1403 } | |
1404 } | |
1405 | |
1406 gtk_paned_set_position(GTK_PANED(lw->tools_pane), lw->div_float); | |
1407 } | |
1408 | |
1409 /* | |
1410 *----------------------------------------------------------------------------- | |
1411 * glue (layout arrangement) | |
1412 *----------------------------------------------------------------------------- | |
1413 */ | |
1414 | |
1415 static void layout_grid_compute(LayoutWindow *lw, | |
1416 GtkWidget *image, GtkWidget *tools, GtkWidget *files, | |
1417 GtkWidget **w1, GtkWidget **w2, GtkWidget **w3) | |
1418 { | |
1419 /* heh, this was fun */ | |
1420 | |
1421 if (layout_location_single(lw->dir_location)) | |
1422 { | |
1423 if (layout_location_first(lw->dir_location)) | |
1424 { | |
1425 *w1 = tools; | |
1426 layout_location_compute(lw->file_location, lw->image_location, files, image, w2, w3); | |
1427 } | |
1428 else | |
1429 { | |
1430 *w3 = tools; | |
1431 layout_location_compute(lw->file_location, lw->image_location, files, image, w1, w2); | |
1432 } | |
1433 } | |
1434 else if (layout_location_single(lw->file_location)) | |
1435 { | |
1436 if (layout_location_first(lw->file_location)) | |
1437 { | |
1438 *w1 = files; | |
1439 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w2, w3); | |
1440 } | |
1441 else | |
1442 { | |
1443 *w3 = files; | |
1444 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w1, w2); | |
1445 } | |
1446 } | |
1447 else | |
1448 { | |
1449 /* image */ | |
1450 if (layout_location_first(lw->image_location)) | |
1451 { | |
1452 *w1 = image; | |
1453 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w2, w3); | |
1454 } | |
1455 else | |
1456 { | |
1457 *w3 = image; | |
1458 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w1, w2); | |
1459 } | |
1460 } | |
1461 } | |
1462 | |
127 | 1463 void layout_split_change(LayoutWindow *lw, ImageSplitMode mode) |
1464 { | |
1465 GtkWidget *image; | |
1466 gint i; | |
1467 for (i=0; i < MAX_SPLIT_IMAGES; i++) | |
1468 { | |
1469 if (lw->split_images[i]) | |
1470 { | |
1471 gtk_widget_hide(lw->split_images[i]->widget); | |
1472 if (lw->split_images[i]->widget->parent != lw->utility_box) | |
1473 gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); | |
1474 } | |
1475 } | |
1476 gtk_container_remove(GTK_CONTAINER(lw->utility_box), lw->split_image_widget); | |
1477 | |
1478 image = layout_image_setup_split(lw, mode); | |
1479 | |
1480 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); | |
1481 gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0); | |
1482 gtk_widget_show(image); | |
1483 } | |
1484 | |
9 | 1485 static void layout_grid_setup(LayoutWindow *lw) |
1486 { | |
1487 gint priority_location; | |
1488 GtkWidget *h; | |
1489 GtkWidget *v; | |
1490 GtkWidget *w1, *w2, *w3; | |
1491 | |
1492 GtkWidget *image; | |
1493 GtkWidget *tools; | |
1494 GtkWidget *files; | |
1495 | |
1496 layout_actions_setup(lw); | |
1497 layout_actions_add_window(lw, lw->window); | |
1498 | |
1499 lw->group_box = gtk_vbox_new(FALSE, 0); | |
1500 gtk_box_pack_start(GTK_BOX(lw->main_box), lw->group_box, TRUE, TRUE, 0); | |
1501 gtk_widget_show(lw->group_box); | |
1502 | |
1503 priority_location = layout_grid_compass(lw); | |
1504 | |
127 | 1505 image = layout_image_setup_split(lw, lw->split_mode); |
1506 | |
1507 | |
9 | 1508 tools = layout_tools_new(lw); |
1509 files = layout_list_new(lw); | |
1510 | |
1511 image = layout_bars_prepare(lw, image); | |
1512 | |
1513 if (lw->tools_float || lw->tools_hidden) | |
1514 { | |
1515 gtk_box_pack_start(GTK_BOX(lw->group_box), image, TRUE, TRUE, 0); | |
1516 gtk_widget_show(image); | |
1517 | |
1518 layout_tools_setup(lw, tools, files); | |
1519 | |
1520 gtk_widget_grab_focus(lw->image->widget); | |
1521 | |
1522 return; | |
1523 } | |
1524 else if (lw->tools) | |
1525 { | |
1526 layout_tools_geometry_sync(lw); | |
1527 gtk_widget_destroy(lw->tools); | |
1528 lw->tools = NULL; | |
1529 lw->tools_pane = NULL; | |
1530 } | |
1531 | |
1532 layout_status_setup(lw, lw->group_box, FALSE); | |
1533 | |
1534 layout_grid_compute(lw, image, tools, files, &w1, &w2, &w3); | |
1535 | |
1536 v = lw->v_pane = gtk_vpaned_new(); | |
1537 | |
1538 h = lw->h_pane = gtk_hpaned_new(); | |
1539 | |
1540 if (!layout_location_vertical(priority_location)) | |
1541 { | |
1542 GtkWidget *tmp; | |
1543 | |
1544 tmp = v; | |
1545 v = h; | |
1546 h = tmp; | |
1547 } | |
1548 | |
1549 gtk_box_pack_start(GTK_BOX(lw->group_box), v, TRUE, TRUE, 0); | |
1550 | |
1551 if (!layout_location_first(priority_location)) | |
1552 { | |
1553 gtk_paned_pack1(GTK_PANED(v), h, FALSE, TRUE); | |
1554 gtk_paned_pack2(GTK_PANED(v), w3, TRUE, TRUE); | |
1555 | |
1556 gtk_paned_pack1(GTK_PANED(h), w1, FALSE, TRUE); | |
1557 gtk_paned_pack2(GTK_PANED(h), w2, TRUE, TRUE); | |
1558 } | |
1559 else | |
1560 { | |
1561 gtk_paned_pack1(GTK_PANED(v), w1, FALSE, TRUE); | |
1562 gtk_paned_pack2(GTK_PANED(v), h, TRUE, TRUE); | |
1563 | |
1564 gtk_paned_pack1(GTK_PANED(h), w2, FALSE, TRUE); | |
1565 gtk_paned_pack2(GTK_PANED(h), w3, TRUE, TRUE); | |
1566 } | |
1567 | |
1568 gtk_widget_show(image); | |
1569 gtk_widget_show(tools); | |
1570 gtk_widget_show(files); | |
1571 | |
1572 gtk_widget_show(v); | |
1573 gtk_widget_show(h); | |
1574 | |
1575 /* fix to have image pane visible when it is left and priority widget */ | |
1576 if (lw->div_h == -1 && | |
1577 w1 == image && | |
1578 !layout_location_vertical(priority_location) && | |
1579 layout_location_first(priority_location)) | |
1580 { | |
1581 gtk_widget_set_size_request(image, 200, -1); | |
1582 } | |
1583 | |
1584 gtk_paned_set_position(GTK_PANED(lw->h_pane), lw->div_h); | |
1585 gtk_paned_set_position(GTK_PANED(lw->v_pane), lw->div_v); | |
1586 | |
1587 gtk_widget_grab_focus(lw->image->widget); | |
1588 } | |
1589 | |
1590 void layout_style_set(LayoutWindow *lw, gint style, const gchar *order) | |
1591 { | |
1592 gchar *path; | |
127 | 1593 gint i; |
9 | 1594 |
1595 if (!layout_valid(&lw)) return; | |
1596 | |
1597 if (style != -1) | |
1598 { | |
1599 LayoutLocation d, f, i; | |
1600 | |
1601 layout_config_parse(style, order, &d, &f, &i); | |
1602 | |
1603 if (lw->dir_location == d && | |
1604 lw->file_location == f && | |
1605 lw->image_location == i) return; | |
1606 | |
1607 lw->dir_location = d; | |
1608 lw->file_location = f; | |
1609 lw->image_location = i; | |
1610 } | |
1611 | |
1612 /* remember state */ | |
1613 | |
1614 layout_image_slideshow_stop(lw); | |
1615 layout_image_full_screen_stop(lw); | |
1616 | |
1617 path = lw->path; | |
1618 lw->path = NULL; | |
1619 lw->image = NULL; | |
1620 lw->utility_box = NULL; | |
1621 | |
1622 layout_geometry_get_dividers(lw, &lw->div_h, &lw->div_v); | |
1623 | |
1624 /* clear it all */ | |
1625 | |
127 | 1626 for (i=0; i < MAX_SPLIT_IMAGES; i++) |
1627 { | |
1628 if (lw->split_images[i]) | |
1629 { | |
1630 gtk_widget_hide(lw->split_images[i]->widget); | |
1631 gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); | |
1632 } | |
1633 } | |
9 | 1634 |
1635 lw->h_pane = NULL; | |
1636 lw->v_pane = NULL; | |
1637 | |
1638 lw->toolbar = NULL; | |
1639 lw->thumb_button = NULL; | |
1640 lw->path_entry = NULL; | |
1641 lw->dir_view = NULL; | |
1642 lw->vdl = NULL; | |
1643 lw->vdt = NULL; | |
1644 | |
1645 lw->file_view = NULL; | |
1646 lw->vfl = NULL; | |
1647 lw->vfi = NULL; | |
1648 | |
1649 lw->info_box = NULL; | |
1650 lw->info_progress_bar = NULL; | |
1651 lw->info_sort = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1652 lw->info_color = NULL; |
9 | 1653 lw->info_status = NULL; |
1654 lw->info_details = NULL; | |
1655 lw->info_zoom = NULL; | |
1656 | |
1657 if (lw->ui_manager) g_object_unref(lw->ui_manager); | |
1658 lw->ui_manager = NULL; | |
1659 lw->action_group = NULL; | |
1660 | |
1661 gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box); | |
1662 lw->group_box = NULL; | |
1663 | |
1664 /* re-fill */ | |
1665 | |
1666 layout_grid_setup(lw); | |
1667 layout_tools_hide(lw, lw->tools_hidden); | |
1668 | |
1669 layout_list_sync_sort(lw); | |
1670 layout_util_sync(lw); | |
1671 layout_status_update_all(lw); | |
1672 | |
1673 /* sync */ | |
1674 | |
127 | 1675 if (image_get_path(lw->image)) |
9 | 1676 { |
127 | 1677 layout_set_path(lw, image_get_path(lw->image)); |
9 | 1678 } |
1679 else | |
1680 { | |
1681 layout_set_path(lw, path); | |
1682 } | |
1683 image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden)); | |
1684 | |
1685 /* clean up */ | |
1686 | |
1687 g_free(path); | |
1688 } | |
1689 | |
1690 void layout_styles_update(void) | |
1691 { | |
1692 GList *work; | |
1693 | |
1694 work = layout_window_list; | |
1695 while (work) | |
1696 { | |
1697 LayoutWindow *lw = work->data; | |
1698 work = work->next; | |
1699 | |
1700 layout_style_set(lw, layout_style, layout_order); | |
1701 } | |
1702 } | |
1703 | |
1704 void layout_colors_update(void) | |
1705 { | |
1706 GList *work; | |
1707 | |
1708 work = layout_window_list; | |
1709 while (work) | |
1710 { | |
1711 LayoutWindow *lw = work->data; | |
1712 work = work->next; | |
1713 | |
1714 if (lw->image) image_background_set_black(lw->image, black_window_background); | |
1715 } | |
1716 } | |
1717 | |
1718 void layout_tools_float_toggle(LayoutWindow *lw) | |
1719 { | |
1720 gint popped; | |
1721 | |
1722 if (!lw) return; | |
1723 | |
1724 if (!lw->tools_hidden) | |
1725 { | |
1726 popped = !lw->tools_float; | |
1727 } | |
1728 else | |
1729 { | |
1730 popped = TRUE; | |
1731 } | |
1732 | |
1733 if (lw->tools_float == popped) | |
1734 { | |
1735 if (popped && lw->tools_hidden) | |
1736 { | |
1737 layout_tools_float_set(lw, popped, FALSE); | |
1738 } | |
1739 } | |
1740 else | |
1741 { | |
1742 if (lw->tools_float) | |
1743 { | |
1744 layout_tools_float_set(lw, FALSE, FALSE); | |
1745 } | |
1746 else | |
1747 { | |
1748 layout_tools_float_set(lw, TRUE, FALSE); | |
1749 } | |
1750 } | |
1751 } | |
1752 | |
1753 void layout_tools_hide_toggle(LayoutWindow *lw) | |
1754 { | |
1755 if (!lw) return; | |
1756 | |
1757 layout_tools_float_set(lw, lw->tools_float, !lw->tools_hidden); | |
1758 } | |
1759 | |
1760 void layout_tools_float_set(LayoutWindow *lw, gint popped, gint hidden) | |
1761 { | |
1762 if (!layout_valid(&lw)) return; | |
1763 | |
1764 if (lw->tools_float == popped && lw->tools_hidden == hidden) return; | |
1765 | |
1766 if (lw->tools_float == popped && lw->tools_float && lw->tools) | |
1767 { | |
1768 layout_tools_hide(lw, hidden); | |
1769 return; | |
1770 } | |
1771 | |
1772 lw->tools_float = popped; | |
1773 lw->tools_hidden = hidden; | |
1774 | |
1775 layout_style_set(lw, -1, NULL); | |
1776 } | |
1777 | |
1778 gint layout_tools_float_get(LayoutWindow *lw, gint *popped, gint *hidden) | |
1779 { | |
1780 if (!layout_valid(&lw)) return FALSE; | |
1781 | |
1782 *popped = lw->tools_float; | |
1783 *hidden = lw->tools_hidden; | |
1784 | |
1785 return TRUE; | |
1786 } | |
1787 | |
1788 void layout_toolbar_toggle(LayoutWindow *lw) | |
1789 { | |
1790 if (!layout_valid(&lw)) return; | |
1791 if (!lw->toolbar) return; | |
1792 | |
1793 lw->toolbar_hidden = !lw->toolbar_hidden; | |
1794 | |
1795 if (lw->toolbar_hidden) | |
1796 { | |
1797 if (GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_hide(lw->toolbar); | |
1798 } | |
1799 else | |
1800 { | |
1801 if (!GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_show(lw->toolbar); | |
1802 } | |
1803 } | |
1804 | |
1805 gint layout_toolbar_hidden(LayoutWindow *lw) | |
1806 { | |
1807 if (!layout_valid(&lw)) return TRUE; | |
1808 | |
1809 return lw->toolbar_hidden; | |
1810 } | |
1811 | |
1812 /* | |
1813 *----------------------------------------------------------------------------- | |
1814 * base | |
1815 *----------------------------------------------------------------------------- | |
1816 */ | |
1817 | |
1818 void layout_close(LayoutWindow *lw) | |
1819 { | |
1820 if (layout_window_list && layout_window_list->next) | |
1821 { | |
1822 layout_free(lw); | |
1823 } | |
1824 else | |
1825 { | |
1826 exit_gqview(); | |
1827 } | |
1828 } | |
1829 | |
1830 void layout_free(LayoutWindow *lw) | |
1831 { | |
1832 if (!lw) return; | |
1833 | |
1834 layout_window_list = g_list_remove(layout_window_list, lw); | |
1835 | |
1836 if (lw->last_time_id != -1) | |
1837 { | |
1838 g_source_remove(lw->last_time_id); | |
1839 } | |
1840 | |
1841 layout_bars_close(lw); | |
1842 | |
1843 gtk_widget_destroy(lw->window); | |
1844 | |
1845 g_free(lw->path); | |
1846 | |
1847 g_free(lw); | |
1848 } | |
1849 | |
1850 static gint layout_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
1851 { | |
1852 LayoutWindow *lw = data; | |
1853 | |
1854 layout_close(lw); | |
1855 return TRUE; | |
1856 } | |
1857 | |
1858 LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden) | |
1859 { | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1860 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
|
1861 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1862 |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1863 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
|
1864 const gchar *geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1865 { |
9 | 1866 LayoutWindow *lw; |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1867 GdkGeometry hint; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1868 GdkWindowHints hint_mask; |
9 | 1869 |
1870 lw = g_new0(LayoutWindow, 1); | |
1871 | |
1872 lw->thumbs_enabled = thumbnails_enabled; | |
1873 lw->sort_method = SORT_NAME; | |
1874 lw->sort_ascend = TRUE; | |
1875 | |
1876 lw->tools_float = popped; | |
1877 lw->tools_hidden = hidden; | |
1878 | |
1879 lw->toolbar_hidden = toolbar_hidden; | |
1880 | |
1881 lw->utility_box = NULL; | |
1882 lw->bar_sort = NULL; | |
1883 lw->bar_sort_enabled = FALSE; | |
1884 lw->bar_exif = NULL; | |
1885 lw->bar_exif_enabled = FALSE; | |
1886 lw->bar_exif_size = -1; | |
1887 lw->bar_exif_advanced = FALSE; | |
1888 | |
1889 /* default layout */ | |
1890 | |
1891 layout_config_parse(layout_style, layout_order, | |
1892 &lw->dir_location, &lw->file_location, &lw->image_location); | |
1893 lw->tree_view = layout_view_tree; | |
1894 lw->icon_view = layout_view_icons; | |
1895 | |
1896 /* divider positions */ | |
1897 | |
1898 if (save_window_positions) | |
1899 { | |
1900 lw->div_h = window_hdivider_pos; | |
1901 lw->div_v = window_vdivider_pos; | |
1902 lw->div_float = float_window_divider; | |
1903 } | |
1904 else | |
1905 { | |
1906 lw->div_h = MAIN_WINDOW_DIV_HPOS; | |
1907 lw->div_v = MAIN_WINDOW_DIV_VPOS; | |
1908 lw->div_float = MAIN_WINDOW_DIV_VPOS; | |
1909 } | |
1910 | |
1911 /* window */ | |
1912 | |
1913 lw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1914 gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE); | |
1915 | |
1916 gtk_window_set_title(GTK_WINDOW(lw->window), "GQview"); | |
1917 gtk_window_set_wmclass(GTK_WINDOW(lw->window), "gqview", "GQview"); | |
1918 gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0); | |
1919 | |
1920 window_set_icon(lw->window, NULL, NULL); | |
1921 | |
1922 if (save_window_positions) | |
1923 { | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1924 hint_mask = GDK_HINT_USER_POS; |
9 | 1925 } |
1926 else | |
1927 { | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1928 hint_mask = 0; |
9 | 1929 } |
1930 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1931 hint.min_width = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1932 hint.min_height = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1933 hint.base_width = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1934 hint.base_height = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1935 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
|
1936 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hint_mask); |
9 | 1937 |
1938 if (save_window_positions) | |
1939 { | |
1940 gtk_window_set_default_size(GTK_WINDOW(lw->window), main_window_w, main_window_h); | |
1941 if (!layout_window_list) | |
1942 { | |
1943 gtk_window_move(GTK_WINDOW(lw->window), main_window_x, main_window_y); | |
1944 if (main_window_maximized) gtk_window_maximize(GTK_WINDOW(lw->window)); | |
1945 } | |
1946 } | |
1947 else | |
1948 { | |
1949 gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT); | |
1950 } | |
1951 | |
1952 g_signal_connect(G_OBJECT(lw->window), "delete_event", | |
1953 G_CALLBACK(layout_delete_cb), lw); | |
1954 | |
1955 layout_keyboard_init(lw, lw->window); | |
1956 | |
1957 lw->main_box = gtk_vbox_new(FALSE, 0); | |
1958 gtk_container_add(GTK_CONTAINER(lw->window), lw->main_box); | |
1959 gtk_widget_show(lw->main_box); | |
1960 | |
1961 layout_grid_setup(lw); | |
1962 image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden)); | |
1963 | |
1964 layout_util_sync(lw); | |
1965 layout_status_update_all(lw); | |
1966 | |
1967 if (path) | |
1968 { | |
1969 layout_set_path(lw, path); | |
1970 } | |
1971 else | |
1972 { | |
1973 GdkPixbuf *pixbuf; | |
1974 | |
1975 pixbuf = pixbuf_inline(PIXBUF_INLINE_LOGO); | |
1976 image_change_pixbuf(lw->image, pixbuf, 1.0); | |
1977 gdk_pixbuf_unref(pixbuf); | |
1978 } | |
1979 | |
1980 /* set up the time stat timeout */ | |
1981 lw->last_time = 0; | |
1982 lw->last_time_id = g_timeout_add(5000, layout_check_for_update_cb, lw); | |
1983 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1984 if (geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1985 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1986 if (!gtk_window_parse_geometry(GTK_WINDOW(lw->window), geometry)) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1987 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1988 print_term(_("Invalid geometry\n")); |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1989 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1990 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1991 |
9 | 1992 gtk_widget_show(lw->window); |
1993 layout_tools_hide(lw, lw->tools_hidden); | |
1994 | |
1995 layout_window_list = g_list_append(layout_window_list, lw); | |
1996 | |
1997 return lw; | |
1998 } | |
1999 | |
2000 /* | |
2001 *----------------------------------------------------------------------------- | |
2002 * maintenance (for rename, move, remove) | |
2003 *----------------------------------------------------------------------------- | |
2004 */ | |
2005 | |
2006 static void layout_real_time_update(LayoutWindow *lw) | |
2007 { | |
2008 /* this resets the last time stamp of path so that a refresh does not occur | |
2009 * from an internal file operation. | |
2010 */ | |
2011 | |
2012 if (lw->path) lw->last_time = filetime(lw->path); | |
2013 } | |
2014 | |
138 | 2015 static void layout_real_renamed(LayoutWindow *lw, FileData *fd) |
9 | 2016 { |
2017 gint update = FALSE; | |
2018 | |
138 | 2019 if (lw->image) layout_image_maint_renamed(lw, fd); |
9 | 2020 |
138 | 2021 if (lw->vfl) update |= vflist_maint_renamed(lw->vfl, fd); |
2022 if (lw->vfi) update |= vficon_maint_renamed(lw->vfi, fd); | |
9 | 2023 |
2024 if (update) layout_real_time_update(lw); | |
2025 } | |
2026 | |
138 | 2027 static void layout_real_removed(LayoutWindow *lw, FileData *fd, GList *ignore_list) |
9 | 2028 { |
2029 gint update = FALSE; | |
2030 | |
138 | 2031 if (lw->image) layout_image_maint_removed(lw, fd); |
9 | 2032 |
138 | 2033 if (lw->vfl) update |= vflist_maint_removed(lw->vfl, fd, ignore_list); |
2034 if (lw->vfi) update |= vficon_maint_removed(lw->vfi, fd, ignore_list); | |
9 | 2035 |
2036 if (update) layout_real_time_update(lw); | |
2037 } | |
2038 | |
138 | 2039 static void layout_real_moved(LayoutWindow *lw, FileData *fd, GList *ignore_list) |
9 | 2040 { |
2041 gint update = FALSE; | |
2042 | |
138 | 2043 if (lw->image) layout_image_maint_moved(lw, fd); |
9 | 2044 |
138 | 2045 if (lw->vfl) update |= vflist_maint_moved(lw->vfl, fd, ignore_list); |
2046 if (lw->vfi) update |= vficon_maint_moved(lw->vfi, fd, ignore_list); | |
9 | 2047 |
2048 if (update) layout_real_time_update(lw); | |
2049 } | |
2050 | |
138 | 2051 void layout_maint_renamed(FileData *fd) |
9 | 2052 { |
2053 GList *work = layout_window_list; | |
2054 while (work) | |
2055 { | |
2056 LayoutWindow *lw = work->data; | |
2057 work = work->next; | |
2058 | |
138 | 2059 layout_real_renamed(lw, fd); |
9 | 2060 } |
2061 } | |
2062 | |
138 | 2063 void layout_maint_removed(FileData *fd, GList *ignore_list) |
9 | 2064 { |
2065 GList *work = layout_window_list; | |
2066 while (work) | |
2067 { | |
2068 LayoutWindow *lw = work->data; | |
2069 work = work->next; | |
2070 | |
138 | 2071 layout_real_removed(lw, fd, ignore_list); |
9 | 2072 } |
2073 } | |
2074 | |
138 | 2075 void layout_maint_moved(FileData *fd, GList *ignore_list) |
9 | 2076 { |
2077 GList *work = layout_window_list; | |
2078 while (work) | |
2079 { | |
2080 LayoutWindow *lw = work->data; | |
2081 work = work->next; | |
2082 | |
138 | 2083 layout_real_moved(lw, fd, ignore_list); |
9 | 2084 } |
2085 } |