| Flutter Linux Embedder |

Classes | Functions
fl_settings_handler.cc File Reference
`#include "flutter/shell/platform/linux/fl_settings_handler.h"`
`#include <gmodule.h>`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "flutter/shell/platform/linux/fl_settings_channel.h"`

Go to the source code of this file.

## Classes
struct | _FlSettingsHandler

## Functions
static FlSettingsChannelPlatformBrightness | to_platform_brightness (FlColorScheme color_scheme)
static void | update_settings (FlSettingsHandler *self)
static void | fl_settings_handler_dispose (GObject *object)
static void | fl_settings_handler_class_init (FlSettingsHandlerClass *klass)
static void | fl_settings_handler_init (FlSettingsHandler *self)
FlSettingsHandler * | fl_settings_handler_new (FlEngine *engine)
void | fl_settings_handler_start (FlSettingsHandler *self, FlSettings *settings)

## Function Documentation

## ◆ fl_settings_handler_class_init()

static void fl_settings_handler_class_init | ( | FlSettingsHandlerClass * | klass | ) |
| static

Definition at line 68 of file fl_settings_handler.cc.

68 {
69 G_OBJECT_CLASS(klass)->dispose = fl_settings_handler_dispose;
70 }

References fl_settings_handler_dispose().

## ◆ fl_settings_handler_dispose()

static void fl_settings_handler_dispose | ( | GObject * | object | ) |
| static

Definition at line 58 of file fl_settings_handler.cc.

58 {
59 FlSettingsHandler* self = FL_SETTINGS_HANDLER(object);
60
61 g_clear_object(&self->channel);
62 g_clear_object(&self->settings);
63 g_weak_ref_clear(&self->engine);
64
65 G_OBJECT_CLASS(fl_settings_handler_parent_class)->dispose(object);
66 }

Referenced by fl_settings_handler_class_init().

## ◆ fl_settings_handler_init()

static void fl_settings_handler_init | ( | FlSettingsHandler * | self | ) |
| static

Definition at line 72 of file fl_settings_handler.cc.

72 {}

## ◆ fl_settings_handler_new()

FlSettingsHandler* fl_settings_handler_new | ( | FlEngine * | engine | ) |

FlSettingsHandler:

#FlSettingsHandler is a handler that implements the Flutter user settings channel. fl_settings_handler_new: @messenger: an #FlEngine

Creates a new handler that sends user settings to the Flutter engine.

Returns: a new #FlSettingsHandler

Definition at line 74 of file fl_settings_handler.cc.

74 {
75 g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
76
77 FlSettingsHandler* self = FL_SETTINGS_HANDLER(
78 g_object_new(fl_settings_handler_get_type(), nullptr));
79
80 g_weak_ref_init(&self->engine, engine);
81
82 FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(engine);
83 self->channel = fl_settings_channel_new(messenger);
84
85 return self;
86 }

References fl_engine_get_binary_messenger(), and fl_settings_channel_new().

Referenced by fl_engine_start(), and TEST().

## ◆ fl_settings_handler_start()

void fl_settings_handler_start | ( | FlSettingsHandler * | handler,
|  | FlSettings * | settings
| ) |  |

fl_settings_handler_start: @handler: an #FlSettingsHandler.

Sends the current settings to the engine and updates when they change.

Definition at line 88 of file fl_settings_handler.cc.

88 {
89 g_return_if_fail(FL_IS_SETTINGS_HANDLER(self));
90 g_return_if_fail(FL_IS_SETTINGS(settings));
91
92 self->settings = FL_SETTINGS(g_object_ref(settings));
93 g_signal_connect_object(settings, "changed", G_CALLBACK(update_settings),
94 self, G_CONNECT_SWAPPED);
95
96 update_settings(self);
97 }

References update_settings().

Referenced by fl_engine_start(), and TEST().

## ◆ to_platform_brightness()

static FlSettingsChannelPlatformBrightness to_platform_brightness | ( | FlColorScheme | color_scheme | ) |
| static

Definition at line 23 of file fl_settings_handler.cc.

24 {
25 switch (color_scheme) {
26 case FL_COLOR_SCHEME_LIGHT:
27 return FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_LIGHT;
28 case FL_COLOR_SCHEME_DARK:
29 return FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_DARK;
30 default:
31 g_assert_not_reached();
32 }
33 }

References FL_COLOR_SCHEME_DARK, FL_COLOR_SCHEME_LIGHT, FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_DARK, and FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_LIGHT.

Referenced by update_settings().

## ◆ update_settings()

static void update_settings | ( | FlSettingsHandler * | self | ) |
| static

Definition at line 36 of file fl_settings_handler.cc.

36 {
37 FlClockFormat clock_format = fl_settings_get_clock_format(self->settings);
38 FlColorScheme color_scheme = fl_settings_get_color_scheme(self->settings);
39 gdouble scaling_factor = fl_settings_get_text_scaling_factor(self->settings);
40
41 fl_settings_channel_send(self->channel, scaling_factor,
42 clock_format == FL_CLOCK_FORMAT_24H,
43 to_platform_brightness(color_scheme));
44
45 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
46 if (engine != nullptr) {
47 int32_t flags = 0;
48 if (!fl_settings_get_enable_animations(self->settings)) {
49 flags |= kFlutterAccessibilityFeatureDisableAnimations;
50 }
51 if (fl_settings_get_high_contrast(self->settings)) {
52 flags |= kFlutterAccessibilityFeatureHighContrast;
53 }
54 fl_engine_update_accessibility_features(engine, flags);
55 }
56 }

References FL_CLOCK_FORMAT_24H, fl_engine_update_accessibility_features(), fl_settings_channel_send(), fl_settings_get_clock_format(), fl_settings_get_color_scheme(), fl_settings_get_enable_animations(), fl_settings_get_high_contrast(), fl_settings_get_text_scaling_factor(), flags, and to_platform_brightness().

Referenced by fl_settings_handler_start().

fl_settings_channel_new
FlSettingsChannel * fl_settings_channel_new(FlBinaryMessenger *messenger)
Definition: fl_settings_channel.cc:39
fl_engine_update_accessibility_features
void fl_engine_update_accessibility_features(FlEngine *self, int32_t flags)
Definition: fl_engine.cc:1225
fl_settings_get_color_scheme
FlColorScheme fl_settings_get_color_scheme(FlSettings *self)
Definition: fl_settings.cc:34
FL_CLOCK_FORMAT_24H
@ FL_CLOCK_FORMAT_24H
Definition: fl_settings.h:23
fl_settings_get_enable_animations
gboolean fl_settings_get_enable_animations(FlSettings *self)
Definition: fl_settings.cc:38
flags
FlutterSemanticsFlag flags
Definition: fl_accessible_node.cc:106
fl_settings_channel_send
void fl_settings_channel_send(FlSettingsChannel *self, double text_scale_factor, gboolean always_use_24_hour_format, FlSettingsChannelPlatformBrightness platform_brightness)
Definition: fl_settings_channel.cc:50
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:1203
FlColorScheme
FlColorScheme
Definition: fl_settings.h:33
fl_settings_get_high_contrast
gboolean fl_settings_get_high_contrast(FlSettings *self)
Definition: fl_settings.cc:42
fl_settings_get_text_scaling_factor
gdouble fl_settings_get_text_scaling_factor(FlSettings *self)
Definition: fl_settings.cc:46
fl_settings_handler_dispose
static void fl_settings_handler_dispose(GObject *object)
Definition: fl_settings_handler.cc:58
to_platform_brightness
static FlSettingsChannelPlatformBrightness to_platform_brightness(FlColorScheme color_scheme)
Definition: fl_settings_handler.cc:23
FL_COLOR_SCHEME_LIGHT
@ FL_COLOR_SCHEME_LIGHT
Definition: fl_settings.h:34
FL_COLOR_SCHEME_DARK
@ FL_COLOR_SCHEME_DARK
Definition: fl_settings.h:35
FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_DARK
@ FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_DARK
Definition: fl_settings_channel.h:14
update_settings
static void update_settings(FlSettingsHandler *self)
Definition: fl_settings_handler.cc:36
FlClockFormat
FlClockFormat
Definition: fl_settings.h:21
FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_LIGHT
@ FL_SETTINGS_CHANNEL_PLATFORM_BRIGHTNESS_LIGHT
Definition: fl_settings_channel.h:13
fl_settings_get_clock_format
FlClockFormat fl_settings_get_clock_format(FlSettings *self)
Definition: fl_settings.cc:30