SF.net SVN: geany: [2342] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri Mar 14 13:11:54 UTC 2008


Revision: 2342
          http://geany.svn.sourceforge.net/geany/?rev=2342&view=rev
Author:   ntrel
Date:     2008-03-14 06:11:46 -0700 (Fri, 14 Mar 2008)

Log Message:
-----------
Set main menu accelerators for keybindings.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keybindings.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-03-14 07:30:08 UTC (rev 2341)
+++ trunk/ChangeLog	2008-03-14 13:11:46 UTC (rev 2342)
@@ -1,6 +1,12 @@
+2008-03-14  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/keybindings.c:
+   Set main menu accelerators for keybindings.
+
+
 2008-03-14  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
- * src/Makefile.am: Add prefs.c to the list of installed header files.
+ * src/Makefile.am: Add prefs.h to the list of installed header files.
 
 
 2008-03-13  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c	2008-03-14 07:30:08 UTC (rev 2341)
+++ trunk/src/keybindings.c	2008-03-14 13:11:46 UTC (rev 2342)
@@ -51,6 +51,7 @@
 /* keyfile group name for non-plugin KB groups */
 const gchar keybindings_keyfile_group_name[] = "Bindings";
 
+static GtkAccelGroup *kb_accel_group = NULL;
 static const gboolean swap_alt_tab_order = FALSE;
 
 
@@ -441,6 +442,17 @@
 }
 
 
+void keybindings_init(void)
+{
+	keybinding_groups = g_ptr_array_sized_new(GEANY_KEY_GROUP_COUNT);
+
+	init_default_kb();
+
+	kb_accel_group = gtk_accel_group_new();
+	gtk_window_add_accel_group(GTK_WINDOW(app->window), kb_accel_group);
+}
+
+
 typedef void (*KBItemCallback) (KeyBindingGroup *group, KeyBinding *kb, gpointer user_data);
 
 static void keybindings_foreach(KBItemCallback cb, gpointer user_data)
@@ -461,8 +473,16 @@
 }
 
 
-static void get_keyfile_kb(KeyBindingGroup *group, KeyBinding *kb, gpointer user_data)
+static void apply_kb_accel(KeyBinding *kb)
 {
+	if (kb->key != 0 && kb->menu_item)
+		gtk_widget_add_accelerator(kb->menu_item, "activate", kb_accel_group,
+			kb->key, kb->mods, GTK_ACCEL_VISIBLE);
+}
+
+
+static void load_kb(KeyBindingGroup *group, KeyBinding *kb, gpointer user_data)
+{
 	GKeyFile *config = user_data;
 	gchar *val;
 	guint key;
@@ -474,6 +494,8 @@
 		gtk_accelerator_parse(val, &key, &mods);
 		kb->key = key;
 		kb->mods = mods;
+
+		apply_kb_accel(kb);
 	}
 	g_free(val);
 }
@@ -487,21 +509,13 @@
 	/* now load user defined keys */
 	if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
 	{
-		keybindings_foreach(get_keyfile_kb, config);
+		keybindings_foreach(load_kb, config);
 	}
 	g_free(configfile);
 	g_key_file_free(config);
 }
 
 
-void keybindings_init(void)
-{
-	keybinding_groups = g_ptr_array_sized_new(GEANY_KEY_GROUP_COUNT);
-
-	init_default_kb();
-}
-
-
 void keybindings_load_keyfile(void)
 {
 	load_user_kb();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list