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