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
This commit is contained in:
parent
1d08d3db4a
commit
d3f6237505
@ -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,
|
static void add_kb_group(GeanyKeyGroup *group,
|
||||||
const gchar *name, const gchar *label, GeanyKeyGroupCallback callback, gboolean plugin)
|
const gchar *name, const gchar *label, GeanyKeyGroupCallback callback, gboolean plugin)
|
||||||
{
|
{
|
||||||
|
@ -275,6 +275,10 @@ GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
|
|||||||
GeanyKeyCallback callback, guint key, GdkModifierType mod,
|
GeanyKeyCallback callback, guint key, GdkModifierType mod,
|
||||||
const gchar *name, const gchar *label, GtkWidget *menu_item);
|
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);
|
GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
|
||||||
|
|
||||||
GdkModifierType keybindings_get_modifiers(GdkModifierType mods);
|
GdkModifierType keybindings_get_modifiers(GdkModifierType mods);
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "geanyobject.h"
|
#include "geanyobject.h"
|
||||||
|
#include "keybindings.h"
|
||||||
|
#include "keybindingsprivate.h"
|
||||||
#include "plugindata.h"
|
#include "plugindata.h"
|
||||||
#include "pluginprivate.h"
|
#include "pluginprivate.h"
|
||||||
#include "plugins.h"
|
#include "plugins.h"
|
||||||
@ -307,6 +309,34 @@ GeanyKeyGroup *plugin_set_key_group(GeanyPlugin *plugin,
|
|||||||
return priv->key_group;
|
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)
|
static void on_pref_btn_clicked(gpointer btn, Plugin *p)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,9 @@ guint plugin_idle_add(struct GeanyPlugin *plugin, GSourceFunc function, gpointer
|
|||||||
struct GeanyKeyGroup *plugin_set_key_group(struct GeanyPlugin *plugin,
|
struct GeanyKeyGroup *plugin_set_key_group(struct GeanyPlugin *plugin,
|
||||||
const gchar *section_name, gsize count, GeanyKeyGroupCallback callback);
|
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_show_configure(struct GeanyPlugin *plugin);
|
||||||
|
|
||||||
void plugin_builder_connect_signals(struct GeanyPlugin *plugin,
|
void plugin_builder_connect_signals(struct GeanyPlugin *plugin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user