Mercurial > geeqie
annotate src/menu.c @ 562:544958ddd70e
Rename thumbs_fd to thumbs_filedata in ViewFileIcon struct to match
the name used in ViewFileList.
author | zas_ |
---|---|
date | Sat, 03 May 2008 15:13:15 +0000 |
parents | f9bf33be53ff |
children | 0da87187d5fb |
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" | |
21 #include "filelist.h" | |
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; | |
283 | 69 for (i = 0; i < GQ_EDITOR_SLOTS; i++) |
1 | 70 { |
318 | 71 if (options->editor_command[i] && strlen(options->editor_command[i]) > 0) |
1 | 72 { |
73 gchar *text; | |
318 | 74 if (options->editor_name[i] && strlen(options->editor_name[i]) > 0) |
455 | 75 text = g_strdup_printf(_("_%d in %s..."), i, options->editor_name[i]); |
1 | 76 else |
455 | 77 text = g_strdup_printf(_("_%d in (unknown)..."), i); |
1 | 78 if (accel_grp) |
79 add_menu_item(menu, text, accel_grp, i + 49, GDK_CONTROL_MASK, func, GINT_TO_POINTER(i)); | |
80 else | |
455 | 81 menu_item_add(menu, text, func, GINT_TO_POINTER(i)); |
1 | 82 g_free(text); |
83 } | |
84 } | |
85 } | |
86 | |
9 | 87 GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data) |
1 | 88 { |
9 | 89 GtkWidget *item; |
90 GtkWidget *submenu; | |
1 | 91 |
9 | 92 item = menu_item_add(menu, _("_Edit"), NULL, NULL); |
1 | 93 |
9 | 94 submenu = gtk_menu_new(); |
95 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
96 add_edit_items(submenu, func, NULL); | |
1 | 97 |
9 | 98 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1 | 99 |
9 | 100 if (menu_item) *menu_item = item; |
1 | 101 |
9 | 102 return submenu; |
1 | 103 } |
104 | |
105 /* | |
106 *----------------------------------------------------------------------------- | |
9 | 107 * sorting |
1 | 108 *----------------------------------------------------------------------------- |
9 | 109 */ |
1 | 110 |
9 | 111 gchar *sort_type_get_text(SortType method) |
1 | 112 { |
9 | 113 switch (method) |
114 { | |
115 case SORT_SIZE: | |
116 return _("Sort by size"); | |
117 break; | |
118 case SORT_TIME: | |
119 return _("Sort by date"); | |
120 break; | |
121 case SORT_NONE: | |
122 return _("Unsorted"); | |
123 break; | |
124 case SORT_PATH: | |
125 return _("Sort by path"); | |
126 break; | |
127 case SORT_NUMBER: | |
128 return _("Sort by number"); | |
129 break; | |
130 case SORT_NAME: | |
131 default: | |
132 return _("Sort by name"); | |
133 break; | |
134 } | |
1 | 135 |
9 | 136 return ""; |
137 } | |
1 | 138 |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
139 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
|
140 GCallback func, SortType type, |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
141 gint show_current, SortType show_type) |
9 | 142 { |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
143 GtkWidget *item; |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
144 |
9 | 145 if (show_current) |
146 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
147 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
|
148 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
|
149 func, GINT_TO_POINTER((gint)type)); |
9 | 150 } |
151 else | |
152 { | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
153 item = menu_item_add(menu, sort_type_get_text(type), |
120 | 154 func, GINT_TO_POINTER((gint)type)); |
9 | 155 } |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
156 |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
157 return item; |
9 | 158 } |
1 | 159 |
9 | 160 GtkWidget *submenu_add_sort(GtkWidget *menu, GCallback func, gpointer data, |
161 gint include_none, gint include_path, | |
162 gint show_current, SortType type) | |
163 { | |
164 GtkWidget *submenu; | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
165 GtkWidget *parent; |
1 | 166 |
9 | 167 submenu = gtk_menu_new(); |
168 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
169 | |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
170 parent = submenu_add_sort_item(submenu, NULL, func, SORT_NAME, show_current, type); |
9 | 171 #ifdef HAVE_STRVERSCMP |
113
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
172 submenu_add_sort_item(submenu, parent, func, SORT_NUMBER, show_current, type); |
9 | 173 #endif |
113
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_TIME, show_current, type); |
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_SIZE, show_current, type); |
55166d93498d
Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents:
82
diff
changeset
|
176 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
|
177 if (include_none) submenu_add_sort_item(submenu, parent, func, SORT_NONE, show_current, type); |
9 | 178 |
179 if (menu) | |
180 { | |
181 GtkWidget *item; | |
182 | |
183 item = menu_item_add(menu, _("Sort"), NULL, NULL); | |
184 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
185 return item; | |
186 } | |
187 | |
188 return submenu; | |
1 | 189 } |
190 | |
191 /* | |
192 *----------------------------------------------------------------------------- | |
9 | 193 * altering |
1 | 194 *----------------------------------------------------------------------------- |
9 | 195 */ |
1 | 196 |
9 | 197 gchar *alter_type_get_text(AlterType type) |
1 | 198 { |
9 | 199 switch (type) |
1 | 200 { |
9 | 201 case ALTER_ROTATE_90: |
202 return _("_Rotate clockwise"); | |
203 break; | |
204 case ALTER_ROTATE_90_CC: | |
205 return _("Rotate _counterclockwise"); | |
206 break; | |
207 case ALTER_ROTATE_180: | |
208 return _("Rotate _180"); | |
209 break; | |
210 case ALTER_MIRROR: | |
211 return _("_Mirror"); | |
212 break; | |
213 case ALTER_FLIP: | |
214 return _("_Flip"); | |
215 break; | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
216 case ALTER_DESATURATE: |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
318
diff
changeset
|
217 return _("Toggle _grayscale"); |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
218 break; |
439 | 219 case ALTER_NONE: |
220 return _("_Original state"); | |
221 break; | |
9 | 222 default: |
223 break; | |
224 } | |
225 | |
226 return ""; | |
227 } | |
228 | |
229 static void submenu_add_alter_item(GtkWidget *menu, GCallback func, AlterType type, | |
230 GtkAccelGroup *accel_group, guint accel_key, guint accel_mods) | |
231 { | |
232 if (accel_group) | |
233 { | |
234 add_menu_item(menu, alter_type_get_text(type), accel_group, | |
235 accel_key, accel_mods, func, GINT_TO_POINTER((gint)type)); | |
442 | 236 |
9 | 237 } |
238 else | |
239 { | |
240 menu_item_add(menu, alter_type_get_text(type), func, GINT_TO_POINTER((gint)type)); | |
1 | 241 } |
242 } | |
243 | |
9 | 244 static GtkWidget *real_submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data, |
245 GtkAccelGroup *accel_group) | |
1 | 246 { |
9 | 247 GtkWidget *submenu; |
1 | 248 |
9 | 249 submenu = gtk_menu_new(); |
250 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
1 | 251 |
9 | 252 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90, accel_group, ']', 0); |
253 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90_CC, accel_group, '[', 0); | |
254 submenu_add_alter_item(submenu, func, ALTER_ROTATE_180, accel_group, 'R', GDK_SHIFT_MASK); | |
255 submenu_add_alter_item(submenu, func, ALTER_MIRROR, accel_group, 'M', GDK_SHIFT_MASK); | |
256 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
|
257 submenu_add_alter_item(submenu, func, ALTER_DESATURATE, accel_group, 'G', GDK_SHIFT_MASK); |
439 | 258 submenu_add_alter_item(submenu, func, ALTER_NONE, accel_group, 'O', GDK_SHIFT_MASK); |
1 | 259 |
9 | 260 if (menu) |
261 { | |
262 GtkWidget *item; | |
1 | 263 |
9 | 264 item = menu_item_add(menu, _("_Adjust"), NULL, NULL); |
265 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
266 return item; | |
267 } | |
268 | |
269 return submenu; | |
1 | 270 } |
271 | |
9 | 272 GtkWidget *submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data) |
1 | 273 { |
9 | 274 return real_submenu_add_alter(menu, func, data, NULL); |
1 | 275 } |