Mercurial > geeqie
annotate src/layout.c @ 930:c87e9835c443
clean up - checks are handled elsewhere
author | nadvornik |
---|---|
date | Sat, 26 Jul 2008 10:27:41 +0000 |
parents | c414002a1f27 |
children | 9791230f83d3 |
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; |
736 | 523 guint s; |
9 | 524 gint64 s_bytes = 0; |
525 const gchar *ss; | |
526 | |
527 if (layout_image_slideshow_active(lw)) | |
528 { | |
529 if (!layout_image_slideshow_paused(lw)) | |
530 { | |
531 ss = _(" Slideshow"); | |
532 } | |
533 else | |
534 { | |
535 ss = _(" Paused"); | |
536 } | |
537 } | |
538 else | |
539 { | |
540 ss = ""; | |
541 } | |
542 | |
543 n = layout_list_count(lw, &n_bytes); | |
544 s = layout_selection_count(lw, &s_bytes); | |
545 | |
546 layout_bars_new_selection(lw, s); | |
547 | |
548 if (s > 0) | |
549 { | |
268 | 550 gchar *b = text_from_size_abrev(n_bytes); |
551 gchar *sb = text_from_size_abrev(s_bytes); | |
9 | 552 buf = g_strdup_printf(_("%s, %d files (%s, %d)%s"), b, n, sb, s, ss); |
553 g_free(b); | |
554 g_free(sb); | |
555 } | |
556 else if (n > 0) | |
557 { | |
268 | 558 gchar *b = text_from_size_abrev(n_bytes); |
9 | 559 buf = g_strdup_printf(_("%s, %d files%s"), b, n, ss); |
560 g_free(b); | |
561 } | |
562 else | |
563 { | |
564 buf = g_strdup_printf(_("%d files%s"), n, ss); | |
565 } | |
566 | |
567 text = buf; | |
568 | |
482 | 569 image_osd_update(lw->image); |
9 | 570 } |
571 | |
583
de3e2bc22336
Revert patch 675, and correctly fix gtk assertion failure.
zas_
parents:
574
diff
changeset
|
572 if (lw->info_status) gtk_label_set_text(GTK_LABEL(lw->info_status), text); |
9 | 573 g_free(buf); |
574 } | |
575 | |
576 void layout_status_update_image(LayoutWindow *lw) | |
577 { | |
578 gchar *text; | |
579 gchar *b; | |
580 | |
581 if (!layout_valid(&lw) || !lw->image) return; | |
582 | |
583 text = image_zoom_get_as_text(lw->image); | |
584 gtk_label_set_text(GTK_LABEL(lw->info_zoom), text); | |
585 g_free(text); | |
586 | |
888 | 587 b = image_get_fd(lw->image) ? text_from_size(image_get_fd(lw->image)->size) : g_strdup("0"); |
9 | 588 |
589 if (lw->image->unknown) | |
590 { | |
591 if (image_get_path(lw->image) && !access_file(image_get_path(lw->image), R_OK)) | |
592 { | |
593 text = g_strdup_printf(_("(no read permission) %s bytes"), b); | |
594 } | |
595 else | |
596 { | |
597 text = g_strdup_printf(_("( ? x ? ) %s bytes"), b); | |
598 } | |
599 } | |
600 else | |
601 { | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
602 gint width, height; |
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
603 |
531 | 604 image_get_image_size(lw->image, &width, &height); |
9 | 605 text = g_strdup_printf(_("( %d x %d ) %s bytes"), |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
606 width, height, b); |
9 | 607 } |
608 | |
609 gtk_label_set_text(GTK_LABEL(lw->info_details), text); | |
610 | |
611 g_free(b); | |
612 g_free(text); | |
613 } | |
614 | |
615 void layout_status_update_all(LayoutWindow *lw) | |
616 { | |
617 layout_status_update_progress(lw, 0.0, NULL); | |
618 layout_status_update_info(lw, NULL); | |
619 layout_status_update_image(lw); | |
620 } | |
621 | |
622 static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gint start, gint size, gint expand) | |
623 { | |
624 GtkWidget *label; | |
625 GtkWidget *frame; | |
626 | |
627 frame = gtk_frame_new(NULL); | |
628 if (size) gtk_widget_set_size_request(frame, size, -1); | |
629 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
630 if (start) | |
631 { | |
632 gtk_box_pack_start(GTK_BOX(box), frame, expand, expand, 0); | |
633 } | |
634 else | |
635 { | |
636 gtk_box_pack_end(GTK_BOX(box), frame, expand, expand, 0); | |
637 } | |
638 gtk_widget_show(frame); | |
639 | |
640 label = gtk_label_new(text ? text : ""); | |
641 gtk_container_add(GTK_CONTAINER(frame), label); | |
642 gtk_widget_show(label); | |
643 | |
644 return label; | |
645 } | |
646 | |
647 static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gint small_format) | |
648 { | |
649 GtkWidget *hbox; | |
650 | |
651 if (lw->info_box) return; | |
652 | |
653 if (small_format) | |
654 { | |
655 lw->info_box = gtk_vbox_new(FALSE, 0); | |
656 } | |
657 else | |
658 { | |
659 lw->info_box = gtk_hbox_new(FALSE, 0); | |
660 } | |
661 gtk_box_pack_end(GTK_BOX(box), lw->info_box, FALSE, FALSE, 0); | |
662 gtk_widget_show(lw->info_box); | |
663 | |
664 if (small_format) | |
665 { | |
666 hbox = gtk_hbox_new(FALSE, 0); | |
667 gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0); | |
668 gtk_widget_show(hbox); | |
669 } | |
670 else | |
671 { | |
672 hbox = lw->info_box; | |
673 } | |
674 lw->info_progress_bar = gtk_progress_bar_new(); | |
675 gtk_widget_set_size_request(lw->info_progress_bar, PROGRESS_WIDTH, -1); | |
676 gtk_box_pack_start(GTK_BOX(hbox), lw->info_progress_bar, FALSE, FALSE, 0); | |
677 gtk_widget_show(lw->info_progress_bar); | |
678 | |
679 lw->info_sort = layout_sort_button(lw); | |
680 gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0); | |
681 gtk_widget_show(lw->info_sort); | |
682 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
683 lw->info_color = layout_color_button(lw); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
684 gtk_widget_show(lw->info_color); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
685 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
686 if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
687 |
9 | 688 lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format)); |
689 | |
690 if (small_format) | |
691 { | |
692 hbox = gtk_hbox_new(FALSE, 0); | |
693 gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0); | |
694 gtk_widget_show(hbox); | |
695 } | |
696 else | |
697 { | |
698 hbox = lw->info_box; | |
699 } | |
700 lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE); | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
701 if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); |
9 | 702 lw->info_zoom = layout_status_label(NULL, hbox, FALSE, ZOOM_LABEL_WIDTH, FALSE); |
703 } | |
704 | |
705 /* | |
706 *----------------------------------------------------------------------------- | |
707 * views | |
708 *----------------------------------------------------------------------------- | |
709 */ | |
710 | |
711 static GtkWidget *layout_tools_new(LayoutWindow *lw) | |
712 { | |
713 lw->dir_view = layout_tool_setup(lw); | |
714 return lw->dir_view; | |
715 } | |
716 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
717 static void layout_list_status_cb(ViewFile *vf, gpointer data) |
9 | 718 { |
719 LayoutWindow *lw = data; | |
720 | |
721 layout_status_update_info(lw, NULL); | |
722 } | |
723 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
724 static void layout_list_thumb_cb(ViewFile *vf, gdouble val, const gchar *text, gpointer data) |
9 | 725 { |
726 LayoutWindow *lw = data; | |
727 | |
728 layout_status_update_progress(lw, val, text); | |
729 } | |
730 | |
731 static GtkWidget *layout_list_new(LayoutWindow *lw) | |
732 { | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
733 lw->vf = vf_new(lw->file_view_type, NULL); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
734 vf_set_layout(lw->vf, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
735 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
736 vf_set_status_func(lw->vf, layout_list_status_cb, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
737 vf_set_thumb_status_func(lw->vf, layout_list_thumb_cb, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
738 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
739 vf_marks_set(lw->vf, lw->marks_enabled); |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
740 |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
741 switch (lw->file_view_type) |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
742 { |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
743 case FILEVIEW_ICON: |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
744 break; |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
745 case FILEVIEW_LIST: |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
746 vf_thumb_set(lw->vf, lw->thumbs_enabled); |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
747 break; |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
748 } |
442 | 749 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
750 return lw->vf->widget; |
9 | 751 } |
752 | |
753 static void layout_list_sync_thumb(LayoutWindow *lw) | |
754 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
755 if (lw->vf) vf_thumb_set(lw->vf, lw->thumbs_enabled); |
9 | 756 } |
757 | |
132 | 758 static void layout_list_sync_marks(LayoutWindow *lw) |
759 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
760 if (lw->vf) vf_marks_set(lw->vf, lw->marks_enabled); |
132 | 761 } |
762 | |
9 | 763 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle) |
764 { | |
765 if (!lw) return; | |
766 #if 0 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
767 if (lw->vf) vf_scroll_to_subpart(lw->vf, needle); |
9 | 768 #endif |
769 } | |
770 | |
771 GList *layout_list(LayoutWindow *lw) | |
772 { | |
773 if (!layout_valid(&lw)) return NULL; | |
774 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
775 if (lw->vf) return vf_get_list(lw->vf); |
9 | 776 |
777 return NULL; | |
778 } | |
779 | |
736 | 780 guint layout_list_count(LayoutWindow *lw, gint64 *bytes) |
9 | 781 { |
782 if (!layout_valid(&lw)) return 0; | |
783 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
784 if (lw->vf) return vf_count(lw->vf, bytes); |
9 | 785 |
786 return 0; | |
787 } | |
788 | |
138 | 789 FileData *layout_list_get_fd(LayoutWindow *lw, gint index) |
790 { | |
791 if (!layout_valid(&lw)) return NULL; | |
792 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
793 if (lw->vf) return vf_index_get_data(lw->vf, index); |
138 | 794 |
795 return NULL; | |
796 } | |
797 | |
783 | 798 gint layout_list_get_index(LayoutWindow *lw, FileData *fd) |
9 | 799 { |
783 | 800 if (!layout_valid(&lw) || !fd) return -1; |
9 | 801 |
783 | 802 if (lw->vf) return vf_index_by_path(lw->vf, fd->path); |
9 | 803 |
804 return -1; | |
805 } | |
806 | |
138 | 807 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd) |
9 | 808 { |
809 if (!layout_valid(&lw)) return; | |
810 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
811 if (lw->vf) vf_select_by_fd(lw->vf, fd); |
9 | 812 } |
813 | |
814 static void layout_list_sync_sort(LayoutWindow *lw) | |
815 { | |
816 if (!layout_valid(&lw)) return; | |
817 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
818 if (lw->vf) vf_sort_set(lw->vf, lw->sort_method, lw->sort_ascend); |
9 | 819 } |
820 | |
821 GList *layout_selection_list(LayoutWindow *lw) | |
822 { | |
823 if (!layout_valid(&lw)) return NULL; | |
824 | |
825 if (layout_image_get_collection(lw, NULL)) | |
826 { | |
138 | 827 FileData *fd; |
9 | 828 |
138 | 829 fd = layout_image_get_fd(lw); |
830 if (fd) return g_list_append(NULL, file_data_ref(fd)); | |
9 | 831 return NULL; |
832 } | |
833 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
834 if (lw->vf) return vf_selection_get_list(lw->vf); |
9 | 835 |
836 return NULL; | |
837 } | |
838 | |
839 GList *layout_selection_list_by_index(LayoutWindow *lw) | |
840 { | |
841 if (!layout_valid(&lw)) return NULL; | |
842 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
843 if (lw->vf) return vf_selection_get_list_by_index(lw->vf); |
9 | 844 |
845 return NULL; | |
846 } | |
847 | |
736 | 848 guint layout_selection_count(LayoutWindow *lw, gint64 *bytes) |
9 | 849 { |
850 if (!layout_valid(&lw)) return 0; | |
851 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
852 if (lw->vf) return vf_selection_count(lw->vf, bytes); |
9 | 853 |
854 return 0; | |
855 } | |
856 | |
857 void layout_select_all(LayoutWindow *lw) | |
858 { | |
859 if (!layout_valid(&lw)) return; | |
860 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
861 if (lw->vf) vf_select_all(lw->vf); |
9 | 862 } |
863 | |
864 void layout_select_none(LayoutWindow *lw) | |
865 { | |
866 if (!layout_valid(&lw)) return; | |
867 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
868 if (lw->vf) vf_select_none(lw->vf); |
9 | 869 } |
870 | |
601 | 871 void layout_select_invert(LayoutWindow *lw) |
872 { | |
873 if (!layout_valid(&lw)) return; | |
874 | |
875 if (lw->vf) vf_select_invert(lw->vf); | |
876 } | |
877 | |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
878 void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode) |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
879 { |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
880 if (!layout_valid(&lw)) return; |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
881 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
882 if (lw->vf) vf_mark_to_selection(lw->vf, mark, mode); |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
883 } |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
884 |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
885 void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode) |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
886 { |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
887 if (!layout_valid(&lw)) return; |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
888 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
889 if (lw->vf) vf_selection_to_mark(lw->vf, mark, mode); |
442 | 890 |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
891 layout_status_update_info(lw, NULL); /* osd in fullscreen mode */ |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
892 } |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
893 |
9 | 894 /* |
895 *----------------------------------------------------------------------------- | |
896 * access | |
897 *----------------------------------------------------------------------------- | |
898 */ | |
899 | |
900 const gchar *layout_get_path(LayoutWindow *lw) | |
901 { | |
902 if (!layout_valid(&lw)) return NULL; | |
783 | 903 return lw->dir_fd ? lw->dir_fd->path : NULL; |
9 | 904 } |
905 | |
906 static void layout_sync_path(LayoutWindow *lw) | |
907 { | |
783 | 908 if (!lw->dir_fd) return; |
9 | 909 |
783 | 910 if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path); |
911 if (lw->vd) vd_set_fd(lw->vd, lw->dir_fd); | |
9 | 912 |
783 | 913 if (lw->vf) vf_set_fd(lw->vf, lw->dir_fd); |
9 | 914 } |
915 | |
916 gint layout_set_path(LayoutWindow *lw, const gchar *path) | |
917 { | |
783 | 918 FileData *fd = file_data_new_simple(path); |
919 gint ret = layout_set_fd(lw, fd); | |
920 file_data_unref(fd); | |
921 return ret; | |
922 } | |
923 | |
924 | |
925 gint layout_set_fd(LayoutWindow *lw, FileData *fd) | |
926 { | |
9 | 927 gint have_file = FALSE; |
928 | |
929 if (!layout_valid(&lw)) return FALSE; | |
930 | |
783 | 931 if (!fd || !isname(fd->path)) return FALSE; |
932 if (lw->dir_fd && fd == lw->dir_fd) | |
9 | 933 { |
934 return TRUE; | |
935 } | |
936 | |
783 | 937 if (isdir(fd->path)) |
9 | 938 { |
791 | 939 if (lw->dir_fd) |
940 { | |
941 file_data_unregister_real_time_monitor(lw->dir_fd); | |
942 file_data_unref(lw->dir_fd); | |
943 } | |
783 | 944 lw->dir_fd = file_data_ref(fd); |
791 | 945 file_data_register_real_time_monitor(fd); |
9 | 946 } |
947 else | |
948 { | |
949 gchar *base; | |
950 | |
783 | 951 base = remove_level_from_path(fd->path); |
952 if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0) | |
9 | 953 { |
954 g_free(base); | |
955 } | |
956 else if (isdir(base)) | |
957 { | |
791 | 958 if (lw->dir_fd) |
959 { | |
960 file_data_unregister_real_time_monitor(lw->dir_fd); | |
961 file_data_unref(lw->dir_fd); | |
962 } | |
783 | 963 lw->dir_fd = file_data_new_simple(base); |
791 | 964 file_data_register_real_time_monitor(lw->dir_fd); |
783 | 965 g_free(base); |
9 | 966 } |
967 else | |
968 { | |
969 g_free(base); | |
970 return FALSE; | |
971 } | |
783 | 972 if (isfile(fd->path)) have_file = TRUE; |
9 | 973 } |
974 | |
783 | 975 if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->dir_fd->path); |
9 | 976 layout_sync_path(lw); |
977 | |
978 if (have_file) | |
979 { | |
980 gint row; | |
981 | |
783 | 982 row = layout_list_get_index(lw, fd); |
9 | 983 if (row >= 0) |
984 { | |
985 layout_image_set_index(lw, row); | |
986 } | |
987 else | |
988 { | |
783 | 989 layout_image_set_fd(lw, fd); |
9 | 990 } |
991 } | |
320 | 992 else if (!options->lazy_image_sync) |
9 | 993 { |
994 layout_image_set_index(lw, 0); | |
995 } | |
996 | |
997 return TRUE; | |
998 } | |
999 | |
1000 static void layout_refresh_lists(LayoutWindow *lw) | |
1001 { | |
390 | 1002 if (lw->vd) vd_refresh(lw->vd); |
9 | 1003 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1004 if (lw->vf) vf_refresh(lw->vf); |
9 | 1005 } |
1006 | |
1007 void layout_refresh(LayoutWindow *lw) | |
1008 { | |
1009 if (!layout_valid(&lw)) return; | |
1010 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
501
diff
changeset
|
1011 DEBUG_1("layout refresh"); |
9 | 1012 |
1013 layout_refresh_lists(lw); | |
1014 | |
1015 if (lw->image) layout_image_refresh(lw); | |
1016 } | |
1017 | |
1018 void layout_thumb_set(LayoutWindow *lw, gint enable) | |
1019 { | |
1020 if (!layout_valid(&lw)) return; | |
1021 | |
1022 if (lw->thumbs_enabled == enable) return; | |
1023 | |
1024 lw->thumbs_enabled = enable; | |
1025 | |
1026 layout_util_sync_thumb(lw); | |
1027 layout_list_sync_thumb(lw); | |
1028 } | |
1029 | |
132 | 1030 void layout_marks_set(LayoutWindow *lw, gint enable) |
1031 { | |
1032 if (!layout_valid(&lw)) return; | |
1033 | |
1034 if (lw->marks_enabled == enable) return; | |
1035 | |
1036 lw->marks_enabled = enable; | |
1037 | |
268 | 1038 // layout_util_sync_marks(lw); |
1039 layout_list_sync_marks(lw); | |
132 | 1040 } |
1041 | |
9 | 1042 gint layout_thumb_get(LayoutWindow *lw) |
1043 { | |
1044 if (!layout_valid(&lw)) return FALSE; | |
1045 | |
1046 return lw->thumbs_enabled; | |
1047 } | |
1048 | |
433
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1049 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
|
1050 { |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1051 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
|
1052 |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1053 return lw->marks_enabled; |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1054 } |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1055 |
9 | 1056 void layout_sort_set(LayoutWindow *lw, SortType type, gint ascend) |
1057 { | |
1058 if (!layout_valid(&lw)) return; | |
1059 if (lw->sort_method == type && lw->sort_ascend == ascend) return; | |
1060 | |
1061 lw->sort_method = type; | |
1062 lw->sort_ascend = ascend; | |
1063 | |
1064 if (lw->info_sort) gtk_label_set_text(GTK_LABEL(GTK_BIN(lw->info_sort)->child), | |
1065 sort_type_get_text(type)); | |
1066 layout_list_sync_sort(lw); | |
1067 } | |
1068 | |
1069 gint layout_sort_get(LayoutWindow *lw, SortType *type, gint *ascend) | |
1070 { | |
1071 if (!layout_valid(&lw)) return FALSE; | |
1072 | |
1073 if (type) *type = lw->sort_method; | |
1074 if (ascend) *ascend = lw->sort_ascend; | |
1075 | |
1076 return TRUE; | |
1077 } | |
1078 | |
1079 gint layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h) | |
1080 { | |
1081 if (!layout_valid(&lw)) return FALSE; | |
1082 | |
1083 gdk_window_get_root_origin(lw->window->window, x, y); | |
1084 gdk_drawable_get_size(lw->window->window, w, h); | |
1085 | |
1086 return TRUE; | |
1087 } | |
1088 | |
1089 gint layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v) | |
1090 { | |
1091 if (!layout_valid(&lw)) return FALSE; | |
1092 | |
1093 if (lw->h_pane && GTK_PANED(lw->h_pane)->child1->allocation.x >= 0) | |
1094 { | |
1095 *h = GTK_PANED(lw->h_pane)->child1->allocation.width; | |
1096 } | |
1097 else if (h != &lw->div_h) | |
1098 { | |
1099 *h = lw->div_h; | |
1100 } | |
1101 | |
1102 if (lw->v_pane && GTK_PANED(lw->v_pane)->child1->allocation.x >= 0) | |
1103 { | |
1104 *v = GTK_PANED(lw->v_pane)->child1->allocation.height; | |
1105 } | |
1106 else if (v != &lw->div_v) | |
1107 { | |
1108 *v = lw->div_v; | |
1109 } | |
1110 | |
1111 return TRUE; | |
1112 } | |
1113 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1114 void layout_views_set(LayoutWindow *lw, DirViewType dir_view_type, FileViewType file_view_type) |
9 | 1115 { |
1116 if (!layout_valid(&lw)) return; | |
1117 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1118 if (lw->dir_view_type == dir_view_type && lw->file_view_type == file_view_type) return; |
9 | 1119 |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1120 lw->dir_view_type = dir_view_type; |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1121 lw->file_view_type = file_view_type; |
9 | 1122 |
1123 layout_style_set(lw, -1, NULL); | |
1124 } | |
1125 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1126 gint layout_views_get(LayoutWindow *lw, DirViewType *dir_view_type, FileViewType *file_view_type) |
9 | 1127 { |
1128 if (!layout_valid(&lw)) return FALSE; | |
1129 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1130 *dir_view_type = lw->dir_view_type; |
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1131 *file_view_type = lw->file_view_type; |
9 | 1132 |
1133 return TRUE; | |
1134 } | |
1135 | |
1136 /* | |
1137 *----------------------------------------------------------------------------- | |
1138 * location utils | |
1139 *----------------------------------------------------------------------------- | |
1140 */ | |
1141 | |
1142 static gint layout_location_single(LayoutLocation l) | |
1143 { | |
1144 return (l == LAYOUT_LEFT || | |
1145 l == LAYOUT_RIGHT || | |
1146 l == LAYOUT_TOP || | |
1147 l == LAYOUT_BOTTOM); | |
1148 } | |
1149 | |
1150 static gint layout_location_vertical(LayoutLocation l) | |
1151 { | |
1152 return (l & LAYOUT_TOP || | |
1153 l & LAYOUT_BOTTOM); | |
1154 } | |
1155 | |
1156 static gint layout_location_first(LayoutLocation l) | |
1157 { | |
1158 return (l & LAYOUT_TOP || | |
1159 l & LAYOUT_LEFT); | |
1160 } | |
1161 | |
1162 static LayoutLocation layout_grid_compass(LayoutWindow *lw) | |
1163 { | |
1164 if (layout_location_single(lw->dir_location)) return lw->dir_location; | |
1165 if (layout_location_single(lw->file_location)) return lw->file_location; | |
1166 return lw->image_location; | |
1167 } | |
1168 | |
1169 static void layout_location_compute(LayoutLocation l1, LayoutLocation l2, | |
1170 GtkWidget *s1, GtkWidget *s2, | |
1171 GtkWidget **d1, GtkWidget **d2) | |
1172 { | |
1173 LayoutLocation l; | |
1174 | |
1175 l = l1 & l2; /* get common compass direction */ | |
1176 l = l1 - l; /* remove it */ | |
1177 | |
1178 if (layout_location_first(l)) | |
1179 { | |
1180 *d1 = s1; | |
1181 *d2 = s2; | |
1182 } | |
1183 else | |
1184 { | |
1185 *d1 = s2; | |
1186 *d2 = s1; | |
1187 } | |
1188 } | |
1189 | |
1190 /* | |
1191 *----------------------------------------------------------------------------- | |
1192 * tools window (for floating/hidden) | |
1193 *----------------------------------------------------------------------------- | |
1194 */ | |
1195 | |
1196 gint layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) | |
1197 { | |
1198 if (!layout_valid(&lw)) return FALSE; | |
1199 | |
1200 if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools)) | |
1201 { | |
1202 /* use the stored values (sort of breaks success return value) */ | |
1203 | |
1204 *divider_pos = lw->div_float; | |
1205 | |
1206 return FALSE; | |
1207 } | |
1208 | |
1209 gdk_window_get_root_origin(lw->tools->window, x, y); | |
1210 gdk_drawable_get_size(lw->tools->window, w, h); | |
1211 | |
1212 if (GTK_IS_VPANED(lw->tools_pane)) | |
1213 { | |
1214 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height; | |
1215 } | |
1216 else | |
1217 { | |
1218 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width; | |
1219 } | |
1220 | |
1221 return TRUE; | |
1222 } | |
1223 | |
1224 static void layout_tools_geometry_sync(LayoutWindow *lw) | |
1225 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1226 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
|
1227 &options->layout.float_window.w, &options->layout.float_window.h, &lw->div_float); |
9 | 1228 } |
1229 | |
1230 static void layout_tools_hide(LayoutWindow *lw, gint hide) | |
1231 { | |
1232 if (!lw->tools) return; | |
1233 | |
1234 if (hide) | |
1235 { | |
1236 if (GTK_WIDGET_VISIBLE(lw->tools)) | |
1237 { | |
1238 layout_tools_geometry_sync(lw); | |
1239 gtk_widget_hide(lw->tools); | |
1240 } | |
1241 } | |
1242 else | |
1243 { | |
1244 if (!GTK_WIDGET_VISIBLE(lw->tools)) | |
1245 { | |
1246 gtk_widget_show(lw->tools); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1247 if (lw->vf) vf_refresh(lw->vf); |
9 | 1248 } |
1249 } | |
1250 | |
1251 lw->tools_hidden = hide; | |
1252 } | |
1253 | |
1254 static gint layout_tools_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
1255 { | |
1256 LayoutWindow *lw = data; | |
1257 | |
1258 layout_tools_float_toggle(lw); | |
1259 | |
1260 return TRUE; | |
1261 } | |
1262 | |
1263 static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *files) | |
1264 { | |
1265 GtkWidget *vbox; | |
1266 GtkWidget *w1, *w2; | |
1267 gint vertical; | |
1268 gint new_window = FALSE; | |
1269 | |
1270 vertical = (layout_location_single(lw->image_location) && !layout_location_vertical(lw->image_location)) || | |
1271 (!layout_location_single(lw->image_location) && layout_location_vertical(layout_grid_compass(lw))); | |
1272 #if 0 | |
1273 layout_location_compute(lw->dir_location, lw->file_location, | |
1274 tools, files, &w1, &w2); | |
1275 #endif | |
1276 /* for now, tools/dir are always first in order */ | |
1277 w1 = tools; | |
1278 w2 = files; | |
1279 | |
1280 if (!lw->tools) | |
1281 { | |
1282 GdkGeometry geometry; | |
1283 GdkWindowHints hints; | |
1284 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
1285 lw->tools = window_new(GTK_WINDOW_TOPLEVEL, "tools", PIXBUF_INLINE_ICON_TOOLS, NULL, _("Tools")); |
9 | 1286 g_signal_connect(G_OBJECT(lw->tools), "delete_event", |
1287 G_CALLBACK(layout_tools_delete_cb), lw); | |
1288 layout_keyboard_init(lw, lw->tools); | |
1289 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1290 if (options->layout.save_window_positions) |
9 | 1291 { |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1292 hints = GDK_HINT_USER_POS; |
9 | 1293 } |
1294 else | |
1295 { | |
1296 hints = 0; | |
1297 } | |
1298 | |
1299 geometry.min_width = 32; | |
1300 geometry.min_height = 32; | |
1301 geometry.base_width = TOOLWINDOW_DEF_WIDTH; | |
1302 geometry.base_height = TOOLWINDOW_DEF_HEIGHT; | |
1303 gtk_window_set_geometry_hints(GTK_WINDOW(lw->tools), NULL, &geometry, | |
1304 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hints); | |
1305 | |
1306 | |
268 | 1307 gtk_window_set_resizable(GTK_WINDOW(lw->tools), TRUE); |
1308 gtk_container_set_border_width(GTK_CONTAINER(lw->tools), 0); | |
442 | 1309 |
9 | 1310 new_window = TRUE; |
1311 } | |
1312 else | |
1313 { | |
1314 layout_tools_geometry_sync(lw); | |
1315 /* dump the contents */ | |
1316 gtk_widget_destroy(GTK_BIN(lw->tools)->child); | |
1317 } | |
1318 | |
1319 layout_actions_add_window(lw, lw->tools); | |
1320 | |
1321 vbox = gtk_vbox_new(FALSE, 0); | |
1322 gtk_container_add(GTK_CONTAINER(lw->tools), vbox); | |
1323 gtk_widget_show(vbox); | |
1324 | |
1325 layout_status_setup(lw, vbox, TRUE); | |
1326 | |
1327 if (vertical) | |
1328 { | |
1329 lw->tools_pane = gtk_vpaned_new(); | |
1330 } | |
1331 else | |
1332 { | |
1333 lw->tools_pane = gtk_hpaned_new(); | |
1334 } | |
1335 gtk_box_pack_start(GTK_BOX(vbox), lw->tools_pane, TRUE, TRUE, 0); | |
1336 gtk_widget_show(lw->tools_pane); | |
1337 | |
1338 gtk_paned_pack1(GTK_PANED(lw->tools_pane), w1, FALSE, TRUE); | |
1339 gtk_paned_pack2(GTK_PANED(lw->tools_pane), w2, TRUE, TRUE); | |
1340 | |
1341 gtk_widget_show(tools); | |
1342 gtk_widget_show(files); | |
1343 | |
1344 if (new_window) | |
1345 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1346 if (options->layout.save_window_positions) |
9 | 1347 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1348 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
|
1349 gtk_window_move(GTK_WINDOW(lw->tools), options->layout.float_window.x, options->layout.float_window.y); |
268 | 1350 } |
9 | 1351 else |
1352 { | |
1353 if (vertical) | |
1354 { | |
1355 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1356 TOOLWINDOW_DEF_WIDTH, TOOLWINDOW_DEF_HEIGHT); | |
1357 } | |
1358 else | |
1359 { | |
1360 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1361 TOOLWINDOW_DEF_HEIGHT, TOOLWINDOW_DEF_WIDTH); | |
1362 } | |
1363 } | |
1364 } | |
1365 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1366 if (!options->layout.save_window_positions) |
9 | 1367 { |
1368 if (vertical) | |
1369 { | |
1370 lw->div_float = MAIN_WINDOW_DIV_VPOS; | |
1371 } | |
1372 else | |
1373 { | |
1374 lw->div_float = MAIN_WINDOW_DIV_HPOS; | |
1375 } | |
1376 } | |
1377 | |
1378 gtk_paned_set_position(GTK_PANED(lw->tools_pane), lw->div_float); | |
1379 } | |
1380 | |
1381 /* | |
1382 *----------------------------------------------------------------------------- | |
1383 * glue (layout arrangement) | |
1384 *----------------------------------------------------------------------------- | |
1385 */ | |
1386 | |
1387 static void layout_grid_compute(LayoutWindow *lw, | |
1388 GtkWidget *image, GtkWidget *tools, GtkWidget *files, | |
1389 GtkWidget **w1, GtkWidget **w2, GtkWidget **w3) | |
1390 { | |
1391 /* heh, this was fun */ | |
1392 | |
1393 if (layout_location_single(lw->dir_location)) | |
1394 { | |
1395 if (layout_location_first(lw->dir_location)) | |
1396 { | |
1397 *w1 = tools; | |
1398 layout_location_compute(lw->file_location, lw->image_location, files, image, w2, w3); | |
1399 } | |
1400 else | |
1401 { | |
1402 *w3 = tools; | |
1403 layout_location_compute(lw->file_location, lw->image_location, files, image, w1, w2); | |
1404 } | |
1405 } | |
1406 else if (layout_location_single(lw->file_location)) | |
1407 { | |
1408 if (layout_location_first(lw->file_location)) | |
1409 { | |
1410 *w1 = files; | |
1411 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w2, w3); | |
1412 } | |
1413 else | |
1414 { | |
1415 *w3 = files; | |
1416 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w1, w2); | |
1417 } | |
1418 } | |
1419 else | |
1420 { | |
1421 /* image */ | |
1422 if (layout_location_first(lw->image_location)) | |
1423 { | |
1424 *w1 = image; | |
1425 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w2, w3); | |
1426 } | |
1427 else | |
1428 { | |
1429 *w3 = image; | |
1430 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w1, w2); | |
1431 } | |
1432 } | |
1433 } | |
1434 | |
127 | 1435 void layout_split_change(LayoutWindow *lw, ImageSplitMode mode) |
1436 { | |
1437 GtkWidget *image; | |
1438 gint i; | |
268 | 1439 |
1440 for (i = 0; i < MAX_SPLIT_IMAGES; i++) | |
127 | 1441 { |
1442 if (lw->split_images[i]) | |
1443 { | |
1444 gtk_widget_hide(lw->split_images[i]->widget); | |
442 | 1445 if (lw->split_images[i]->widget->parent != lw->utility_box) |
127 | 1446 gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); |
1447 } | |
1448 } | |
1449 gtk_container_remove(GTK_CONTAINER(lw->utility_box), lw->split_image_widget); | |
1450 | |
1451 image = layout_image_setup_split(lw, mode); | |
1452 | |
1453 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); | |
1454 gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0); | |
1455 gtk_widget_show(image); | |
1456 } | |
1457 | |
9 | 1458 static void layout_grid_setup(LayoutWindow *lw) |
1459 { | |
1460 gint priority_location; | |
1461 GtkWidget *h; | |
1462 GtkWidget *v; | |
1463 GtkWidget *w1, *w2, *w3; | |
1464 | |
1465 GtkWidget *image; | |
1466 GtkWidget *tools; | |
1467 GtkWidget *files; | |
1468 | |
1469 layout_actions_setup(lw); | |
1470 layout_actions_add_window(lw, lw->window); | |
1471 | |
1472 lw->group_box = gtk_vbox_new(FALSE, 0); | |
1473 gtk_box_pack_start(GTK_BOX(lw->main_box), lw->group_box, TRUE, TRUE, 0); | |
1474 gtk_widget_show(lw->group_box); | |
1475 | |
1476 priority_location = layout_grid_compass(lw); | |
1477 | |
127 | 1478 image = layout_image_setup_split(lw, lw->split_mode); |
442 | 1479 |
9 | 1480 tools = layout_tools_new(lw); |
1481 files = layout_list_new(lw); | |
1482 | |
1483 image = layout_bars_prepare(lw, image); | |
1484 | |
1485 if (lw->tools_float || lw->tools_hidden) | |
1486 { | |
1487 gtk_box_pack_start(GTK_BOX(lw->group_box), image, TRUE, TRUE, 0); | |
1488 gtk_widget_show(image); | |
1489 | |
1490 layout_tools_setup(lw, tools, files); | |
1491 | |
1492 gtk_widget_grab_focus(lw->image->widget); | |
1493 | |
1494 return; | |
1495 } | |
1496 else if (lw->tools) | |
1497 { | |
1498 layout_tools_geometry_sync(lw); | |
1499 gtk_widget_destroy(lw->tools); | |
1500 lw->tools = NULL; | |
1501 lw->tools_pane = NULL; | |
1502 } | |
1503 | |
1504 layout_status_setup(lw, lw->group_box, FALSE); | |
1505 | |
1506 layout_grid_compute(lw, image, tools, files, &w1, &w2, &w3); | |
1507 | |
1508 v = lw->v_pane = gtk_vpaned_new(); | |
1509 | |
1510 h = lw->h_pane = gtk_hpaned_new(); | |
1511 | |
1512 if (!layout_location_vertical(priority_location)) | |
1513 { | |
1514 GtkWidget *tmp; | |
1515 | |
1516 tmp = v; | |
1517 v = h; | |
1518 h = tmp; | |
1519 } | |
1520 | |
1521 gtk_box_pack_start(GTK_BOX(lw->group_box), v, TRUE, TRUE, 0); | |
1522 | |
1523 if (!layout_location_first(priority_location)) | |
1524 { | |
1525 gtk_paned_pack1(GTK_PANED(v), h, FALSE, TRUE); | |
1526 gtk_paned_pack2(GTK_PANED(v), w3, TRUE, TRUE); | |
1527 | |
1528 gtk_paned_pack1(GTK_PANED(h), w1, FALSE, TRUE); | |
1529 gtk_paned_pack2(GTK_PANED(h), w2, TRUE, TRUE); | |
1530 } | |
1531 else | |
1532 { | |
1533 gtk_paned_pack1(GTK_PANED(v), w1, FALSE, TRUE); | |
1534 gtk_paned_pack2(GTK_PANED(v), h, TRUE, TRUE); | |
1535 | |
1536 gtk_paned_pack1(GTK_PANED(h), w2, FALSE, TRUE); | |
1537 gtk_paned_pack2(GTK_PANED(h), w3, TRUE, TRUE); | |
1538 } | |
1539 | |
1540 gtk_widget_show(image); | |
1541 gtk_widget_show(tools); | |
1542 gtk_widget_show(files); | |
1543 | |
1544 gtk_widget_show(v); | |
1545 gtk_widget_show(h); | |
1546 | |
1547 /* fix to have image pane visible when it is left and priority widget */ | |
1548 if (lw->div_h == -1 && | |
1549 w1 == image && | |
1550 !layout_location_vertical(priority_location) && | |
1551 layout_location_first(priority_location)) | |
1552 { | |
1553 gtk_widget_set_size_request(image, 200, -1); | |
1554 } | |
1555 | |
1556 gtk_paned_set_position(GTK_PANED(lw->h_pane), lw->div_h); | |
1557 gtk_paned_set_position(GTK_PANED(lw->v_pane), lw->div_v); | |
1558 | |
1559 gtk_widget_grab_focus(lw->image->widget); | |
1560 } | |
1561 | |
1562 void layout_style_set(LayoutWindow *lw, gint style, const gchar *order) | |
1563 { | |
783 | 1564 FileData *dir_fd; |
127 | 1565 gint i; |
9 | 1566 |
1567 if (!layout_valid(&lw)) return; | |
1568 | |
1569 if (style != -1) | |
1570 { | |
1571 LayoutLocation d, f, i; | |
1572 | |
1573 layout_config_parse(style, order, &d, &f, &i); | |
1574 | |
1575 if (lw->dir_location == d && | |
1576 lw->file_location == f && | |
1577 lw->image_location == i) return; | |
1578 | |
1579 lw->dir_location = d; | |
1580 lw->file_location = f; | |
1581 lw->image_location = i; | |
1582 } | |
1583 | |
1584 /* remember state */ | |
1585 | |
1586 layout_image_slideshow_stop(lw); | |
1587 layout_image_full_screen_stop(lw); | |
1588 | |
783 | 1589 dir_fd = lw->dir_fd; |
791 | 1590 file_data_unregister_real_time_monitor(lw->dir_fd); |
783 | 1591 lw->dir_fd = NULL; |
9 | 1592 lw->image = NULL; |
1593 lw->utility_box = NULL; | |
1594 | |
1595 layout_geometry_get_dividers(lw, &lw->div_h, &lw->div_v); | |
1596 | |
1597 /* clear it all */ | |
1598 | |
268 | 1599 for (i = 0; i < MAX_SPLIT_IMAGES; i++) |
127 | 1600 { |
1601 if (lw->split_images[i]) | |
1602 { | |
1603 gtk_widget_hide(lw->split_images[i]->widget); | |
1604 gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); | |
1605 } | |
1606 } | |
9 | 1607 |
1608 lw->h_pane = NULL; | |
1609 lw->v_pane = NULL; | |
1610 | |
1611 lw->toolbar = NULL; | |
1612 lw->thumb_button = NULL; | |
1613 lw->path_entry = NULL; | |
1614 lw->dir_view = NULL; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
1615 lw->vd = NULL; |
9 | 1616 |
1617 lw->file_view = NULL; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1618 lw->vf = NULL; |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1619 lw->vf = NULL; |
9 | 1620 |
1621 lw->info_box = NULL; | |
1622 lw->info_progress_bar = NULL; | |
1623 lw->info_sort = NULL; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
1624 lw->info_color = NULL; |
9 | 1625 lw->info_status = NULL; |
1626 lw->info_details = NULL; | |
1627 lw->info_zoom = NULL; | |
1628 | |
1629 if (lw->ui_manager) g_object_unref(lw->ui_manager); | |
1630 lw->ui_manager = NULL; | |
1631 lw->action_group = NULL; | |
1632 | |
1633 gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box); | |
1634 lw->group_box = NULL; | |
1635 | |
1636 /* re-fill */ | |
1637 | |
1638 layout_grid_setup(lw); | |
1639 layout_tools_hide(lw, lw->tools_hidden); | |
1640 | |
1641 layout_list_sync_sort(lw); | |
1642 layout_util_sync(lw); | |
1643 layout_status_update_all(lw); | |
1644 | |
1645 /* sync */ | |
1646 | |
783 | 1647 if (image_get_fd(lw->image)) |
9 | 1648 { |
783 | 1649 layout_set_fd(lw, image_get_fd(lw->image)); |
9 | 1650 } |
1651 else | |
1652 { | |
783 | 1653 layout_set_fd(lw, dir_fd); |
9 | 1654 } |
1655 image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden)); | |
1656 | |
1657 /* clean up */ | |
1658 | |
783 | 1659 file_data_unref(dir_fd); |
9 | 1660 } |
1661 | |
1662 void layout_styles_update(void) | |
1663 { | |
1664 GList *work; | |
1665 | |
1666 work = layout_window_list; | |
1667 while (work) | |
1668 { | |
1669 LayoutWindow *lw = work->data; | |
1670 work = work->next; | |
1671 | |
327 | 1672 layout_style_set(lw, options->layout.style, options->layout.order); |
9 | 1673 } |
1674 } | |
1675 | |
1676 void layout_colors_update(void) | |
1677 { | |
1678 GList *work; | |
1679 | |
1680 work = layout_window_list; | |
1681 while (work) | |
1682 { | |
1683 LayoutWindow *lw = work->data; | |
1684 work = work->next; | |
442 | 1685 |
208
fa0e05f985c3
set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents:
196
diff
changeset
|
1686 if (!lw->image) continue; |
339
de1c2cd06fce
Rename user_specified_window_background and window_background_color
zas_
parents:
338
diff
changeset
|
1687 image_background_set_color(lw->image, options->image.use_custom_border_color ? &options->image.border_color : NULL); |
9 | 1688 } |
1689 } | |
1690 | |
1691 void layout_tools_float_toggle(LayoutWindow *lw) | |
1692 { | |
1693 gint popped; | |
1694 | |
1695 if (!lw) return; | |
1696 | |
1697 if (!lw->tools_hidden) | |
1698 { | |
1699 popped = !lw->tools_float; | |
1700 } | |
1701 else | |
1702 { | |
1703 popped = TRUE; | |
1704 } | |
1705 | |
1706 if (lw->tools_float == popped) | |
1707 { | |
1708 if (popped && lw->tools_hidden) | |
1709 { | |
1710 layout_tools_float_set(lw, popped, FALSE); | |
1711 } | |
1712 } | |
1713 else | |
1714 { | |
1715 if (lw->tools_float) | |
1716 { | |
1717 layout_tools_float_set(lw, FALSE, FALSE); | |
1718 } | |
1719 else | |
1720 { | |
1721 layout_tools_float_set(lw, TRUE, FALSE); | |
1722 } | |
1723 } | |
1724 } | |
1725 | |
1726 void layout_tools_hide_toggle(LayoutWindow *lw) | |
1727 { | |
1728 if (!lw) return; | |
1729 | |
1730 layout_tools_float_set(lw, lw->tools_float, !lw->tools_hidden); | |
1731 } | |
1732 | |
1733 void layout_tools_float_set(LayoutWindow *lw, gint popped, gint hidden) | |
1734 { | |
1735 if (!layout_valid(&lw)) return; | |
1736 | |
1737 if (lw->tools_float == popped && lw->tools_hidden == hidden) return; | |
1738 | |
1739 if (lw->tools_float == popped && lw->tools_float && lw->tools) | |
1740 { | |
1741 layout_tools_hide(lw, hidden); | |
1742 return; | |
1743 } | |
1744 | |
1745 lw->tools_float = popped; | |
1746 lw->tools_hidden = hidden; | |
1747 | |
1748 layout_style_set(lw, -1, NULL); | |
1749 } | |
1750 | |
1751 gint layout_tools_float_get(LayoutWindow *lw, gint *popped, gint *hidden) | |
1752 { | |
1753 if (!layout_valid(&lw)) return FALSE; | |
1754 | |
1755 *popped = lw->tools_float; | |
1756 *hidden = lw->tools_hidden; | |
1757 | |
1758 return TRUE; | |
1759 } | |
1760 | |
1761 void layout_toolbar_toggle(LayoutWindow *lw) | |
1762 { | |
1763 if (!layout_valid(&lw)) return; | |
1764 if (!lw->toolbar) return; | |
1765 | |
1766 lw->toolbar_hidden = !lw->toolbar_hidden; | |
1767 | |
1768 if (lw->toolbar_hidden) | |
1769 { | |
1770 if (GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_hide(lw->toolbar); | |
1771 } | |
1772 else | |
1773 { | |
1774 if (!GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_show(lw->toolbar); | |
1775 } | |
1776 } | |
1777 | |
1778 gint layout_toolbar_hidden(LayoutWindow *lw) | |
1779 { | |
1780 if (!layout_valid(&lw)) return TRUE; | |
1781 | |
1782 return lw->toolbar_hidden; | |
1783 } | |
1784 | |
1785 /* | |
1786 *----------------------------------------------------------------------------- | |
1787 * base | |
1788 *----------------------------------------------------------------------------- | |
1789 */ | |
1790 | |
1791 void layout_close(LayoutWindow *lw) | |
1792 { | |
1793 if (layout_window_list && layout_window_list->next) | |
1794 { | |
1795 layout_free(lw); | |
1796 } | |
1797 else | |
1798 { | |
278 | 1799 exit_program(); |
9 | 1800 } |
1801 } | |
1802 | |
1803 void layout_free(LayoutWindow *lw) | |
1804 { | |
1805 if (!lw) return; | |
1806 | |
1807 layout_window_list = g_list_remove(layout_window_list, lw); | |
1808 | |
791 | 1809 |
9 | 1810 layout_bars_close(lw); |
1811 | |
1812 gtk_widget_destroy(lw->window); | |
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
820
diff
changeset
|
1813 |
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
820
diff
changeset
|
1814 if (lw->split_image_sizegroup) g_object_unref(lw->split_image_sizegroup); |
442 | 1815 |
796 | 1816 file_data_unregister_notify_func(layout_image_notify_cb, lw); |
1817 | |
791 | 1818 if (lw->dir_fd) |
1819 { | |
1820 file_data_unregister_real_time_monitor(lw->dir_fd); | |
1821 file_data_unref(lw->dir_fd); | |
1822 } | |
9 | 1823 |
1824 g_free(lw); | |
1825 } | |
1826 | |
1827 static gint layout_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
1828 { | |
1829 LayoutWindow *lw = data; | |
1830 | |
1831 layout_close(lw); | |
1832 return TRUE; | |
1833 } | |
1834 | |
783 | 1835 LayoutWindow *layout_new(FileData *dir_fd, gint popped, gint hidden) |
9 | 1836 { |
783 | 1837 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
|
1838 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1839 |
783 | 1840 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
|
1841 const gchar *geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1842 { |
9 | 1843 LayoutWindow *lw; |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1844 GdkGeometry hint; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1845 GdkWindowHints hint_mask; |
9 | 1846 |
1847 lw = g_new0(LayoutWindow, 1); | |
1848 | |
340
77103f3f2cb1
Rename option thumbnails.enabled to layout.show_thumbnails as it makes
zas_
parents:
339
diff
changeset
|
1849 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
|
1850 lw->marks_enabled = options->layout.show_marks; |
9 | 1851 lw->sort_method = SORT_NAME; |
1852 lw->sort_ascend = TRUE; | |
1853 | |
1854 lw->tools_float = popped; | |
1855 lw->tools_hidden = hidden; | |
1856 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1857 lw->toolbar_hidden = options->layout.toolbar_hidden; |
9 | 1858 |
1859 lw->utility_box = NULL; | |
1860 lw->bar_sort = NULL; | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
482
diff
changeset
|
1861 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
|
1862 |
9 | 1863 lw->bar_exif = NULL; |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
482
diff
changeset
|
1864 lw->bar_exif_enabled = options->panels.exif.enabled; |
9 | 1865 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
|
1866 |
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
482
diff
changeset
|
1867 lw->bar_info = NULL; |
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
482
diff
changeset
|
1868 lw->bar_info_enabled = options->panels.info.enabled; |
9 | 1869 |
1870 /* default layout */ | |
1871 | |
327 | 1872 layout_config_parse(options->layout.style, options->layout.order, |
9 | 1873 &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
|
1874 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
|
1875 lw->file_view_type = CLAMP(options->layout.file_view_type, 0, VIEW_FILE_TYPES_COUNT - 1); |
9 | 1876 |
1877 /* divider positions */ | |
1878 | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1879 if (options->layout.save_window_positions) |
9 | 1880 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1881 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
|
1882 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
|
1883 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
|
1884 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
|
1885 lw->bar_info_width = options->panels.info.width; |
9 | 1886 } |
1887 else | |
1888 { | |
1889 lw->div_h = MAIN_WINDOW_DIV_HPOS; | |
1890 lw->div_v = MAIN_WINDOW_DIV_VPOS; | |
1891 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
|
1892 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
|
1893 lw->bar_info_width = PANEL_DEFAULT_WIDTH; |
9 | 1894 } |
1895 | |
1896 /* window */ | |
1897 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
1898 lw->window = window_new(GTK_WINDOW_TOPLEVEL, GQ_WMCLASS, NULL, NULL, NULL); |
9 | 1899 gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE); |
1900 gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0); | |
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 { |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1904 hint_mask = GDK_HINT_USER_POS; |
9 | 1905 } |
1906 else | |
1907 { | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1908 hint_mask = 0; |
9 | 1909 } |
1910 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1911 hint.min_width = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1912 hint.min_height = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1913 hint.base_width = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1914 hint.base_height = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1915 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
|
1916 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hint_mask); |
9 | 1917 |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1918 if (options->layout.save_window_positions) |
9 | 1919 { |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1920 gtk_window_set_default_size(GTK_WINDOW(lw->window), options->layout.main_window.w, options->layout.main_window.h); |
9 | 1921 if (!layout_window_list) |
1922 { | |
338
41c3cb73120f
Rename window options (moved to layout) and re-order rc file.
zas_
parents:
333
diff
changeset
|
1923 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
|
1924 if (options->layout.main_window.maximized) gtk_window_maximize(GTK_WINDOW(lw->window)); |
9 | 1925 } |
1926 } | |
1927 else | |
1928 { | |
1929 gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT); | |
1930 } | |
1931 | |
1932 g_signal_connect(G_OBJECT(lw->window), "delete_event", | |
1933 G_CALLBACK(layout_delete_cb), lw); | |
1934 | |
1935 layout_keyboard_init(lw, lw->window); | |
1936 | |
528 | 1937 #ifdef HAVE_LIRC |
1938 layout_image_lirc_init(lw); | |
1939 #endif | |
1940 | |
9 | 1941 lw->main_box = gtk_vbox_new(FALSE, 0); |
1942 gtk_container_add(GTK_CONTAINER(lw->window), lw->main_box); | |
1943 gtk_widget_show(lw->main_box); | |
1944 | |
1945 layout_grid_setup(lw); | |
1946 image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden)); | |
1947 | |
1948 layout_util_sync(lw); | |
1949 layout_status_update_all(lw); | |
1950 | |
783 | 1951 if (dir_fd) |
9 | 1952 { |
783 | 1953 layout_set_fd(lw, dir_fd); |
9 | 1954 } |
1955 else | |
1956 { | |
1957 GdkPixbuf *pixbuf; | |
1958 | |
1959 pixbuf = pixbuf_inline(PIXBUF_INLINE_LOGO); | |
1960 image_change_pixbuf(lw->image, pixbuf, 1.0); | |
1961 gdk_pixbuf_unref(pixbuf); | |
1962 } | |
1963 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1964 if (geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1965 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1966 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
|
1967 { |
694 | 1968 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
|
1969 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1970 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
1971 |
9 | 1972 gtk_widget_show(lw->window); |
1973 layout_tools_hide(lw, lw->tools_hidden); | |
1974 | |
1975 layout_window_list = g_list_append(layout_window_list, lw); | |
1976 | |
796 | 1977 file_data_register_notify_func(layout_image_notify_cb, lw, NOTIFY_PRIORITY_LOW); |
1978 | |
9 | 1979 return lw; |
1980 } | |
1981 |