Mercurial > geeqie
annotate src/menu.c @ 1412:5a534e1501e1
fixed saving of file_view_type
author | nadvornik |
---|---|
date | Tue, 10 Mar 2009 22:52:12 +0000 |
parents | 67573155210c |
children | 3bc4967aaa57 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
1284 | 4 * Copyright (C) 2008 - 2009 The Geeqie Team |
1 | 5 * |
6 * Author: John Ellis | |
7 * | |
9 | 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! | |
1 | 11 */ |
12 | |
13 | |
281 | 14 #include "main.h" |
9 | 15 #include "menu.h" |
1 | 16 |
9 | 17 #include "cache_maint.h" |
18 #include "collect.h" | |
19 #include "collect-dlg.h" | |
20 #include "dupe.h" | |
731
fa8f7d7396cf
Introduce an helper function that returns the name of an editor.
zas_
parents:
730
diff
changeset
|
21 #include "editors.h" |
586 | 22 #include "filedata.h" |
9 | 23 #include "img-view.h" |
1398 | 24 #include "pixbuf_util.h" |
9 | 25 #include "preferences.h" |
26 #include "slideshow.h" | |
27 #include "utilops.h" | |
28 #include "ui_fileops.h" | |
29 #include "ui_tabcomp.h" | |
30 #include "ui_menu.h" | |
31 | |
32 static GtkWidget *real_submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data, | |
33 GtkAccelGroup *accel_group); | |
1 | 34 |
35 /* | |
36 *----------------------------------------------------------------------------- | |
9 | 37 * menu utils |
1 | 38 *----------------------------------------------------------------------------- |
442 | 39 */ |
1 | 40 |
9 | 41 static GtkWidget *add_menu_item(GtkWidget *menu, gchar *label, GtkAccelGroup *accel_group, |
42 guint accel_key, guint accel_mods, GCallback func, gpointer data) | |
1 | 43 { |
44 GtkWidget *item; | |
45 | |
46 item = gtk_menu_item_new_with_label(label); | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
475
diff
changeset
|
47 gtk_widget_add_accelerator(item, "activate", accel_group, accel_key, accel_mods, GTK_ACCEL_VISIBLE); |
9 | 48 g_signal_connect(G_OBJECT(item), "activate", func, data); |
49 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
1 | 50 gtk_widget_show(item); |
9 | 51 |
52 return item; | |
1 | 53 } |
54 | |
9 | 55 gpointer submenu_item_get_data(GtkWidget *menu) |
1 | 56 { |
9 | 57 if (!menu->parent || !GTK_IS_MENU(menu->parent)) return NULL; |
1 | 58 |
9 | 59 return g_object_get_data(G_OBJECT(menu->parent), "submenu_data"); |
1 | 60 } |
61 | |
62 /* | |
63 *----------------------------------------------------------------------------- | |
9 | 64 * edit menu |
1 | 65 *----------------------------------------------------------------------------- |
442 | 66 */ |
1 | 67 |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
68 static void add_edit_items(GtkWidget *menu, GCallback func, GList *fd_list) |
1 | 69 { |
1272 | 70 GList *editors_list = editor_list_get(); |
71 GList *work = editors_list; | |
731
fa8f7d7396cf
Introduce an helper function that returns the name of an editor.
zas_
parents:
730
diff
changeset
|
72 |
1272 | 73 while (work) |
74 { | |
75 const EditorDescription *editor = work->data; | |
76 work = work->next; | |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
77 gboolean active = TRUE; |
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
78 |
1400
67573155210c
Add helper macros EDITOR_ERRORS() and EDITOR_ERRORS_BUT_SKIPPED() to clean up the code a bit. Minor tidy up.
zas_
parents:
1398
diff
changeset
|
79 if (fd_list && EDITOR_ERRORS(editor_command_parse(editor, fd_list, NULL))) |
67573155210c
Add helper macros EDITOR_ERRORS() and EDITOR_ERRORS_BUT_SKIPPED() to clean up the code a bit. Minor tidy up.
zas_
parents:
1398
diff
changeset
|
80 active = FALSE; |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
81 |
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
82 if (active) |
1398 | 83 { |
84 const gchar *stock_id = NULL; | |
85 if (editor->icon && register_theme_icon_as_stock(editor->key, editor->icon)) | |
86 stock_id = editor->key; | |
87 | |
88 menu_item_add_stock(menu, editor->name, stock_id, func, editor->key); | |
89 } | |
1272 | 90 } |
91 | |
92 g_list_free(editors_list); | |
93 } | |
731
fa8f7d7396cf
Introduce an helper function that returns the name of an editor.
zas_
parents:
730
diff
changeset
|
94 |
1 | 95 |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
96 GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data, GList *fd_list) |
1 | 97 { |
9 | 98 GtkWidget *item; |
99 GtkWidget *submenu; | |
1 | 100 |
9 | 101 item = menu_item_add(menu, _("_Edit"), NULL, NULL); |
1 | 102 |
9 | 103 submenu = gtk_menu_new(); |
104 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1284
diff
changeset
|
105 add_edit_items(submenu, func, fd_list); |
1 | 106 |
9 | 107 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1 | 108 |
9 | 109 if (menu_item) *menu_item = item; |
1 | 110 |
9 | 111 return submenu; |
1 | 112 } |
113 | |
114 /* | |
115 *----------------------------------------------------------------------------- | |
9 | 116 * sorting |
1 | 117 *----------------------------------------------------------------------------- |
9 | 118 */ |
1 | 119 |
9 | 120 gchar *sort_type_get_text(SortType method) |
1 | 121 { |
9 | 122 switch (method) |
123 { | |
124 case SORT_SIZE: | |
125 return _("Sort by size"); | |
126 break; | |
127 case SORT_TIME: | |
128 return _("Sort by date"); | |
129 break; | |
130 case SORT_NONE: | |
131 return _("Unsorted"); | |
132 break; | |
133 case SORT_PATH: | |
134 return _("Sort by path"); | |
135 break; | |
136 case SORT_NUMBER: | |
137 return _("Sort by number"); | |
138 break; | |
139 case SORT_NAME: | |
140 default: | |
141 return _("Sort by name"); | |
142 break; | |
143 } | |
1 | 144 |
9 | 145 return ""; |
146 } | |
1 | 147 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
148 static GtkWidget *submenu_add_sort_item(GtkWidget *menu, GtkWidget *parent, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
149 GCallback func, SortType type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
150 gint show_current, SortType show_type) |
9 | 151 { |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
152 GtkWidget *item; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
153 |
9 | 154 if (show_current) |
155 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
156 item = menu_item_add_radio(menu, parent, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
157 sort_type_get_text(type), (type == show_type), |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
158 func, GINT_TO_POINTER((gint)type)); |
9 | 159 } |
160 else | |
161 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
162 item = menu_item_add(menu, sort_type_get_text(type), |
120 | 163 func, GINT_TO_POINTER((gint)type)); |
9 | 164 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
165 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
166 return item; |
9 | 167 } |
1 | 168 |
9 | 169 GtkWidget *submenu_add_sort(GtkWidget *menu, GCallback func, gpointer data, |
170 gint include_none, gint include_path, | |
171 gint show_current, SortType type) | |
172 { | |
173 GtkWidget *submenu; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
174 GtkWidget *parent; |
1 | 175 |
9 | 176 submenu = gtk_menu_new(); |
177 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
178 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
179 parent = submenu_add_sort_item(submenu, NULL, func, SORT_NAME, show_current, type); |
9 | 180 #ifdef HAVE_STRVERSCMP |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
181 submenu_add_sort_item(submenu, parent, func, SORT_NUMBER, show_current, type); |
9 | 182 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
183 submenu_add_sort_item(submenu, parent, func, SORT_TIME, show_current, type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
184 submenu_add_sort_item(submenu, parent, func, SORT_SIZE, show_current, type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
185 if (include_path) submenu_add_sort_item(submenu, parent, func, SORT_PATH, show_current, type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
186 if (include_none) submenu_add_sort_item(submenu, parent, func, SORT_NONE, show_current, type); |
9 | 187 |
188 if (menu) | |
189 { | |
190 GtkWidget *item; | |
191 | |
192 item = menu_item_add(menu, _("Sort"), NULL, NULL); | |
193 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
194 return item; | |
195 } | |
196 | |
197 return submenu; | |
1 | 198 } |
199 | |
200 /* | |
201 *----------------------------------------------------------------------------- | |
9 | 202 * altering |
1 | 203 *----------------------------------------------------------------------------- |
9 | 204 */ |
1 | 205 |
9 | 206 gchar *alter_type_get_text(AlterType type) |
1 | 207 { |
9 | 208 switch (type) |
1 | 209 { |
9 | 210 case ALTER_ROTATE_90: |
211 return _("_Rotate clockwise"); | |
212 break; | |
213 case ALTER_ROTATE_90_CC: | |
214 return _("Rotate _counterclockwise"); | |
215 break; | |
216 case ALTER_ROTATE_180: | |
217 return _("Rotate _180"); | |
218 break; | |
219 case ALTER_MIRROR: | |
220 return _("_Mirror"); | |
221 break; | |
222 case ALTER_FLIP: | |
223 return _("_Flip"); | |
224 break; | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
225 case ALTER_DESATURATE: |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
318
diff
changeset
|
226 return _("Toggle _grayscale"); |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
227 break; |
439 | 228 case ALTER_NONE: |
229 return _("_Original state"); | |
230 break; | |
9 | 231 default: |
232 break; | |
233 } | |
234 | |
235 return ""; | |
236 } | |
237 | |
238 static void submenu_add_alter_item(GtkWidget *menu, GCallback func, AlterType type, | |
239 GtkAccelGroup *accel_group, guint accel_key, guint accel_mods) | |
240 { | |
241 if (accel_group) | |
242 { | |
243 add_menu_item(menu, alter_type_get_text(type), accel_group, | |
244 accel_key, accel_mods, func, GINT_TO_POINTER((gint)type)); | |
442 | 245 |
9 | 246 } |
247 else | |
248 { | |
249 menu_item_add(menu, alter_type_get_text(type), func, GINT_TO_POINTER((gint)type)); | |
1 | 250 } |
251 } | |
252 | |
9 | 253 static GtkWidget *real_submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data, |
254 GtkAccelGroup *accel_group) | |
1 | 255 { |
9 | 256 GtkWidget *submenu; |
1 | 257 |
9 | 258 submenu = gtk_menu_new(); |
259 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
1 | 260 |
9 | 261 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90, accel_group, ']', 0); |
262 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90_CC, accel_group, '[', 0); | |
263 submenu_add_alter_item(submenu, func, ALTER_ROTATE_180, accel_group, 'R', GDK_SHIFT_MASK); | |
264 submenu_add_alter_item(submenu, func, ALTER_MIRROR, accel_group, 'M', GDK_SHIFT_MASK); | |
265 submenu_add_alter_item(submenu, func, ALTER_FLIP, accel_group, 'F', GDK_SHIFT_MASK); | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
266 submenu_add_alter_item(submenu, func, ALTER_DESATURATE, accel_group, 'G', GDK_SHIFT_MASK); |
439 | 267 submenu_add_alter_item(submenu, func, ALTER_NONE, accel_group, 'O', GDK_SHIFT_MASK); |
1 | 268 |
9 | 269 if (menu) |
270 { | |
271 GtkWidget *item; | |
1 | 272 |
9 | 273 item = menu_item_add(menu, _("_Adjust"), NULL, NULL); |
274 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
275 return item; | |
276 } | |
277 | |
278 return submenu; | |
1 | 279 } |
280 | |
9 | 281 GtkWidget *submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data) |
1 | 282 { |
9 | 283 return real_submenu_add_alter(menu, func, data, NULL); |
1 | 284 } |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
731
diff
changeset
|
285 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |