[gnome-builder/wip/chergert/perspective] prefs: handle various settings target values
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/perspective] prefs: handle various settings target values
- Date: Sat, 7 Nov 2015 07:45:52 +0000 (UTC)
commit fcacf97bc8f023aa1b87e45693f20e98b9f8cc83
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 6 23:45:43 2015 -0800
prefs: handle various settings target values
* booleans
* any type that matches the gsetting
* string <=> strv (for flags)
libide/preferences/ide-preferences-switch.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-switch.c b/libide/preferences/ide-preferences-switch.c
index ca68192..5c4220a 100644
--- a/libide/preferences/ide-preferences-switch.c
+++ b/libide/preferences/ide-preferences-switch.c
@@ -56,17 +56,32 @@ ide_preferences_switch_changed (IdePreferencesSwitch *self,
GSettings *settings)
{
GVariant *value;
- gboolean active;
+ gboolean active = FALSE;
g_assert (IDE_IS_PREFERENCES_SWITCH (self));
g_assert (key != NULL);
g_assert (G_IS_SETTINGS (settings));
value = g_settings_get_value (settings, key);
- active = g_variant_equal (value, self->target);
- gtk_switch_set_active (self->widget, active);
- gtk_widget_set_visible (GTK_WIDGET (self->image), active);
+ if (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
+ active = g_variant_get_boolean (value);
+ else if ((self->target != NULL) &&
+ g_variant_is_of_type (value, g_variant_get_type (self->target)))
+ active = g_variant_equal (value, self->target);
+ else if ((self->target != NULL) &&
+ g_variant_is_of_type (self->target, G_VARIANT_TYPE_STRING) &&
+ g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY))
+ {
+ g_autofree const gchar **strv = g_variant_get_strv (value, NULL);
+ const gchar *flag = g_variant_get_string (self->target, NULL);
+ active = g_strv_contains (strv, flag);
+ }
+
+ if (self->is_radio)
+ gtk_widget_set_visible (GTK_WIDGET (self->image), active);
+ else
+ gtk_switch_set_active (self->widget, active);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]