Flutter Linux Embedder
fl_settings_handler.h File Reference

Go to the source code of this file.

Functions

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (FlSettingsHandler, fl_settings_handler, FL, SETTINGS_HANDLER, GObject)
 
FlSettingsHandler * fl_settings_handler_new (FlEngine *engine)
 
void fl_settings_handler_start (FlSettingsHandler *handler, FlSettings *settings)
 

Function Documentation

◆ 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 94 of file fl_settings_handler.cc.

94  {
95  g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
96 
97  FlSettingsHandler* self = FL_SETTINGS_HANDLER(
98  g_object_new(fl_settings_handler_get_type(), nullptr));
99 
100  self->engine = engine;
101  g_object_add_weak_pointer(G_OBJECT(self),
102  reinterpret_cast<gpointer*>(&(self->engine)));
103 
104  FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(engine);
105  g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
106  self->channel = fl_basic_message_channel_new(messenger, kChannelName,
107  FL_MESSAGE_CODEC(codec));
108 
109  return self;
110 }

References fl_basic_message_channel_new(), fl_engine_get_binary_messenger(), fl_json_message_codec_new(), and kChannelName.

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 112 of file fl_settings_handler.cc.

112  {
113  g_return_if_fail(FL_IS_SETTINGS_HANDLER(self));
114  g_return_if_fail(FL_IS_SETTINGS(settings));
115 
116  self->settings = FL_SETTINGS(g_object_ref(settings));
117  g_signal_connect_object(settings, "changed", G_CALLBACK(update_settings),
118  self, G_CONNECT_SWAPPED);
119 
120  update_settings(self);
121 }

References update_settings().

Referenced by fl_engine_start(), and TEST().

◆ G_DECLARE_FINAL_TYPE()

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE ( FlSettingsHandler  ,
fl_settings_handler  ,
FL  ,
SETTINGS_HANDLER  ,
GObject   
)
fl_json_message_codec_new
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
Definition: fl_json_message_codec.cc:306
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:995
kChannelName
static constexpr char kChannelName[]
Definition: fl_settings_handler.cc:15
update_settings
static void update_settings(FlSettingsHandler *self)
Definition: fl_settings_handler.cc:44
fl_basic_message_channel_new
G_MODULE_EXPORT FlBasicMessageChannel * fl_basic_message_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMessageCodec *codec)
Definition: fl_basic_message_channel.cc:154