5#include "flutter/shell/platform/linux/fl_platform_plugin.h"
10#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_method_codec.h"
11#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
16 "Unknown Clipboard Format";
24 "System.initializationComplete";
52G_DEFINE_TYPE(FlPlatformPlugin, fl_platform_plugin, G_TYPE_OBJECT)
56 FlMethodResponse* response) {
57 g_autoptr(GError)
error =
nullptr;
59 g_warning(
"Failed to send method call response: %s",
error->message);
70 if (
text !=
nullptr) {
75 g_autoptr(FlMethodResponse) response =
91 g_autoptr(FlMethodResponse) response =
105 if (text_value ==
nullptr ||
111 GtkClipboard* clipboard =
112 gtk_clipboard_get_default(gdk_display_get_default());
135 GtkClipboard* clipboard =
136 gtk_clipboard_get_default(gdk_display_get_default());
147 FlPlatformPlugin*
self,
149 GtkClipboard* clipboard =
150 gtk_clipboard_get_default(gdk_display_get_default());
160 if (response ==
nullptr) {
164 g_autoptr(GError)
error =
nullptr;
167 g_warning(
"Error returned from System.requestAppExit: %s",
error->message);
171 g_warning(
"System.requestAppExit result argument map missing or malformed");
177 g_warning(
"Invalid response from System.requestAppExit");
185 GApplication*
app = g_application_get_default();
186 if (
app ==
nullptr) {
194 if (GTK_IS_APPLICATION(
app)) {
195 GList* windows = gtk_application_get_windows(GTK_APPLICATION(
app));
198 gtk_window_set_application(GTK_WINDOW(
window), NULL);
202 g_application_quit(
app);
211 g_autoptr(GError)
error =
nullptr;
212 g_autoptr(FlMethodResponse) method_response =
215 g_autofree gchar* exit_response =
nullptr;
216 if (method_response ==
nullptr) {
217 if (g_error_matches(
error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
220 g_warning(
"Failed to complete System.requestAppExit: %s",
error->message);
225 if (exit_response ==
nullptr) {
236 if (
self->exit_application_method_call !=
nullptr) {
240 g_autoptr(FlMethodResponse) exit_response =
243 exit_response, &
error)) {
244 g_warning(
"Failed to send response to System.exitApplication: %s",
247 g_clear_object(&
self->exit_application_method_call);
255 if (!
self->app_initialization_complete ||
271 FlPlatformPlugin*
self,
273 self->app_initialization_complete =
TRUE;
287 if (type_value ==
nullptr ||
295 if (
self->exit_application_method_call !=
nullptr) {
299 self->exit_application_method_call =
304 if (!
self->app_initialization_complete ||
330 GdkDisplay* display = gdk_display_get_default();
331 if (display !=
nullptr) {
332 gdk_display_beep(display);
337 g_warning(
"Ignoring unknown sound type %s in SystemSound.play.\n",
type);
358 g_autoptr(FlMethodResponse) response =
nullptr;
377 if (response !=
nullptr) {
383 FlPlatformPlugin*
self = FL_PLATFORM_PLUGIN(
object);
385 g_cancellable_cancel(
self->cancellable);
387 g_clear_object(&
self->channel);
388 g_clear_object(&
self->exit_application_method_call);
389 g_clear_object(&
self->cancellable);
391 G_OBJECT_CLASS(fl_platform_plugin_parent_class)->dispose(
object);
399 self->cancellable = g_cancellable_new();
403 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger),
nullptr);
405 FlPlatformPlugin*
self =
406 FL_PLATFORM_PLUGIN(g_object_new(fl_platform_plugin_get_type(),
nullptr));
413 self->app_initialization_complete =
FALSE;
419 g_return_if_fail(FL_IS_PLATFORM_PLUGIN(
self));
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_MODULE_EXPORT FlJsonMethodCodec * fl_json_method_codec_new()
G_MODULE_EXPORT const gchar * fl_method_call_get_name(FlMethodCall *self)
G_MODULE_EXPORT gboolean fl_method_call_respond(FlMethodCall *self, FlMethodResponse *response, GError **error)
G_MODULE_EXPORT FlValue * fl_method_call_get_args(FlMethodCall *self)
G_MODULE_EXPORT FlMethodResponse * fl_method_channel_invoke_method_finish(FlMethodChannel *self, GAsyncResult *result, GError **error)
G_MODULE_EXPORT FlMethodChannel * fl_method_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMethodCodec *codec)
G_MODULE_EXPORT void fl_method_channel_invoke_method(FlMethodChannel *self, const gchar *method, FlValue *args, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(FlMethodChannel *self, FlMethodChannelMethodCallHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
G_MODULE_EXPORT FlValue * fl_method_response_get_result(FlMethodResponse *self, GError **error)
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
G_MODULE_EXPORT FlValue * fl_value_new_map()
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
typedefG_BEGIN_DECLS struct _FlValue FlValue
def link(from_root, to_root)