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