Mercurial > geeqie
annotate src/layout.c @ 1549:7302ff300a52
show color management status on statusbar
author | nadvornik |
---|---|
date | Mon, 13 Apr 2009 14:39:50 +0000 |
parents | 2a3efbdf73b0 |
children | e6da3a90e7b2 |
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 |
1284 | 4 * Copyright (C) 2008 - 2009 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" |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1177
diff
changeset
|
35 #include "metadata.h" |
1309 | 36 #include "rcfile.h" |
37 #include "bar.h" | |
1320 | 38 #include "bar_sort.h" |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
39 #include "preferences.h" |
648
e34c1002e553
Move some functions from main.[ch] to new window.[ch].
zas_
parents:
632
diff
changeset
|
40 |
528 | 41 #ifdef HAVE_LIRC |
42 #include "lirc.h" | |
43 #endif | |
9 | 44 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
45 #define MAINWINDOW_DEF_WIDTH 700 |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
46 #define MAINWINDOW_DEF_HEIGHT 500 |
9 | 47 |
553
32cf2e7992fd
Change default positions of dividers since width of the main menu
zas_
parents:
531
diff
changeset
|
48 #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
|
49 #define MAIN_WINDOW_DIV_VPOS (MAINWINDOW_DEF_HEIGHT / 2) |
9 | 50 |
51 #define TOOLWINDOW_DEF_WIDTH 260 | |
52 #define TOOLWINDOW_DEF_HEIGHT 450 | |
553
32cf2e7992fd
Change default positions of dividers since width of the main menu
zas_
parents:
531
diff
changeset
|
53 |
9 | 54 #define PROGRESS_WIDTH 150 |
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
55 #define PIXEL_LABEL_WIDTH 130 |
9 | 56 #define ZOOM_LABEL_WIDTH 64 |
57 | |
58 #define PANE_DIVIDER_SIZE 10 | |
59 | |
60 | |
61 GList *layout_window_list = NULL; | |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
62 LayoutWindow *current_lw = NULL; |
9 | 63 |
64 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle); | |
65 | |
66 | |
67 /* | |
68 *----------------------------------------------------------------------------- | |
69 * misc | |
70 *----------------------------------------------------------------------------- | |
71 */ | |
72 | |
1416 | 73 gboolean layout_valid(LayoutWindow **lw) |
9 | 74 { |
75 if (*lw == NULL) | |
76 { | |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
77 if (current_lw) *lw = current_lw; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
78 else if (layout_window_list) *lw = layout_window_list->data; |
9 | 79 return (*lw != NULL); |
80 } | |
81 return (g_list_find(layout_window_list, *lw) != NULL); | |
82 } | |
83 | |
84 LayoutWindow *layout_find_by_image(ImageWindow *imd) | |
85 { | |
86 GList *work; | |
87 | |
88 work = layout_window_list; | |
89 while (work) | |
90 { | |
91 LayoutWindow *lw = work->data; | |
92 work = work->next; | |
93 | |
94 if (lw->image == imd) return lw; | |
95 } | |
96 | |
97 return NULL; | |
98 } | |
99 | |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
100 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
|
101 { |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
102 GList *work; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
103 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
104 work = layout_window_list; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
105 while (work) |
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 LayoutWindow *lw = work->data; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
108 work = work->next; |
1372 | 109 |
368
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
110 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
|
111 return lw; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
112 } |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
113 |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
114 return NULL; |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
115 } |
95fe470440ad
New Go to directory view feature that permits to find and display the directory
zas_
parents:
340
diff
changeset
|
116 |
1466
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
117 LayoutWindow *layout_find_by_layout_id(const gchar *id) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
118 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
119 GList *work; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
120 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
121 if (!id || !id[0]) return NULL; |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
122 |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
123 if (strcmp(id, LAYOUT_ID_CURRENT) == 0) |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
124 { |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
125 if (current_lw) return current_lw; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
126 if (layout_window_list) return layout_window_list->data; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
127 return NULL; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
128 } |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
129 |
1466
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
130 work = layout_window_list; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
131 while (work) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
132 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
133 LayoutWindow *lw = work->data; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
134 work = work->next; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
135 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
136 if (lw->options.id && strcmp(id, lw->options.id) == 0) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
137 return lw; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
138 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
139 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
140 return NULL; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
141 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
142 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
143 static void layout_set_unique_id(LayoutWindow *lw) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
144 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
145 char id[10]; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
146 gint i; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
147 if (lw->options.id && lw->options.id[0]) return; /* id is already set */ |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
148 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
149 g_free(lw->options.id); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
150 lw->options.id = NULL; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
151 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
152 if (!layout_find_by_layout_id("main")) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
153 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
154 lw->options.id = g_strdup("main"); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
155 return; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
156 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
157 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
158 i = 1; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
159 while (TRUE) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
160 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
161 g_snprintf(id, sizeof(id), "lw%d", i); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
162 if (!layout_find_by_layout_id(id)) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
163 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
164 lw->options.id = g_strdup(id); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
165 return; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
166 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
167 i++; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
168 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
169 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
170 |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
171 static gboolean layout_set_current_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
172 { |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
173 LayoutWindow *lw = data; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
174 current_lw = lw; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
175 return FALSE; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
176 } |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
177 |
9 | 178 /* |
179 *----------------------------------------------------------------------------- | |
180 * menu, toolbar, and dir view | |
181 *----------------------------------------------------------------------------- | |
182 */ | |
183 | |
184 static void layout_path_entry_changed_cb(GtkWidget *widget, gpointer data) | |
185 { | |
186 LayoutWindow *lw = data; | |
187 gchar *buf; | |
188 | |
189 if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) < 0) return; | |
190 | |
191 buf = g_strdup(gtk_entry_get_text(GTK_ENTRY(lw->path_entry))); | |
1372 | 192 if (!lw->dir_fd || strcmp(buf, lw->dir_fd->path) != 0) |
9 | 193 { |
1372 | 194 layout_set_path(lw, buf); |
9 | 195 } |
196 | |
442 | 197 g_free(buf); |
9 | 198 } |
199 | |
200 static void layout_path_entry_tab_cb(const gchar *path, gpointer data) | |
201 { | |
202 LayoutWindow *lw = data; | |
203 gchar *buf; | |
204 | |
205 buf = g_strdup(path); | |
206 parse_out_relatives(buf); | |
1372 | 207 |
9 | 208 if (isdir(buf)) |
209 { | |
783 | 210 if ((!lw->dir_fd || strcmp(lw->dir_fd->path, buf) != 0) && layout_set_path(lw, buf)) |
9 | 211 { |
212 gint pos = -1; | |
726 | 213 /* put the G_DIR_SEPARATOR back, if we are in tab completion for a dir and result was path change */ |
725 | 214 gtk_editable_insert_text(GTK_EDITABLE(lw->path_entry), G_DIR_SEPARATOR_S, -1, &pos); |
9 | 215 gtk_editable_set_position(GTK_EDITABLE(lw->path_entry), |
216 strlen(gtk_entry_get_text(GTK_ENTRY(lw->path_entry)))); | |
217 } | |
218 } | |
1372 | 219 else if (lw->dir_fd) |
9 | 220 { |
1372 | 221 gchar *base = remove_level_from_path(buf); |
222 | |
223 if (strcmp(lw->dir_fd->path, base) == 0) | |
224 { | |
225 layout_list_scroll_to_subpart(lw, filename_from_path(buf)); | |
226 } | |
227 g_free(base); | |
9 | 228 } |
1372 | 229 |
9 | 230 g_free(buf); |
231 } | |
232 | |
233 static void layout_path_entry_cb(const gchar *path, gpointer data) | |
234 { | |
235 LayoutWindow *lw = data; | |
236 gchar *buf; | |
237 | |
238 buf = g_strdup(path); | |
239 parse_out_relatives(buf); | |
240 | |
241 layout_set_path(lw, buf); | |
242 | |
243 g_free(buf); | |
244 } | |
245 | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
246 static void layout_vd_select_cb(ViewDir *vd, const gchar *path, gpointer data) |
9 | 247 { |
248 LayoutWindow *lw = data; | |
249 | |
250 layout_set_path(lw, path); | |
251 } | |
252 | |
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
|
253 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
|
254 { |
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
|
255 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
|
256 |
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
|
257 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
|
258 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
|
259 |
1372 | 260 /* Enable back button if it makes sense */ |
261 gtk_widget_set_sensitive(lw->back_button, (n > 1)); | |
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
|
262 } |
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
|
263 |
9 | 264 static GtkWidget *layout_tool_setup(LayoutWindow *lw) |
265 { | |
266 GtkWidget *box; | |
267 GtkWidget *menu_bar; | |
268 GtkWidget *tabcomp; | |
269 | |
270 box = gtk_vbox_new(FALSE, 0); | |
271 | |
272 menu_bar = layout_actions_menu_bar(lw); | |
273 gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0); | |
274 gtk_widget_show(menu_bar); | |
275 | |
1470 | 276 layout_actions_toolbar(lw); |
9 | 277 gtk_box_pack_start(GTK_BOX(box), lw->toolbar, FALSE, FALSE, 0); |
1309 | 278 if (!lw->options.toolbar_hidden) gtk_widget_show(lw->toolbar); |
9 | 279 |
280 tabcomp = tab_completion_new_with_history(&lw->path_entry, NULL, "path_list", -1, | |
281 layout_path_entry_cb, lw); | |
282 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
|
283 tab_completion_add_append_func(lw->path_entry, layout_path_entry_tab_append_cb, lw); |
9 | 284 gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0); |
285 gtk_widget_show(tabcomp); | |
286 | |
287 g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed", | |
288 G_CALLBACK(layout_path_entry_changed_cb), lw); | |
289 | |
1309 | 290 lw->vd = vd_new(lw->options.dir_view_type, lw->dir_fd); |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
291 vd_set_layout(lw->vd, lw); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
292 vd_set_select_func(lw->vd, layout_vd_select_cb, lw); |
9 | 293 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
294 lw->dir_view = lw->vd->widget; |
9 | 295 |
296 gtk_box_pack_start(GTK_BOX(box), lw->dir_view, TRUE, TRUE, 0); | |
297 gtk_widget_show(lw->dir_view); | |
298 | |
299 gtk_widget_show(box); | |
300 | |
301 return box; | |
302 } | |
303 | |
304 /* | |
305 *----------------------------------------------------------------------------- | |
306 * sort button (and menu) | |
307 *----------------------------------------------------------------------------- | |
308 */ | |
309 | |
310 static void layout_sort_menu_cb(GtkWidget *widget, gpointer data) | |
311 { | |
312 LayoutWindow *lw; | |
313 SortType type; | |
314 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
315 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
|
316 |
9 | 317 lw = submenu_item_get_data(widget); |
318 if (!lw) return; | |
319 | |
320 type = (SortType)GPOINTER_TO_INT(data); | |
321 | |
322 layout_sort_set(lw, type, lw->sort_ascend); | |
323 } | |
324 | |
325 static void layout_sort_menu_ascend_cb(GtkWidget *widget, gpointer data) | |
326 { | |
327 LayoutWindow *lw = data; | |
328 | |
329 layout_sort_set(lw, lw->sort_method, !lw->sort_ascend); | |
330 } | |
331 | |
332 static void layout_sort_menu_hide_cb(GtkWidget *widget, gpointer data) | |
333 { | |
334 /* destroy the menu */ | |
1043 | 335 #if GTK_CHECK_VERSION(2,12,0) |
336 g_object_unref(widget); | |
337 #else | |
9 | 338 gtk_widget_unref(GTK_WIDGET(widget)); |
1043 | 339 #endif |
9 | 340 } |
341 | |
342 static void layout_sort_button_press_cb(GtkWidget *widget, gpointer data) | |
343 { | |
344 LayoutWindow *lw = data; | |
345 GtkWidget *menu; | |
346 GdkEvent *event; | |
347 guint32 etime; | |
348 | |
349 menu = submenu_add_sort(NULL, G_CALLBACK(layout_sort_menu_cb), lw, FALSE, FALSE, TRUE, lw->sort_method); | |
350 | |
88
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
351 /* take ownership of menu */ |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
352 #ifdef GTK_OBJECT_FLOATING |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
353 /* GTK+ < 2.10 */ |
9 | 354 g_object_ref(G_OBJECT(menu)); |
355 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
|
356 #else |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
357 /* GTK+ >= 2.10 */ |
2099ee3f9a8d
Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents:
81
diff
changeset
|
358 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
|
359 #endif |
9 | 360 |
442 | 361 /* ascending option */ |
9 | 362 menu_item_add_divider(menu); |
363 menu_item_add_check(menu, _("Ascending"), lw->sort_ascend, G_CALLBACK(layout_sort_menu_ascend_cb), lw); | |
364 | |
365 g_signal_connect(G_OBJECT(menu), "selection_done", | |
366 G_CALLBACK(layout_sort_menu_hide_cb), NULL); | |
367 | |
368 event = gtk_get_current_event(); | |
369 if (event) | |
370 { | |
371 etime = gdk_event_get_time(event); | |
372 gdk_event_free(event); | |
373 } | |
374 else | |
375 { | |
376 etime = 0; | |
377 } | |
378 | |
379 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, etime); | |
380 } | |
381 | |
382 static GtkWidget *layout_sort_button(LayoutWindow *lw) | |
383 { | |
384 GtkWidget *button; | |
385 | |
386 button = gtk_button_new_with_label(sort_type_get_text(lw->sort_method)); | |
442 | 387 g_signal_connect(G_OBJECT(button), "clicked", |
9 | 388 G_CALLBACK(layout_sort_button_press_cb), lw); |
442 | 389 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9 | 390 |
442 | 391 return button; |
9 | 392 } |
393 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
394 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
|
395 { |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
396 GtkWidget *button; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
397 GtkWidget *image; |
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 button = gtk_button_new(); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
400 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
|
401 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
|
402 gtk_widget_show(image); |
268 | 403 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
|
404 |
1549 | 405 gtk_widget_set_sensitive(GTK_BIN(button)->child, FALSE); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
406 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
407 return button; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
408 } |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
409 /* |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
410 *----------------------------------------------------------------------------- |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
411 * write button |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
412 *----------------------------------------------------------------------------- |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
413 */ |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
414 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
415 static void layout_write_button_press_cb(GtkWidget *widget, gpointer data) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
416 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
417 metadata_write_queue_confirm(NULL, NULL); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
418 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
419 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
420 static GtkWidget *layout_write_button(LayoutWindow *lw) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
421 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
422 GtkWidget *button; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
423 GtkWidget *image; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
424 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
425 button = gtk_button_new(); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
426 image = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
427 gtk_container_add(GTK_CONTAINER(button), image); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
428 gtk_widget_show(image); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
429 g_signal_connect(G_OBJECT(button), "clicked", |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
430 G_CALLBACK(layout_write_button_press_cb), lw); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
431 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
432 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
433 gtk_widget_set_sensitive(button, metadata_queue_length() > 0); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
434 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
435 return button; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
436 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
437 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
438 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
439 /* |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
440 *----------------------------------------------------------------------------- |
9 | 441 * status bar |
442 *----------------------------------------------------------------------------- | |
443 */ | |
444 | |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
445 void layout_status_update_write(LayoutWindow *lw) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
446 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
447 if (!layout_valid(&lw)) return; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
448 if (!lw->info_write) return; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
449 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
450 gtk_widget_set_sensitive(lw->info_write, metadata_queue_length() > 0); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
451 /* FIXME: maybe show also the number of files */ |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
452 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
453 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
454 void layout_status_update_write_all(void) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
455 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
456 GList *work; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
457 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
458 work = layout_window_list; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
459 while (work) |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
460 { |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
461 LayoutWindow *lw = work->data; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
462 work = work->next; |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
463 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
464 layout_status_update_write(lw); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
465 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
466 } |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
467 |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
468 |
9 | 469 void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text) |
470 { | |
471 if (!layout_valid(&lw)) return; | |
472 if (!lw->info_progress_bar) return; | |
473 | |
474 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(lw->info_progress_bar), val); | |
475 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(lw->info_progress_bar), (text) ? text : " "); | |
476 } | |
477 | |
478 void layout_status_update_info(LayoutWindow *lw, const gchar *text) | |
479 { | |
480 gchar *buf = NULL; | |
481 | |
482 if (!layout_valid(&lw)) return; | |
483 | |
484 if (!text) | |
485 { | |
736 | 486 guint n; |
9 | 487 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
|
488 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
489 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
|
490 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
491 if (n) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
492 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
493 guint s; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
494 gint64 s_bytes = 0; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
495 const gchar *ss; |
9 | 496 |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
497 if (layout_image_slideshow_active(lw)) |
9 | 498 { |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
499 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
|
500 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
501 ss = _(" Slideshow"); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
502 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
503 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
504 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
505 ss = _(" Paused"); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
506 } |
9 | 507 } |
508 else | |
509 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
510 ss = ""; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
511 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
512 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
513 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
|
514 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
515 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
|
516 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
517 if (s > 0) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
518 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
519 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
|
520 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
|
521 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
|
522 g_free(b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
523 g_free(sb); |
9 | 524 } |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
525 else if (n > 0) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
526 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
527 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
|
528 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
|
529 g_free(b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
530 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
531 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
532 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
533 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
|
534 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
535 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
536 text = buf; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
537 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
538 image_osd_update(lw->image); |
9 | 539 } |
540 else | |
541 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
542 text = ""; |
9 | 543 } |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
544 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
545 |
583
de3e2bc22336
Revert patch 675, and correctly fix gtk assertion failure.
zas_
parents:
574
diff
changeset
|
546 if (lw->info_status) gtk_label_set_text(GTK_LABEL(lw->info_status), text); |
9 | 547 g_free(buf); |
548 } | |
549 | |
550 void layout_status_update_image(LayoutWindow *lw) | |
551 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
552 guint64 n; |
1549 | 553 gchar *image_profile; |
554 gchar *screen_profile; | |
555 | |
9 | 556 if (!layout_valid(&lw) || !lw->image) return; |
557 | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
558 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
|
559 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
560 if (!n) |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
561 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
562 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
|
563 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
|
564 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
565 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
566 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
567 gchar *text; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
568 gchar *b; |
9 | 569 |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
570 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
|
571 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
|
572 g_free(text); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
573 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
574 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
|
575 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
576 if (lw->image->unknown) |
9 | 577 { |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
578 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
|
579 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
580 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
|
581 } |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
582 else |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
583 { |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
584 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
|
585 } |
9 | 586 } |
587 else | |
588 { | |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
589 gint width, height; |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
590 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
591 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
|
592 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
|
593 width, height, b); |
9 | 594 } |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
595 |
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
596 g_signal_emit_by_name (lw->image->pr, "update-pixel"); |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
597 |
984
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
598 g_free(b); |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
599 |
bc73dc055cd0
Only display status if there is at least one file in the file list.
zas_
parents:
960
diff
changeset
|
600 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
|
601 g_free(text); |
9 | 602 } |
1549 | 603 |
604 if (layout_image_color_profile_get_status(lw, &image_profile, &screen_profile)) | |
605 { | |
606 gchar *buf; | |
607 gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, TRUE); | |
608 buf = g_strdup_printf(_("Image profile: %s\nScreen profile: %s"), image_profile, screen_profile); | |
609 /* FIXME: not sure if a tooltip is the best form of presentation */ | |
610 gtk_widget_set_tooltip_text(GTK_WIDGET(lw->info_color), buf); | |
611 g_free(image_profile); | |
612 g_free(screen_profile); | |
613 g_free(buf); | |
614 } | |
615 else | |
616 { | |
617 gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, FALSE); | |
618 gtk_widget_set_tooltip_text(GTK_WIDGET(lw->info_color), NULL); | |
619 } | |
9 | 620 } |
621 | |
622 void layout_status_update_all(LayoutWindow *lw) | |
623 { | |
624 layout_status_update_progress(lw, 0.0, NULL); | |
625 layout_status_update_info(lw, NULL); | |
626 layout_status_update_image(lw); | |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
627 layout_status_update_write(lw); |
9 | 628 } |
629 | |
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1431
diff
changeset
|
630 static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand) |
9 | 631 { |
632 GtkWidget *label; | |
633 GtkWidget *frame; | |
634 | |
635 frame = gtk_frame_new(NULL); | |
636 if (size) gtk_widget_set_size_request(frame, size, -1); | |
637 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
638 if (start) | |
639 { | |
640 gtk_box_pack_start(GTK_BOX(box), frame, expand, expand, 0); | |
641 } | |
642 else | |
643 { | |
644 gtk_box_pack_end(GTK_BOX(box), frame, expand, expand, 0); | |
645 } | |
646 gtk_widget_show(frame); | |
647 | |
648 label = gtk_label_new(text ? text : ""); | |
649 gtk_container_add(GTK_CONTAINER(frame), label); | |
650 gtk_widget_show(label); | |
651 | |
652 return label; | |
653 } | |
654 | |
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1431
diff
changeset
|
655 static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small_format) |
9 | 656 { |
657 GtkWidget *hbox; | |
658 | |
659 if (lw->info_box) return; | |
660 | |
661 if (small_format) | |
662 { | |
663 lw->info_box = gtk_vbox_new(FALSE, 0); | |
664 } | |
665 else | |
666 { | |
667 lw->info_box = gtk_hbox_new(FALSE, 0); | |
668 } | |
669 gtk_box_pack_end(GTK_BOX(box), lw->info_box, FALSE, FALSE, 0); | |
670 gtk_widget_show(lw->info_box); | |
671 | |
672 if (small_format) | |
673 { | |
674 hbox = gtk_hbox_new(FALSE, 0); | |
675 gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0); | |
676 gtk_widget_show(hbox); | |
677 } | |
678 else | |
679 { | |
680 hbox = lw->info_box; | |
681 } | |
682 lw->info_progress_bar = gtk_progress_bar_new(); | |
683 gtk_widget_set_size_request(lw->info_progress_bar, PROGRESS_WIDTH, -1); | |
684 gtk_box_pack_start(GTK_BOX(hbox), lw->info_progress_bar, FALSE, FALSE, 0); | |
685 gtk_widget_show(lw->info_progress_bar); | |
686 | |
687 lw->info_sort = layout_sort_button(lw); | |
688 gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0); | |
689 gtk_widget_show(lw->info_sort); | |
690 | |
1549 | 691 lw->info_color = layout_color_button(lw); |
692 gtk_widget_show(lw->info_color); | |
693 | |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
694 lw->info_write = layout_write_button(lw); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
695 gtk_widget_show(lw->info_write); |
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
696 |
1549 | 697 if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
698 if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
91
diff
changeset
|
699 |
9 | 700 lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format)); |
701 | |
702 if (small_format) | |
703 { | |
704 hbox = gtk_hbox_new(FALSE, 0); | |
705 gtk_box_pack_start(GTK_BOX(lw->info_box), hbox, FALSE, FALSE, 0); | |
706 gtk_widget_show(hbox); | |
707 } | |
708 else | |
709 { | |
710 hbox = lw->info_box; | |
711 } | |
712 lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE); | |
1549 | 713 if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); |
1240
30e207ac22e4
added a status bar button for writting metadata immediately
nadvornik
parents:
1231
diff
changeset
|
714 if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); |
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
715 lw->info_pixel = layout_status_label(NULL, hbox, FALSE, PIXEL_LABEL_WIDTH, TRUE); |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
716 if (lw->options.info_pixel_hidden) gtk_widget_hide(gtk_widget_get_parent(lw->info_pixel)); |
9 | 717 lw->info_zoom = layout_status_label(NULL, hbox, FALSE, ZOOM_LABEL_WIDTH, FALSE); |
718 } | |
719 | |
720 /* | |
721 *----------------------------------------------------------------------------- | |
722 * views | |
723 *----------------------------------------------------------------------------- | |
724 */ | |
725 | |
726 static GtkWidget *layout_tools_new(LayoutWindow *lw) | |
727 { | |
728 lw->dir_view = layout_tool_setup(lw); | |
729 return lw->dir_view; | |
730 } | |
731 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
732 static void layout_list_status_cb(ViewFile *vf, gpointer data) |
9 | 733 { |
734 LayoutWindow *lw = data; | |
735 | |
736 layout_status_update_info(lw, NULL); | |
737 } | |
738 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
739 static void layout_list_thumb_cb(ViewFile *vf, gdouble val, const gchar *text, gpointer data) |
9 | 740 { |
741 LayoutWindow *lw = data; | |
742 | |
743 layout_status_update_progress(lw, val, text); | |
744 } | |
745 | |
1506
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
746 static void layout_list_sync_thumb(LayoutWindow *lw) |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
747 { |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
748 if (lw->vf) vf_thumb_set(lw->vf, lw->options.show_thumbnails); |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
749 } |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
750 |
9 | 751 static GtkWidget *layout_list_new(LayoutWindow *lw) |
752 { | |
1412 | 753 lw->vf = vf_new(lw->options.file_view_type, NULL); |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
754 vf_set_layout(lw->vf, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
755 |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
756 vf_set_status_func(lw->vf, layout_list_status_cb, lw); |
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
757 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
|
758 |
1309 | 759 vf_marks_set(lw->vf, lw->options.show_marks); |
1506
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
760 |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
761 layout_list_sync_thumb(lw); |
442 | 762 |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
763 return lw->vf->widget; |
9 | 764 } |
765 | |
132 | 766 static void layout_list_sync_marks(LayoutWindow *lw) |
767 { | |
1309 | 768 if (lw->vf) vf_marks_set(lw->vf, lw->options.show_marks); |
132 | 769 } |
770 | |
9 | 771 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle) |
772 { | |
773 if (!lw) return; | |
774 #if 0 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
775 if (lw->vf) vf_scroll_to_subpart(lw->vf, needle); |
9 | 776 #endif |
777 } | |
778 | |
779 GList *layout_list(LayoutWindow *lw) | |
780 { | |
781 if (!layout_valid(&lw)) return NULL; | |
782 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
783 if (lw->vf) return vf_get_list(lw->vf); |
9 | 784 |
785 return NULL; | |
786 } | |
787 | |
736 | 788 guint layout_list_count(LayoutWindow *lw, gint64 *bytes) |
9 | 789 { |
790 if (!layout_valid(&lw)) return 0; | |
791 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
792 if (lw->vf) return vf_count(lw->vf, bytes); |
9 | 793 |
794 return 0; | |
795 } | |
796 | |
138 | 797 FileData *layout_list_get_fd(LayoutWindow *lw, gint index) |
798 { | |
799 if (!layout_valid(&lw)) return NULL; | |
800 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
801 if (lw->vf) return vf_index_get_data(lw->vf, index); |
138 | 802 |
803 return NULL; | |
804 } | |
805 | |
783 | 806 gint layout_list_get_index(LayoutWindow *lw, FileData *fd) |
9 | 807 { |
783 | 808 if (!layout_valid(&lw) || !fd) return -1; |
9 | 809 |
1503 | 810 if (lw->vf) return vf_index_by_fd(lw->vf, fd); |
9 | 811 |
812 return -1; | |
813 } | |
814 | |
138 | 815 void layout_list_sync_fd(LayoutWindow *lw, FileData *fd) |
9 | 816 { |
817 if (!layout_valid(&lw)) return; | |
818 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
819 if (lw->vf) vf_select_by_fd(lw->vf, fd); |
9 | 820 } |
821 | |
822 static void layout_list_sync_sort(LayoutWindow *lw) | |
823 { | |
824 if (!layout_valid(&lw)) return; | |
825 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
826 if (lw->vf) vf_sort_set(lw->vf, lw->sort_method, lw->sort_ascend); |
9 | 827 } |
828 | |
829 GList *layout_selection_list(LayoutWindow *lw) | |
830 { | |
831 if (!layout_valid(&lw)) return NULL; | |
832 | |
833 if (layout_image_get_collection(lw, NULL)) | |
834 { | |
138 | 835 FileData *fd; |
9 | 836 |
138 | 837 fd = layout_image_get_fd(lw); |
838 if (fd) return g_list_append(NULL, file_data_ref(fd)); | |
9 | 839 return NULL; |
840 } | |
841 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
842 if (lw->vf) return vf_selection_get_list(lw->vf); |
9 | 843 |
844 return NULL; | |
845 } | |
846 | |
847 GList *layout_selection_list_by_index(LayoutWindow *lw) | |
848 { | |
849 if (!layout_valid(&lw)) return NULL; | |
850 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
851 if (lw->vf) return vf_selection_get_list_by_index(lw->vf); |
9 | 852 |
853 return NULL; | |
854 } | |
855 | |
736 | 856 guint layout_selection_count(LayoutWindow *lw, gint64 *bytes) |
9 | 857 { |
858 if (!layout_valid(&lw)) return 0; | |
859 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
860 if (lw->vf) return vf_selection_count(lw->vf, bytes); |
9 | 861 |
862 return 0; | |
863 } | |
864 | |
865 void layout_select_all(LayoutWindow *lw) | |
866 { | |
867 if (!layout_valid(&lw)) return; | |
868 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
869 if (lw->vf) vf_select_all(lw->vf); |
9 | 870 } |
871 | |
872 void layout_select_none(LayoutWindow *lw) | |
873 { | |
874 if (!layout_valid(&lw)) return; | |
875 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
876 if (lw->vf) vf_select_none(lw->vf); |
9 | 877 } |
878 | |
601 | 879 void layout_select_invert(LayoutWindow *lw) |
880 { | |
881 if (!layout_valid(&lw)) return; | |
882 | |
883 if (lw->vf) vf_select_invert(lw->vf); | |
884 } | |
885 | |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
886 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
|
887 { |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
888 if (!layout_valid(&lw)) return; |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
889 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
890 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
|
891 } |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
892 |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
893 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
|
894 { |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
895 if (!layout_valid(&lw)) return; |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
896 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
897 if (lw->vf) vf_selection_to_mark(lw->vf, mark, mode); |
442 | 898 |
162
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
899 layout_status_update_info(lw, NULL); /* osd in fullscreen mode */ |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
900 } |
1a42a2451575
created menu "Select" with selection and marks operations
nadvornik
parents:
138
diff
changeset
|
901 |
9 | 902 /* |
903 *----------------------------------------------------------------------------- | |
904 * access | |
905 *----------------------------------------------------------------------------- | |
906 */ | |
907 | |
908 const gchar *layout_get_path(LayoutWindow *lw) | |
909 { | |
910 if (!layout_valid(&lw)) return NULL; | |
783 | 911 return lw->dir_fd ? lw->dir_fd->path : NULL; |
9 | 912 } |
913 | |
914 static void layout_sync_path(LayoutWindow *lw) | |
915 { | |
783 | 916 if (!lw->dir_fd) return; |
9 | 917 |
783 | 918 if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path); |
1372 | 919 |
783 | 920 if (lw->vd) vd_set_fd(lw->vd, lw->dir_fd); |
921 if (lw->vf) vf_set_fd(lw->vf, lw->dir_fd); | |
9 | 922 } |
923 | |
1416 | 924 gboolean layout_set_path(LayoutWindow *lw, const gchar *path) |
9 | 925 { |
959 | 926 FileData *fd; |
1416 | 927 gboolean ret; |
1372 | 928 |
959 | 929 if (!path) return FALSE; |
1372 | 930 |
959 | 931 fd = file_data_new_simple(path); |
1372 | 932 ret = layout_set_fd(lw, fd); |
783 | 933 file_data_unref(fd); |
934 return ret; | |
935 } | |
936 | |
937 | |
1416 | 938 gboolean layout_set_fd(LayoutWindow *lw, FileData *fd) |
783 | 939 { |
1416 | 940 gboolean have_file = FALSE; |
9 | 941 |
942 if (!layout_valid(&lw)) return FALSE; | |
943 | |
783 | 944 if (!fd || !isname(fd->path)) return FALSE; |
945 if (lw->dir_fd && fd == lw->dir_fd) | |
9 | 946 { |
947 return TRUE; | |
948 } | |
949 | |
783 | 950 if (isdir(fd->path)) |
9 | 951 { |
791 | 952 if (lw->dir_fd) |
953 { | |
954 file_data_unregister_real_time_monitor(lw->dir_fd); | |
955 file_data_unref(lw->dir_fd); | |
956 } | |
783 | 957 lw->dir_fd = file_data_ref(fd); |
791 | 958 file_data_register_real_time_monitor(fd); |
9 | 959 } |
960 else | |
961 { | |
962 gchar *base; | |
963 | |
783 | 964 base = remove_level_from_path(fd->path); |
965 if (lw->dir_fd && strcmp(lw->dir_fd->path, base) == 0) | |
9 | 966 { |
967 g_free(base); | |
968 } | |
969 else if (isdir(base)) | |
970 { | |
791 | 971 if (lw->dir_fd) |
972 { | |
973 file_data_unregister_real_time_monitor(lw->dir_fd); | |
974 file_data_unref(lw->dir_fd); | |
975 } | |
783 | 976 lw->dir_fd = file_data_new_simple(base); |
791 | 977 file_data_register_real_time_monitor(lw->dir_fd); |
783 | 978 g_free(base); |
9 | 979 } |
980 else | |
981 { | |
982 g_free(base); | |
983 return FALSE; | |
984 } | |
783 | 985 if (isfile(fd->path)) have_file = TRUE; |
9 | 986 } |
987 | |
783 | 988 if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->dir_fd->path); |
9 | 989 layout_sync_path(lw); |
1301
8c47a4f521ad
Fix bug 2599857: file list sort order was wrong in many cases.
zas_
parents:
1296
diff
changeset
|
990 layout_list_sync_sort(lw); |
8c47a4f521ad
Fix bug 2599857: file list sort order was wrong in many cases.
zas_
parents:
1296
diff
changeset
|
991 |
9 | 992 if (have_file) |
993 { | |
994 gint row; | |
995 | |
783 | 996 row = layout_list_get_index(lw, fd); |
9 | 997 if (row >= 0) |
998 { | |
999 layout_image_set_index(lw, row); | |
1000 } | |
1001 else | |
1002 { | |
783 | 1003 layout_image_set_fd(lw, fd); |
9 | 1004 } |
1005 } | |
320 | 1006 else if (!options->lazy_image_sync) |
9 | 1007 { |
1008 layout_image_set_index(lw, 0); | |
1009 } | |
1010 | |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1177
diff
changeset
|
1011 if (options->metadata.confirm_on_dir_change) |
1231 | 1012 metadata_write_queue_confirm(NULL, NULL); |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1177
diff
changeset
|
1013 |
9 | 1014 return TRUE; |
1015 } | |
1016 | |
1017 static void layout_refresh_lists(LayoutWindow *lw) | |
1018 { | |
390 | 1019 if (lw->vd) vd_refresh(lw->vd); |
9 | 1020 |
1506
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
1021 if (lw->vf) |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
1022 { |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
1023 vf_refresh(lw->vf); |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
1024 vf_thumb_update(lw->vf); |
d352a44545a6
Force thumbnails refreshing when thumbnails dimensions are modified through Preferences.
zas_
parents:
1503
diff
changeset
|
1025 } |
9 | 1026 } |
1027 | |
1028 void layout_refresh(LayoutWindow *lw) | |
1029 { | |
1030 if (!layout_valid(&lw)) return; | |
1031 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
501
diff
changeset
|
1032 DEBUG_1("layout refresh"); |
9 | 1033 |
1034 layout_refresh_lists(lw); | |
1035 | |
1036 if (lw->image) layout_image_refresh(lw); | |
1037 } | |
1038 | |
1416 | 1039 void layout_thumb_set(LayoutWindow *lw, gboolean enable) |
9 | 1040 { |
1041 if (!layout_valid(&lw)) return; | |
1042 | |
1309 | 1043 if (lw->options.show_thumbnails == enable) return; |
1044 | |
1045 lw->options.show_thumbnails = enable; | |
9 | 1046 |
1047 layout_util_sync_thumb(lw); | |
1048 layout_list_sync_thumb(lw); | |
1049 } | |
1050 | |
1416 | 1051 void layout_marks_set(LayoutWindow *lw, gboolean enable) |
132 | 1052 { |
1053 if (!layout_valid(&lw)) return; | |
1054 | |
1309 | 1055 if (lw->options.show_marks == enable) return; |
1056 | |
1057 lw->options.show_marks = enable; | |
132 | 1058 |
268 | 1059 // layout_util_sync_marks(lw); |
1060 layout_list_sync_marks(lw); | |
132 | 1061 } |
1062 | |
1416 | 1063 gboolean layout_thumb_get(LayoutWindow *lw) |
9 | 1064 { |
1065 if (!layout_valid(&lw)) return FALSE; | |
1066 | |
1309 | 1067 return lw->options.show_thumbnails; |
9 | 1068 } |
1069 | |
1416 | 1070 gboolean layout_marks_get(LayoutWindow *lw) |
433
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1071 { |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1072 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
|
1073 |
1309 | 1074 return lw->options.show_marks; |
433
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1075 } |
5ddcf93278c7
Save Show Marks state to rc file and display current state in menu.
zas_
parents:
432
diff
changeset
|
1076 |
1416 | 1077 void layout_sort_set(LayoutWindow *lw, SortType type, gboolean ascend) |
9 | 1078 { |
1079 if (!layout_valid(&lw)) return; | |
1080 if (lw->sort_method == type && lw->sort_ascend == ascend) return; | |
1081 | |
1082 lw->sort_method = type; | |
1083 lw->sort_ascend = ascend; | |
1084 | |
1085 if (lw->info_sort) gtk_label_set_text(GTK_LABEL(GTK_BIN(lw->info_sort)->child), | |
1086 sort_type_get_text(type)); | |
1087 layout_list_sync_sort(lw); | |
1088 } | |
1089 | |
1416 | 1090 gboolean layout_sort_get(LayoutWindow *lw, SortType *type, gboolean *ascend) |
9 | 1091 { |
1092 if (!layout_valid(&lw)) return FALSE; | |
1093 | |
1094 if (type) *type = lw->sort_method; | |
1095 if (ascend) *ascend = lw->sort_ascend; | |
1096 | |
1097 return TRUE; | |
1098 } | |
1099 | |
1416 | 1100 gboolean layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h) |
9 | 1101 { |
1102 if (!layout_valid(&lw)) return FALSE; | |
1103 | |
1104 gdk_window_get_root_origin(lw->window->window, x, y); | |
1105 gdk_drawable_get_size(lw->window->window, w, h); | |
1106 | |
1107 return TRUE; | |
1108 } | |
1109 | |
1416 | 1110 gboolean layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v) |
9 | 1111 { |
1112 if (!layout_valid(&lw)) return FALSE; | |
1113 | |
1114 if (lw->h_pane && GTK_PANED(lw->h_pane)->child1->allocation.x >= 0) | |
1115 { | |
1116 *h = GTK_PANED(lw->h_pane)->child1->allocation.width; | |
1117 } | |
1309 | 1118 else if (h != &lw->options.main_window.hdivider_pos) |
9 | 1119 { |
1309 | 1120 *h = lw->options.main_window.hdivider_pos; |
9 | 1121 } |
1122 | |
1123 if (lw->v_pane && GTK_PANED(lw->v_pane)->child1->allocation.x >= 0) | |
1124 { | |
1125 *v = GTK_PANED(lw->v_pane)->child1->allocation.height; | |
1126 } | |
1309 | 1127 else if (v != &lw->options.main_window.vdivider_pos) |
9 | 1128 { |
1309 | 1129 *v = lw->options.main_window.vdivider_pos; |
9 | 1130 } |
1131 | |
1132 return TRUE; | |
1133 } | |
1134 | |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
555
diff
changeset
|
1135 void layout_views_set(LayoutWindow *lw, DirViewType dir_view_type, FileViewType file_view_type) |
9 | 1136 { |
1137 if (!layout_valid(&lw)) return; | |
1138 | |
1412 | 1139 if (lw->options.dir_view_type == dir_view_type && lw->options.file_view_type == file_view_type) return; |
1309 | 1140 |
1141 lw->options.dir_view_type = dir_view_type; | |
1412 | 1142 lw->options.file_view_type = file_view_type; |
9 | 1143 |
1144 layout_style_set(lw, -1, NULL); | |
1145 } | |
1146 | |
1416 | 1147 gboolean layout_views_get(LayoutWindow *lw, DirViewType *dir_view_type, FileViewType *file_view_type) |
9 | 1148 { |
1149 if (!layout_valid(&lw)) return FALSE; | |
1150 | |
1309 | 1151 *dir_view_type = lw->options.dir_view_type; |
1412 | 1152 *file_view_type = lw->options.file_view_type; |
9 | 1153 |
1154 return TRUE; | |
1155 } | |
1156 | |
1157 /* | |
1158 *----------------------------------------------------------------------------- | |
1159 * location utils | |
1160 *----------------------------------------------------------------------------- | |
1161 */ | |
1162 | |
1416 | 1163 static gboolean layout_location_single(LayoutLocation l) |
9 | 1164 { |
1165 return (l == LAYOUT_LEFT || | |
1166 l == LAYOUT_RIGHT || | |
1167 l == LAYOUT_TOP || | |
1168 l == LAYOUT_BOTTOM); | |
1169 } | |
1170 | |
1416 | 1171 static gboolean layout_location_vertical(LayoutLocation l) |
9 | 1172 { |
1173 return (l & LAYOUT_TOP || | |
1174 l & LAYOUT_BOTTOM); | |
1175 } | |
1176 | |
1416 | 1177 static gboolean layout_location_first(LayoutLocation l) |
9 | 1178 { |
1179 return (l & LAYOUT_TOP || | |
1180 l & LAYOUT_LEFT); | |
1181 } | |
1182 | |
1183 static LayoutLocation layout_grid_compass(LayoutWindow *lw) | |
1184 { | |
1185 if (layout_location_single(lw->dir_location)) return lw->dir_location; | |
1186 if (layout_location_single(lw->file_location)) return lw->file_location; | |
1187 return lw->image_location; | |
1188 } | |
1189 | |
1190 static void layout_location_compute(LayoutLocation l1, LayoutLocation l2, | |
1191 GtkWidget *s1, GtkWidget *s2, | |
1192 GtkWidget **d1, GtkWidget **d2) | |
1193 { | |
1194 LayoutLocation l; | |
1195 | |
1196 l = l1 & l2; /* get common compass direction */ | |
1197 l = l1 - l; /* remove it */ | |
1198 | |
1199 if (layout_location_first(l)) | |
1200 { | |
1201 *d1 = s1; | |
1202 *d2 = s2; | |
1203 } | |
1204 else | |
1205 { | |
1206 *d1 = s2; | |
1207 *d2 = s1; | |
1208 } | |
1209 } | |
1210 | |
1211 /* | |
1212 *----------------------------------------------------------------------------- | |
1213 * tools window (for floating/hidden) | |
1214 *----------------------------------------------------------------------------- | |
1215 */ | |
1216 | |
1416 | 1217 gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) |
9 | 1218 { |
1219 if (!layout_valid(&lw)) return FALSE; | |
1220 | |
1221 if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools)) | |
1222 { | |
1223 /* use the stored values (sort of breaks success return value) */ | |
1224 | |
1309 | 1225 *divider_pos = lw->options.float_window.vdivider_pos; |
9 | 1226 |
1227 return FALSE; | |
1228 } | |
1229 | |
1230 gdk_window_get_root_origin(lw->tools->window, x, y); | |
1231 gdk_drawable_get_size(lw->tools->window, w, h); | |
1232 | |
1233 if (GTK_IS_VPANED(lw->tools_pane)) | |
1234 { | |
1235 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height; | |
1236 } | |
1237 else | |
1238 { | |
1239 *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width; | |
1240 } | |
1241 | |
1242 return TRUE; | |
1243 } | |
1244 | |
1245 static void layout_tools_geometry_sync(LayoutWindow *lw) | |
1246 { | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1247 layout_geometry_get_tools(lw, &lw->options.float_window.x, &lw->options.float_window.x, |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1248 &lw->options.float_window.w, &lw->options.float_window.h, &lw->options.float_window.vdivider_pos); |
9 | 1249 } |
1250 | |
1416 | 1251 static void layout_tools_hide(LayoutWindow *lw, gboolean hide) |
9 | 1252 { |
1253 if (!lw->tools) return; | |
1254 | |
1255 if (hide) | |
1256 { | |
1257 if (GTK_WIDGET_VISIBLE(lw->tools)) | |
1258 { | |
1259 layout_tools_geometry_sync(lw); | |
1260 gtk_widget_hide(lw->tools); | |
1261 } | |
1262 } | |
1263 else | |
1264 { | |
1265 if (!GTK_WIDGET_VISIBLE(lw->tools)) | |
1266 { | |
1267 gtk_widget_show(lw->tools); | |
574
3da75054d4e1
Drop ViewFileIcon, use ViewFile and ViewFileInfoIcon instead.
zas_
parents:
573
diff
changeset
|
1268 if (lw->vf) vf_refresh(lw->vf); |
9 | 1269 } |
1270 } | |
1271 | |
1309 | 1272 lw->options.tools_hidden = hide; |
9 | 1273 } |
1274 | |
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1431
diff
changeset
|
1275 static gboolean layout_tools_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) |
9 | 1276 { |
1277 LayoutWindow *lw = data; | |
1278 | |
1279 layout_tools_float_toggle(lw); | |
1280 | |
1281 return TRUE; | |
1282 } | |
1283 | |
1284 static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *files) | |
1285 { | |
1286 GtkWidget *vbox; | |
1287 GtkWidget *w1, *w2; | |
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1431
diff
changeset
|
1288 gboolean vertical; |
1416 | 1289 gboolean new_window = FALSE; |
9 | 1290 |
1291 vertical = (layout_location_single(lw->image_location) && !layout_location_vertical(lw->image_location)) || | |
1292 (!layout_location_single(lw->image_location) && layout_location_vertical(layout_grid_compass(lw))); | |
1293 #if 0 | |
1294 layout_location_compute(lw->dir_location, lw->file_location, | |
1295 tools, files, &w1, &w2); | |
1296 #endif | |
1297 /* for now, tools/dir are always first in order */ | |
1298 w1 = tools; | |
1299 w2 = files; | |
1300 | |
1301 if (!lw->tools) | |
1302 { | |
1303 GdkGeometry geometry; | |
1304 GdkWindowHints hints; | |
1305 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
1306 lw->tools = window_new(GTK_WINDOW_TOPLEVEL, "tools", PIXBUF_INLINE_ICON_TOOLS, NULL, _("Tools")); |
9 | 1307 g_signal_connect(G_OBJECT(lw->tools), "delete_event", |
1308 G_CALLBACK(layout_tools_delete_cb), lw); | |
1309 layout_keyboard_init(lw, lw->tools); | |
1310 | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1311 if (options->save_window_positions) |
9 | 1312 { |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
1313 hints = GDK_HINT_USER_POS; |
9 | 1314 } |
1315 else | |
1316 { | |
1317 hints = 0; | |
1318 } | |
1319 | |
1029
1a4b18c58556
Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents:
1006
diff
changeset
|
1320 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
|
1321 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE; |
9 | 1322 geometry.base_width = TOOLWINDOW_DEF_WIDTH; |
1323 geometry.base_height = TOOLWINDOW_DEF_HEIGHT; | |
1324 gtk_window_set_geometry_hints(GTK_WINDOW(lw->tools), NULL, &geometry, | |
1325 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hints); | |
1326 | |
1327 | |
268 | 1328 gtk_window_set_resizable(GTK_WINDOW(lw->tools), TRUE); |
1329 gtk_container_set_border_width(GTK_CONTAINER(lw->tools), 0); | |
442 | 1330 |
9 | 1331 new_window = TRUE; |
1332 } | |
1333 else | |
1334 { | |
1335 layout_tools_geometry_sync(lw); | |
1336 /* dump the contents */ | |
1337 gtk_widget_destroy(GTK_BIN(lw->tools)->child); | |
1338 } | |
1339 | |
1340 layout_actions_add_window(lw, lw->tools); | |
1341 | |
1342 vbox = gtk_vbox_new(FALSE, 0); | |
1343 gtk_container_add(GTK_CONTAINER(lw->tools), vbox); | |
1344 gtk_widget_show(vbox); | |
1345 | |
1346 layout_status_setup(lw, vbox, TRUE); | |
1347 | |
1348 if (vertical) | |
1349 { | |
1350 lw->tools_pane = gtk_vpaned_new(); | |
1351 } | |
1352 else | |
1353 { | |
1354 lw->tools_pane = gtk_hpaned_new(); | |
1355 } | |
1356 gtk_box_pack_start(GTK_BOX(vbox), lw->tools_pane, TRUE, TRUE, 0); | |
1357 gtk_widget_show(lw->tools_pane); | |
1358 | |
1359 gtk_paned_pack1(GTK_PANED(lw->tools_pane), w1, FALSE, TRUE); | |
1360 gtk_paned_pack2(GTK_PANED(lw->tools_pane), w2, TRUE, TRUE); | |
1361 | |
1362 gtk_widget_show(tools); | |
1363 gtk_widget_show(files); | |
1364 | |
1365 if (new_window) | |
1366 { | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1367 if (options->save_window_positions) |
9 | 1368 { |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1369 gtk_window_set_default_size(GTK_WINDOW(lw->tools), lw->options.float_window.w, lw->options.float_window.h); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1370 gtk_window_move(GTK_WINDOW(lw->tools), lw->options.float_window.x, lw->options.float_window.y); |
268 | 1371 } |
9 | 1372 else |
1373 { | |
1374 if (vertical) | |
1375 { | |
1376 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1377 TOOLWINDOW_DEF_WIDTH, TOOLWINDOW_DEF_HEIGHT); | |
1378 } | |
1379 else | |
1380 { | |
1381 gtk_window_set_default_size(GTK_WINDOW(lw->tools), | |
1382 TOOLWINDOW_DEF_HEIGHT, TOOLWINDOW_DEF_WIDTH); | |
1383 } | |
1384 } | |
1385 } | |
1386 | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1387 if (!options->save_window_positions) |
9 | 1388 { |
1389 if (vertical) | |
1390 { | |
1309 | 1391 lw->options.float_window.vdivider_pos = MAIN_WINDOW_DIV_VPOS; |
9 | 1392 } |
1393 else | |
1394 { | |
1309 | 1395 lw->options.float_window.vdivider_pos = MAIN_WINDOW_DIV_HPOS; |
9 | 1396 } |
1397 } | |
1398 | |
1309 | 1399 gtk_paned_set_position(GTK_PANED(lw->tools_pane), lw->options.float_window.vdivider_pos); |
9 | 1400 } |
1401 | |
1402 /* | |
1403 *----------------------------------------------------------------------------- | |
1404 * glue (layout arrangement) | |
1405 *----------------------------------------------------------------------------- | |
1406 */ | |
1407 | |
1408 static void layout_grid_compute(LayoutWindow *lw, | |
1409 GtkWidget *image, GtkWidget *tools, GtkWidget *files, | |
1410 GtkWidget **w1, GtkWidget **w2, GtkWidget **w3) | |
1411 { | |
1412 /* heh, this was fun */ | |
1413 | |
1414 if (layout_location_single(lw->dir_location)) | |
1415 { | |
1416 if (layout_location_first(lw->dir_location)) | |
1417 { | |
1418 *w1 = tools; | |
1419 layout_location_compute(lw->file_location, lw->image_location, files, image, w2, w3); | |
1420 } | |
1421 else | |
1422 { | |
1423 *w3 = tools; | |
1424 layout_location_compute(lw->file_location, lw->image_location, files, image, w1, w2); | |
1425 } | |
1426 } | |
1427 else if (layout_location_single(lw->file_location)) | |
1428 { | |
1429 if (layout_location_first(lw->file_location)) | |
1430 { | |
1431 *w1 = files; | |
1432 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w2, w3); | |
1433 } | |
1434 else | |
1435 { | |
1436 *w3 = files; | |
1437 layout_location_compute(lw->dir_location, lw->image_location, tools, image, w1, w2); | |
1438 } | |
1439 } | |
1440 else | |
1441 { | |
1442 /* image */ | |
1443 if (layout_location_first(lw->image_location)) | |
1444 { | |
1445 *w1 = image; | |
1446 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w2, w3); | |
1447 } | |
1448 else | |
1449 { | |
1450 *w3 = image; | |
1451 layout_location_compute(lw->file_location, lw->dir_location, files, tools, w1, w2); | |
1452 } | |
1453 } | |
1454 } | |
1455 | |
127 | 1456 void layout_split_change(LayoutWindow *lw, ImageSplitMode mode) |
1457 { | |
1458 GtkWidget *image; | |
1459 gint i; | |
268 | 1460 |
1461 for (i = 0; i < MAX_SPLIT_IMAGES; i++) | |
127 | 1462 { |
1463 if (lw->split_images[i]) | |
1464 { | |
1465 gtk_widget_hide(lw->split_images[i]->widget); | |
1383 | 1466 if (lw->split_images[i]->widget->parent != lw->utility_paned) |
127 | 1467 gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget); |
1468 } | |
1469 } | |
1383 | 1470 gtk_container_remove(GTK_CONTAINER(lw->utility_paned), lw->split_image_widget); |
127 | 1471 |
1472 image = layout_image_setup_split(lw, mode); | |
1473 | |
1383 | 1474 // gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); |
1475 // gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0); | |
1476 gtk_paned_pack1(GTK_PANED(lw->utility_paned), image, TRUE, FALSE); | |
127 | 1477 gtk_widget_show(image); |
1478 } | |
1479 | |
9 | 1480 static void layout_grid_setup(LayoutWindow *lw) |
1481 { | |
1482 gint priority_location; | |
1483 GtkWidget *h; | |
1484 GtkWidget *v; | |
1485 GtkWidget *w1, *w2, *w3; | |
1486 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1487 GtkWidget *image_sb; /* image together with sidebars in utility box */ |
9 | 1488 GtkWidget *tools; |
1489 GtkWidget *files; | |
1490 | |
1491 layout_actions_setup(lw); | |
1492 | |
1493 lw->group_box = gtk_vbox_new(FALSE, 0); | |
1494 gtk_box_pack_start(GTK_BOX(lw->main_box), lw->group_box, TRUE, TRUE, 0); | |
1495 gtk_widget_show(lw->group_box); | |
1496 | |
1497 priority_location = layout_grid_compass(lw); | |
1498 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1499 if (lw->utility_box) |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1500 { |
1480 | 1501 layout_split_change(lw, lw->split_mode); /* this re-creates image frame for the new configuration */ |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1502 image_sb = lw->utility_box; |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1503 } |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1504 else |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1505 { |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1506 GtkWidget *image; /* image or split images together */ |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1507 image = layout_image_setup_split(lw, lw->split_mode); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1508 image_sb = layout_bars_prepare(lw, image); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1509 } |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1510 |
9 | 1511 tools = layout_tools_new(lw); |
1512 files = layout_list_new(lw); | |
1513 | |
1514 | |
1309 | 1515 if (lw->options.tools_float || lw->options.tools_hidden) |
9 | 1516 { |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1517 gtk_box_pack_start(GTK_BOX(lw->group_box), image_sb, TRUE, TRUE, 0); |
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1518 gtk_widget_show(image_sb); |
9 | 1519 |
1520 layout_tools_setup(lw, tools, files); | |
1521 | |
1482 | 1522 image_grab_focus(lw->image); |
9 | 1523 |
1524 return; | |
1525 } | |
1526 else if (lw->tools) | |
1527 { | |
1528 layout_tools_geometry_sync(lw); | |
1529 gtk_widget_destroy(lw->tools); | |
1530 lw->tools = NULL; | |
1531 lw->tools_pane = NULL; | |
1532 } | |
1533 | |
1534 layout_status_setup(lw, lw->group_box, FALSE); | |
1535 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1536 layout_grid_compute(lw, image_sb, tools, files, &w1, &w2, &w3); |
9 | 1537 |
1538 v = lw->v_pane = gtk_vpaned_new(); | |
1539 | |
1540 h = lw->h_pane = gtk_hpaned_new(); | |
1541 | |
1542 if (!layout_location_vertical(priority_location)) | |
1543 { | |
1544 GtkWidget *tmp; | |
1545 | |
1546 tmp = v; | |
1547 v = h; | |
1548 h = tmp; | |
1549 } | |
1550 | |
1551 gtk_box_pack_start(GTK_BOX(lw->group_box), v, TRUE, TRUE, 0); | |
1552 | |
1553 if (!layout_location_first(priority_location)) | |
1554 { | |
1555 gtk_paned_pack1(GTK_PANED(v), h, FALSE, TRUE); | |
1556 gtk_paned_pack2(GTK_PANED(v), w3, TRUE, TRUE); | |
1557 | |
1558 gtk_paned_pack1(GTK_PANED(h), w1, FALSE, TRUE); | |
1559 gtk_paned_pack2(GTK_PANED(h), w2, TRUE, TRUE); | |
1560 } | |
1561 else | |
1562 { | |
1563 gtk_paned_pack1(GTK_PANED(v), w1, FALSE, TRUE); | |
1564 gtk_paned_pack2(GTK_PANED(v), h, TRUE, TRUE); | |
1565 | |
1566 gtk_paned_pack1(GTK_PANED(h), w2, FALSE, TRUE); | |
1567 gtk_paned_pack2(GTK_PANED(h), w3, TRUE, TRUE); | |
1568 } | |
1569 | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1570 gtk_widget_show(image_sb); |
9 | 1571 gtk_widget_show(tools); |
1572 gtk_widget_show(files); | |
1573 | |
1574 gtk_widget_show(v); | |
1575 gtk_widget_show(h); | |
1576 | |
1577 /* fix to have image pane visible when it is left and priority widget */ | |
1309 | 1578 if (lw->options.main_window.hdivider_pos == -1 && |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1579 w1 == image_sb && |
9 | 1580 !layout_location_vertical(priority_location) && |
1581 layout_location_first(priority_location)) | |
1582 { | |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1583 gtk_widget_set_size_request(image_sb, 200, -1); |
9 | 1584 } |
1585 | |
1309 | 1586 gtk_paned_set_position(GTK_PANED(lw->h_pane), lw->options.main_window.hdivider_pos); |
1587 gtk_paned_set_position(GTK_PANED(lw->v_pane), lw->options.main_window.vdivider_pos); | |
9 | 1588 |
1482 | 1589 image_grab_focus(lw->image); |
9 | 1590 } |
1591 | |
1592 void layout_style_set(LayoutWindow *lw, gint style, const gchar *order) | |
1593 { | |
783 | 1594 FileData *dir_fd; |
9 | 1595 |
1596 if (!layout_valid(&lw)) return; | |
1597 | |
1598 if (style != -1) | |
1599 { | |
1600 LayoutLocation d, f, i; | |
1601 | |
1602 layout_config_parse(style, order, &d, &f, &i); | |
1603 | |
1604 if (lw->dir_location == d && | |
1605 lw->file_location == f && | |
1606 lw->image_location == i) return; | |
1607 | |
1608 lw->dir_location = d; | |
1609 lw->file_location = f; | |
1610 lw->image_location = i; | |
1611 } | |
1612 | |
1613 /* remember state */ | |
1614 | |
1615 layout_image_slideshow_stop(lw); | |
1616 layout_image_full_screen_stop(lw); | |
1617 | |
783 | 1618 dir_fd = lw->dir_fd; |
960
37fdfe8f2ab1
fixed crash with float file list and geeqie --blank
nadvornik
parents:
959
diff
changeset
|
1619 if (dir_fd) file_data_unregister_real_time_monitor(dir_fd); |
783 | 1620 lw->dir_fd = NULL; |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1621 |
1403 | 1622 layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos); |
1623 | |
1470 | 1624 /* preserve utility_box (image + sidebars), menu_bar and toolbar to be reused later in layout_grid_setup */ |
1322
4370b90fa774
reuse original utility_box (image + sidebars) on layout change (switch
nadvornik
parents:
1320
diff
changeset
|
1625 /* lw->image is preserved together with lw->utility_box */ |
1470 | 1626 if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box); |
1627 if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(lw->menu_bar->parent), lw->menu_bar); | |
1628 if (lw->toolbar) gtk_container_remove(GTK_CONTAINER(lw->toolbar->parent), lw->toolbar); | |
9 | 1629 |
1630 /* clear it all */ | |
1631 | |
1632 lw->h_pane = NULL; | |
1633 lw->v_pane = NULL; | |
1634 | |
1635 lw->path_entry = NULL; | |
1636 lw->dir_view = NULL; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
368
diff
changeset
|
1637 lw->vd = NULL; |
9 | 1638 |
1639 lw->file_view = NULL; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1640 lw->vf = NULL; |
9 | 1641 |
1642 lw->info_box = NULL; | |
1643 lw->info_progress_bar = NULL; | |
1644 lw->info_sort = NULL; | |
1549 | 1645 lw->info_color = NULL; |
9 | 1646 lw->info_status = NULL; |
1647 lw->info_details = NULL; | |
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1648 lw->info_pixel = NULL; |
9 | 1649 lw->info_zoom = NULL; |
1650 | |
1470 | 1651 /* |
9 | 1652 if (lw->ui_manager) g_object_unref(lw->ui_manager); |
1653 lw->ui_manager = NULL; | |
1654 lw->action_group = NULL; | |
1463
25168240a247
added function to reload external editors at any time
nadvornik
parents:
1461
diff
changeset
|
1655 lw->action_group_editors = NULL; |
1470 | 1656 */ |
9 | 1657 |
1658 gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box); | |
1659 lw->group_box = NULL; | |
1660 | |
1661 /* re-fill */ | |
1662 | |
1663 layout_grid_setup(lw); | |
1309 | 1664 layout_tools_hide(lw, lw->options.tools_hidden); |
9 | 1665 |
1666 layout_util_sync(lw); | |
1667 layout_status_update_all(lw); | |
1668 | |
1470 | 1669 |
1670 // printf("%d %d %d \n", G_OBJECT(lw->utility_box)->ref_count, G_OBJECT(lw->menu_bar)->ref_count, G_OBJECT(lw->toolbar)->ref_count); | |
1671 | |
9 | 1672 /* sync */ |
1673 | |
783 | 1674 if (image_get_fd(lw->image)) |
9 | 1675 { |
783 | 1676 layout_set_fd(lw, image_get_fd(lw->image)); |
9 | 1677 } |
1678 else | |
1679 { | |
783 | 1680 layout_set_fd(lw, dir_fd); |
9 | 1681 } |
1309 | 1682 image_top_window_set_sync(lw->image, (lw->options.tools_float || lw->options.tools_hidden)); |
9 | 1683 |
1684 /* clean up */ | |
1685 | |
783 | 1686 file_data_unref(dir_fd); |
9 | 1687 } |
1688 | |
1689 void layout_colors_update(void) | |
1690 { | |
1691 GList *work; | |
1692 | |
1693 work = layout_window_list; | |
1694 while (work) | |
1695 { | |
1696 LayoutWindow *lw = work->data; | |
1697 work = work->next; | |
442 | 1698 |
208
fa0e05f985c3
set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents:
196
diff
changeset
|
1699 if (!lw->image) continue; |
339
de1c2cd06fce
Rename user_specified_window_background and window_background_color
zas_
parents:
338
diff
changeset
|
1700 image_background_set_color(lw->image, options->image.use_custom_border_color ? &options->image.border_color : NULL); |
9 | 1701 } |
1702 } | |
1703 | |
1704 void layout_tools_float_toggle(LayoutWindow *lw) | |
1705 { | |
1416 | 1706 gboolean popped; |
9 | 1707 |
1708 if (!lw) return; | |
1709 | |
1309 | 1710 if (!lw->options.tools_hidden) |
9 | 1711 { |
1309 | 1712 popped = !lw->options.tools_float; |
9 | 1713 } |
1714 else | |
1715 { | |
1716 popped = TRUE; | |
1717 } | |
1718 | |
1309 | 1719 if (lw->options.tools_float == popped) |
9 | 1720 { |
1309 | 1721 if (popped && lw->options.tools_hidden) |
9 | 1722 { |
1723 layout_tools_float_set(lw, popped, FALSE); | |
1724 } | |
1725 } | |
1726 else | |
1727 { | |
1309 | 1728 if (lw->options.tools_float) |
9 | 1729 { |
1730 layout_tools_float_set(lw, FALSE, FALSE); | |
1731 } | |
1732 else | |
1733 { | |
1734 layout_tools_float_set(lw, TRUE, FALSE); | |
1735 } | |
1736 } | |
1737 } | |
1738 | |
1739 void layout_tools_hide_toggle(LayoutWindow *lw) | |
1740 { | |
1741 if (!lw) return; | |
1742 | |
1309 | 1743 layout_tools_float_set(lw, lw->options.tools_float, !lw->options.tools_hidden); |
9 | 1744 } |
1745 | |
1416 | 1746 void layout_tools_float_set(LayoutWindow *lw, gboolean popped, gboolean hidden) |
9 | 1747 { |
1748 if (!layout_valid(&lw)) return; | |
1749 | |
1309 | 1750 if (lw->options.tools_float == popped && lw->options.tools_hidden == hidden) return; |
1751 | |
1752 if (lw->options.tools_float == popped && lw->options.tools_float && lw->tools) | |
9 | 1753 { |
1754 layout_tools_hide(lw, hidden); | |
1755 return; | |
1756 } | |
1757 | |
1309 | 1758 lw->options.tools_float = popped; |
1759 lw->options.tools_hidden = hidden; | |
9 | 1760 |
1761 layout_style_set(lw, -1, NULL); | |
1762 } | |
1763 | |
1416 | 1764 gboolean layout_tools_float_get(LayoutWindow *lw, gboolean *popped, gboolean *hidden) |
9 | 1765 { |
1766 if (!layout_valid(&lw)) return FALSE; | |
1767 | |
1309 | 1768 *popped = lw->options.tools_float; |
1769 *hidden = lw->options.tools_hidden; | |
9 | 1770 |
1771 return TRUE; | |
1772 } | |
1773 | |
1774 void layout_toolbar_toggle(LayoutWindow *lw) | |
1775 { | |
1776 if (!layout_valid(&lw)) return; | |
1777 if (!lw->toolbar) return; | |
1778 | |
1309 | 1779 lw->options.toolbar_hidden = !lw->options.toolbar_hidden; |
1780 | |
1781 if (lw->options.toolbar_hidden) | |
9 | 1782 { |
1783 if (GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_hide(lw->toolbar); | |
1784 } | |
1785 else | |
1786 { | |
1787 if (!GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_show(lw->toolbar); | |
1788 } | |
1789 } | |
1790 | |
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1791 void layout_info_pixel_toggle(LayoutWindow *lw) |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1792 { |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1793 GtkWidget *frame; |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1794 |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1795 if (!layout_valid(&lw)) return; |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1796 if (!lw->info_pixel) return; |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1797 |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1798 lw->options.info_pixel_hidden = !lw->options.info_pixel_hidden; |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1799 |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1800 frame = gtk_widget_get_parent(lw->info_pixel); |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1801 if (lw->options.info_pixel_hidden) |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1802 { |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1803 if (GTK_WIDGET_VISIBLE(frame)) gtk_widget_hide(frame); |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1804 } |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1805 else |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1806 { |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1807 if (!GTK_WIDGET_VISIBLE(frame)) gtk_widget_show(frame); |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1808 } |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1809 } |
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
1810 |
9 | 1811 /* |
1812 *----------------------------------------------------------------------------- | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1813 * configuration |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1814 *----------------------------------------------------------------------------- |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1815 */ |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1816 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1817 #define CONFIG_WINDOW_DEF_WIDTH 600 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1818 #define CONFIG_WINDOW_DEF_HEIGHT 400 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1819 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1820 typedef struct _LayoutConfig LayoutConfig; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1821 struct _LayoutConfig |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1822 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1823 LayoutWindow *lw; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1824 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1825 GtkWidget *configwindow; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1826 GtkWidget *home_path_entry; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1827 GtkWidget *layout_widget; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1828 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1829 LayoutOptions options; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1830 }; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1831 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1832 static gint layout_config_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1833 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1834 static void layout_config_close_cb(GtkWidget *widget, gpointer data) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1835 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1836 LayoutConfig *lc = data; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1837 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1838 gtk_widget_destroy(lc->configwindow); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1839 free_layout_options_content(&lc->options); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1840 g_free(lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1841 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1842 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1843 static gint layout_config_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1844 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1845 layout_config_close_cb(w, data); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1846 return TRUE; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1847 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1848 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1849 static void layout_config_apply_cb(GtkWidget *widget, gpointer data) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1850 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1851 LayoutConfig *lc = data; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1852 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1853 g_free(lc->options.order); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1854 lc->options.order = layout_config_get(lc->layout_widget, &lc->options.style); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1855 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1856 config_entry_to_option(lc->home_path_entry, &lc->options.home_path, remove_trailing_slash); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1857 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1858 layout_apply_options(lc->lw, &lc->options); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1859 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1860 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1861 static void layout_config_ok_cb(GtkWidget *widget, gpointer data) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1862 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1863 LayoutConfig *lc = data; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1864 layout_config_apply_cb(widget, lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1865 layout_config_close_cb(widget, lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1866 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1867 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1868 static void home_path_set_current_cb(GtkWidget *widget, gpointer data) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1869 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1870 LayoutConfig *lc = data; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1871 gtk_entry_set_text(GTK_ENTRY(lc->home_path_entry), layout_get_path(lc->lw)); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1872 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1873 |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1874 static void startup_path_set_current_cb(GtkWidget *widget, gpointer data) |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1875 { |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1876 LayoutConfig *lc = data; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1877 lc->options.startup_path = STARTUP_PATH_CURRENT; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1878 } |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1879 |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1880 static void startup_path_set_last_cb(GtkWidget *widget, gpointer data) |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1881 { |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1882 LayoutConfig *lc = data; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1883 lc->options.startup_path = STARTUP_PATH_LAST; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1884 } |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1885 |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1886 static void startup_path_set_home_cb(GtkWidget *widget, gpointer data) |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1887 { |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1888 LayoutConfig *lc = data; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1889 lc->options.startup_path = STARTUP_PATH_HOME; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1890 } |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1891 |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1892 |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1893 /* |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1894 static void layout_config_save_cb(GtkWidget *widget, gpointer data) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1895 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1896 layout_config_apply(); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1897 save_options(options); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1898 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1899 */ |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1900 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1901 void layout_show_config_window(LayoutWindow *lw) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1902 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1903 LayoutConfig *lc; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1904 GtkWidget *win_vbox; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1905 GtkWidget *hbox; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1906 GtkWidget *vbox; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1907 GtkWidget *button; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1908 GtkWidget *ct_button; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1909 GtkWidget *group; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1910 GtkWidget *frame; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1911 GtkWidget *tabcomp; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1912 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1913 lc = g_new0(LayoutConfig, 1); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1914 lc->lw = lw; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1915 layout_sync_options_with_current_state(lw); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1916 copy_layout_options(&lc->options, &lw->options); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1917 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1918 lc->configwindow = window_new(GTK_WINDOW_TOPLEVEL, "Layout", PIXBUF_INLINE_ICON_CONFIG, NULL, _("Window options and layout")); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1919 gtk_window_set_type_hint(GTK_WINDOW(lc->configwindow), GDK_WINDOW_TYPE_HINT_DIALOG); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1920 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1921 g_signal_connect(G_OBJECT(lc->configwindow), "delete_event", |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1922 G_CALLBACK(layout_config_delete_cb), lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1923 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1924 gtk_window_set_default_size(GTK_WINDOW(lc->configwindow), CONFIG_WINDOW_DEF_WIDTH, CONFIG_WINDOW_DEF_HEIGHT); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1925 gtk_window_set_resizable(GTK_WINDOW(lc->configwindow), TRUE); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1926 gtk_container_set_border_width(GTK_CONTAINER(lc->configwindow), PREF_PAD_BORDER); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1927 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1928 win_vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1929 gtk_container_add(GTK_CONTAINER(lc->configwindow), win_vbox); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1930 gtk_widget_show(win_vbox); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1931 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1932 hbox = gtk_hbutton_box_new(); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1933 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1934 gtk_box_set_spacing(GTK_BOX(hbox), PREF_PAD_BUTTON_GAP); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1935 gtk_box_pack_end(GTK_BOX(win_vbox), hbox, FALSE, FALSE, 0); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1936 gtk_widget_show(hbox); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1937 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1938 button = pref_button_new(NULL, GTK_STOCK_OK, NULL, FALSE, |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1939 G_CALLBACK(layout_config_ok_cb), lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1940 gtk_container_add(GTK_CONTAINER(hbox), button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1941 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1942 gtk_widget_grab_default(button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1943 gtk_widget_show(button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1944 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1945 ct_button = button; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1946 /* |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1947 button = pref_button_new(NULL, GTK_STOCK_SAVE, NULL, FALSE, |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1948 G_CALLBACK(layout_config_save_cb), NULL); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1949 gtk_container_add(GTK_CONTAINER(hbox), button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1950 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1951 gtk_widget_show(button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1952 */ |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1953 button = pref_button_new(NULL, GTK_STOCK_APPLY, NULL, FALSE, |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1954 G_CALLBACK(layout_config_apply_cb), lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1955 gtk_container_add(GTK_CONTAINER(hbox), button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1956 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1957 gtk_widget_show(button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1958 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1959 button = pref_button_new(NULL, GTK_STOCK_CANCEL, NULL, FALSE, |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1960 G_CALLBACK(layout_config_close_cb), lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1961 gtk_container_add(GTK_CONTAINER(hbox), button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1962 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1963 gtk_widget_show(button); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1964 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1965 if (!generic_dialog_get_alternative_button_order(lc->configwindow)) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1966 { |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1967 gtk_box_reorder_child(GTK_BOX(hbox), ct_button, -1); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1968 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1969 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1970 frame = pref_frame_new(win_vbox, TRUE, NULL, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1971 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1972 vbox = gtk_vbox_new(FALSE, PREF_PAD_SPACE); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1973 gtk_container_add(GTK_CONTAINER(frame), vbox); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1974 gtk_widget_show(vbox); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1975 |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1976 |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1977 group = pref_group_new(vbox, FALSE, _("General options"), GTK_ORIENTATION_VERTICAL); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1978 |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1979 pref_label_new(group, _("Home path (empty to use your home directory)")); |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1980 hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1981 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1982 tabcomp = tab_completion_new(&lc->home_path_entry, lc->options.home_path, NULL, NULL); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1983 tab_completion_add_select_button(lc->home_path_entry, NULL, TRUE); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1984 gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1985 gtk_widget_show(tabcomp); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1986 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1987 button = pref_button_new(hbox, NULL, _("Use current"), FALSE, |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1988 G_CALLBACK(home_path_set_current_cb), lc); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1989 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1990 pref_checkbox_new_int(group, _("Show date in directories list view"), |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1991 lc->options.show_directory_date, &lc->options.show_directory_date); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
1992 |
1514
22174e704d0b
added option that simplifies saving of multi-window configurations
nadvornik
parents:
1511
diff
changeset
|
1993 pref_checkbox_new_int(group, _("Exit program when this window is closed"), |
22174e704d0b
added option that simplifies saving of multi-window configurations
nadvornik
parents:
1511
diff
changeset
|
1994 lc->options.exit_on_close, &lc->options.exit_on_close); |
22174e704d0b
added option that simplifies saving of multi-window configurations
nadvornik
parents:
1511
diff
changeset
|
1995 |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1996 group = pref_group_new(vbox, FALSE, _("Start-up directory:"), GTK_ORIENTATION_VERTICAL); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1997 |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1998 button = pref_radiobutton_new(group, NULL, _("No change"), |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
1999 (lc->options.startup_path == STARTUP_PATH_CURRENT), |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2000 G_CALLBACK(startup_path_set_current_cb), lc); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2001 button = pref_radiobutton_new(group, button, _("Restore last path"), |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2002 (lc->options.startup_path == STARTUP_PATH_LAST), |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2003 G_CALLBACK(startup_path_set_last_cb), lc); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2004 button = pref_radiobutton_new(group, button, _("Home path"), |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2005 (lc->options.startup_path == STARTUP_PATH_HOME), |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2006 G_CALLBACK(startup_path_set_home_cb), lc); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2007 |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2008 group = pref_group_new(vbox, FALSE, _("Layout"), GTK_ORIENTATION_VERTICAL); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2009 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2010 lc->layout_widget = layout_config_new(); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2011 layout_config_set(lc->layout_widget, lw->options.style, lw->options.order); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2012 gtk_box_pack_start(GTK_BOX(group), lc->layout_widget, TRUE, TRUE, 0); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2013 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2014 gtk_widget_show(lc->layout_widget); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2015 gtk_widget_show(lc->configwindow); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2016 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2017 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2018 /* |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2019 *----------------------------------------------------------------------------- |
9 | 2020 * base |
2021 *----------------------------------------------------------------------------- | |
2022 */ | |
2023 | |
1309 | 2024 void layout_sync_options_with_current_state(LayoutWindow *lw) |
2025 { | |
1336 | 2026 Histogram *histogram; |
1309 | 2027 if (!layout_valid(&lw)) return; |
2028 | |
2029 lw->options.main_window.maximized = window_maximized(lw->window); | |
2030 if (!lw->options.main_window.maximized) | |
2031 { | |
2032 layout_geometry_get(lw, &lw->options.main_window.x, &lw->options.main_window.y, | |
2033 &lw->options.main_window.w, &lw->options.main_window.h); | |
2034 } | |
2035 | |
2036 layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos); | |
2037 | |
2038 // layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending); | |
2039 | |
2040 layout_geometry_get_tools(lw, &lw->options.float_window.x, &lw->options.float_window.y, | |
2041 &lw->options.float_window.w, &lw->options.float_window.h, &lw->options.float_window.vdivider_pos); | |
2042 | |
1336 | 2043 lw->options.image_overlay.state = image_osd_get(lw->image); |
2044 histogram = image_osd_get_histogram(lw->image); | |
2045 | |
2046 lw->options.image_overlay.histogram_channel = histogram->histogram_channel; | |
2047 lw->options.image_overlay.histogram_mode = histogram->histogram_mode; | |
2048 | |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2049 g_free(lw->options.last_path); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2050 lw->options.last_path = g_strdup(layout_get_path(lw)); |
1309 | 2051 } |
2052 | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2053 void layout_apply_options(LayoutWindow *lw, LayoutOptions *lop) |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2054 { |
1437 | 2055 gboolean refresh_style; |
2056 gboolean refresh_lists; | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2057 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2058 if (!layout_valid(&lw)) return; |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2059 /* FIXME: add other options too */ |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2060 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2061 refresh_style = (lop->style != lw->options.style || strcmp(lop->order, lw->options.order) != 0); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2062 refresh_lists = (lop->show_directory_date != lw->options.show_directory_date); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2063 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2064 copy_layout_options(&lw->options, lop); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2065 |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2066 if (refresh_style) layout_style_set(lw, lw->options.style, lw->options.order); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2067 if (refresh_lists) layout_refresh(lw); |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2068 } |
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2069 |
1309 | 2070 |
9 | 2071 void layout_close(LayoutWindow *lw) |
2072 { | |
1514
22174e704d0b
added option that simplifies saving of multi-window configurations
nadvornik
parents:
1511
diff
changeset
|
2073 if (!lw->options.exit_on_close && layout_window_list && layout_window_list->next) |
9 | 2074 { |
2075 layout_free(lw); | |
2076 } | |
2077 else | |
2078 { | |
278 | 2079 exit_program(); |
9 | 2080 } |
2081 } | |
2082 | |
2083 void layout_free(LayoutWindow *lw) | |
2084 { | |
2085 if (!lw) return; | |
2086 | |
2087 layout_window_list = g_list_remove(layout_window_list, lw); | |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2088 if (current_lw == lw) current_lw = NULL; |
9 | 2089 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1291
diff
changeset
|
2090 if (lw->exif_window) g_signal_handlers_disconnect_matched(G_OBJECT(lw->exif_window), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, lw); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1291
diff
changeset
|
2091 |
9 | 2092 layout_bars_close(lw); |
2093 | |
1470 | 2094 g_object_unref(lw->menu_bar); |
2095 g_object_unref(lw->toolbar); | |
2096 g_object_unref(lw->utility_box); | |
2097 | |
9 | 2098 gtk_widget_destroy(lw->window); |
837
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
820
diff
changeset
|
2099 |
f8c22438376c
use GtkSizeGroup to control initial size of split images
nadvornik
parents:
820
diff
changeset
|
2100 if (lw->split_image_sizegroup) g_object_unref(lw->split_image_sizegroup); |
442 | 2101 |
796 | 2102 file_data_unregister_notify_func(layout_image_notify_cb, lw); |
2103 | |
995 | 2104 if (lw->dir_fd) |
791 | 2105 { |
2106 file_data_unregister_real_time_monitor(lw->dir_fd); | |
2107 file_data_unref(lw->dir_fd); | |
2108 } | |
9 | 2109 |
1335 | 2110 string_list_free(lw->toolbar_actions); |
1309 | 2111 free_layout_options_content(&lw->options); |
9 | 2112 g_free(lw); |
2113 } | |
2114 | |
1433
b4ad1d201279
Use gboolean where applicable, minor cleanup and indentations fixes.
zas_
parents:
1431
diff
changeset
|
2115 static gboolean layout_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) |
9 | 2116 { |
2117 LayoutWindow *lw = data; | |
2118 | |
2119 layout_close(lw); | |
2120 return TRUE; | |
2121 } | |
2122 | |
1309 | 2123 LayoutWindow *layout_new(FileData *dir_fd, LayoutOptions *lop) |
9 | 2124 { |
1309 | 2125 return layout_new_with_geometry(dir_fd, lop, NULL); |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2126 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2127 |
1309 | 2128 LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop, |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2129 const gchar *geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2130 { |
9 | 2131 LayoutWindow *lw; |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2132 GdkGeometry hint; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2133 GdkWindowHints hint_mask; |
1336 | 2134 Histogram *histogram; |
9 | 2135 |
2136 lw = g_new0(LayoutWindow, 1); | |
2137 | |
1309 | 2138 if (lop) |
2139 copy_layout_options(&lw->options, lop); | |
2140 else | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2141 init_layout_options(&lw->options); |
1309 | 2142 |
9 | 2143 lw->sort_method = SORT_NAME; |
2144 lw->sort_ascend = TRUE; | |
2145 | |
1466
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2146 layout_set_unique_id(lw); |
1309 | 2147 // lw->options.tools_float = popped; |
2148 // lw->options.tools_hidden = hidden; | |
2149 // lw->bar_sort_enabled = options->panels.sort.enabled; | |
2150 // lw->bar_enabled = options->panels.info.enabled; | |
9 | 2151 |
2152 /* default layout */ | |
2153 | |
1309 | 2154 layout_config_parse(lw->options.style, lw->options.order, |
9 | 2155 &lw->dir_location, &lw->file_location, &lw->image_location); |
1309 | 2156 if (lw->options.dir_view_type >= VIEW_DIR_TYPES_COUNT) lw->options.dir_view_type = 0; |
2157 if (lw->options.file_view_type >= VIEW_FILE_TYPES_COUNT) lw->options.file_view_type = 0; | |
9 | 2158 |
2159 /* divider positions */ | |
2160 | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2161 if (!options->save_window_positions) |
9 | 2162 { |
1309 | 2163 lw->options.main_window.hdivider_pos = MAIN_WINDOW_DIV_HPOS; |
2164 lw->options.main_window.vdivider_pos = MAIN_WINDOW_DIV_VPOS; | |
2165 lw->options.float_window.vdivider_pos = MAIN_WINDOW_DIV_VPOS; | |
9 | 2166 } |
2167 | |
2168 /* window */ | |
2169 | |
1174
0bea79d87065
Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents:
1167
diff
changeset
|
2170 lw->window = window_new(GTK_WINDOW_TOPLEVEL, GQ_APPNAME_LC, NULL, NULL, NULL); |
9 | 2171 gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE); |
2172 gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0); | |
2173 | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2174 if (options->save_window_positions) |
9 | 2175 { |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2176 hint_mask = GDK_HINT_USER_POS; |
9 | 2177 } |
2178 else | |
2179 { | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2180 hint_mask = 0; |
9 | 2181 } |
2182 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2183 hint.min_width = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2184 hint.min_height = 32; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2185 hint.base_width = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2186 hint.base_height = 0; |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2187 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
|
2188 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hint_mask); |
9 | 2189 |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2190 if (options->save_window_positions) |
9 | 2191 { |
1309 | 2192 gtk_window_set_default_size(GTK_WINDOW(lw->window), lw->options.main_window.w, lw->options.main_window.h); |
2193 // if (!layout_window_list) | |
2194 // { | |
2195 gtk_window_move(GTK_WINDOW(lw->window), lw->options.main_window.x, lw->options.main_window.y); | |
2196 if (lw->options.main_window.maximized) gtk_window_maximize(GTK_WINDOW(lw->window)); | |
2197 // } | |
9 | 2198 } |
2199 else | |
2200 { | |
2201 gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT); | |
2202 } | |
2203 | |
2204 g_signal_connect(G_OBJECT(lw->window), "delete_event", | |
2205 G_CALLBACK(layout_delete_cb), lw); | |
2206 | |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2207 g_signal_connect(G_OBJECT(lw->window), "focus-in-event", |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2208 G_CALLBACK(layout_set_current_cb), lw); |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2209 |
9 | 2210 layout_keyboard_init(lw, lw->window); |
2211 | |
528 | 2212 #ifdef HAVE_LIRC |
2213 layout_image_lirc_init(lw); | |
2214 #endif | |
2215 | |
9 | 2216 lw->main_box = gtk_vbox_new(FALSE, 0); |
2217 gtk_container_add(GTK_CONTAINER(lw->window), lw->main_box); | |
2218 gtk_widget_show(lw->main_box); | |
2219 | |
2220 layout_grid_setup(lw); | |
1309 | 2221 image_top_window_set_sync(lw->image, (lw->options.tools_float || lw->options.tools_hidden)); |
9 | 2222 |
2223 layout_util_sync(lw); | |
2224 layout_status_update_all(lw); | |
2225 | |
783 | 2226 if (dir_fd) |
9 | 2227 { |
783 | 2228 layout_set_fd(lw, dir_fd); |
9 | 2229 } |
2230 else | |
2231 { | |
2232 GdkPixbuf *pixbuf; | |
2233 | |
2234 pixbuf = pixbuf_inline(PIXBUF_INLINE_LOGO); | |
1287
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2235 |
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2236 /* FIXME: the zoom value set here is the value, which is then copied again and again |
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2237 in "Leave Zoom at previous setting" mode. This is not ideal. */ |
5fdf258f9c24
Start with "Fit to window" in "Leave Zoom at previous setting" mode
nadvornik
parents:
1284
diff
changeset
|
2238 image_change_pixbuf(lw->image, pixbuf, 0.0, FALSE); |
1043 | 2239 g_object_unref(pixbuf); |
9 | 2240 } |
2241 | |
81
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2242 if (geometry) |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2243 { |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2244 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
|
2245 { |
694 | 2246 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
|
2247 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2248 } |
0ef72a64930b
Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
2249 |
9 | 2250 gtk_widget_show(lw->window); |
1309 | 2251 layout_tools_hide(lw, lw->options.tools_hidden); |
9 | 2252 |
1336 | 2253 image_osd_set(lw->image, lw->options.image_overlay.state); |
2254 histogram = image_osd_get_histogram(lw->image); | |
2255 | |
2256 histogram->histogram_channel = lw->options.image_overlay.histogram_channel; | |
2257 histogram->histogram_mode = lw->options.image_overlay.histogram_mode; | |
1313 | 2258 |
9 | 2259 layout_window_list = g_list_append(layout_window_list, lw); |
2260 | |
796 | 2261 file_data_register_notify_func(layout_image_notify_cb, lw, NOTIFY_PRIORITY_LOW); |
2262 | |
9 | 2263 return lw; |
2264 } | |
2265 | |
1309 | 2266 void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent) |
2267 { | |
1466
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2268 WRITE_NL(); WRITE_CHAR(*layout, id); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2269 |
1461 | 2270 WRITE_NL(); WRITE_INT(*layout, style); |
2271 WRITE_NL(); WRITE_CHAR(*layout, order); | |
2272 WRITE_NL(); WRITE_UINT(*layout, dir_view_type); | |
2273 WRITE_NL(); WRITE_UINT(*layout, file_view_type); | |
2274 WRITE_NL(); WRITE_BOOL(*layout, show_marks); | |
2275 WRITE_NL(); WRITE_BOOL(*layout, show_thumbnails); | |
2276 WRITE_NL(); WRITE_BOOL(*layout, show_directory_date); | |
2277 WRITE_NL(); WRITE_CHAR(*layout, home_path); | |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2278 WRITE_NL(); WRITE_CHAR(*layout, last_path); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2279 WRITE_NL(); WRITE_UINT(*layout, startup_path); |
1514
22174e704d0b
added option that simplifies saving of multi-window configurations
nadvornik
parents:
1511
diff
changeset
|
2280 WRITE_NL(); WRITE_BOOL(*layout, exit_on_close); |
1309 | 2281 WRITE_SEPARATOR(); |
2282 | |
1461 | 2283 WRITE_NL(); WRITE_INT(*layout, main_window.x); |
2284 WRITE_NL(); WRITE_INT(*layout, main_window.y); | |
2285 WRITE_NL(); WRITE_INT(*layout, main_window.w); | |
2286 WRITE_NL(); WRITE_INT(*layout, main_window.h); | |
2287 WRITE_NL(); WRITE_BOOL(*layout, main_window.maximized); | |
2288 WRITE_NL(); WRITE_INT(*layout, main_window.hdivider_pos); | |
2289 WRITE_NL(); WRITE_INT(*layout, main_window.vdivider_pos); | |
1309 | 2290 WRITE_SEPARATOR(); |
2291 | |
1461 | 2292 WRITE_NL(); WRITE_INT(*layout, float_window.x); |
2293 WRITE_NL(); WRITE_INT(*layout, float_window.y); | |
2294 WRITE_NL(); WRITE_INT(*layout, float_window.w); | |
2295 WRITE_NL(); WRITE_INT(*layout, float_window.h); | |
2296 WRITE_NL(); WRITE_INT(*layout, float_window.vdivider_pos); | |
1309 | 2297 WRITE_SEPARATOR(); |
2298 | |
1461 | 2299 WRITE_NL(); WRITE_INT(*layout, properties_window.w); |
2300 WRITE_NL(); WRITE_INT(*layout, properties_window.h); | |
1309 | 2301 WRITE_SEPARATOR(); |
2302 | |
1461 | 2303 WRITE_NL(); WRITE_BOOL(*layout, tools_float); |
2304 WRITE_NL(); WRITE_BOOL(*layout, tools_hidden); | |
1309 | 2305 WRITE_SEPARATOR(); |
2306 | |
1461 | 2307 WRITE_NL(); WRITE_BOOL(*layout, toolbar_hidden); |
2308 WRITE_NL(); WRITE_BOOL(*layout, info_pixel_hidden); | |
2309 | |
2310 WRITE_NL(); WRITE_UINT(*layout, image_overlay.state); | |
2311 WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_channel); | |
2312 WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_mode); | |
1309 | 2313 } |
2314 | |
2315 | |
2316 void layout_write_config(LayoutWindow *lw, GString *outstr, gint indent) | |
2317 { | |
2318 layout_sync_options_with_current_state(lw); | |
1461 | 2319 WRITE_NL(); WRITE_STRING("<layout"); |
1309 | 2320 layout_write_attributes(&lw->options, outstr, indent + 1); |
1461 | 2321 WRITE_STRING(">"); |
1309 | 2322 |
1320 | 2323 bar_sort_write_config(lw->bar_sort, outstr, indent + 1); |
1309 | 2324 bar_write_config(lw->bar, outstr, indent + 1); |
2325 | |
1335 | 2326 layout_toolbar_write_config(lw, outstr, indent + 1); |
2327 | |
1461 | 2328 WRITE_NL(); WRITE_STRING("</layout>"); |
1309 | 2329 } |
2330 | |
2331 void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names, const gchar **attribute_values) | |
2332 { | |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2333 gchar *id = NULL; |
1309 | 2334 |
2335 while (*attribute_names) | |
2336 { | |
2337 const gchar *option = *attribute_names++; | |
2338 const gchar *value = *attribute_values++; | |
2339 | |
2340 /* layout options */ | |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2341 if (READ_CHAR_FULL("id", id)) continue; |
1309 | 2342 |
1315 | 2343 if (READ_INT(*layout, style)) continue; |
2344 if (READ_CHAR(*layout, order)) continue; | |
1309 | 2345 |
1315 | 2346 if (READ_UINT(*layout, dir_view_type)) continue; |
2347 if (READ_UINT(*layout, file_view_type)) continue; | |
2348 if (READ_BOOL(*layout, show_marks)) continue; | |
2349 if (READ_BOOL(*layout, show_thumbnails)) continue; | |
2350 if (READ_BOOL(*layout, show_directory_date)) continue; | |
2351 if (READ_CHAR(*layout, home_path)) continue; | |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2352 if (READ_CHAR(*layout, last_path)) continue; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2353 if (READ_UINT_CLAMP(*layout, startup_path, 0, STARTUP_PATH_HOME)) continue; |
1514
22174e704d0b
added option that simplifies saving of multi-window configurations
nadvornik
parents:
1511
diff
changeset
|
2354 if (READ_BOOL(*layout, exit_on_close)) continue; |
1309 | 2355 |
2356 /* window positions */ | |
2357 | |
1315 | 2358 if (READ_INT(*layout, main_window.x)) continue; |
2359 if (READ_INT(*layout, main_window.y)) continue; | |
2360 if (READ_INT(*layout, main_window.w)) continue; | |
2361 if (READ_INT(*layout, main_window.h)) continue; | |
2362 if (READ_BOOL(*layout, main_window.maximized)) continue; | |
2363 if (READ_INT(*layout, main_window.hdivider_pos)) continue; | |
2364 if (READ_INT(*layout, main_window.vdivider_pos)) continue; | |
2365 | |
2366 if (READ_INT(*layout, float_window.x)) continue; | |
2367 if (READ_INT(*layout, float_window.y)) continue; | |
2368 if (READ_INT(*layout, float_window.w)) continue; | |
2369 if (READ_INT(*layout, float_window.h)) continue; | |
2370 if (READ_INT(*layout, float_window.vdivider_pos)) continue; | |
1309 | 2371 |
1315 | 2372 if (READ_INT(*layout, properties_window.w)) continue; |
2373 if (READ_INT(*layout, properties_window.h)) continue; | |
2374 | |
2375 if (READ_BOOL(*layout, tools_float)) continue; | |
2376 if (READ_BOOL(*layout, tools_hidden)) continue; | |
2377 if (READ_BOOL(*layout, toolbar_hidden)) continue; | |
1375
df58e511d90e
Display pixel coordinates and rgb - patch by Ruben Stein
nadvornik
parents:
1372
diff
changeset
|
2378 if (READ_BOOL(*layout, info_pixel_hidden)) continue; |
1309 | 2379 |
1336 | 2380 if (READ_UINT(*layout, image_overlay.state)) continue; |
2381 if (READ_INT(*layout, image_overlay.histogram_channel)) continue; | |
2382 if (READ_INT(*layout, image_overlay.histogram_mode)) continue; | |
2383 | |
1464 | 2384 log_printf("unknown attribute %s = %s\n", option, value); |
1309 | 2385 } |
1473
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2386 if (id && strcmp(id, LAYOUT_ID_CURRENT) != 0) |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2387 { |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2388 g_free(layout->id); |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2389 layout->id = id; |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2390 } |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2391 else |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2392 { |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2393 g_free(id); |
01693e68707b
layout id "_current_" matches the currently active layout window
nadvornik
parents:
1470
diff
changeset
|
2394 } |
1309 | 2395 } |
2396 | |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2397 static void layout_config_startup_path(LayoutOptions *lop, gchar **path) |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2398 { |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2399 switch (lop->startup_path) |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2400 { |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2401 case STARTUP_PATH_LAST: |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2402 *path = (lop->last_path && isdir(lop->last_path)) ? g_strdup(lop->last_path) : get_current_dir(); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2403 break; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2404 case STARTUP_PATH_HOME: |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2405 *path = (lop->home_path && isdir(lop->home_path)) ? g_strdup(lop->home_path) : g_strdup(homedir()); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2406 break; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2407 default: |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2408 *path = get_current_dir(); |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2409 break; |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2410 } |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2411 } |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2412 |
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2413 |
1313 | 2414 static void layout_config_commandline(LayoutOptions *lop, gchar **path) |
2415 { | |
2416 if (command_line->startup_blank) | |
2417 { | |
2418 *path = NULL; | |
2419 } | |
2420 else if (command_line->file) | |
2421 { | |
2422 *path = g_strdup(command_line->file); | |
2423 } | |
2424 else if (command_line->path) | |
2425 { | |
2426 *path = g_strdup(command_line->path); | |
2427 } | |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2428 else layout_config_startup_path(lop, path); |
1313 | 2429 |
2430 if (command_line->tools_show) | |
2431 { | |
2432 lop->tools_float = FALSE; | |
2433 lop->tools_hidden = FALSE; | |
2434 } | |
2435 else if (command_line->tools_hide) | |
2436 { | |
2437 lop->tools_hidden = TRUE; | |
2438 } | |
2439 } | |
2440 | |
2441 LayoutWindow *layout_new_from_config(const gchar **attribute_names, const gchar **attribute_values, gboolean use_commandline) | |
1309 | 2442 { |
2443 LayoutOptions lop; | |
2444 LayoutWindow *lw; | |
1313 | 2445 gchar *path = NULL; |
2446 | |
1436
d7a6fb7a90dd
completely separated global and layout window options
nadvornik
parents:
1433
diff
changeset
|
2447 init_layout_options(&lop); |
1309 | 2448 |
1313 | 2449 if (attribute_names) layout_load_attributes(&lop, attribute_names, attribute_values); |
2450 | |
2451 if (use_commandline) | |
2452 { | |
2453 layout_config_commandline(&lop, &path); | |
2454 } | |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2455 else |
1313 | 2456 { |
1511
73cecf473802
startup path options simplified and moved to layout options
nadvornik
parents:
1506
diff
changeset
|
2457 layout_config_startup_path(&lop, &path); |
1313 | 2458 } |
2459 | |
2460 lw = layout_new_with_geometry(NULL, &lop, use_commandline ? command_line->geometry : NULL); | |
1309 | 2461 layout_sort_set(lw, options->file_sort.method, options->file_sort.ascending); |
1313 | 2462 layout_set_path(lw, path); |
2463 | |
2464 if (use_commandline && command_line->startup_full_screen) layout_image_full_screen_start(lw); | |
2465 if (use_commandline && command_line->startup_in_slideshow) layout_image_slideshow_start(lw); | |
2466 | |
2467 | |
2468 g_free(path); | |
1309 | 2469 free_layout_options_content(&lop); |
2470 return lw; | |
2471 } | |
2472 | |
1466
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2473 void layout_update_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values) |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2474 { |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2475 LayoutOptions lop; |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2476 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2477 init_layout_options(&lop); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2478 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2479 if (attribute_names) layout_load_attributes(&lop, attribute_names, attribute_values); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2480 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2481 layout_apply_options(lw, &lop); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2482 |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2483 free_layout_options_content(&lop); |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2484 } |
6e020d3ab168
added possibility to update existing layout window from config
nadvornik
parents:
1464
diff
changeset
|
2485 |
1309 | 2486 |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1045
diff
changeset
|
2487 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |