[geany/geany] d3f623: plugin api: introduce keybindings_set_item_full and plugin_set_key_group_full
Thomas Martitz
git-noreply at xxxxx
Mon Oct 12 21:06:50 UTC 2015
Branch: refs/heads/master
Author: Thomas Martitz <kugel at rockbox.org>
Committer: Thomas Martitz <kugel at rockbox.org>
Date: Wed, 26 Aug 2015 21:49:37 UTC
Commit: d3f6237505f1627d5b12c9ae5bed6dc736249878
https://github.com/geany/geany/commit/d3f6237505f1627d5b12c9ae5bed6dc736249878
Log Message:
-----------
plugin api: introduce keybindings_set_item_full and plugin_set_key_group_full
These function actually set the new GeanyKeyGroupFunc and
GeanyKeyBindingFunc and are exported for plugins
Modified Paths:
--------------
src/keybindings.c
src/keybindings.h
src/pluginutils.c
src/pluginutils.h
Modified: src/keybindings.c
39 lines changed, 39 insertions(+), 0 deletions(-)
===================================================================
@@ -202,6 +202,45 @@ GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
}
+/** Creates a new keybinding using a GeanyKeyBindingFunc and attaches is to a keybinding group
+ *
+ * If given the callback should return @c TRUE if the keybinding was handled, otherwise @c FALSE
+ * to allow other callbacks to be run. This allows for multiplexing keybindings on the same keys,
+ * depending on the focused widget (or context). If the callback is NULL the group's callback will
+ * be invoked, but the same rule applies.
+ *
+ * @param group Group.
+ * @param key_id Keybinding index for the group.
+ * @param cb New-style callback to be called when activated, or @c NULL to use the group callback.
+ * @param pdata Plugin-specific data passed back to the callback.
+ * @param key (Lower case) default key, e.g. @c GDK_j, but usually 0 for unset.
+ * @param mod Default modifier, e.g. @c GDK_CONTROL_MASK, but usually 0 for unset.
+ * @param kf_name Key name for the configuration file, such as @c "menu_new".
+ * @param label Label used in the preferences dialog keybindings tab. May contain
+ * underscores - these won't be displayed.
+ * @param menu_item Optional widget to set an accelerator for, or @c NULL.
+ * @return The keybinding - normally this is ignored.
+ *
+ * @since 1.26 (API 226)
+ * @see See plugin_set_key_group_full
+ **/
+GEANY_API_SYMBOL
+GeanyKeyBinding *keybindings_set_item_full(GeanyKeyGroup *group, gsize key_id,
+ GeanyKeyBindingFunc cb, gpointer pdata, guint key, GdkModifierType mod,
+ const gchar *kf_name, const gchar *label, GtkWidget *menu_item)
+{
+ GeanyKeyBinding *kb;
+
+ /* For now, this is intended for plugins only */
+ g_assert(group->plugin);
+
+ kb = keybindings_set_item(group, key_id, NULL, key, mod, kf_name, label, menu_item);
+ kb->cb_func = cb;
+ kb->cb_data = pdata;
+ return kb;
+}
+
+
static void add_kb_group(GeanyKeyGroup *group,
const gchar *name, const gchar *label, GeanyKeyGroupCallback callback, gboolean plugin)
{
Modified: src/keybindings.h
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -275,6 +275,10 @@ GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
GeanyKeyCallback callback, guint key, GdkModifierType mod,
const gchar *name, const gchar *label, GtkWidget *menu_item);
+GeanyKeyBinding *keybindings_set_item_full(GeanyKeyGroup *group, gsize key_id,
+ GeanyKeyBindingFunc cb, gpointer pdata, guint key, GdkModifierType mod,
+ const gchar *kf_name, const gchar *label, GtkWidget *menu_item);
+
GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
GdkModifierType keybindings_get_modifiers(GdkModifierType mods);
Modified: src/pluginutils.c
30 lines changed, 30 insertions(+), 0 deletions(-)
===================================================================
@@ -33,6 +33,8 @@
#include "app.h"
#include "geanyobject.h"
+#include "keybindings.h"
+#include "keybindingsprivate.h"
#include "plugindata.h"
#include "pluginprivate.h"
#include "plugins.h"
@@ -307,6 +309,34 @@ GeanyKeyGroup *plugin_set_key_group(GeanyPlugin *plugin,
return priv->key_group;
}
+/** Sets up or resizes a keybinding group for the plugin
+ *
+ * You should then call keybindings_set_item() or keybindings_set_item_full() for each
+ * keybinding in the group.
+ * @param plugin Must be @ref geany_plugin.
+ * @param section_name Name used in the configuration file, such as @c "html_chars".
+ * @param count Number of keybindings for the group.
+ * @param cb New-style group callback, or @c NULL if you only want individual keybinding callbacks.
+ * @param pdata Plugin specific data, passed to the group callback.
+ * @return The plugin's keybinding group.
+ *
+ * @since 1.26 (API 226)
+ * @see See keybindings_set_item
+ * @see See keybindings_set_item_full
+ **/
+GEANY_API_SYMBOL
+GeanyKeyGroup *plugin_set_key_group_full(GeanyPlugin *plugin,
+ const gchar *section_name, gsize count, GeanyKeyGroupFunc cb, gpointer pdata)
+{
+ GeanyKeyGroup *group;
+
+ group = plugin_set_key_group(plugin, section_name, count, NULL);
+ group->cb_func = cb;
+ group->cb_data = pdata;
+
+ return group;
+}
+
static void on_pref_btn_clicked(gpointer btn, Plugin *p)
{
Modified: src/pluginutils.h
3 lines changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -54,6 +54,9 @@ guint plugin_idle_add(struct GeanyPlugin *plugin, GSourceFunc function, gpointer
struct GeanyKeyGroup *plugin_set_key_group(struct GeanyPlugin *plugin,
const gchar *section_name, gsize count, GeanyKeyGroupCallback callback);
+GeanyKeyGroup *plugin_set_key_group_full(struct GeanyPlugin *plugin,
+ const gchar *section_name, gsize count, GeanyKeyGroupFunc cb, gpointer pdata);
+
void plugin_show_configure(struct GeanyPlugin *plugin);
void plugin_builder_connect_signals(struct GeanyPlugin *plugin,
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list