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