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