Kaydet (Commit) 5f43e01f authored tarafından Nick Treleaven's avatar Nick Treleaven

Add keybindings_set_item() to the plugin API and update the HTML

Characters plugin.
Rename KBCallback, cmd_id, cb_func with clearer names.
Add KeyBinding::menu_item field for setting accelerators (currently
does nothing).


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/plugin-keybindings@2318 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 747d2d2b
2008-03-10 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c, src/keybindings.h, src/plugindata.h,
src/plugins.c, plugins/htmlchars.c:
Add keybindings_set_item() to the plugin API and update the HTML
Characters plugin.
Rename KBCallback, cmd_id, cb_func with clearer names.
Add KeyBinding::menu_item field for setting accelerators (currently
does nothing).
2008-03-07 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2008-03-07 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.h: * src/keybindings.h:
......
...@@ -520,25 +520,6 @@ static void kb_activate(G_GNUC_UNUSED guint key_id) ...@@ -520,25 +520,6 @@ static void kb_activate(G_GNUC_UNUSED guint key_id)
} }
/* simple convenience function to fill a KeyBinding struct item */
static void add_kb(KeyBindingGroup *group, gsize kb_id,
KBCallback func, guint key, GdkModifierType mod,
const gchar *name, const gchar *label)
{
KeyBinding *kb;
g_assert(kb_id < group->count);
kb = &group->keys[kb_id];
kb->name = name;
kb->label = label;
kb->key = key;
kb->mods = mod;
kb->cb_func = func;
}
/* Called by Geany to initialize the plugin */ /* Called by Geany to initialize the plugin */
void init(GeanyData *data) void init(GeanyData *data)
{ {
...@@ -556,8 +537,8 @@ void init(GeanyData *data) ...@@ -556,8 +537,8 @@ void init(GeanyData *data)
plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE; plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE;
/* setup keybindings */ /* setup keybindings */
add_kb(plugin_key_group, KB_INSERT_HTML_CHARS, kb_activate, p_keybindings->set_item(plugin_key_group, KB_INSERT_HTML_CHARS, kb_activate,
0, 0, "insert_html_chars", menu_text); 0, 0, "insert_html_chars", menu_text, demo_item);
} }
......
This diff is collapsed.
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#endif #endif
typedef void (*KBCallback) (guint key_id); typedef void (*KeyCallback) (guint key_id);
/** Represents a single keybinding action */ /** Represents a single keybinding action */
typedef struct KeyBinding typedef struct KeyBinding
...@@ -48,7 +48,8 @@ typedef struct KeyBinding ...@@ -48,7 +48,8 @@ typedef struct KeyBinding
GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK */ GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK */
const gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */ const gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */
const gchar *label; /**< Label used in the preferences dialog keybindings tab */ const gchar *label; /**< Label used in the preferences dialog keybindings tab */
KBCallback cb_func; /**< Callback function called when the key combination is pressed */ KeyCallback callback; /**< Callback function called when the key combination is pressed */
GtkWidget *menu_item; /**< Menu item widget for setting the menu accelerator */
} KeyBinding; } KeyBinding;
...@@ -253,9 +254,13 @@ void keybindings_init(void); ...@@ -253,9 +254,13 @@ void keybindings_init(void);
void keybindings_free(void); void keybindings_free(void);
void keybindings_send_command(gint group_id, gint cmd_id); void keybindings_set_item(KeyBindingGroup *group, gsize key_id,
KeyCallback callback, guint key, GdkModifierType mod,
const gchar *name, const gchar *label, GtkWidget *menu_item);
KeyBinding *keybindings_lookup_item(guint group_id, guint cmd_id); void keybindings_send_command(gint group_id, gint key_id);
KeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
/* just write the content of the keys array to the config file */ /* just write the content of the keys array to the config file */
void keybindings_write_to_file(void); void keybindings_write_to_file(void);
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#ifndef PLUGIN_H #ifndef PLUGIN_H
#define PLUGIN_H #define PLUGIN_H
#include "keybindings.h" /* needed for KeyCallback typedef */
/** /**
* @file plugindata.h * @file plugindata.h
...@@ -36,7 +38,7 @@ ...@@ -36,7 +38,7 @@
/* The API version should be incremented whenever any plugin data types below are /* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */ * modified or appended to. */
static const gint api_version = 46; static const gint api_version = 47;
/* The ABI version should be incremented whenever existing fields in the plugin /* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields * data types below have to be changed or reordered. It should stay the same if fields
...@@ -332,7 +334,10 @@ EncodingFuncs; ...@@ -332,7 +334,10 @@ EncodingFuncs;
typedef struct KeybindingFuncs typedef struct KeybindingFuncs
{ {
void (*send_command) (gint group_id, gint cmd_id); void (*send_command) (gint group_id, gint key_id);
void (*set_item) (struct KeyBindingGroup *group, gsize key_id,
KeyCallback callback, guint key, GdkModifierType mod,
const gchar *name, const gchar *label, GtkWidget *menu_item);
} }
KeybindingFuncs; KeybindingFuncs;
......
...@@ -188,7 +188,8 @@ static EncodingFuncs encoding_funcs = { ...@@ -188,7 +188,8 @@ static EncodingFuncs encoding_funcs = {
}; };
static KeybindingFuncs keybindings_funcs = { static KeybindingFuncs keybindings_funcs = {
&keybindings_send_command &keybindings_send_command,
&keybindings_set_item
}; };
static TagManagerFuncs tagmanager_funcs = { static TagManagerFuncs tagmanager_funcs = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment