summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-10-10 21:42:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-10-10 21:42:43 (GMT)
commit7e53295ae7e67c8473aca2974e519aa0a593788e (patch)
tree6b89f5dde1f36ea8c7a132b3908156b8ace73f71 /src
parentc0831e2a8d16d65e8f31e52a63b703086609d8dd (diff)
Introduced menu item accelerators.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@183 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/editor.c10
-rw-r--r--src/gtkext/easygtk.c27
-rw-r--r--src/gtkext/easygtk.h3
3 files changed, 40 insertions, 0 deletions
diff --git a/src/editor.c b/src/editor.c
index c446234..59401d9 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -228,6 +228,9 @@ GtkWidget *create_editor(void)
GtkWidget *button; /* Btn. de commande inférieur */
+ GtkAccelGroup *accgroup;
+
+
result = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(result, 800, 600);
@@ -240,6 +243,10 @@ GtkWidget *create_editor(void)
ref = G_OBJECT(result);
+ accgroup = gtk_accel_group_new();
+ gtk_window_add_accel_group(GTK_WINDOW(result), accgroup);
+
+
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
@@ -260,6 +267,7 @@ GtkWidget *create_editor(void)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menubar);
submenuitem = qck_create_menu_item(NULL, NULL, _("New project"), G_CALLBACK(mcb_file_new_project), result);
+ add_accelerator_to_menu_item(submenuitem, "<Control>N", accgroup);
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
submenuitem = qck_create_menu_item(NULL, NULL, _("Open project"), G_CALLBACK(mcb_file_open_project), result);
@@ -291,12 +299,14 @@ GtkWidget *create_editor(void)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menubar);
submenuitem = qck_create_radio_menu_item(ref, "textview", NULL, _("Text view"), G_CALLBACK(mcb_view_change_support), result);
+ add_accelerator_to_menu_item(submenuitem, "F2", accgroup);
g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_BLOCK));
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
rgroup = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(submenuitem));
submenuitem = qck_create_radio_menu_item(ref, "graphview", rgroup, _("Graph view"), G_CALLBACK(mcb_view_change_support), result);
+ add_accelerator_to_menu_item(submenuitem, "F3", accgroup);
g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_GRAPH));
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
diff --git a/src/gtkext/easygtk.c b/src/gtkext/easygtk.c
index c14042c..15071e0 100644
--- a/src/gtkext/easygtk.c
+++ b/src/gtkext/easygtk.c
@@ -591,6 +591,33 @@ GtkWidget *qck_create_radio_menu_item(GObject *object, const char *name, GSList
/******************************************************************************
* *
+* Paramètres : item = élément d'un menu à mettre à jour. *
+* accelerator = description sous forme de chaîne de caractères.*
+* group = groupe d'appartenance du raccourci. *
+* *
+* Description : Ajoute un accélérateur à un élément de menu existant. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void add_accelerator_to_menu_item(GtkWidget *item, const char *accelerator, GtkAccelGroup *group)
+{
+ guint key; /* Touche concernée */
+ GdkModifierType mods; /* Eventuels modificateurs */
+
+ gtk_accelerator_parse(accelerator, &key, &mods);
+
+ gtk_widget_add_accelerator(item, "activate", group,
+ key, mods, GTK_ACCEL_VISIBLE);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Crée et enregistre un composant 'GtkSeparatorMenuItem'. *
diff --git a/src/gtkext/easygtk.h b/src/gtkext/easygtk.h
index 1dae530..13a415a 100644
--- a/src/gtkext/easygtk.h
+++ b/src/gtkext/easygtk.h
@@ -77,6 +77,9 @@ GtkWidget *qck_create_check_menu_item(GObject *, const char *, const char *, GCa
/* Crée et enregistre un composant 'GtkRadioMenuItem'. */
GtkWidget *qck_create_radio_menu_item(GObject *, const char *, GSList *, const char *, GCallback, gpointer);
+/* Ajoute un accélérateur à un élément de menu existant. */
+void add_accelerator_to_menu_item(GtkWidget *, const char *, GtkAccelGroup *);
+
/* Crée et enregistre un composant 'GtkSeparatorMenuItem'. */
GtkWidget *qck_create_menu_separator(void);