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