SF.net SVN: geany: [2339] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Mar 13 17:12:19 UTC 2008


Revision: 2339
          http://geany.svn.sourceforge.net/geany/?rev=2339&view=rev
Author:   ntrel
Date:     2008-03-13 10:12:18 -0700 (Thu, 13 Mar 2008)

Log Message:
-----------
Check plugin keybinding group name is valid.
Ignore plugin keybinding groups with no elements defined.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/plugins.dox
    trunk/src/keybindings.c
    trunk/src/keybindings.h
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-03-13 15:18:42 UTC (rev 2338)
+++ trunk/ChangeLog	2008-03-13 17:12:18 UTC (rev 2339)
@@ -3,6 +3,9 @@
  * src/plugindata.h, doc/plugins.dox:
    Update documentation for plugin_key_group[] to mention declaring it
    manually.
+ * src/keybindings.c, src/keybindings.h, src/plugins.c, doc/plugins.dox:
+   Check plugin keybinding group name is valid.
+   Ignore plugin keybinding groups with no elements defined.
 
 
 2008-03-13  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/doc/plugins.dox
===================================================================
--- trunk/doc/plugins.dox	2008-03-13 15:18:42 UTC (rev 2338)
+++ trunk/doc/plugins.dox	2008-03-13 17:12:18 UTC (rev 2339)
@@ -68,7 +68,11 @@
  * 	  Most plugins should use the PLUGIN_KEY_GROUP() macro to define it. However,
  *    its fields are not read until after init() is called for the plugin, so it
  *    is possible to setup a variable number of keybindings, e.g. based on the
- *    plugin's configuration file.
+ *    plugin's configuration file settings.
+ *    - The @c name field must not be empty or match Geany's default group name.
+ *    - Ths @c label field is set by Geany after init() is called to the name of the
+ *    plugin.
+ *
  *    @note This is a single element array for implementation reasons,
  *    but you can treat it like a pointer.
  *

Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c	2008-03-13 15:18:42 UTC (rev 2338)
+++ trunk/src/keybindings.c	2008-03-13 17:12:18 UTC (rev 2339)
@@ -49,7 +49,7 @@
 GPtrArray *keybinding_groups;	/* array of KeyBindingGroup pointers */
 
 /* keyfile group name for non-plugin KB groups */
-static const gchar default_group_name[] = "Bindings";
+const gchar keybindings_keyfile_group_name[] = "Bindings";
 
 static const gboolean swap_alt_tab_order = FALSE;
 
@@ -143,7 +143,7 @@
  * add_kb_group(&groups[GEANY_KEY_GROUP_FILE], NULL, _("File menu"),
  * 	GEANY_KEYS_FILE_COUNT, FILE_keys); */
 #define ADD_KB_GROUP(group_id, label) \
-	add_kb_group(&groups[GEANY_KEY_GROUP_ ## group_id], default_group_name, label, \
+	add_kb_group(&groups[GEANY_KEY_GROUP_ ## group_id], keybindings_keyfile_group_name, label, \
 		GEANY_KEYS_ ## group_id ## _COUNT, group_id ## _keys)
 
 /* Init all fields of keys with default values.

Modified: trunk/src/keybindings.h
===================================================================
--- trunk/src/keybindings.h	2008-03-13 15:18:42 UTC (rev 2338)
+++ trunk/src/keybindings.h	2008-03-13 17:12:18 UTC (rev 2339)
@@ -65,7 +65,9 @@
 
 extern GPtrArray *keybinding_groups;	/* array of KeyBindingGroup pointers */
 
+extern const gchar keybindings_keyfile_group_name[];
 
+
 /** Keybinding group IDs */
 enum
 {

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2008-03-13 15:18:42 UTC (rev 2338)
+++ trunk/src/plugins.c	2008-03-13 17:12:18 UTC (rev 2339)
@@ -342,9 +342,18 @@
 static void
 add_kb_group(Plugin *plugin)
 {
-	g_ptr_array_add(keybinding_groups, plugin->key_group);
+	g_return_if_fail(NZV(plugin->key_group->name));
+	g_return_if_fail(! g_str_equal(plugin->key_group->name, keybindings_keyfile_group_name));
 
+	if (plugin->key_group->count == 0)
+	{
+		plugin->key_group = NULL;	/* Ignore the group */
+		return;
+	}
+
 	plugin->key_group->label = plugin->info()->name;
+
+	g_ptr_array_add(keybinding_groups, plugin->key_group);
 }
 
 


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