comparison src/menu.c @ 1272:e0e12512cde2

read external editors from .desktop files
author nadvornik
date Sun, 01 Feb 2009 12:48:14 +0000
parents 1646720364cf
children 8b89e3ff286b
comparison
equal deleted inserted replaced
1271:4fcdbb497df3 1272:e0e12512cde2
62 *----------------------------------------------------------------------------- 62 *-----------------------------------------------------------------------------
63 * edit menu 63 * edit menu
64 *----------------------------------------------------------------------------- 64 *-----------------------------------------------------------------------------
65 */ 65 */
66 66
67 static void add_edit_items(GtkWidget *menu, GCallback func, GtkAccelGroup *accel_grp) 67 static void add_edit_items(GtkWidget *menu, GCallback func)
68 { 68 {
69 gint i; 69 GList *editors_list = editor_list_get();
70 70 GList *work = editors_list;
71 for (i = 0; i < GQ_EDITOR_GENERIC_SLOTS; i++) 71
72 { 72 while (work)
73 gchar *text; 73 {
74 const gchar *name = editor_get_name(i); 74 const EditorDescription *editor = work->data;
75 75 work = work->next;
76 if (!name) continue;
77
78 text = g_strdup_printf(_("_%d %s..."), i, name);
79 if (accel_grp)
80 add_menu_item(menu, text, accel_grp, i + 49, GDK_CONTROL_MASK, func, GINT_TO_POINTER(i));
81 else
82 menu_item_add(menu, text, func, GINT_TO_POINTER(i));
83 g_free(text);
84 76
85 } 77 menu_item_add(menu, editor->name, func, editor->key);
86 } 78 }
79
80 g_list_free(editors_list);
81 }
82
87 83
88 GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data) 84 GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data)
89 { 85 {
90 GtkWidget *item; 86 GtkWidget *item;
91 GtkWidget *submenu; 87 GtkWidget *submenu;
92 88
93 item = menu_item_add(menu, _("_Edit"), NULL, NULL); 89 item = menu_item_add(menu, _("_Edit"), NULL, NULL);
94 90
95 submenu = gtk_menu_new(); 91 submenu = gtk_menu_new();
96 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); 92 g_object_set_data(G_OBJECT(submenu), "submenu_data", data);
97 add_edit_items(submenu, func, NULL); 93 add_edit_items(submenu, func);
98 94
99 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); 95 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
100 96
101 if (menu_item) *menu_item = item; 97 if (menu_item) *menu_item = item;
102 98