Mercurial > geeqie
annotate src/menu.c @ 450:d643890c48d0
Fix a typo introduced by revision 521.
author | zas_ |
---|---|
date | Sun, 20 Apr 2008 21:38:45 +0000 |
parents | ddabc4873a3f |
children | 0ef1a94ee4c5 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "menu.h" |
1 | 15 |
9 | 16 #include "cache_maint.h" |
17 #include "collect.h" | |
18 #include "collect-dlg.h" | |
19 #include "dupe.h" | |
20 #include "filelist.h" | |
21 #include "img-view.h" | |
22 #include "preferences.h" | |
23 #include "slideshow.h" | |
24 #include "utilops.h" | |
25 #include "ui_fileops.h" | |
26 #include "ui_tabcomp.h" | |
27 #include "ui_menu.h" | |
28 | |
29 static GtkWidget *real_submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data, | |
30 GtkAccelGroup *accel_group); | |
1 | 31 |
32 /* | |
33 *----------------------------------------------------------------------------- | |
9 | 34 * menu utils |
1 | 35 *----------------------------------------------------------------------------- |
442 | 36 */ |
1 | 37 |
9 | 38 static GtkWidget *add_menu_item(GtkWidget *menu, gchar *label, GtkAccelGroup *accel_group, |
39 guint accel_key, guint accel_mods, GCallback func, gpointer data) | |
1 | 40 { |
41 GtkWidget *item; | |
42 | |
43 item = gtk_menu_item_new_with_label(label); | |
44 gtk_widget_add_accelerator (item, "activate", accel_group, accel_key, accel_mods, GTK_ACCEL_VISIBLE); | |
9 | 45 g_signal_connect(G_OBJECT(item), "activate", func, data); |
46 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
1 | 47 gtk_widget_show(item); |
9 | 48 |
49 return item; | |
1 | 50 } |
51 | |
9 | 52 gpointer submenu_item_get_data(GtkWidget *menu) |
1 | 53 { |
9 | 54 if (!menu->parent || !GTK_IS_MENU(menu->parent)) return NULL; |
1 | 55 |
9 | 56 return g_object_get_data(G_OBJECT(menu->parent), "submenu_data"); |
1 | 57 } |
58 | |
59 /* | |
60 *----------------------------------------------------------------------------- | |
9 | 61 * edit menu |
1 | 62 *----------------------------------------------------------------------------- |
442 | 63 */ |
1 | 64 |
9 | 65 static void add_edit_items(GtkWidget *menu, GCallback func, GtkAccelGroup *accel_grp) |
1 | 66 { |
67 gint i; | |
283 | 68 for (i = 0; i < GQ_EDITOR_SLOTS; i++) |
1 | 69 { |
318 | 70 if (options->editor_command[i] && strlen(options->editor_command[i]) > 0) |
1 | 71 { |
72 gchar *text; | |
318 | 73 if (options->editor_name[i] && strlen(options->editor_name[i]) > 0) |
74 text = g_strdup_printf(_("in %s..."), options->editor_name[i]); | |
1 | 75 else |
76 text = g_strdup(_("in (unknown)...")); | |
77 if (accel_grp) | |
78 add_menu_item(menu, text, accel_grp, i + 49, GDK_CONTROL_MASK, func, GINT_TO_POINTER(i)); | |
79 else | |
9 | 80 menu_item_add_simple(menu, text, func, GINT_TO_POINTER(i)); |
1 | 81 g_free(text); |
82 } | |
83 } | |
84 } | |
85 | |
9 | 86 GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data) |
1 | 87 { |
9 | 88 GtkWidget *item; |
89 GtkWidget *submenu; | |
1 | 90 |
9 | 91 item = menu_item_add(menu, _("_Edit"), NULL, NULL); |
1 | 92 |
9 | 93 submenu = gtk_menu_new(); |
94 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
95 add_edit_items(submenu, func, NULL); | |
1 | 96 |
9 | 97 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1 | 98 |
9 | 99 if (menu_item) *menu_item = item; |
1 | 100 |
9 | 101 return submenu; |
1 | 102 } |
103 | |
104 /* | |
105 *----------------------------------------------------------------------------- | |
9 | 106 * sorting |
1 | 107 *----------------------------------------------------------------------------- |
9 | 108 */ |
1 | 109 |
9 | 110 gchar *sort_type_get_text(SortType method) |
1 | 111 { |
9 | 112 switch (method) |
113 { | |
114 case SORT_SIZE: | |
115 return _("Sort by size"); | |
116 break; | |
117 case SORT_TIME: | |
118 return _("Sort by date"); | |
119 break; | |
120 case SORT_NONE: | |
121 return _("Unsorted"); | |
122 break; | |
123 case SORT_PATH: | |
124 return _("Sort by path"); | |
125 break; | |
126 case SORT_NUMBER: | |
127 return _("Sort by number"); | |
128 break; | |
129 case SORT_NAME: | |
130 default: | |
131 return _("Sort by name"); | |
132 break; | |
133 } | |
1 | 134 |
9 | 135 return ""; |
136 } | |
1 | 137 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
138 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
|
139 GCallback func, SortType type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
140 gint show_current, SortType show_type) |
9 | 141 { |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
142 GtkWidget *item; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
143 |
9 | 144 if (show_current) |
145 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
146 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
|
147 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
|
148 func, GINT_TO_POINTER((gint)type)); |
9 | 149 } |
150 else | |
151 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
152 item = menu_item_add(menu, sort_type_get_text(type), |
120 | 153 func, GINT_TO_POINTER((gint)type)); |
9 | 154 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
155 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
156 return item; |
9 | 157 } |
1 | 158 |
9 | 159 GtkWidget *submenu_add_sort(GtkWidget *menu, GCallback func, gpointer data, |
160 gint include_none, gint include_path, | |
161 gint show_current, SortType type) | |
162 { | |
163 GtkWidget *submenu; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
164 GtkWidget *parent; |
1 | 165 |
9 | 166 submenu = gtk_menu_new(); |
167 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
168 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
169 parent = submenu_add_sort_item(submenu, NULL, func, SORT_NAME, show_current, type); |
9 | 170 #ifdef HAVE_STRVERSCMP |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
171 submenu_add_sort_item(submenu, parent, func, SORT_NUMBER, show_current, type); |
9 | 172 #endif |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 if (include_none) submenu_add_sort_item(submenu, parent, func, SORT_NONE, show_current, type); |
9 | 177 |
178 if (menu) | |
179 { | |
180 GtkWidget *item; | |
181 | |
182 item = menu_item_add(menu, _("Sort"), NULL, NULL); | |
183 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
184 return item; | |
185 } | |
186 | |
187 return submenu; | |
1 | 188 } |
189 | |
190 /* | |
191 *----------------------------------------------------------------------------- | |
9 | 192 * altering |
1 | 193 *----------------------------------------------------------------------------- |
9 | 194 */ |
1 | 195 |
9 | 196 gchar *alter_type_get_text(AlterType type) |
1 | 197 { |
9 | 198 switch (type) |
1 | 199 { |
9 | 200 case ALTER_ROTATE_90: |
201 return _("_Rotate clockwise"); | |
202 break; | |
203 case ALTER_ROTATE_90_CC: | |
204 return _("Rotate _counterclockwise"); | |
205 break; | |
206 case ALTER_ROTATE_180: | |
207 return _("Rotate _180"); | |
208 break; | |
209 case ALTER_MIRROR: | |
210 return _("_Mirror"); | |
211 break; | |
212 case ALTER_FLIP: | |
213 return _("_Flip"); | |
214 break; | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
215 case ALTER_DESATURATE: |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
318
diff
changeset
|
216 return _("Toggle _grayscale"); |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
217 break; |
439 | 218 case ALTER_NONE: |
219 return _("_Original state"); | |
220 break; | |
9 | 221 default: |
222 break; | |
223 } | |
224 | |
225 return ""; | |
226 } | |
227 | |
228 static void submenu_add_alter_item(GtkWidget *menu, GCallback func, AlterType type, | |
229 GtkAccelGroup *accel_group, guint accel_key, guint accel_mods) | |
230 { | |
231 if (accel_group) | |
232 { | |
233 add_menu_item(menu, alter_type_get_text(type), accel_group, | |
234 accel_key, accel_mods, func, GINT_TO_POINTER((gint)type)); | |
442 | 235 |
9 | 236 } |
237 else | |
238 { | |
239 menu_item_add(menu, alter_type_get_text(type), func, GINT_TO_POINTER((gint)type)); | |
1 | 240 } |
241 } | |
242 | |
9 | 243 static GtkWidget *real_submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data, |
244 GtkAccelGroup *accel_group) | |
1 | 245 { |
9 | 246 GtkWidget *submenu; |
1 | 247 |
9 | 248 submenu = gtk_menu_new(); |
249 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
1 | 250 |
9 | 251 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90, accel_group, ']', 0); |
252 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90_CC, accel_group, '[', 0); | |
253 submenu_add_alter_item(submenu, func, ALTER_ROTATE_180, accel_group, 'R', GDK_SHIFT_MASK); | |
254 submenu_add_alter_item(submenu, func, ALTER_MIRROR, accel_group, 'M', GDK_SHIFT_MASK); | |
255 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
|
256 submenu_add_alter_item(submenu, func, ALTER_DESATURATE, accel_group, 'G', GDK_SHIFT_MASK); |
439 | 257 submenu_add_alter_item(submenu, func, ALTER_NONE, accel_group, 'O', GDK_SHIFT_MASK); |
1 | 258 |
9 | 259 if (menu) |
260 { | |
261 GtkWidget *item; | |
1 | 262 |
9 | 263 item = menu_item_add(menu, _("_Adjust"), NULL, NULL); |
264 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
265 return item; | |
266 } | |
267 | |
268 return submenu; | |
1 | 269 } |
270 | |
9 | 271 GtkWidget *submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data) |
1 | 272 { |
9 | 273 return real_submenu_add_alter(menu, func, data, NULL); |
1 | 274 } |