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