[gnome-builder] libide/tweaks: add set_variant helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: add set_variant helper
- Date: Fri, 26 Aug 2022 04:21:01 +0000 (UTC)
commit f3b4cc18fd2535d03ac967b912f7cf227e9c0378
Author: Christian Hergert <chergert redhat com>
Date: Thu Aug 25 21:13:11 2022 -0700
libide/tweaks: add set_variant helper
Converts to a GValue and then sets that.
src/libide/tweaks/ide-tweaks-binding.c | 25 +++++++++++++++++++++++++
src/libide/tweaks/ide-tweaks-binding.h | 3 +++
2 files changed, 28 insertions(+)
---
diff --git a/src/libide/tweaks/ide-tweaks-binding.c b/src/libide/tweaks/ide-tweaks-binding.c
index dd09fee2a..7faa912ba 100644
--- a/src/libide/tweaks/ide-tweaks-binding.c
+++ b/src/libide/tweaks/ide-tweaks-binding.c
@@ -24,6 +24,8 @@
#include "ide-tweaks-binding.h"
+#include "gsettings-mapping.h"
+
typedef struct
{
IdeTweaksBindingTransform get_transform;
@@ -413,3 +415,26 @@ ide_tweaks_binding_dup_string (IdeTweaksBinding *self)
return NULL;
}
+
+void
+ide_tweaks_binding_set_variant (IdeTweaksBinding *self,
+ GVariant *variant)
+{
+ g_auto(GValue) value = G_VALUE_INIT;
+ g_autoptr(GVariant) hold = NULL;
+ GType type;
+
+ g_return_if_fail (IDE_IS_TWEAKS_BINDING (self));
+ g_return_if_fail (variant != NULL);
+
+ hold = g_variant_ref_sink (variant);
+
+ if (!ide_tweaks_binding_get_expected_type (self, &type))
+ return;
+
+ g_value_init (&value, type);
+ if (!g_settings_get_mapping (&value, variant, NULL))
+ return;
+
+ ide_tweaks_binding_set_value (self, &value);
+}
diff --git a/src/libide/tweaks/ide-tweaks-binding.h b/src/libide/tweaks/ide-tweaks-binding.h
index 5c5b399ae..b24d79846 100644
--- a/src/libide/tweaks/ide-tweaks-binding.h
+++ b/src/libide/tweaks/ide-tweaks-binding.h
@@ -58,6 +58,9 @@ IDE_AVAILABLE_IN_ALL
void ide_tweaks_binding_set_value (IdeTweaksBinding *self,
const GValue *value);
IDE_AVAILABLE_IN_ALL
+void ide_tweaks_binding_set_variant (IdeTweaksBinding *self,
+ GVariant *variant);
+IDE_AVAILABLE_IN_ALL
char *ide_tweaks_binding_dup_string (IdeTweaksBinding *self);
IDE_AVAILABLE_IN_ALL
void ide_tweaks_binding_bind (IdeTweaksBinding *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]