[libdazzle] shortcuts: cleanup context implementation
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] shortcuts: cleanup context implementation
- Date: Tue, 13 Jun 2017 06:48:00 +0000 (UTC)
commit 49f70136f8e48695125ead632dc015d6f650204d
Author: Christian Hergert <chergert redhat com>
Date: Mon Jun 12 18:50:14 2017 -0700
shortcuts: cleanup context implementation
We need a default -1 value for use-binding-sets so that we can determine
when to merge a new value in upcoming theme merging.
Also, just intern the context name. They aren't meant to be terribly
dynamic or anything.
src/shortcuts/dzl-shortcut-context.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-context.c b/src/shortcuts/dzl-shortcut-context.c
index 7ca7c16..c030dbd 100644
--- a/src/shortcuts/dzl-shortcut-context.c
+++ b/src/shortcuts/dzl-shortcut-context.c
@@ -28,9 +28,21 @@
typedef struct
{
- gchar *name;
+ /* The name of the context, interned */
+ const gchar *name;
+
+ /* The table of entries in this context which maps to a shortcut.
+ * These need to be copied across when merging down to another
+ * context layer.
+ */
DzlShortcutChordTable *table;
- guint use_binding_sets : 1;
+
+ /* If we should use binding sets. By default this is true, but
+ * we use a signed 2-bit int for -1 being "unset". That allows
+ * us to know when the value was set on a layer and merge that
+ * value upwards.
+ */
+ gint use_binding_sets : 2;
} DzlShortcutContextPrivate;
enum {
@@ -338,7 +350,6 @@ dzl_shortcut_context_finalize (GObject *object)
DzlShortcutContext *self = (DzlShortcutContext *)object;
DzlShortcutContextPrivate *priv = dzl_shortcut_context_get_instance_private (self);
- g_clear_pointer (&priv->name, g_free);
g_clear_pointer (&priv->table, dzl_shortcut_chord_table_free);
G_OBJECT_CLASS (dzl_shortcut_context_parent_class)->finalize (object);
@@ -360,7 +371,7 @@ dzl_shortcut_context_get_property (GObject *object,
break;
case PROP_USE_BINDING_SETS:
- g_value_set_boolean (value, priv->use_binding_sets);
+ g_value_set_boolean (value, !!priv->use_binding_sets);
break;
default:
@@ -380,7 +391,7 @@ dzl_shortcut_context_set_property (GObject *object,
switch (prop_id)
{
case PROP_NAME:
- priv->name = g_value_dup_string (value);
+ priv->name = g_intern_string (g_value_get_string (value));
break;
case PROP_USE_BINDING_SETS:
@@ -423,7 +434,7 @@ dzl_shortcut_context_init (DzlShortcutContext *self)
{
DzlShortcutContextPrivate *priv = dzl_shortcut_context_get_instance_private (self);
- priv->use_binding_sets = TRUE;
+ priv->use_binding_sets = -1;
}
DzlShortcutContext *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]