summaryrefslogtreecommitdiff
path: root/capplets/keybindings
diff options
context:
space:
mode:
Diffstat (limited to 'capplets/keybindings')
-rw-r--r--capplets/keybindings/Makefile.am16
-rw-r--r--capplets/keybindings/eggaccelerators.c327
-rw-r--r--capplets/keybindings/eggcellrendererkeys.c512
-rw-r--r--capplets/keybindings/mate-keybinding-properties.c586
4 files changed, 722 insertions, 719 deletions
diff --git a/capplets/keybindings/Makefile.am b/capplets/keybindings/Makefile.am
index ed97253f..e15c07f0 100644
--- a/capplets/keybindings/Makefile.am
+++ b/capplets/keybindings/Makefile.am
@@ -4,16 +4,16 @@ cappletname = keybinding
bin_PROGRAMS = mate-keybinding-properties
mate_keybinding_properties_LDADD = $(MATECC_CAPPLETS_LIBS)
-mate_keybinding_properties_SOURCES = \
- mate-keybinding-properties.c \
- eggcellrendererkeys.c \
- eggcellrendererkeys.h \
- eggaccelerators.c \
+mate_keybinding_properties_SOURCES = \
+ mate-keybinding-properties.c \
+ eggcellrendererkeys.c \
+ eggcellrendererkeys.h \
+ eggaccelerators.c \
eggaccelerators.h
@INTLTOOL_DESKTOP_RULE@
-uidir = $(pkgdatadir)/ui
+uidir = $(pkgdatadir)/ui
ui_DATA = mate-keybinding-properties.ui
desktopdir = $(datadir)/applications
@@ -22,9 +22,9 @@ desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_XML_NOMERGE_RULE@
-xmldir = $(pkgdatadir)/keybindings
+xmldir = $(pkgdatadir)/keybindings
xml_in_files = 00-multimedia-key.xml.in 01-desktop-key.xml.in
-xml_DATA = $(xml_in_files:.xml.in=.xml)
+xml_DATA = $(xml_in_files:.xml.in=.xml)
pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA = mate-keybindings.pc
diff --git a/capplets/keybindings/eggaccelerators.c b/capplets/keybindings/eggaccelerators.c
index 0728229d..643808bf 100644
--- a/capplets/keybindings/eggaccelerators.c
+++ b/capplets/keybindings/eggaccelerators.c
@@ -26,162 +26,160 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
-enum
-{
- EGG_MODMAP_ENTRY_SHIFT = 0,
- EGG_MODMAP_ENTRY_LOCK = 1,
- EGG_MODMAP_ENTRY_CONTROL = 2,
- EGG_MODMAP_ENTRY_MOD1 = 3,
- EGG_MODMAP_ENTRY_MOD2 = 4,
- EGG_MODMAP_ENTRY_MOD3 = 5,
- EGG_MODMAP_ENTRY_MOD4 = 6,
- EGG_MODMAP_ENTRY_MOD5 = 7,
- EGG_MODMAP_ENTRY_LAST = 8
+enum {
+ EGG_MODMAP_ENTRY_SHIFT = 0,
+ EGG_MODMAP_ENTRY_LOCK = 1,
+ EGG_MODMAP_ENTRY_CONTROL = 2,
+ EGG_MODMAP_ENTRY_MOD1 = 3,
+ EGG_MODMAP_ENTRY_MOD2 = 4,
+ EGG_MODMAP_ENTRY_MOD3 = 5,
+ EGG_MODMAP_ENTRY_MOD4 = 6,
+ EGG_MODMAP_ENTRY_MOD5 = 7,
+ EGG_MODMAP_ENTRY_LAST = 8
};
#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
-typedef struct
-{
- EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
-
+typedef struct {
+ EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
} EggModmap;
-const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+const EggModmap* egg_keymap_get_modmap(GdkKeymap* keymap);
-static inline gboolean
-is_alt (const gchar *string)
+static inline gboolean is_alt(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'a' || string[1] == 'A') &&
- (string[2] == 'l' || string[2] == 'L') &&
- (string[3] == 't' || string[3] == 'T') &&
- (string[4] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'a' || string[1] == 'A') &&
+ (string[2] == 'l' || string[2] == 'L') &&
+ (string[3] == 't' || string[3] == 'T') &&
+ (string[4] == '>'));
}
-static inline gboolean
-is_ctl (const gchar *string)
+static inline gboolean is_ctl (const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'c' || string[1] == 'C') &&
- (string[2] == 't' || string[2] == 'T') &&
- (string[3] == 'l' || string[3] == 'L') &&
- (string[4] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'c' || string[1] == 'C') &&
+ (string[2] == 't' || string[2] == 'T') &&
+ (string[3] == 'l' || string[3] == 'L') &&
+ (string[4] == '>'));
}
-static inline gboolean
-is_modx (const gchar *string)
+static inline gboolean is_modx(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'm' || string[1] == 'M') &&
- (string[2] == 'o' || string[2] == 'O') &&
- (string[3] == 'd' || string[3] == 'D') &&
- (string[4] >= '1' && string[4] <= '5') &&
- (string[5] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'm' || string[1] == 'M') &&
+ (string[2] == 'o' || string[2] == 'O') &&
+ (string[3] == 'd' || string[3] == 'D') &&
+ (string[4] >= '1' && string[4] <= '5') &&
+ (string[5] == '>'));
}
-static inline gboolean
-is_ctrl (const gchar *string)
+static inline gboolean is_ctrl(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'c' || string[1] == 'C') &&
- (string[2] == 't' || string[2] == 'T') &&
- (string[3] == 'r' || string[3] == 'R') &&
- (string[4] == 'l' || string[4] == 'L') &&
- (string[5] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'c' || string[1] == 'C') &&
+ (string[2] == 't' || string[2] == 'T') &&
+ (string[3] == 'r' || string[3] == 'R') &&
+ (string[4] == 'l' || string[4] == 'L') &&
+ (string[5] == '>'));
}
-static inline gboolean
-is_shft (const gchar *string)
+static inline gboolean is_shft (const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 's' || string[1] == 'S') &&
- (string[2] == 'h' || string[2] == 'H') &&
- (string[3] == 'f' || string[3] == 'F') &&
- (string[4] == 't' || string[4] == 'T') &&
- (string[5] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 's' || string[1] == 'S') &&
+ (string[2] == 'h' || string[2] == 'H') &&
+ (string[3] == 'f' || string[3] == 'F') &&
+ (string[4] == 't' || string[4] == 'T') &&
+ (string[5] == '>'));
}
-static inline gboolean
-is_shift (const gchar *string)
+static inline gboolean is_shift(const gchar* string)
{
return ((string[0] == '<') &&
- (string[1] == 's' || string[1] == 'S') &&
- (string[2] == 'h' || string[2] == 'H') &&
- (string[3] == 'i' || string[3] == 'I') &&
- (string[4] == 'f' || string[4] == 'F') &&
- (string[5] == 't' || string[5] == 'T') &&
- (string[6] == '>'));
+ (string[1] == 's' || string[1] == 'S') &&
+ (string[2] == 'h' || string[2] == 'H') &&
+ (string[3] == 'i' || string[3] == 'I') &&
+ (string[4] == 'f' || string[4] == 'F') &&
+ (string[5] == 't' || string[5] == 'T') &&
+ (string[6] == '>'));
}
-static inline gboolean
-is_control (const gchar *string)
+static inline gboolean is_control(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'c' || string[1] == 'C') &&
- (string[2] == 'o' || string[2] == 'O') &&
- (string[3] == 'n' || string[3] == 'N') &&
- (string[4] == 't' || string[4] == 'T') &&
- (string[5] == 'r' || string[5] == 'R') &&
- (string[6] == 'o' || string[6] == 'O') &&
- (string[7] == 'l' || string[7] == 'L') &&
- (string[8] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'c' || string[1] == 'C') &&
+ (string[2] == 'o' || string[2] == 'O') &&
+ (string[3] == 'n' || string[3] == 'N') &&
+ (string[4] == 't' || string[4] == 'T') &&
+ (string[5] == 'r' || string[5] == 'R') &&
+ (string[6] == 'o' || string[6] == 'O') &&
+ (string[7] == 'l' || string[7] == 'L') &&
+ (string[8] == '>'));
}
-static inline gboolean
-is_release (const gchar *string)
+static inline gboolean is_release(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'r' || string[1] == 'R') &&
- (string[2] == 'e' || string[2] == 'E') &&
- (string[3] == 'l' || string[3] == 'L') &&
- (string[4] == 'e' || string[4] == 'E') &&
- (string[5] == 'a' || string[5] == 'A') &&
- (string[6] == 's' || string[6] == 'S') &&
- (string[7] == 'e' || string[7] == 'E') &&
- (string[8] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'r' || string[1] == 'R') &&
+ (string[2] == 'e' || string[2] == 'E') &&
+ (string[3] == 'l' || string[3] == 'L') &&
+ (string[4] == 'e' || string[4] == 'E') &&
+ (string[5] == 'a' || string[5] == 'A') &&
+ (string[6] == 's' || string[6] == 'S') &&
+ (string[7] == 'e' || string[7] == 'E') &&
+ (string[8] == '>'));
}
-static inline gboolean
-is_meta (const gchar *string)
+static inline gboolean is_meta(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 'm' || string[1] == 'M') &&
- (string[2] == 'e' || string[2] == 'E') &&
- (string[3] == 't' || string[3] == 'T') &&
- (string[4] == 'a' || string[4] == 'A') &&
- (string[5] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'm' || string[1] == 'M') &&
+ (string[2] == 'e' || string[2] == 'E') &&
+ (string[3] == 't' || string[3] == 'T') &&
+ (string[4] == 'a' || string[4] == 'A') &&
+ (string[5] == '>'));
}
-static inline gboolean
-is_super (const gchar *string)
+static inline gboolean is_super(const gchar* string)
{
- return ((string[0] == '<') &&
- (string[1] == 's' || string[1] == 'S') &&
- (string[2] == 'u' || string[2] == 'U') &&
- (string[3] == 'p' || string[3] == 'P') &&
- (string[4] == 'e' || string[4] == 'E') &&
- (string[5] == 'r' || string[5] == 'R') &&
- (string[6] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 's' || string[1] == 'S') &&
+ (string[2] == 'u' || string[2] == 'U') &&
+ (string[3] == 'p' || string[3] == 'P') &&
+ (string[4] == 'e' || string[4] == 'E') &&
+ (string[5] == 'r' || string[5] == 'R') &&
+ (string[6] == '>'));
}
-static inline gboolean
-is_hyper (const gchar *string)
+static inline gboolean is_hyper(const gchar *string)
{
- return ((string[0] == '<') &&
- (string[1] == 'h' || string[1] == 'H') &&
- (string[2] == 'y' || string[2] == 'Y') &&
- (string[3] == 'p' || string[3] == 'P') &&
- (string[4] == 'e' || string[4] == 'E') &&
- (string[5] == 'r' || string[5] == 'R') &&
- (string[6] == '>'));
+ return ((string[0] == '<') &&
+ (string[1] == 'h' || string[1] == 'H') &&
+ (string[2] == 'y' || string[2] == 'Y') &&
+ (string[3] == 'p' || string[3] == 'P') &&
+ (string[4] == 'e' || string[4] == 'E') &&
+ (string[5] == 'r' || string[5] == 'R') &&
+ (string[6] == '>'));
+}
+
+static inline gboolean is_primary(const gchar* string)
+{
+ return ((string[0] == '<') &&
+ (string[1] == 'p' || string[1] == 'P') &&
+ (string[2] == 'r' || string[2] == 'R') &&
+ (string[3] == 'i' || string[3] == 'I') &&
+ (string[4] == 'm' || string[4] == 'M') &&
+ (string[5] == 'a' || string[5] == 'A') &&
+ (string[6] == 'r' || string[6] == 'R') &&
+ (string[7] == 'y' || string[7] == 'Y') &&
+ (string[8] == '>'));
}
-static inline gboolean
-is_keycode (const gchar *string)
+static inline gboolean is_keycode(const gchar *string)
{
- return ((string[0] == '0') &&
- (string[1] == 'x'));
+ return ((string[0] == '0') &&
+ (string[1] == 'x'));
}
/**
@@ -250,6 +248,12 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
len -= 9;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
+ else if (len >= 9 && is_primary (accelerator))
+ {
+ accelerator += 9;
+ len -= 9;
+ mods |= EGG_VIRTUAL_CONTROL_MASK;
+ }
else if (len >= 7 && is_shift (accelerator))
{
accelerator += 7;
@@ -356,7 +360,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
}
else if (keycode != NULL)
{
- *keycode = XKeysymToKeycode (GDK_DISPLAY(), keyval);
+ *keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keyval);
if (*keycode == 0)
bad_keyval = TRUE;
}
@@ -387,26 +391,28 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
*
* The caller of this function must free the returned string.
*/
-gchar*
-egg_virtual_accelerator_name (guint accelerator_key,
- guint keycode,
- EggVirtualModifierType accelerator_mods)
+gchar* egg_virtual_accelerator_name (guint accelerator_key, guint keycode, EggVirtualModifierType accelerator_mods)
{
- gchar *gtk_name;
- GdkModifierType gdkmods = 0;
+ /* Acá esta el problema...
+ * */
+ gchar* gtk_name;
+ GdkModifierType gdkmods = 0;
- egg_keymap_resolve_virtual_modifiers (NULL, accelerator_mods, &gdkmods);
- gtk_name = gtk_accelerator_name (accelerator_key, gdkmods);
+ egg_keymap_resolve_virtual_modifiers(NULL, accelerator_mods, &gdkmods);
- if (!accelerator_key)
- {
- gchar *name;
- name = g_strdup_printf ("%s0x%02x", gtk_name, keycode);
- g_free (gtk_name);
- return name;
- }
+ /* en la funcion gtk_accelerator_name, desde la modificacion del 16 de sep
+ * del 2011 en GTK+, la tecla <Control> es tomada como <Primary> (?) */
+ gtk_name = gtk_accelerator_name(accelerator_key, gdkmods);
+
+ if (!accelerator_key)
+ {
+ gchar *name;
+ name = g_strdup_printf ("%s0x%02x", gtk_name, keycode);
+ g_free (gtk_name);
+ return name;
+ }
- return gtk_name;
+ return gtk_name;
}
/**
@@ -428,47 +434,46 @@ egg_virtual_accelerator_label (guint accelerator_key,
guint keycode,
EggVirtualModifierType accelerator_mods)
{
- gchar *gtk_label;
- GdkModifierType gdkmods = 0;
+ gchar *gtk_label;
+ GdkModifierType gdkmods = 0;
- egg_keymap_resolve_virtual_modifiers (NULL, accelerator_mods, &gdkmods);
- gtk_label = gtk_accelerator_get_label (accelerator_key, gdkmods);
+ egg_keymap_resolve_virtual_modifiers (NULL, accelerator_mods, &gdkmods);
+ gtk_label = gtk_accelerator_get_label (accelerator_key, gdkmods);
- if (!accelerator_key)
- {
- gchar *label;
- label = g_strdup_printf ("%s0x%02x", gtk_label, keycode);
- g_free (gtk_label);
- return label;
- }
+ if (!accelerator_key)
+ {
+ gchar *label;
+ label = g_strdup_printf ("%s0x%02x", gtk_label, keycode);
+ g_free (gtk_label);
+ return label;
+ }
- return gtk_label;
+ return gtk_label;
}
-void
-egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
- EggVirtualModifierType virtual_mods,
- GdkModifierType *concrete_mods)
+void egg_keymap_resolve_virtual_modifiers (GdkKeymap* keymap, EggVirtualModifierType virtual_mods, GdkModifierType* concrete_mods)
{
- GdkModifierType concrete;
- int i;
- const EggModmap *modmap;
+ GdkModifierType concrete;
+ int i;
+ const EggModmap* modmap;
- g_return_if_fail (concrete_mods != NULL);
- g_return_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap));
+ g_return_if_fail (concrete_mods != NULL);
+ g_return_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap));
- modmap = egg_keymap_get_modmap (keymap);
+ modmap = egg_keymap_get_modmap(keymap);
- /* Not so sure about this algorithm. */
+ /* Not so sure about this algorithm. */
+ concrete = 0;
- concrete = 0;
- for (i = 0; i < EGG_MODMAP_ENTRY_LAST; ++i)
- {
- if (modmap->mapping[i] & virtual_mods)
- concrete |= MODMAP_ENTRY_TO_MODIFIER (i);
- }
+ for (i = 0; i < EGG_MODMAP_ENTRY_LAST; ++i)
+ {
+ if (modmap->mapping[i] & virtual_mods)
+ {
+ concrete |= MODMAP_ENTRY_TO_MODIFIER (i);
+ }
+ }
- *concrete_mods = concrete;
+ *concrete_mods = concrete;
}
void
diff --git a/capplets/keybindings/eggcellrendererkeys.c b/capplets/keybindings/eggcellrendererkeys.c
index 776a5391..5d84c2de 100644
--- a/capplets/keybindings/eggcellrendererkeys.c
+++ b/capplets/keybindings/eggcellrendererkeys.c
@@ -7,13 +7,13 @@
#include "eggaccelerators.h"
#ifndef EGG_COMPILATION
-#ifndef _
-#define _(x) dgettext (GETTEXT_PACKAGE, x)
-#define N_(x) x
-#endif
+ #ifndef _
+ #define _(x) dgettext (GETTEXT_PACKAGE, x)
+ #define N_(x) x
+ #endif
#else
-#define _(x) x
-#define N_(x) x
+ #define _(x) x
+ #define N_(x) x
#endif
#define EGG_CELL_RENDERER_TEXT_PATH "egg-cell-renderer-text"
@@ -58,81 +58,75 @@ enum {
PROP_ACCEL_MODE
};
-static GtkCellRendererTextClass *parent_class = NULL;
+static GtkCellRendererTextClass* parent_class = NULL;
-GType
-egg_cell_renderer_keys_get_type (void)
+GType egg_cell_renderer_keys_get_type(void)
{
- static GType cell_keys_type = 0;
-
- if (!cell_keys_type)
- {
- static const GTypeInfo cell_keys_info =
- {
- sizeof (EggCellRendererKeysClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)egg_cell_renderer_keys_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EggCellRendererKeys),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_cell_renderer_keys_init
- };
+ static GType cell_keys_type = 0;
- cell_keys_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "EggCellRendererKeys", &cell_keys_info, 0);
- }
+ if (!cell_keys_type)
+ {
+ static const GTypeInfo cell_keys_info = {
+ sizeof (EggCellRendererKeysClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc)egg_cell_renderer_keys_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EggCellRendererKeys),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) egg_cell_renderer_keys_init
+ };
+
+ cell_keys_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "EggCellRendererKeys", &cell_keys_info, 0);
+ }
- return cell_keys_type;
+ return cell_keys_type;
}
-static void
-egg_cell_renderer_keys_init (EggCellRendererKeys *cell_keys)
+static void egg_cell_renderer_keys_init(EggCellRendererKeys* cell_keys)
{
- cell_keys->accel_mode = EGG_CELL_RENDERER_KEYS_MODE_GTK;
+ cell_keys->accel_mode = EGG_CELL_RENDERER_KEYS_MODE_GTK;
}
/* FIXME setup stuff to generate this */
/* VOID:STRING,UINT,FLAGS,UINT */
-static void
-marshal_VOID__STRING_UINT_FLAGS_UINT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
+static void marshal_VOID__STRING_UINT_FLAGS_UINT(GClosure* closure, GValue* return_value, guint n_param_values, const GValue* param_values, gpointer invocation_hint, gpointer marshal_data)
{
- typedef void (*GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (gpointer data1,
- const char *arg_1,
- guint arg_2,
- int arg_3,
- guint arg_4,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 5);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
+ /* typedef inside a function? wow */
+ typedef void (*GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (
+ gpointer data1,
+ const char* arg_1,
+ guint arg_2,
+ int arg_3,
+ guint arg_4,
+ gpointer data2);
+
+ register GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT callback;
+ register GCClosure* cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA(closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer(param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer(param_values + 0);
+ data2 = closure->data;
+ }
- callback = (GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (marshal_data ? marshal_data : cc->callback);
+ callback = (GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (marshal_data ? marshal_data : cc->callback);
- callback (data1,
- g_value_get_string (param_values + 1),
- g_value_get_uint (param_values + 2),
- g_value_get_flags (param_values + 3),
- g_value_get_uint (param_values + 4),
- data2);
+ callback(data1,
+ g_value_get_string(param_values + 1),
+ g_value_get_uint(param_values + 2),
+ g_value_get_flags(param_values + 3),
+ g_value_get_uint(param_values + 4),
+ data2);
}
static void
@@ -220,28 +214,26 @@ egg_cell_renderer_keys_class_init (EggCellRendererKeysClass *cell_keys_class)
}
-GtkCellRenderer *
-egg_cell_renderer_keys_new (void)
+GtkCellRenderer* egg_cell_renderer_keys_new(void)
{
- return GTK_CELL_RENDERER (g_object_new (EGG_TYPE_CELL_RENDERER_KEYS, NULL));
+ return GTK_CELL_RENDERER(g_object_new(EGG_TYPE_CELL_RENDERER_KEYS, NULL));
}
-static void
-egg_cell_renderer_keys_finalize (GObject *object)
+static void egg_cell_renderer_keys_finalize(GObject* object)
{
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ (*G_OBJECT_CLASS(parent_class)->finalize)(object);
}
-static gchar *
-convert_keysym_state_to_string (guint keysym,
- guint keycode,
- EggVirtualModifierType mask)
+static gchar* convert_keysym_state_to_string(guint keysym, guint keycode, EggVirtualModifierType mask)
{
- if (keysym == 0 && keycode == 0)
- return g_strdup (_("Disabled"));
- else
- return egg_virtual_accelerator_label (keysym, keycode, mask);
+ if (keysym == 0 && keycode == 0)
+ {
+ return g_strdup (_("Disabled"));
+ }
+ else
+ {
+ return egg_virtual_accelerator_label(keysym, keycode, mask);
+ }
}
static void
@@ -318,31 +310,32 @@ egg_cell_renderer_keys_set_property (GObject *object,
}
}
-static gboolean
-is_modifier (guint keycode)
+static gboolean is_modifier(guint keycode)
{
- gint i;
- gint map_size;
- XModifierKeymap *mod_keymap;
- gboolean retval = FALSE;
+ gint i;
+ gint map_size;
+ XModifierKeymap* mod_keymap;
+ gboolean retval = FALSE;
- mod_keymap = XGetModifierMapping (gdk_display);
+ mod_keymap = XGetModifierMapping(gdk_display);
- map_size = 8 * mod_keymap->max_keypermod;
- i = 0;
- while (i < map_size)
- {
- if (keycode == mod_keymap->modifiermap[i])
- {
- retval = TRUE;
- break;
- }
- ++i;
- }
+ map_size = 8 * mod_keymap->max_keypermod;
+ i = 0;
+
+ while (i < map_size)
+ {
+ if (keycode == mod_keymap->modifiermap[i])
+ {
+ retval = TRUE;
+ break;
+ }
- XFreeModifiermap (mod_keymap);
+ ++i;
+ }
+
+ XFreeModifiermap(mod_keymap);
- return retval;
+ return retval;
}
static void
@@ -374,142 +367,143 @@ egg_cell_renderer_keys_get_size (GtkCellRenderer *cell,
* GTK mode) and a removed key.
*/
-static gboolean
-grab_key_callback (GtkWidget *widget,
- GdkEventKey *event,
- void *data)
+static gboolean grab_key_callback(GtkWidget* widget, GdkEventKey* event, void* data)
{
- GdkModifierType accel_mods = 0;
- guint accel_keyval;
- EggCellRendererKeys *keys;
- char *path;
- gboolean edited;
- gboolean cleared;
- GdkModifierType consumed_modifiers;
- guint upper;
- GdkModifierType ignored_modifiers;
-
- keys = EGG_CELL_RENDERER_KEYS (data);
+ GdkModifierType accel_mods = 0;
+ guint accel_keyval;
+ EggCellRendererKeys *keys;
+ char *path;
+ gboolean edited;
+ gboolean cleared;
+ GdkModifierType consumed_modifiers;
+ guint upper;
+ GdkModifierType ignored_modifiers;
+
+ keys = EGG_CELL_RENDERER_KEYS(data);
+
+ if (is_modifier(event->hardware_keycode))
+ {
+ return TRUE;
+ }
- if (is_modifier (event->hardware_keycode))
- return TRUE;
+ edited = FALSE;
+ cleared = FALSE;
- edited = FALSE;
- cleared = FALSE;
+ consumed_modifiers = 0;
+ gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
+ event->hardware_keycode,
+ event->state,
+ event->group,
+ NULL, NULL, NULL, &consumed_modifiers);
- consumed_modifiers = 0;
- gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
- event->hardware_keycode,
- event->state,
- event->group,
- NULL, NULL, NULL, &consumed_modifiers);
+ upper = event->keyval;
+ accel_keyval = gdk_keyval_to_lower(upper);
- upper = event->keyval;
- accel_keyval = gdk_keyval_to_lower (upper);
- if (accel_keyval == GDK_ISO_Left_Tab)
- accel_keyval = GDK_Tab;
+ if (accel_keyval == GDK_ISO_Left_Tab)
+ {
+ accel_keyval = GDK_Tab;
+ }
+ /* Put shift back if it changed the case of the key, not otherwise. */
+ if (upper != accel_keyval && (consumed_modifiers & GDK_SHIFT_MASK))
+ {
+ consumed_modifiers &= ~(GDK_SHIFT_MASK);
+ }
+ egg_keymap_resolve_virtual_modifiers(gdk_keymap_get_default(),
+ EGG_VIRTUAL_NUM_LOCK_MASK |
+ EGG_VIRTUAL_SCROLL_LOCK_MASK |
+ EGG_VIRTUAL_LOCK_MASK,
+ &ignored_modifiers);
+
+ /* http://bugzilla.gnome.org/show_bug.cgi?id=139605
+ * mouse keys should effect keybindings */
+ ignored_modifiers |= GDK_BUTTON1_MASK |
+ GDK_BUTTON2_MASK |
+ GDK_BUTTON3_MASK |
+ GDK_BUTTON4_MASK |
+ GDK_BUTTON5_MASK;
+
+ /* filter consumed/ignored modifiers */
+ if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
+ {
+ accel_mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers | ignored_modifiers);
+ }
+ else if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_X)
+ {
+ accel_mods = event->state & GDK_MODIFIER_MASK & ~(ignored_modifiers);
+ }
+ else
+ {
+ g_assert_not_reached();
+ }
- /* Put shift back if it changed the case of the key, not otherwise.
- */
- if (upper != accel_keyval &&
- (consumed_modifiers & GDK_SHIFT_MASK))
- {
- consumed_modifiers &= ~(GDK_SHIFT_MASK);
- }
+ if (accel_mods == 0 && accel_keyval == GDK_Escape)
+ {
+ goto out; /* cancel */
+ }
- egg_keymap_resolve_virtual_modifiers (gdk_keymap_get_default (),
- EGG_VIRTUAL_NUM_LOCK_MASK |
- EGG_VIRTUAL_SCROLL_LOCK_MASK |
- EGG_VIRTUAL_LOCK_MASK,
- &ignored_modifiers);
-
- /* http://bugzilla.gnome.org/show_bug.cgi?id=139605
- * mouse keys should effect keybindings */
- ignored_modifiers |= GDK_BUTTON1_MASK |
- GDK_BUTTON2_MASK |
- GDK_BUTTON3_MASK |
- GDK_BUTTON4_MASK |
- GDK_BUTTON5_MASK;
-
- /* filter consumed/ignored modifiers */
-
- if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
- accel_mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers | ignored_modifiers);
- else if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_X)
- accel_mods = event->state & GDK_MODIFIER_MASK & ~(ignored_modifiers);
- else
- g_assert_not_reached ();
-
- if (accel_mods == 0 && accel_keyval == GDK_Escape)
- goto out; /* cancel */
-
- /* clear the accelerator on Backspace */
- if (accel_mods == 0 && accel_keyval == GDK_BackSpace)
- {
- cleared = TRUE;
- goto out;
- }
+ /* clear the accelerator on Backspace */
+ if (accel_mods == 0 && accel_keyval == GDK_BackSpace)
+ {
+ cleared = TRUE;
+ goto out;
+ }
- if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
- {
- if (!gtk_accelerator_valid (accel_keyval, accel_mods))
+ if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
{
- accel_keyval = 0;
- accel_mods = 0;
+ if (!gtk_accelerator_valid (accel_keyval, accel_mods))
+ {
+ accel_keyval = 0;
+ accel_mods = 0;
+ }
}
- }
- edited = TRUE;
- out:
- gdk_keyboard_ungrab (event->time);
- gdk_pointer_ungrab (event->time);
+ edited = TRUE;
- path = g_strdup (g_object_get_data (G_OBJECT (keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH));
+ out:
- gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (keys->edit_widget));
- gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (keys->edit_widget));
- keys->edit_widget = NULL;
- keys->grab_widget = NULL;
+ gdk_keyboard_ungrab(event->time);
+ gdk_pointer_ungrab(event->time);
- if (edited)
- {
- g_signal_emit_by_name (G_OBJECT (keys), "accel_edited", path,
- accel_keyval, accel_mods, event->hardware_keycode);
- }
- else if (cleared)
- {
- g_signal_emit_by_name (G_OBJECT (keys), "accel_cleared", path);
- }
+ path = g_strdup(g_object_get_data(G_OBJECT(keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH));
+
+ gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(keys->edit_widget));
+ gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(keys->edit_widget));
+ keys->edit_widget = NULL;
+ keys->grab_widget = NULL;
- g_free (path);
- return TRUE;
+ if (edited)
+ {
+ g_signal_emit_by_name(G_OBJECT(keys), "accel_edited", path, accel_keyval, accel_mods, event->hardware_keycode);
+ }
+ else if (cleared)
+ {
+ g_signal_emit_by_name(G_OBJECT(keys), "accel_cleared", path);
+ }
+
+ g_free (path);
+ return TRUE;
}
-static void
-ungrab_stuff (GtkWidget *widget, gpointer data)
+static void ungrab_stuff(GtkWidget* widget, gpointer data)
{
- EggCellRendererKeys *keys = EGG_CELL_RENDERER_KEYS (data);
+ EggCellRendererKeys* keys = EGG_CELL_RENDERER_KEYS(data);
- gdk_keyboard_ungrab (GDK_CURRENT_TIME);
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+ gdk_pointer_ungrab(GDK_CURRENT_TIME);
- g_signal_handlers_disconnect_by_func (G_OBJECT (keys->grab_widget),
- G_CALLBACK (grab_key_callback), data);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(keys->grab_widget), G_CALLBACK(grab_key_callback), data);
}
-static void
-pointless_eventbox_start_editing (GtkCellEditable *cell_editable,
- GdkEvent *event)
+static void pointless_eventbox_start_editing(GtkCellEditable* cell_editable, GdkEvent* event)
{
- /* do nothing, because we are pointless */
+ /* do nothing, because we are pointless */
}
-static void
-pointless_eventbox_cell_editable_init (GtkCellEditableIface *iface)
+static void pointless_eventbox_cell_editable_init(GtkCellEditableIface* iface)
{
- iface->start_editing = pointless_eventbox_start_editing;
+ iface->start_editing = pointless_eventbox_start_editing;
}
static GType
@@ -623,73 +617,69 @@ egg_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
return GTK_CELL_EDITABLE (keys->edit_widget);
}
-void
-egg_cell_renderer_keys_set_accelerator (EggCellRendererKeys *keys,
- guint keyval,
- guint keycode,
- EggVirtualModifierType mask)
+void egg_cell_renderer_keys_set_accelerator(EggCellRendererKeys* keys, guint keyval, guint keycode, EggVirtualModifierType mask)
{
- char *text;
- gboolean changed;
+ char *text;
+ gboolean changed;
- g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
+ g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
- g_object_freeze_notify (G_OBJECT (keys));
+ g_object_freeze_notify (G_OBJECT (keys));
- changed = FALSE;
+ changed = FALSE;
- if (keyval != keys->accel_key)
- {
- keys->accel_key = keyval;
- g_object_notify (G_OBJECT (keys), "accel_key");
- changed = TRUE;
- }
+ if (keyval != keys->accel_key)
+ {
+ keys->accel_key = keyval;
+ g_object_notify (G_OBJECT (keys), "accel_key");
+ changed = TRUE;
+ }
- if (mask != keys->accel_mask)
- {
- keys->accel_mask = mask;
+ if (mask != keys->accel_mask)
+ {
+ keys->accel_mask = mask;
- g_object_notify (G_OBJECT (keys), "accel_mask");
- changed = TRUE;
- }
+ g_object_notify (G_OBJECT (keys), "accel_mask");
+ changed = TRUE;
+ }
- if (keycode != keys->keycode)
- {
- keys->keycode = keycode;
+ if (keycode != keys->keycode)
+ {
+ keys->keycode = keycode;
- g_object_notify (G_OBJECT (keys), "keycode");
- changed = TRUE;
- }
- g_object_thaw_notify (G_OBJECT (keys));
+ g_object_notify (G_OBJECT (keys), "keycode");
+ changed = TRUE;
+ }
- if (changed)
- {
- /* sync string to the key values */
- text = convert_keysym_state_to_string (keys->accel_key, keys->keycode, keys->accel_mask);
- g_object_set (keys, "text", text, NULL);
- g_free (text);
- }
+ g_object_thaw_notify (G_OBJECT (keys));
+
+ if (changed)
+ {
+ /* sync string to the key values */
+ text = convert_keysym_state_to_string (keys->accel_key, keys->keycode, keys->accel_mask);
+ g_object_set (keys, "text", text, NULL);
+ g_free (text);
+ }
}
-void
-egg_cell_renderer_keys_get_accelerator (EggCellRendererKeys *keys,
- guint *keyval,
- EggVirtualModifierType *mask)
+void egg_cell_renderer_keys_get_accelerator(EggCellRendererKeys* keys, guint* keyval, EggVirtualModifierType* mask)
{
- g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
+ g_return_if_fail(EGG_IS_CELL_RENDERER_KEYS(keys));
- if (keyval)
- *keyval = keys->accel_key;
+ if (keyval)
+ {
+ *keyval = keys->accel_key;
+ }
- if (mask)
- *mask = keys->accel_mask;
+ if (mask)
+ {
+ *mask = keys->accel_mask;
+ }
}
-void
-egg_cell_renderer_keys_set_accel_mode (EggCellRendererKeys *keys,
- EggCellRendererKeysMode accel_mode)
+void egg_cell_renderer_keys_set_accel_mode (EggCellRendererKeys* keys, EggCellRendererKeysMode accel_mode)
{
- g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
- keys->accel_mode = accel_mode;
- g_object_notify (G_OBJECT (keys), "accel_mode");
+ g_return_if_fail(EGG_IS_CELL_RENDERER_KEYS(keys));
+ keys->accel_mode = accel_mode;
+ g_object_notify(G_OBJECT(keys), "accel_mode");
}
diff --git a/capplets/keybindings/mate-keybinding-properties.c b/capplets/keybindings/mate-keybinding-properties.c
index fb6c8785..b0ac2f7f 100644
--- a/capplets/keybindings/mate-keybinding-properties.c
+++ b/capplets/keybindings/mate-keybinding-properties.c
@@ -82,10 +82,9 @@ static GtkWidget *custom_shortcut_dialog = NULL;
static GtkWidget *custom_shortcut_name_entry = NULL;
static GtkWidget *custom_shortcut_command_entry = NULL;
-static GtkWidget*
-_gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
+static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name)
{
- return GTK_WIDGET (gtk_builder_get_object (builder, name));
+ return GTK_WIDGET (gtk_builder_get_object (builder, name));
}
static GtkBuilder *
@@ -105,18 +104,23 @@ create_builder (void)
return builder;
}
-static char*
-binding_name (guint keyval,
- guint keycode,
- EggVirtualModifierType mask,
- gboolean translate)
+static char* binding_name(guint keyval, guint keycode, EggVirtualModifierType mask, gboolean translate)
{
- if (keyval != 0 || keycode != 0)
- return translate ?
- egg_virtual_accelerator_label (keyval, keycode, mask) :
- egg_virtual_accelerator_name (keyval, keycode, mask);
- else
- return g_strdup (translate ? _("Disabled") : "");
+ if (keyval != 0 || keycode != 0)
+ {
+ if (translate)
+ {
+ return egg_virtual_accelerator_label (keyval, keycode, mask);
+ }
+ else
+ {
+ return egg_virtual_accelerator_name (keyval, keycode, mask);
+ }
+ }
+ else
+ {
+ return g_strdup (translate ? _("Disabled") : "");
+ }
}
static gboolean
@@ -421,72 +425,78 @@ typedef struct {
gboolean found;
} KeyMatchData;
-static gboolean
-key_match (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+static gboolean key_match(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
{
- KeyMatchData *match_data = data;
- KeyEntry *element;
+ KeyMatchData* match_data = data;
+ KeyEntry* element;
- gtk_tree_model_get (model, iter,
- KEYENTRY_COLUMN, &element,
- -1);
+ gtk_tree_model_get(model, iter,
+ KEYENTRY_COLUMN, &element,
+ -1);
- if (element && g_strcmp0 (element->mateconf_key, match_data->key) == 0)
- {
- match_data->found = TRUE;
- return TRUE;
- }
+ if (element && g_strcmp0(element->mateconf_key, match_data->key) == 0)
+ {
+ match_data->found = TRUE;
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-static gboolean
-key_is_already_shown (GtkTreeModel *model, const KeyListEntry *entry)
+static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
{
- KeyMatchData data;
+ KeyMatchData data;
- data.key = entry->name;
- data.found = FALSE;
- gtk_tree_model_foreach (model, key_match, &data);
+ data.key = entry->name;
+ data.found = FALSE;
+ gtk_tree_model_foreach(model, key_match, &data);
- return data.found;
+ return data.found;
}
-static gboolean
-should_show_key (const KeyListEntry *entry)
+static gboolean should_show_key(const KeyListEntry* entry)
{
- int value;
- MateConfClient *client;
+ int value;
+ MateConfClient *client;
- if (entry->comparison == COMPARISON_NONE)
- return TRUE;
+ if (entry->comparison == COMPARISON_NONE)
+ {
+ return TRUE;
+ }
- g_return_val_if_fail (entry->key != NULL, FALSE);
+ g_return_val_if_fail(entry->key != NULL, FALSE);
- client = mateconf_client_get_default();
- value = mateconf_client_get_int (client, entry->key, NULL);
- g_object_unref (client);
+ client = mateconf_client_get_default();
+ value = mateconf_client_get_int (client, entry->key, NULL);
+ g_object_unref (client);
- switch (entry->comparison) {
- case COMPARISON_NONE:
- /* For compiler warnings */
- g_assert_not_reached ();
- return FALSE;
- case COMPARISON_GT:
- if (value > entry->value)
- return TRUE;
- break;
- case COMPARISON_LT:
- if (value < entry->value)
- return TRUE;
- break;
- case COMPARISON_EQ:
- if (value == entry->value)
- return TRUE;
- break;
- }
+ switch (entry->comparison)
+ {
+ case COMPARISON_NONE:
+ /* For compiler warnings */
+ g_assert_not_reached ();
+ return FALSE;
+ case COMPARISON_GT:
+ if (value > entry->value)
+ {
+ return TRUE;
+ }
+ break;
+ case COMPARISON_LT:
+ if (value < entry->value)
+ {
+ return TRUE;
+ }
+ break;
+ case COMPARISON_EQ:
+ if (value == entry->value)
+ {
+ return TRUE;
+ }
+ break;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -1015,73 +1025,78 @@ key_entry_controlling_key_changed (MateConfClient *client,
reload_key_entries (user_data);
}
-static gboolean
-cb_check_for_uniqueness (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- KeyEntry *new_key)
+static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key)
{
- KeyEntry *element;
+ KeyEntry* element;
- gtk_tree_model_get (new_key->model, iter,
- KEYENTRY_COLUMN, &element,
- -1);
+ gtk_tree_model_get (new_key->model, iter,
+ KEYENTRY_COLUMN, &element,
+ -1);
- /* no conflict for : blanks, different modifiers, or ourselves */
- if (element == NULL || new_key->mask != element->mask ||
- !strcmp (new_key->mateconf_key, element->mateconf_key))
- return FALSE;
+ /* no conflict for : blanks, different modifiers, or ourselves */
+ if (element == NULL || new_key->mask != element->mask ||
+ !strcmp (new_key->mateconf_key, element->mateconf_key))
+ {
+ return FALSE;
+ }
- if (new_key->keyval != 0) {
- if (new_key->keyval != element->keyval)
- return FALSE;
- } else if (element->keyval != 0 || new_key->keycode != element->keycode)
- return FALSE;
+ if (new_key->keyval != 0)
+ {
+ if (new_key->keyval != element->keyval)
+ {
+ return FALSE;
+ }
+ }
+ else if (element->keyval != 0 || new_key->keycode != element->keycode)
+ {
+ return FALSE;
+ }
- new_key->editable = FALSE;
- new_key->mateconf_key = element->mateconf_key;
- new_key->description = element->description;
- new_key->desc_mateconf_key = element->desc_mateconf_key;
- new_key->desc_editable = element->desc_editable;
- return TRUE;
+ new_key->editable = FALSE;
+ new_key->mateconf_key = element->mateconf_key;
+ new_key->description = element->description;
+ new_key->desc_mateconf_key = element->desc_mateconf_key;
+ new_key->desc_editable = element->desc_editable;
+
+ return TRUE;
}
static const guint forbidden_keyvals[] = {
- /* Navigation keys */
- GDK_Home,
- GDK_Left,
- GDK_Up,
- GDK_Right,
- GDK_Down,
- GDK_Page_Up,
- GDK_Page_Down,
- GDK_End,
- GDK_Tab,
-
- /* Return */
- GDK_KP_Enter,
- GDK_Return,
-
- GDK_space,
- GDK_Mode_switch
+ /* Navigation keys */
+ GDK_Home,
+ GDK_Left,
+ GDK_Up,
+ GDK_Right,
+ GDK_Down,
+ GDK_Page_Up,
+ GDK_Page_Down,
+ GDK_End,
+ GDK_Tab,
+
+ /* Return */
+ GDK_KP_Enter,
+ GDK_Return,
+
+ GDK_space,
+ GDK_Mode_switch
};
-static gboolean
-keyval_is_forbidden (guint keyval)
+static gboolean keyval_is_forbidden(guint keyval)
{
- guint i;
+ guint i;
- for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals); i++) {
- if (keyval == forbidden_keyvals[i])
- return TRUE;
- }
+ for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals); i++)
+ {
+ if (keyval == forbidden_keyvals[i])
+ {
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
-static void
-show_error (GtkWindow *parent,
- GError *err)
+static void show_error(GtkWindow* parent, GError* err)
{
GtkWidget *dialog;
@@ -1097,24 +1112,18 @@ show_error (GtkWindow *parent,
gtk_widget_destroy (dialog);
}
-static void
-accel_edited_callback (GtkCellRendererText *cell,
- const char *path_string,
- guint keyval,
- EggVirtualModifierType mask,
- guint keycode,
- gpointer data)
+static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data)
{
- MateConfClient *client;
- GtkTreeView *view = (GtkTreeView *)data;
- GtkTreeModel *model;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- GtkTreeIter iter;
- KeyEntry *key_entry, tmp_key;
- GError *err = NULL;
- char *str;
+ MateConfClient* client;
+ GtkTreeView* view = (GtkTreeView*) data;
+ GtkTreeModel* model;
+ GtkTreePath* path = gtk_tree_path_new_from_string (path_string);
+ GtkTreeIter iter;
+ KeyEntry* key_entry, tmp_key;
+ GError* err = NULL;
+ char* str;
- block_accels = FALSE;
+ block_accels = FALSE;
model = gtk_tree_view_get_model (view);
gtk_tree_model_get_iter (model, &iter, path);
@@ -1123,171 +1132,172 @@ accel_edited_callback (GtkCellRendererText *cell,
KEYENTRY_COLUMN, &key_entry,
-1);
- /* sanity check */
- if (key_entry == NULL)
- return;
-
- /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
- mask &= ~EGG_VIRTUAL_LOCK_MASK;
+ /* sanity check */
+ if (key_entry == NULL)
+ {
+ return;
+ }
- tmp_key.model = model;
- tmp_key.keyval = keyval;
- tmp_key.keycode = keycode;
- tmp_key.mask = mask;
- tmp_key.mateconf_key = key_entry->mateconf_key;
- tmp_key.description = NULL;
- tmp_key.editable = TRUE; /* kludge to stuff in a return flag */
+ /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
+ mask &= ~EGG_VIRTUAL_LOCK_MASK;
- if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
- gtk_tree_model_foreach (model,
- (GtkTreeModelForeachFunc) cb_check_for_uniqueness,
- &tmp_key);
+ tmp_key.model = model;
+ tmp_key.keyval = keyval;
+ tmp_key.keycode = keycode;
+ tmp_key.mask = mask;
+ tmp_key.mateconf_key = key_entry->mateconf_key;
+ tmp_key.description = NULL;
+ tmp_key.editable = TRUE; /* kludge to stuff in a return flag */
- /* Check for unmodified keys */
- if (tmp_key.mask == 0 && tmp_key.keycode != 0)
- {
- if ((tmp_key.keyval >= GDK_a && tmp_key.keyval <= GDK_z)
- || (tmp_key.keyval >= GDK_A && tmp_key.keyval <= GDK_Z)
- || (tmp_key.keyval >= GDK_0 && tmp_key.keyval <= GDK_9)
- || (tmp_key.keyval >= GDK_kana_fullstop && tmp_key.keyval <= GDK_semivoicedsound)
- || (tmp_key.keyval >= GDK_Arabic_comma && tmp_key.keyval <= GDK_Arabic_sukun)
- || (tmp_key.keyval >= GDK_Serbian_dje && tmp_key.keyval <= GDK_Cyrillic_HARDSIGN)
- || (tmp_key.keyval >= GDK_Greek_ALPHAaccent && tmp_key.keyval <= GDK_Greek_omega)
- || (tmp_key.keyval >= GDK_hebrew_doublelowline && tmp_key.keyval <= GDK_hebrew_taf)
- || (tmp_key.keyval >= GDK_Thai_kokai && tmp_key.keyval <= GDK_Thai_lekkao)
- || (tmp_key.keyval >= GDK_Hangul && tmp_key.keyval <= GDK_Hangul_Special)
- || (tmp_key.keyval >= GDK_Hangul_Kiyeog && tmp_key.keyval <= GDK_Hangul_J_YeorinHieuh)
- || keyval_is_forbidden (tmp_key.keyval)) {
- GtkWidget *dialog;
- char *name;
-
- name = binding_name (keyval, keycode, mask, TRUE);
-
- dialog =
- gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
- "Please try with a key such as Control, Alt or Shift at the same time."),
- name);
-
- g_free (name);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- /* set it back to its previous value. */
- egg_cell_renderer_keys_set_accelerator
- (EGG_CELL_RENDERER_KEYS (cell),
- key_entry->keyval, key_entry->keycode, key_entry->mask);
- return;
- }
- }
+ if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
+ {
+ gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key);
+ }
- /* flag to see if the new accelerator was in use by something */
- if (!tmp_key.editable)
+ /* Check for unmodified keys */
+ if (tmp_key.mask == 0 && tmp_key.keycode != 0)
{
- GtkWidget *dialog;
- char *name;
- int response;
-
- name = binding_name (keyval, keycode, mask, TRUE);
-
- dialog =
- gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
+ if ((tmp_key.keyval >= GDK_a && tmp_key.keyval <= GDK_z)
+ || (tmp_key.keyval >= GDK_A && tmp_key.keyval <= GDK_Z)
+ || (tmp_key.keyval >= GDK_0 && tmp_key.keyval <= GDK_9)
+ || (tmp_key.keyval >= GDK_kana_fullstop && tmp_key.keyval <= GDK_semivoicedsound)
+ || (tmp_key.keyval >= GDK_Arabic_comma && tmp_key.keyval <= GDK_Arabic_sukun)
+ || (tmp_key.keyval >= GDK_Serbian_dje && tmp_key.keyval <= GDK_Cyrillic_HARDSIGN)
+ || (tmp_key.keyval >= GDK_Greek_ALPHAaccent && tmp_key.keyval <= GDK_Greek_omega)
+ || (tmp_key.keyval >= GDK_hebrew_doublelowline && tmp_key.keyval <= GDK_hebrew_taf)
+ || (tmp_key.keyval >= GDK_Thai_kokai && tmp_key.keyval <= GDK_Thai_lekkao)
+ || (tmp_key.keyval >= GDK_Hangul && tmp_key.keyval <= GDK_Hangul_Special)
+ || (tmp_key.keyval >= GDK_Hangul_Kiyeog && tmp_key.keyval <= GDK_Hangul_J_YeorinHieuh)
+ || keyval_is_forbidden (tmp_key.keyval))
+ {
+
+ GtkWidget *dialog;
+ char *name;
+
+ name = binding_name (keyval, keycode, mask, TRUE);
+
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_CANCEL,
- _("The shortcut \"%s\" is already used for\n\"%s\""),
- name, tmp_key.description ?
- tmp_key.description : tmp_key.mateconf_key);
- g_free (name);
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
- "will be disabled."),
- key_entry->description ?
- key_entry->description : key_entry->mateconf_key,
- tmp_key.description ?
- tmp_key.description : tmp_key.mateconf_key);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Reassign"),
- GTK_RESPONSE_ACCEPT);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
+ "Please try with a key such as Control, Alt or Shift at the same time."),
+ name);
+
+ g_free (name);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ /* set it back to its previous value. */
+ egg_cell_renderer_keys_set_accelerator(
+ EGG_CELL_RENDERER_KEYS(cell),
+ key_entry->keyval,
+ key_entry->keycode,
+ key_entry->mask);
+ return;
+ }
+ }
- if (response == GTK_RESPONSE_ACCEPT)
+ /* flag to see if the new accelerator was in use by something */
+ if (!tmp_key.editable)
{
- MateConfClient *client;
-
- client = mateconf_client_get_default ();
+ GtkWidget* dialog;
+ char* name;
+ int response;
+
+ name = binding_name(keyval, keycode, mask, TRUE);
+
+ dialog = gtk_message_dialog_new(
+ GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ _("The shortcut \"%s\" is already used for\n\"%s\""),
+ name,
+ tmp_key.description ? tmp_key.description : tmp_key.mateconf_key);
+ g_free (name);
+
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
+ "will be disabled."),
+ key_entry->description ? key_entry->description : key_entry->mateconf_key,
+ tmp_key.description ? tmp_key.description : tmp_key.mateconf_key);
+
+ gtk_dialog_add_button(GTK_DIALOG (dialog), _("_Reassign"), GTK_RESPONSE_ACCEPT);
+
+ gtk_dialog_set_default_response(GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ MateConfClient* client;
+
+ client = mateconf_client_get_default ();
+
+ mateconf_client_set_string(
+ client,
+ tmp_key.mateconf_key,
+ "",
+ &err);
+
+ if (err != NULL)
+ {
+ show_error(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
+ g_error_free (err);
+ g_object_unref (client);
+ return;
+ }
+
+ str = binding_name (keyval, keycode, mask, FALSE);
+ mateconf_client_set_string (client, key_entry->mateconf_key, str, &err);
+
+ if (err != NULL)
+ {
+ show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
+ g_error_free (err);
+
+ /* reset the previous shortcut */
+ mateconf_client_set_string (client, tmp_key.mateconf_key, str, NULL);
+ }
+
+ g_free (str);
+ g_object_unref (client);
+ }
+ else
+ {
+ /* set it back to its previous value. */
+ egg_cell_renderer_keys_set_accelerator(
+ EGG_CELL_RENDERER_KEYS(cell),
+ key_entry->keyval,
+ key_entry->keycode,
+ key_entry->mask);
+ }
+
+ return;
+ }
- mateconf_client_set_string (client,
- tmp_key.mateconf_key,
- "", &err);
+ str = binding_name (keyval, keycode, mask, FALSE);
- if (err != NULL)
- {
- show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- err);
- g_error_free (err);
- g_object_unref (client);
- return;
- }
+ client = mateconf_client_get_default ();
+ mateconf_client_set_string(
+ client,
+ key_entry->mateconf_key,
+ str,
+ &err);
- str = binding_name (keyval, keycode, mask, FALSE);
- mateconf_client_set_string (client,
- key_entry->mateconf_key,
- str, &err);
+ g_free (str);
+ g_object_unref (client);
- if (err != NULL)
- {
- show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- err);
- g_error_free (err);
-
- /* reset the previous shortcut */
- mateconf_client_set_string (client,
- tmp_key.mateconf_key,
- str, NULL);
- }
-
- g_free (str);
- g_object_unref (client);
- }
- else
+ if (err != NULL)
{
- /* set it back to its previous value. */
- egg_cell_renderer_keys_set_accelerator (EGG_CELL_RENDERER_KEYS (cell),
- key_entry->keyval,
- key_entry->keycode,
- key_entry->mask);
+ show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
+ g_error_free (err);
+ key_entry->editable = FALSE;
}
-
- return;
- }
-
- str = binding_name (keyval, keycode, mask, FALSE);
-
- client = mateconf_client_get_default ();
- mateconf_client_set_string (client,
- key_entry->mateconf_key,
- str,
- &err);
- g_free (str);
- g_object_unref (client);
-
- if (err != NULL)
- {
- show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
- g_error_free (err);
- key_entry->editable = FALSE;
- }
}
static void
@@ -1733,16 +1743,14 @@ start_editing_cb (GtkTreeView *tree_view,
/* this handler is used to keep accels from activating while the user
* is assigning a new shortcut so that he won't accidentally trigger one
* of the widgets */
-static gboolean
-maybe_block_accels (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data)
+static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
{
- if (block_accels)
- {
- return gtk_window_propagate_key_event (GTK_WINDOW (widget), event);
- }
- return FALSE;
+ if (block_accels)
+ {
+ return gtk_window_propagate_key_event(GTK_WINDOW(widget), event);
+ }
+
+ return FALSE;
}
static void