| Flutter Linux Embedder |

fl_settings.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/linux/fl_settings.h"
6 #include "flutter/shell/platform/linux/fl_gnome_settings.h"
7 #include "flutter/shell/platform/linux/fl_settings_portal.h"
8
9 G_DEFINE_INTERFACE(FlSettings, fl_settings, G_TYPE_OBJECT)
10
11 enum {
12 SIGNAL_CHANGED,
13 LAST_SIGNAL,
14 };
15
16 static guint signals[LAST_SIGNAL];
17
18 static void fl_settings_default_init(FlSettingsInterface* iface) {
19 /**
20 * FlSettings::changed:
21 * @settings: an #FlSettings
22 *
23 * This signal is emitted after the settings have been changed.
24 */
25 signals[SIGNAL_CHANGED] =
26 g_signal_new("changed", G_TYPE_FROM_INTERFACE(iface), G_SIGNAL_RUN_LAST,
27 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
28 }
29
30 FlClockFormat fl_settings_get_clock_format(FlSettings* self) {
31 return FL_SETTINGS_GET_IFACE(self)->get_clock_format(self);
32 }
33
34 FlColorScheme fl_settings_get_color_scheme(FlSettings* self) {
35 return FL_SETTINGS_GET_IFACE(self)->get_color_scheme(self);
36 }
37
38 gboolean fl_settings_get_enable_animations(FlSettings* self) {
39 return FL_SETTINGS_GET_IFACE(self)->get_enable_animations(self);
40 }
41
42 gboolean fl_settings_get_high_contrast(FlSettings* self) {
43 return FL_SETTINGS_GET_IFACE(self)->get_high_contrast(self);
44 }
45
46 gdouble fl_settings_get_text_scaling_factor(FlSettings* self) {
47 return FL_SETTINGS_GET_IFACE(self)->get_text_scaling_factor(self);
48 }
49
50 void fl_settings_emit_changed(FlSettings* self) {
51 g_return_if_fail(FL_IS_SETTINGS(self));
52 g_signal_emit(self, signals[SIGNAL_CHANGED], 0);
53 }
54
55 FlSettings* fl_settings_new() {
56 g_autoptr(FlSettingsPortal) portal = fl_settings_portal_new();
57
58 g_autoptr(GError) error = nullptr;
59 if (!fl_settings_portal_start(portal, &error)) {
60 g_debug("XDG desktop portal settings unavailable: %s", error->message);
61 return fl_gnome_settings_new();
62 }
63
64 return FL_SETTINGS(g_object_ref(portal));
65 }
g_signal_emit
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
fl_gnome_settings_new
FlSettings * fl_gnome_settings_new()
Definition: fl_gnome_settings.cc:164
fl_gnome_settings.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_settings_get_high_contrast
gboolean fl_settings_get_high_contrast(FlSettings *self)
Definition: fl_settings.cc:42
fl_settings_default_init
static void fl_settings_default_init(FlSettingsInterface *iface)
Definition: fl_settings.cc:18
signals
static guint signals[LAST_SIGNAL]
Definition: fl_settings.cc:16
fl_settings_get_text_scaling_factor
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
Definition: fl_settings.cc:46
LAST_SIGNAL
@ LAST_SIGNAL
Definition: fl_settings.cc:13
SIGNAL_CHANGED
@ SIGNAL_CHANGED
Definition: fl_settings.cc:12
fl_settings_emit_changed
void fl_settings_emit_changed(FlSettings *self)
Definition: fl_settings.cc:50
fl_settings_get_enable_animations
gboolean fl_settings_get_enable_animations(FlSettings *self)
Definition: fl_settings.cc:38
fl_settings_get_color_scheme
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
Definition: fl_settings.cc:34
fl_settings_get_clock_format
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
Definition: fl_settings.cc:30
fl_settings_new
FlSettings * fl_settings_new()
Definition: fl_settings.cc:55
fl_settings.h
FlColorScheme
FlColorScheme
Definition: fl_settings.h:33
FlClockFormat
FlClockFormat
Definition: fl_settings.h:21
fl_settings_portal_new
FlSettingsPortal * fl_settings_portal_new()
Definition: fl_settings_portal.cc:267
fl_settings_portal_start
gboolean fl_settings_portal_start(FlSettingsPortal *self, GError **error)
Definition: fl_settings_portal.cc:280
fl_settings_portal.h