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