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