[gnome-control-center] keyboard: Don't update binding by hand
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] keyboard: Don't update binding by hand
- Date: Wed, 16 Feb 2011 01:31:51 +0000 (UTC)
commit 6b5fa49cc600b4ad0298322c3b0aff4b59a72a58
Author: Bastien Nocera <hadess hadess net>
Date: Wed Feb 16 01:28:04 2011 +0000
keyboard: Don't update binding by hand
Let the CcKeyboardItem update keyval, keymask, etc. for us when
we set the binding value, instead of having us do it by hand.
panels/keyboard/cc-keyboard-item.c | 28 ++++++++++++++++++++++++++++
panels/keyboard/keyboard-shortcuts.c | 26 --------------------------
2 files changed, 28 insertions(+), 26 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-item.c b/panels/keyboard/cc-keyboard-item.c
index dfe222d..244374b 100644
--- a/panels/keyboard/cc-keyboard-item.c
+++ b/panels/keyboard/cc-keyboard-item.c
@@ -30,6 +30,7 @@
#include <gconf/gconf-client.h>
#include "cc-keyboard-item.h"
+#include "eggaccelerators.h"
#define CC_KEYBOARD_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_ITEM, CcKeyboardItemPrivate))
@@ -56,6 +57,30 @@ static void cc_keyboard_item_finalize (GObject *object);
G_DEFINE_TYPE (CcKeyboardItem, cc_keyboard_item, G_TYPE_OBJECT)
+static gboolean
+binding_from_string (const char *str,
+ guint *accelerator_key,
+ guint *keycode,
+ EggVirtualModifierType *accelerator_mods)
+{
+ g_return_val_if_fail (accelerator_key != NULL, FALSE);
+
+ if (str == NULL || strcmp (str, "disabled") == 0)
+ {
+ *accelerator_key = 0;
+ *keycode = 0;
+ *accelerator_mods = 0;
+ return TRUE;
+ }
+
+ egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods);
+
+ if (*accelerator_key == 0)
+ return FALSE;
+ else
+ return TRUE;
+}
+
static void
_set_description (CcKeyboardItem *item,
const char *value)
@@ -78,6 +103,7 @@ _set_binding (CcKeyboardItem *item,
{
g_free (item->binding);
item->binding = g_strdup (value);
+ binding_from_string (item->binding, &item->keyval, &item->keycode, &item->mask);
}
const char *
@@ -382,6 +408,7 @@ cc_keyboard_item_load_from_gconf (CcKeyboardItem *item,
(GConfClientNotifyFunc) &keybinding_key_changed,
item, NULL, NULL);
item->binding = gconf_client_get_string (client, item->gconf_key, NULL);
+ binding_from_string (item->binding, &item->keyval, &item->keycode, &item->mask);
gconf_entry_free (entry);
g_object_unref (client);
@@ -438,6 +465,7 @@ cc_keyboard_item_load_from_gconf_dir (CcKeyboardItem *item,
item, NULL, NULL);
item->binding = gconf_client_get_string (client, item->binding_gconf_key, NULL);
+ binding_from_string (item->binding, &item->keyval, &item->keycode, &item->mask);
gconf_entry_free (entry);
g_object_unref (client);
diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c
index f8b7a9c..9143005 100644
--- a/panels/keyboard/keyboard-shortcuts.c
+++ b/panels/keyboard/keyboard-shortcuts.c
@@ -183,30 +183,6 @@ should_show_key (const KeyListEntry *entry)
}
static gboolean
-binding_from_string (const char *str,
- guint *accelerator_key,
- guint *keycode,
- EggVirtualModifierType *accelerator_mods)
-{
- g_return_val_if_fail (accelerator_key != NULL, FALSE);
-
- if (str == NULL || strcmp (str, "disabled") == 0)
- {
- *accelerator_key = 0;
- *keycode = 0;
- *accelerator_mods = 0;
- return TRUE;
- }
-
- egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods);
-
- if (*accelerator_key == 0)
- return FALSE;
- else
- return TRUE;
-}
-
-static gboolean
keybinding_key_changed_foreach (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
@@ -232,7 +208,6 @@ item_changed (CcKeyboardItem *item,
gpointer user_data)
{
/* update the model */
- binding_from_string (item->binding, &item->keyval, &item->keycode, &item->mask);
gtk_tree_model_foreach (item->model, (GtkTreeModelForeachFunc) keybinding_key_changed_foreach, item);
}
@@ -292,7 +267,6 @@ append_section (GtkBuilder *builder,
item->model = shortcut_model;
item->group = group;
- binding_from_string (item->binding, &item->keyval, &item->keycode, &item->mask);
g_signal_connect (G_OBJECT (item), "notify",
G_CALLBACK (item_changed), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]