Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
9G_DEFINE_INTERFACE(FlSettings, fl_settings, G_TYPE_OBJECT)
10
11enum {
14};
15
17
18static 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 */
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
31 return FL_SETTINGS_GET_IFACE(self)->get_clock_format(self);
32}
33
35 return FL_SETTINGS_GET_IFACE(self)->get_color_scheme(self);
36}
37
39 return FL_SETTINGS_GET_IFACE(self)->get_enable_animations(self);
40}
41
42gboolean fl_settings_get_high_contrast(FlSettings* self) {
43 return FL_SETTINGS_GET_IFACE(self)->get_high_contrast(self);
44}
45
47 return FL_SETTINGS_GET_IFACE(self)->get_text_scaling_factor(self);
48}
49
50void fl_settings_emit_changed(FlSettings* self) {
51 g_return_if_fail(FL_IS_SETTINGS(self));
52 g_signal_emit(self, signals[kSignalChanged], 0);
53}
54
55FlSettings* 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}
FlSettings * fl_gnome_settings_new()
G_DEFINE_INTERFACE(FlKeyboardViewDelegate, fl_keyboard_view_delegate, G_TYPE_OBJECT) static void fl_keyboard_view_delegate_default_init(FlKeyboardViewDelegateInterface *iface)
const uint8_t uint32_t uint32_t GError ** error
gboolean fl_settings_get_high_contrast(FlSettings *self)
static void fl_settings_default_init(FlSettingsInterface *iface)
static guint signals[kSignalLastSignal]
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
@ kSignalChanged
@ kSignalLastSignal
void fl_settings_emit_changed(FlSettings *self)
gboolean fl_settings_get_enable_animations(FlSettings *self)
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
FlSettings * fl_settings_new()
FlColorScheme
Definition fl_settings.h:35
FlClockFormat
Definition fl_settings.h:21
gboolean fl_settings_portal_start(FlSettingsPortal *self, GError **error)
FlSettingsPortal * fl_settings_portal_new()