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