| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
fl_gnome_settings.cc File Reference
`#include "flutter/shell/platform/linux/fl_gnome_settings.h"`
`#include <gio/gio.h>`
`#include <glib.h>`

Go to the source code of this file.

## Classes
struct | _FlGnomeSettings

## Enumerations
enum | { kProp0, kPropInterfaceSettings, kPropLast }

## Functions
static void | fl_gnome_settings_iface_init (FlSettingsInterface *iface)
| G_DEFINE_TYPE_WITH_CODE (FlGnomeSettings, fl_gnome_settings, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_settings_get_type(), fl_gnome_settings_iface_init)) static FlClockFormat fl_gnome_settings_get_clock_format(FlSettings *settings)
static FlColorScheme | fl_gnome_settings_get_color_scheme (FlSettings *settings)
static gboolean | fl_gnome_settings_get_enable_animations (FlSettings *settings)
static gboolean | fl_gnome_settings_get_high_contrast (FlSettings *settings)
static gdouble | fl_gnome_settings_get_text_scaling_factor (FlSettings *settings)
static void | fl_gnome_settings_set_interface_settings (FlGnomeSettings *self, GSettings *settings)
static void | fl_gnome_settings_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static void | fl_gnome_settings_dispose (GObject *object)
static void | fl_gnome_settings_class_init (FlGnomeSettingsClass *klass)
static void | fl_gnome_settings_init (FlGnomeSettings *self)
static GSettings * | create_settings (const gchar *schema_id)
FlSettings * | fl_gnome_settings_new ()

## Variables
static constexpr char | kDesktopInterfaceSchema [] = "org.gnome.desktop.interface"
static constexpr char | kDesktopTextScalingFactorKey [] = "text-scaling-factor"
static constexpr char | kDesktopClockFormatKey [] = "clock-format"
static constexpr char | kDesktopGtkThemeKey [] = "gtk-theme"
static constexpr char | kClockFormat12Hour [] = "12h"
static constexpr char | kGtkThemeDarkSuffix [] = "-dark"
static constexpr char | kInterfaceSettings [] = "interface-settings"

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kProp0 |
kPropInterfaceSettings |
kPropLast |

Definition at line 25 of file fl_gnome_settings.cc.

25 { kProp0, kPropInterfaceSettings, kPropLast };

## Function Documentation

## ◆ create_settings()

static GSettings* create_settings | ( | const gchar * | schema_id | ) |
| static

Definition at line 151 of file fl_gnome_settings.cc.

151 {
152 GSettings* settings = nullptr;
153 GSettingsSchemaSource* source = g_settings_schema_source_get_default();
154 if (source != nullptr) {
155 g_autoptr(GSettingsSchema) schema =
156 g_settings_schema_source_lookup(source, schema_id, TRUE);
157 if (schema != nullptr) {
158 settings = g_settings_new_full(schema, nullptr, nullptr);
159 }
160 }
161 return settings;
162 }

References TRUE.

Referenced by fl_gnome_settings_new().

## ◆ fl_gnome_settings_class_init()

static void fl_gnome_settings_class_init | ( | FlGnomeSettingsClass * | klass | ) |
| static

Definition at line 127 of file fl_gnome_settings.cc.

127 {
128 GObjectClass* object_class = G_OBJECT_CLASS(klass);
129 object_class->dispose = fl_gnome_settings_dispose;
130 object_class->set_property = fl_gnome_settings_set_property;
131
132 g_object_class_install_property(
133 object_class, kPropInterfaceSettings,
134 g_param_spec_object(
135 kInterfaceSettings, kInterfaceSettings, kDesktopInterfaceSchema,
136 g_settings_get_type(),
137 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
138 G_PARAM_STATIC_STRINGS)));
139 }

References fl_gnome_settings_dispose(), fl_gnome_settings_set_property(), kDesktopInterfaceSchema, kInterfaceSettings, and kPropInterfaceSettings.

## ◆ fl_gnome_settings_dispose()

static void fl_gnome_settings_dispose | ( | GObject * | object | ) |
| static

Definition at line 119 of file fl_gnome_settings.cc.

119 {
120 FlGnomeSettings* self = FL_GNOME_SETTINGS(object);
121
122 g_clear_object(&self->interface_settings);
123
124 G_OBJECT_CLASS(fl_gnome_settings_parent_class)->dispose(object);
125 }

Referenced by fl_gnome_settings_class_init().

## ◆ fl_gnome_settings_get_color_scheme()

static FlColorScheme fl_gnome_settings_get_color_scheme | ( | FlSettings * | settings | ) |
| static

Definition at line 50 of file fl_gnome_settings.cc.

50 {
51 FlGnomeSettings* self = FL_GNOME_SETTINGS(settings);
52
53 FlColorScheme color_scheme = FL_COLOR_SCHEME_LIGHT;
54
55 if (self->interface_settings != nullptr) {
56 // check whether org.gnome.desktop.interface.gtk-theme ends with "-dark"
57 g_autofree gchar* value =
58 g_settings_get_string(self->interface_settings, kDesktopGtkThemeKey);
59 if (g_str_has_suffix(value, kGtkThemeDarkSuffix)) {
60 color_scheme = FL_COLOR_SCHEME_DARK;
61 }
62 }
63 return color_scheme;
64 }

References FL_COLOR_SCHEME_DARK, FL_COLOR_SCHEME_LIGHT, kDesktopGtkThemeKey, kGtkThemeDarkSuffix, and value.

Referenced by fl_gnome_settings_iface_init().

## ◆ fl_gnome_settings_get_enable_animations()

static gboolean fl_gnome_settings_get_enable_animations | ( | FlSettings * | settings | ) |
| static

Definition at line 66 of file fl_gnome_settings.cc.

66 {
67 return true;
68 }

Referenced by fl_gnome_settings_iface_init().

## ◆ fl_gnome_settings_get_high_contrast()

static gboolean fl_gnome_settings_get_high_contrast | ( | FlSettings * | settings | ) |
| static

Definition at line 70 of file fl_gnome_settings.cc.

70 {
71 return false;
72 }

Referenced by fl_gnome_settings_iface_init().

## ◆ fl_gnome_settings_get_text_scaling_factor()

static gdouble fl_gnome_settings_get_text_scaling_factor | ( | FlSettings * | settings | ) |
| static

Definition at line 74 of file fl_gnome_settings.cc.

74 {
75 FlGnomeSettings* self = FL_GNOME_SETTINGS(settings);
76
77 gdouble scaling_factor = 1.0;
78
79 if (self->interface_settings != nullptr) {
80 scaling_factor = g_settings_get_double(self->interface_settings,
81 kDesktopTextScalingFactorKey);
82 }
83 return scaling_factor;
84 }

References kDesktopTextScalingFactorKey.

Referenced by fl_gnome_settings_iface_init().

## ◆ fl_gnome_settings_iface_init()

static void fl_gnome_settings_iface_init | ( | FlSettingsInterface * | iface | ) |
| static

Definition at line 141 of file fl_gnome_settings.cc.

141 {
142 iface->get_clock_format = fl_gnome_settings_get_clock_format;
143 iface->get_color_scheme = fl_gnome_settings_get_color_scheme;
144 iface->get_enable_animations = fl_gnome_settings_get_enable_animations;
145 iface->get_high_contrast = fl_gnome_settings_get_high_contrast;
146 iface->get_text_scaling_factor = fl_gnome_settings_get_text_scaling_factor;
147 }

References fl_gnome_settings_get_color_scheme(), fl_gnome_settings_get_enable_animations(), fl_gnome_settings_get_high_contrast(), and fl_gnome_settings_get_text_scaling_factor().

## ◆ fl_gnome_settings_init()

static void fl_gnome_settings_init | ( | FlGnomeSettings * | self | ) |
| static

Definition at line 149 of file fl_gnome_settings.cc.

149 {}

## ◆ fl_gnome_settings_new()

FlSettings* fl_gnome_settings_new | ( |  | ) |

fl_gnome_settings_new:

Creates a new settings instance for GNOME.

Returns: a new #FlSettings.

Definition at line 164 of file fl_gnome_settings.cc.

164 {
165 g_autoptr(GSettings) interface_settings =
166 create_settings(kDesktopInterfaceSchema);
167 return FL_SETTINGS(g_object_new(fl_gnome_settings_get_type(),
168 kInterfaceSettings, interface_settings,
169 nullptr));
170 }

References create_settings(), kDesktopInterfaceSchema, and kInterfaceSettings.

Referenced by fl_settings_new(), and TEST_F().

## ◆ fl_gnome_settings_set_interface_settings()

static void fl_gnome_settings_set_interface_settings | ( | FlGnomeSettings * | self,
|  | GSettings * | settings
| ) |  |
| static

Definition at line 86 of file fl_gnome_settings.cc.

87 {
88 g_return_if_fail(G_IS_SETTINGS(settings));
89
90 g_signal_connect_object(settings, "changed::clock-format",
91 G_CALLBACK(fl_settings_emit_changed), self,
92 G_CONNECT_SWAPPED);
93 g_signal_connect_object(settings, "changed::gtk-theme",
94 G_CALLBACK(fl_settings_emit_changed), self,
95 G_CONNECT_SWAPPED);
96 g_signal_connect_object(settings, "changed::text-scaling-factor",
97 G_CALLBACK(fl_settings_emit_changed), self,
98 G_CONNECT_SWAPPED);
99
100 self->interface_settings = G_SETTINGS(g_object_ref(settings));
101 }

References fl_settings_emit_changed().

Referenced by fl_gnome_settings_set_property().

## ◆ fl_gnome_settings_set_property()

static void fl_gnome_settings_set_property | ( | GObject * | object,
|  | guint | prop_id,
|  | const GValue * | value,
|  | GParamSpec * | pspec
| ) |  |
| static

Definition at line 103 of file fl_gnome_settings.cc.

106 {
107 FlGnomeSettings* self = FL_GNOME_SETTINGS(object);
108 switch (prop_id) {
109 case kPropInterfaceSettings:
110 fl_gnome_settings_set_interface_settings(
111 self, G_SETTINGS(g_value_get_object(value)));
112 break;
113 default:
114 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
115 break;
116 }
117 }

References fl_gnome_settings_set_interface_settings(), kPropInterfaceSettings, prop_id, pspec, and value.

Referenced by fl_gnome_settings_class_init().

## ◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE | ( | FlGnomeSettings | ,
|  | fl_gnome_settings | ,
|  | G_TYPE_OBJECT | ,
|  | G_IMPLEMENT_INTERFACE(fl_settings_get_type(), fl_gnome_settings_iface_init) |
| ) |  |

Definition at line 29 of file fl_gnome_settings.cc.

35 {
36 FlGnomeSettings* self = FL_GNOME_SETTINGS(settings);
37
38 FlClockFormat clock_format = FL_CLOCK_FORMAT_24H;
39
40 if (self->interface_settings != nullptr) {
41 g_autofree gchar* value =
42 g_settings_get_string(self->interface_settings, kDesktopClockFormatKey);
43 if (g_strcmp0(value, kClockFormat12Hour) == 0) {
44 clock_format = FL_CLOCK_FORMAT_12H;
45 }
46 }
47 return clock_format;
48 }

References FL_CLOCK_FORMAT_12H, FL_CLOCK_FORMAT_24H, kClockFormat12Hour, kDesktopClockFormatKey, and value.

## Variable Documentation

## ◆ kClockFormat12Hour

constexpr char kClockFormat12Hour[] = "12h"
| static constexpr

Definition at line 15 of file fl_gnome_settings.cc.

Referenced by G_DEFINE_TYPE_WITH_CODE().

## ◆ kDesktopClockFormatKey

constexpr char kDesktopClockFormatKey[] = "clock-format"
| static constexpr

Definition at line 12 of file fl_gnome_settings.cc.

Referenced by G_DEFINE_TYPE_WITH_CODE().

## ◆ kDesktopGtkThemeKey

constexpr char kDesktopGtkThemeKey[] = "gtk-theme"
| static constexpr

Definition at line 13 of file fl_gnome_settings.cc.

Referenced by fl_gnome_settings_get_color_scheme().

## ◆ kDesktopInterfaceSchema

constexpr char kDesktopInterfaceSchema[] = "org.gnome.desktop.interface"
| static constexpr

Definition at line 10 of file fl_gnome_settings.cc.

Referenced by fl_gnome_settings_class_init(), and fl_gnome_settings_new().

## ◆ kDesktopTextScalingFactorKey

constexpr char kDesktopTextScalingFactorKey[] = "text-scaling-factor"
| static constexpr

Definition at line 11 of file fl_gnome_settings.cc.

Referenced by fl_gnome_settings_get_text_scaling_factor().

## ◆ kGtkThemeDarkSuffix

constexpr char kGtkThemeDarkSuffix[] = "-dark"
| static constexpr

Definition at line 16 of file fl_gnome_settings.cc.

Referenced by fl_gnome_settings_get_color_scheme().

## ◆ kInterfaceSettings

constexpr char kInterfaceSettings[] = "interface-settings"
| static constexpr

Definition at line 17 of file fl_gnome_settings.cc.

Referenced by fl_gnome_settings_class_init(), and fl_gnome_settings_new().

prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
fl_gnome_settings_get_color_scheme
static FlColorScheme fl_gnome_settings_get_color_scheme(FlSettings *settings)
Definition: fl_gnome_settings.cc:50
fl_gnome_settings_get_text_scaling_factor
static gdouble fl_gnome_settings_get_text_scaling_factor(FlSettings *settings)
Definition: fl_gnome_settings.cc:74
kDesktopClockFormatKey
static constexpr char kDesktopClockFormatKey[]
Definition: fl_gnome_settings.cc:12
kDesktopInterfaceSchema
static constexpr char kDesktopInterfaceSchema[]
Definition: fl_gnome_settings.cc:10
fl_gnome_settings_set_interface_settings
static void fl_gnome_settings_set_interface_settings(FlGnomeSettings *self, GSettings *settings)
Definition: fl_gnome_settings.cc:86
FL_CLOCK_FORMAT_12H
@ FL_CLOCK_FORMAT_12H
Definition: fl_settings.h:23
FL_CLOCK_FORMAT_24H
@ FL_CLOCK_FORMAT_24H
Definition: fl_settings.h:24
kPropLast
@ kPropLast
Definition: fl_gnome_settings.cc:25
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
fl_gnome_settings_get_high_contrast
static gboolean fl_gnome_settings_get_high_contrast(FlSettings *settings)
Definition: fl_gnome_settings.cc:70
FlColorScheme
FlColorScheme
Definition: fl_settings.h:35
kGtkThemeDarkSuffix
static constexpr char kGtkThemeDarkSuffix[]
Definition: fl_gnome_settings.cc:16
fl_settings_emit_changed
void fl_settings_emit_changed(FlSettings *self)
Definition: fl_settings.cc:50
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
kPropInterfaceSettings
@ kPropInterfaceSettings
Definition: fl_gnome_settings.cc:25
kInterfaceSettings
static constexpr char kInterfaceSettings[]
Definition: fl_gnome_settings.cc:17
create_settings
static GSettings * create_settings(const gchar *schema_id)
Definition: fl_gnome_settings.cc:151
FL_COLOR_SCHEME_LIGHT
@ FL_COLOR_SCHEME_LIGHT
Definition: fl_settings.h:37
kDesktopGtkThemeKey
static constexpr char kDesktopGtkThemeKey[]
Definition: fl_gnome_settings.cc:13
kDesktopTextScalingFactorKey
static constexpr char kDesktopTextScalingFactorKey[]
Definition: fl_gnome_settings.cc:11
FL_COLOR_SCHEME_DARK
@ FL_COLOR_SCHEME_DARK
Definition: fl_settings.h:38
fl_gnome_settings_dispose
static void fl_gnome_settings_dispose(GObject *object)
Definition: fl_gnome_settings.cc:119
kProp0
@ kProp0
Definition: fl_gnome_settings.cc:25
fl_gnome_settings_set_property
static void fl_gnome_settings_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_gnome_settings.cc:103
FlClockFormat
FlClockFormat
Definition: fl_settings.h:21
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
kClockFormat12Hour
static constexpr char kClockFormat12Hour[]
Definition: fl_gnome_settings.cc:15
fl_gnome_settings_get_enable_animations
static gboolean fl_gnome_settings_get_enable_animations(FlSettings *settings)
Definition: fl_gnome_settings.cc:66