Mercurial > geeqie
annotate src/menu.c @ 99:d19b0de6d0bb
Sat Nov 4 17:14:47 2006 John Ellis <johne@verizon.net>
* pan-view.c: Always recalculate canvas size when displaying popups.
* README: Updates.
* po/eo.po: Mark translation for 'Command Line' not fuzzy.
* configure.in: Release 2.1.4 (quick bug fix for pan view).
author | gqview |
---|---|
date | Sat, 04 Nov 2006 22:24:47 +0000 |
parents | a4c1b7014e6e |
children | 55166d93498d |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
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 | |
9 | 13 #include "gqview.h" |
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 *----------------------------------------------------------------------------- |
36 */ | |
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 *----------------------------------------------------------------------------- |
63 */ | |
64 | |
9 | 65 static void add_edit_items(GtkWidget *menu, GCallback func, GtkAccelGroup *accel_grp) |
1 | 66 { |
67 gint i; | |
9 | 68 for (i = 0; i < GQVIEW_EDITOR_SLOTS; i++) |
1 | 69 { |
70 if (editor_command[i] && strlen(editor_command[i]) > 0) | |
71 { | |
72 gchar *text; | |
73 if (editor_name[i] && strlen(editor_name[i]) > 0) | |
74 text = g_strdup_printf(_("in %s..."), editor_name[i]); | |
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 |
9 | 138 static void submenu_add_sort_item(GtkWidget *menu, GCallback func, SortType type, |
139 gint show_current, SortType show_type) | |
140 { | |
141 if (show_current) | |
142 { | |
143 menu_item_add_check(menu, sort_type_get_text(type), (type == show_type), | |
144 func, GINT_TO_POINTER((gint)type)); | |
145 } | |
146 else | |
147 { | |
148 menu_item_add(menu, sort_type_get_text(type), | |
149 func, GINT_TO_POINTER((gint)type)); | |
150 } | |
151 } | |
1 | 152 |
9 | 153 GtkWidget *submenu_add_sort(GtkWidget *menu, GCallback func, gpointer data, |
154 gint include_none, gint include_path, | |
155 gint show_current, SortType type) | |
156 { | |
157 GtkWidget *submenu; | |
1 | 158 |
9 | 159 submenu = gtk_menu_new(); |
160 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
161 | |
162 submenu_add_sort_item(submenu, func, SORT_NAME, show_current, type); | |
163 #ifdef HAVE_STRVERSCMP | |
164 submenu_add_sort_item(submenu, func, SORT_NUMBER, show_current, type); | |
165 #endif | |
166 submenu_add_sort_item(submenu, func, SORT_TIME, show_current, type); | |
167 submenu_add_sort_item(submenu, func, SORT_SIZE, show_current, type); | |
168 if (include_path) submenu_add_sort_item(submenu, func, SORT_PATH, show_current, type); | |
169 if (include_none) submenu_add_sort_item(submenu, func, SORT_NONE, show_current, type); | |
170 | |
171 if (menu) | |
172 { | |
173 GtkWidget *item; | |
174 | |
175 item = menu_item_add(menu, _("Sort"), NULL, NULL); | |
176 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
177 return item; | |
178 } | |
179 | |
180 return submenu; | |
1 | 181 } |
182 | |
183 /* | |
184 *----------------------------------------------------------------------------- | |
9 | 185 * altering |
1 | 186 *----------------------------------------------------------------------------- |
9 | 187 */ |
1 | 188 |
9 | 189 gchar *alter_type_get_text(AlterType type) |
1 | 190 { |
9 | 191 switch (type) |
1 | 192 { |
9 | 193 case ALTER_ROTATE_90: |
194 return _("_Rotate clockwise"); | |
195 break; | |
196 case ALTER_ROTATE_90_CC: | |
197 return _("Rotate _counterclockwise"); | |
198 break; | |
199 case ALTER_ROTATE_180: | |
200 return _("Rotate _180"); | |
201 break; | |
202 case ALTER_MIRROR: | |
203 return _("_Mirror"); | |
204 break; | |
205 case ALTER_FLIP: | |
206 return _("_Flip"); | |
207 break; | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
208 case ALTER_DESATURATE: |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
209 return _("_Grayscale"); |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
210 break; |
9 | 211 default: |
212 break; | |
213 } | |
214 | |
215 return ""; | |
216 } | |
217 | |
218 static void submenu_add_alter_item(GtkWidget *menu, GCallback func, AlterType type, | |
219 GtkAccelGroup *accel_group, guint accel_key, guint accel_mods) | |
220 { | |
221 if (accel_group) | |
222 { | |
223 add_menu_item(menu, alter_type_get_text(type), accel_group, | |
224 accel_key, accel_mods, func, GINT_TO_POINTER((gint)type)); | |
225 | |
226 } | |
227 else | |
228 { | |
229 menu_item_add(menu, alter_type_get_text(type), func, GINT_TO_POINTER((gint)type)); | |
1 | 230 } |
231 } | |
232 | |
9 | 233 static GtkWidget *real_submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data, |
234 GtkAccelGroup *accel_group) | |
1 | 235 { |
9 | 236 GtkWidget *submenu; |
1 | 237 |
9 | 238 submenu = gtk_menu_new(); |
239 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); | |
1 | 240 |
9 | 241 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90, accel_group, ']', 0); |
242 submenu_add_alter_item(submenu, func, ALTER_ROTATE_90_CC, accel_group, '[', 0); | |
243 submenu_add_alter_item(submenu, func, ALTER_ROTATE_180, accel_group, 'R', GDK_SHIFT_MASK); | |
244 submenu_add_alter_item(submenu, func, ALTER_MIRROR, accel_group, 'M', GDK_SHIFT_MASK); | |
245 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
|
246 submenu_add_alter_item(submenu, func, ALTER_DESATURATE, accel_group, 'G', GDK_SHIFT_MASK); |
1 | 247 |
9 | 248 if (menu) |
249 { | |
250 GtkWidget *item; | |
1 | 251 |
9 | 252 item = menu_item_add(menu, _("_Adjust"), NULL, NULL); |
253 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
254 return item; | |
255 } | |
256 | |
257 return submenu; | |
1 | 258 } |
259 | |
9 | 260 GtkWidget *submenu_add_alter(GtkWidget *menu, GCallback func, gpointer data) |
1 | 261 { |
9 | 262 return real_submenu_add_alter(menu, func, data, NULL); |
1 | 263 } |
264 | |
265 |