Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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.

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}
SkBitmap source
Definition examples.cpp:28

◆ 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(
136 g_settings_get_type(),
137 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
138 G_PARAM_STATIC_STRINGS)));
139}
static constexpr char kDesktopInterfaceSchema[]
static void fl_gnome_settings_dispose(GObject *object)
static void fl_gnome_settings_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static constexpr char kInterfaceSettings[]

◆ 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}

◆ 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
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}
static constexpr char kDesktopGtkThemeKey[]
static constexpr char kGtkThemeDarkSuffix[]
FlColorScheme
Definition fl_settings.h:35
@ FL_COLOR_SCHEME_DARK
Definition fl_settings.h:38
@ FL_COLOR_SCHEME_LIGHT
Definition fl_settings.h:37
uint8_t value

◆ 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}

◆ 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}

◆ 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,
82 }
83 return scaling_factor;
84}
static constexpr char kDesktopTextScalingFactorKey[]

◆ 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}
static gboolean fl_gnome_settings_get_high_contrast(FlSettings *settings)
static FlColorScheme fl_gnome_settings_get_color_scheme(FlSettings *settings)
static gboolean fl_gnome_settings_get_enable_animations(FlSettings *settings)
static gdouble fl_gnome_settings_get_text_scaling_factor(FlSettings *settings)

◆ 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 =
167 return FL_SETTINGS(g_object_new(fl_gnome_settings_get_type(),
168 kInterfaceSettings, interface_settings,
169 nullptr));
170}
static GSettings * create_settings(const gchar *schema_id)

◆ 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}
void fl_settings_emit_changed(FlSettings *self)

◆ 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) {
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}
static void fl_gnome_settings_set_interface_settings(FlGnomeSettings *self, GSettings *settings)
guint const GValue GParamSpec * pspec

◆ 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
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}
static constexpr char kClockFormat12Hour[]
static constexpr char kDesktopClockFormatKey[]
FlClockFormat
Definition fl_settings.h:21
@ FL_CLOCK_FORMAT_12H
Definition fl_settings.h:23
@ FL_CLOCK_FORMAT_24H
Definition fl_settings.h:24

Variable Documentation

◆ kClockFormat12Hour

constexpr char kClockFormat12Hour[] = "12h"
staticconstexpr

Definition at line 15 of file fl_gnome_settings.cc.

◆ kDesktopClockFormatKey

constexpr char kDesktopClockFormatKey[] = "clock-format"
staticconstexpr

Definition at line 12 of file fl_gnome_settings.cc.

◆ kDesktopGtkThemeKey

constexpr char kDesktopGtkThemeKey[] = "gtk-theme"
staticconstexpr

Definition at line 13 of file fl_gnome_settings.cc.

◆ kDesktopInterfaceSchema

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

Definition at line 10 of file fl_gnome_settings.cc.

◆ kDesktopTextScalingFactorKey

constexpr char kDesktopTextScalingFactorKey[] = "text-scaling-factor"
staticconstexpr

Definition at line 11 of file fl_gnome_settings.cc.

◆ kGtkThemeDarkSuffix

constexpr char kGtkThemeDarkSuffix[] = "-dark"
staticconstexpr

Definition at line 16 of file fl_gnome_settings.cc.

◆ kInterfaceSettings

constexpr char kInterfaceSettings[] = "interface-settings"
staticconstexpr

Definition at line 17 of file fl_gnome_settings.cc.