[gnome-control-center] keyboard: Add support for hidden keybinding XML data
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] keyboard: Add support for hidden keybinding XML data
- Date: Sun, 17 Aug 2014 18:21:07 +0000 (UTC)
commit ba9a8bc8ff6b5ea0e8481c4a408a48aa06384ea6
Author: Christophe Fergeau <cfergeau redhat com>
Date: Sat Jun 28 00:21:01 2014 +0200
keyboard: Add support for hidden keybinding XML data
If a KeyListEntry has a hidden="true" attribute, then the corresponding
binding information will be loaded as usual, but the binding won't be
displayed in the user interface.
This is useful as the keyboard panel will take into account hidden
keybindings when detecting conflicting shortcuts, or to suggest to set a
reverse shortcut.
For now, this will be used for the various reverse mutter keybindings
({switch,cycle}.*-backward) as they should not be shown in the UI, but
we still want the keyboard panel to know about them.
https://bugzilla.gnome.org/show_bug.cgi?id=731618
panels/keyboard/cc-keyboard-item.c | 15 +++++++++++++++
panels/keyboard/cc-keyboard-item.h | 3 +++
panels/keyboard/keyboard-shortcuts.c | 26 ++++++++++++++++++--------
3 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-item.c b/panels/keyboard/cc-keyboard-item.c
index 4e3817e..fc1028e 100644
--- a/panels/keyboard/cc-keyboard-item.c
+++ b/panels/keyboard/cc-keyboard-item.c
@@ -40,6 +40,7 @@ struct CcKeyboardItemPrivate
/* internal */
CcKeyboardItem *reverse_item;
gboolean is_reversed;
+ gboolean hidden;
};
enum {
@@ -495,6 +496,20 @@ cc_keyboard_item_get_reverse_item (CcKeyboardItem *item)
{
return item->priv->reverse_item;
}
+
+
+void
+cc_keyboard_item_set_hidden (CcKeyboardItem *item, gboolean hidden)
+{
+ item->priv->hidden = !!hidden;
+}
+
+
+gboolean
+cc_keyboard_item_is_hidden (CcKeyboardItem *item)
+{
+ return item->priv->hidden;
+}
/*
* vim: sw=2 ts=8 cindent noai bs=2
*/
diff --git a/panels/keyboard/cc-keyboard-item.h b/panels/keyboard/cc-keyboard-item.h
index 1e8eb56..4006f48 100644
--- a/panels/keyboard/cc-keyboard-item.h
+++ b/panels/keyboard/cc-keyboard-item.h
@@ -107,6 +107,9 @@ void cc_keyboard_item_add_reverse_item (CcKeyboardItem *item,
gboolean is_reversed);
CcKeyboardItem * cc_keyboard_item_get_reverse_item (CcKeyboardItem *item);
+void cc_keyboard_item_set_hidden (CcKeyboardItem *item,
+ gboolean hidden);
+gboolean cc_keyboard_item_is_hidden (CcKeyboardItem *item);
G_END_DECLS
diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c
index 5b67988..7b37932 100644
--- a/panels/keyboard/keyboard-shortcuts.c
+++ b/panels/keyboard/keyboard-shortcuts.c
@@ -62,6 +62,7 @@ typedef struct
char *name; /* GSettings schema path, or GSettings key name depending on type */
char *reverse_entry;
gboolean is_reversed;
+ gboolean hidden;
} KeyListEntry;
typedef enum
@@ -278,6 +279,7 @@ append_section (GtkBuilder *builder,
continue;
}
+ cc_keyboard_item_set_hidden (item, keys_list[i].hidden);
item->model = shortcut_model;
item->group = group;
@@ -339,7 +341,7 @@ parse_start_tag (GMarkupParseContext *ctx,
KeyList *keylist = (KeyList *) user_data;
KeyListEntry key = { 0, };
const char *name, *schema, *description, *package, *context, *orig_description, *reverse_entry;
- gboolean is_reversed;
+ gboolean is_reversed, hidden;
name = NULL;
schema = NULL;
@@ -425,6 +427,7 @@ parse_start_tag (GMarkupParseContext *ctx,
orig_description = NULL;
reverse_entry = NULL;
is_reversed = FALSE;
+ hidden = FALSE;
while (*attr_names && *attr_values)
{
@@ -449,7 +452,10 @@ parse_start_tag (GMarkupParseContext *ctx,
} else if (g_str_equal (*attr_names, "is-reversed")) {
if (g_str_equal (*attr_values, "true"))
is_reversed = TRUE;
- }
+ } else if (g_str_equal (*attr_names, "hidden")) {
+ if (g_str_equal (*attr_values, "true"))
+ hidden = TRUE;
+ }
++attr_names;
++attr_values;
@@ -476,6 +482,7 @@ parse_start_tag (GMarkupParseContext *ctx,
key.schema = schema ? g_strdup (schema) : g_strdup (keylist->schema);
key.reverse_entry = g_strdup (reverse_entry);
key.is_reversed = is_reversed;
+ key.hidden = hidden;
g_array_append_val (keylist->entries, key);
}
@@ -943,12 +950,15 @@ section_selection_changed (GtkTreeSelection *selection, gpointer data)
GtkTreeIter new_row;
CcKeyboardItem *item = g_ptr_array_index (keys, i);
- gtk_list_store_append (GTK_LIST_STORE (shortcut_model), &new_row);
- gtk_list_store_set (GTK_LIST_STORE (shortcut_model), &new_row,
- DETAIL_DESCRIPTION_COLUMN, item->description,
- DETAIL_KEYENTRY_COLUMN, item,
- DETAIL_TYPE_COLUMN, SHORTCUT_TYPE_KEY_ENTRY,
- -1);
+ if (!cc_keyboard_item_is_hidden (item))
+ {
+ gtk_list_store_append (GTK_LIST_STORE (shortcut_model), &new_row);
+ gtk_list_store_set (GTK_LIST_STORE (shortcut_model), &new_row,
+ DETAIL_DESCRIPTION_COLUMN, item->description,
+ DETAIL_KEYENTRY_COLUMN, item,
+ DETAIL_TYPE_COLUMN, SHORTCUT_TYPE_KEY_ENTRY,
+ -1);
+ }
}
if (g_str_equal (id, "Typing"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]