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