Flutter Linux Embedder
fl_settings_plugin.h File Reference

Go to the source code of this file.

Functions

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (FlSettingsPlugin, fl_settings_plugin, FL, SETTINGS_PLUGIN, GObject)
 
FlSettingsPlugin * fl_settings_plugin_new (FlEngine *engine)
 
void fl_settings_plugin_start (FlSettingsPlugin *plugin, FlSettings *settings)
 

Function Documentation

◆ fl_settings_plugin_new()

FlSettingsPlugin* fl_settings_plugin_new ( FlEngine *  engine)

FlSettingsPlugin:

#FlSettingsPlugin is a plugin that implements the Flutter user settings channel. fl_settings_plugin_new: @messenger: an #FlEngine

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

Returns: a new #FlSettingsPlugin

Definition at line 94 of file fl_settings_plugin.cc.

94  {
95  g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
96 
97  FlSettingsPlugin* self =
98  FL_SETTINGS_PLUGIN(g_object_new(fl_settings_plugin_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_plugin_start()

void fl_settings_plugin_start ( FlSettingsPlugin *  plugin,
FlSettings *  settings 
)

fl_settings_plugin_start: @self: an #FlSettingsPlugin.

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

Definition at line 112 of file fl_settings_plugin.cc.

112  {
113  g_return_if_fail(FL_IS_SETTINGS_PLUGIN(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 ( FlSettingsPlugin  ,
fl_settings_plugin  ,
FL  ,
SETTINGS_PLUGIN  ,
GObject   
)
fl_json_message_codec_new
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
Definition: fl_json_message_codec.cc:306
update_settings
static void update_settings(FlSettingsPlugin *self)
Definition: fl_settings_plugin.cc:44
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:918
kChannelName
static constexpr char kChannelName[]
Definition: fl_settings_plugin.cc:15
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