| 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 | { PROP_0 , PROP_INTERFACE_SETTINGS , PROP_LAST }

## 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
PROP_0 |
PROP_INTERFACE_SETTINGS |
PROP_LAST |

Definition at line 25 of file fl_gnome_settings.cc.

25 { PROP_0, PROP_INTERFACE_SETTINGS, PROP_LAST };
PROP_INTERFACE_SETTINGS
@ PROP_INTERFACE_SETTINGS
Definition: fl_gnome_settings.cc:25
PROP_LAST
@ PROP_LAST
Definition: fl_gnome_settings.cc:25
PROP_0
@ PROP_0
Definition: fl_gnome_settings.cc:25

## 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 }
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53

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, PROP_INTERFACE_SETTINGS,
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 }
kDesktopInterfaceSchema
static constexpr char kDesktopInterfaceSchema[]
Definition: fl_gnome_settings.cc:10
fl_gnome_settings_dispose
static void fl_gnome_settings_dispose(GObject *object)
Definition: fl_gnome_settings.cc:119
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
kInterfaceSettings
static constexpr char kInterfaceSettings[]
Definition: fl_gnome_settings.cc:17

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

## ◆ 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 }
kDesktopGtkThemeKey
static constexpr char kDesktopGtkThemeKey[]
Definition: fl_gnome_settings.cc:13
kGtkThemeDarkSuffix
static constexpr char kGtkThemeDarkSuffix[]
Definition: fl_gnome_settings.cc:16
FlColorScheme
FlColorScheme
Definition: fl_settings.h:33
FL_COLOR_SCHEME_DARK
@ FL_COLOR_SCHEME_DARK
Definition: fl_settings.h:35
FL_COLOR_SCHEME_LIGHT
@ FL_COLOR_SCHEME_LIGHT
Definition: fl_settings.h:34
value
uint8_t value
Definition: fl_standard_message_codec.cc:36

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 }

References TRUE.

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 }
kDesktopTextScalingFactorKey
static constexpr char kDesktopTextScalingFactorKey[]
Definition: fl_gnome_settings.cc:11

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 }
fl_gnome_settings_get_high_contrast
static gboolean fl_gnome_settings_get_high_contrast(FlSettings *settings)
Definition: fl_gnome_settings.cc:70
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_enable_animations
static gboolean fl_gnome_settings_get_enable_animations(FlSettings *settings)
Definition: fl_gnome_settings.cc:66
fl_gnome_settings_get_text_scaling_factor
static gdouble fl_gnome_settings_get_text_scaling_factor(FlSettings *settings)
Definition: fl_gnome_settings.cc:74

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 }
create_settings
static GSettings * create_settings(const gchar *schema_id)
Definition: fl_gnome_settings.cc:151

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 }
fl_settings_emit_changed
void fl_settings_emit_changed(FlSettings *self)
Definition: fl_settings.cc:50

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 PROP_INTERFACE_SETTINGS:
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 }
fl_gnome_settings_set_interface_settings
static void fl_gnome_settings_set_interface_settings(FlGnomeSettings *self, GSettings *settings)
Definition: fl_gnome_settings.cc:86
prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33

References fl_gnome_settings_set_interface_settings(), prop_id, PROP_INTERFACE_SETTINGS, 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 }
kClockFormat12Hour
static constexpr char kClockFormat12Hour[]
Definition: fl_gnome_settings.cc:15
kDesktopClockFormatKey
static constexpr char kDesktopClockFormatKey[]
Definition: fl_gnome_settings.cc:12
FlClockFormat
FlClockFormat
Definition: fl_settings.h:21
FL_CLOCK_FORMAT_12H
@ FL_CLOCK_FORMAT_12H
Definition: fl_settings.h:22
FL_CLOCK_FORMAT_24H
@ FL_CLOCK_FORMAT_24H
Definition: fl_settings.h:23

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().