Make KeyBinding name and label fields non-const strings so they can

be freed by any plugins that need to use malloc'd strings.
Document KeyCallback typedef.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2345 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-03-14 17:23:24 +00:00
parent 7a47ee09ab
commit 664ee2f75d
5 changed files with 15 additions and 7 deletions

View File

@ -2,6 +2,11 @@
* src/keybindings.c:
Set main menu accelerators for keybindings.
* src/keybindings.c, src/keybindings.h, src/plugindata.h,
plugins/htmlchars.c:
Make KeyBinding name and label fields non-const strings so they can
be freed by any plugins that need to use malloc'd strings.
Document KeyCallback typedef.
2008-03-14 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -525,7 +525,7 @@ void init(GeanyData *data)
{
GtkWidget *demo_item;
const gchar *menu_text = _("_Insert Special HTML Characters");
const gchar *kb_label = _("Insert Special HTML Characters");
gchar *kb_label = _("Insert Special HTML Characters");
/* Add an item to the Tools menu */
demo_item = gtk_menu_item_new_with_mnemonic(menu_text);

View File

@ -101,7 +101,7 @@ static void add_popup_menu_accels(void);
/** Simple convenience function to fill a KeyBinding struct item */
void keybindings_set_item(KeyBindingGroup *group, gsize key_id,
KeyCallback callback, guint key, GdkModifierType mod,
const gchar *name, const gchar *label, GtkWidget *menu_item)
gchar *name, gchar *label, GtkWidget *menu_item)
{
KeyBinding *kb;

View File

@ -39,15 +39,18 @@
#endif
/** Function pointer type used for keybinding callbacks */
typedef void (*KeyCallback) (guint key_id);
/** Represents a single keybinding action */
/* Note: name and label are not const strings so plugins can set them to malloc'd strings
* and free them in cleanup(). */
typedef struct KeyBinding
{
guint key; /**< Key value in lower-case, such as @c GDK_a */
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 *label; /**< Label used in the preferences dialog keybindings tab */
gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */
gchar *label; /**< Label used in the preferences dialog keybindings tab */
KeyCallback callback; /**< Callback function called when the key combination is pressed */
GtkWidget *menu_item; /**< Menu item widget for setting the menu accelerator */
} KeyBinding;
@ -302,7 +305,7 @@ void keybindings_free(void);
void keybindings_set_item(KeyBindingGroup *group, gsize key_id,
KeyCallback callback, guint key, GdkModifierType mod,
const gchar *name, const gchar *label, GtkWidget *menu_item);
gchar *name, gchar *label, GtkWidget *menu_item);
void keybindings_send_command(guint group_id, guint key_id);

View File

@ -35,7 +35,7 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
static const gint api_version = 48;
static const gint api_version = 49;
/* 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
@ -335,7 +335,7 @@ typedef struct KeybindingFuncs
void (*send_command) (guint group_id, guint 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);
gchar *name, gchar *label, GtkWidget *menu_item);
}
KeybindingFuncs;