[mutter] In case of GConf failure, fall back to local keybinding values
- From: Owen Taylor <otaylor src gnome org>
- To: svn-commits-list gnome org
- Subject: [mutter] In case of GConf failure, fall back to local keybinding values
- Date: Fri, 24 Apr 2009 09:57:09 -0400 (EDT)
commit 52638b9d8e44919de90d9dfa92caaca8d052946a
Author: Owen W. Taylor <otaylor redhat com>
Date: Fri Mar 20 16:28:13 2009 -0400
In case of GConf failure, fall back to local keybinding values
Always compile the default keybindings into Metacity, and if we
fail to retrieve the values from GConf, use the compiled-in
value. This makes things more robust especially in an environment
like JHBuild where GConf-schema-installation may not work
correctly.
Also use these values for the no-GConf case, rather than
having a separate arrray and code path.
http://bugzilla.gnome.org/show_bug.cgi?id=576127
---
src/core/prefs.c | 61 +++++++++-----------------------------------------
src/include/prefs.h | 1 +
2 files changed, 12 insertions(+), 50 deletions(-)
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 6968ab5..bd8a25d 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -1871,48 +1871,15 @@ meta_prefs_set_num_workspaces (int n_workspaces)
}
#define keybind(name, handler, param, flags, stroke, description) \
- { #name, NULL, !!(flags & BINDING_REVERSES), !!(flags & BINDING_PER_WINDOW) },
+ { #name, stroke, NULL, !!(flags & BINDING_REVERSES), !!(flags & BINDING_PER_WINDOW) },
static MetaKeyPref key_bindings[] = {
#include "all-keybindings.h"
- { NULL, NULL, FALSE }
+ { NULL, NULL, NULL, FALSE }
};
#undef keybind
static MetaKeyCombo overlay_key_combo = { 0, 0, 0 };
-#ifndef HAVE_GCONF
-
-/**
- * A type to map names of keybindings (such as "switch_windows")
- * to the binding strings themselves (such as "<Alt>Tab").
- * It exists only when GConf is turned off in ./configure and
- * functions as a sort of ersatz GConf.
- */
-typedef struct
-{
- const char *name;
- const char *keybinding;
-} MetaSimpleKeyMapping;
-
-/* FIXME: This would be neater if the array only contained entries whose
- * default keystroke was non-null. You COULD do this by defining
- * ONLY_BOUND_BY_DEFAULT around various blocks at the cost of making
- * the bindings file way more complicated. However, we could stop this being
- * data and move it into code. Then the compiler would optimise away
- * the problem lines.
- */
-
-#define keybind(name, handler, param, flags, stroke, description) \
- { #name, stroke },
-
-static MetaSimpleKeyMapping key_string_bindings[] = {
-#include "all-keybindings.h"
- { NULL, NULL }
-};
-#undef keybind
-
-#endif /* NOT HAVE_GCONF */
-
/* These bindings are for modifiers alone, so they need special handling */
static void
init_special_bindings (void)
@@ -2000,22 +1967,13 @@ init_bindings (void)
#else /* HAVE_GCONF */
int i = 0;
- int which = 0;
-
- while (key_string_bindings[i].name)
+ while (key_bindings[i].name)
{
- if (key_string_bindings[i].keybinding == NULL) {
- ++i;
- continue;
- }
-
- while (strcmp(key_bindings[which].name,
- key_string_bindings[i].name) != 0)
- which++;
-
- /* Set the binding */
- update_binding (&key_bindings[which],
- key_string_bindings[i].keybinding);
+ if (key_bindings[i].default_keybinding)
+ {
+ /* Set the binding */
+ update_binding (&key_bindings[i], NULL);
+ }
++i;
}
@@ -2105,6 +2063,9 @@ update_binding (MetaKeyPref *binding,
MetaKeyCombo *combo;
gboolean changed;
+ if (value == NULL)
+ value = binding->default_keybinding;
+
meta_topic (META_DEBUG_KEYBINDINGS,
"Binding \"%s\" has new gconf value \"%s\"\n",
binding->name, value ? value : "none");
diff --git a/src/include/prefs.h b/src/include/prefs.h
index ed419db..2731700 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -222,6 +222,7 @@ typedef struct
typedef struct
{
const char *name;
+ const char *default_keybinding;
/**
* A list of MetaKeyCombos. Each of them is bound to
* this keypref. If one has keysym==modifiers==0, it is
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]