7
7
8
8
#include " flutter/generated_plugin_registrant.h"
9
9
10
- struct _MyApplication {
10
+ struct _MyApplication
11
+ {
11
12
GtkApplication parent_instance;
12
- char ** dart_entrypoint_arguments;
13
+ char ** dart_entrypoint_arguments;
13
14
};
14
15
15
16
G_DEFINE_TYPE (MyApplication, my_application, GTK_TYPE_APPLICATION)
16
17
17
18
// Implements GApplication::activate.
18
- static void my_application_activate(GApplication* application) {
19
- MyApplication* self = MY_APPLICATION (application);
20
- GtkWindow* window =
19
+ static void my_application_activate(GApplication *application)
20
+ {
21
+ MyApplication *self = MY_APPLICATION (application);
22
+ GtkWindow *window =
21
23
GTK_WINDOW (gtk_application_window_new (GTK_APPLICATION (application)));
22
24
23
25
// Use a header bar when running in GNOME as this is the common style used
@@ -30,21 +32,25 @@ static void my_application_activate(GApplication* application) {
30
32
gboolean use_header_bar = TRUE ;
31
33
#ifdef GDK_WINDOWING_X11
32
34
GdkScreen *screen = gtk_window_get_screen (window);
33
- if (GDK_IS_X11_SCREEN (screen)) {
34
- const gchar* wm_name = gdk_x11_screen_get_window_manager_name (screen);
35
- if (g_strcmp0 (wm_name, " GNOME Shell" ) != 0 ) {
36
- use_header_bar = FALSE ;
37
- }
35
+ if (GDK_IS_X11_SCREEN (screen))
36
+ {
37
+ const gchar *wm_name = gdk_x11_screen_get_window_manager_name (screen);
38
+ if (g_strcmp0 (wm_name, " GNOME Shell" ) != 0 )
39
+ {
40
+ use_header_bar = FALSE ;
41
+ }
38
42
}
39
43
#endif
40
- if (use_header_bar) {
44
+ if (use_header_bar)
45
+ {
41
46
GtkHeaderBar *header_bar = GTK_HEADER_BAR (gtk_header_bar_new ());
42
47
gtk_widget_show (GTK_WIDGET (header_bar));
43
48
gtk_header_bar_set_title (header_bar, " ccxgui" );
44
49
gtk_header_bar_set_show_close_button (header_bar, TRUE );
45
50
gtk_window_set_titlebar (window, GTK_WIDGET (header_bar));
46
51
}
47
- else {
52
+ else
53
+ {
48
54
gtk_window_set_title (window, " ccxgui" );
49
55
}
50
56
@@ -54,7 +60,7 @@ static void my_application_activate(GApplication* application) {
54
60
g_autoptr (FlDartProject) project = fl_dart_project_new ();
55
61
fl_dart_project_set_dart_entrypoint_arguments (project, self->dart_entrypoint_arguments );
56
62
57
- FlView* view = fl_view_new (project);
63
+ FlView * view = fl_view_new (project);
58
64
gtk_widget_show (GTK_WIDGET (view));
59
65
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (view));
60
66
@@ -64,16 +70,18 @@ static void my_application_activate(GApplication* application) {
64
70
}
65
71
66
72
// Implements GApplication::local_command_line.
67
- static gboolean my_application_local_command_line (GApplication* application, gchar ***arguments, int *exit_status) {
68
- MyApplication* self = MY_APPLICATION (application);
73
+ static gboolean my_application_local_command_line (GApplication *application, gchar ***arguments, int *exit_status)
74
+ {
75
+ MyApplication *self = MY_APPLICATION (application);
69
76
// Strip out the first argument as it is the binary name.
70
77
self->dart_entrypoint_arguments = g_strdupv (*arguments + 1 );
71
78
72
79
g_autoptr (GError) error = nullptr ;
73
- if (!g_application_register (application, nullptr , &error)) {
74
- g_warning (" Failed to register: %s" , error->message );
75
- *exit_status = 1 ;
76
- return TRUE ;
80
+ if (!g_application_register (application, nullptr , &error))
81
+ {
82
+ g_warning (" Failed to register: %s" , error->message );
83
+ *exit_status = 1 ;
84
+ return TRUE ;
77
85
}
78
86
79
87
g_application_activate (application);
@@ -83,22 +91,26 @@ static gboolean my_application_local_command_line(GApplication* application, gch
83
91
}
84
92
85
93
// Implements GObject::dispose.
86
- static void my_application_dispose (GObject *object) {
87
- MyApplication* self = MY_APPLICATION (object);
94
+ static void my_application_dispose (GObject *object)
95
+ {
96
+ MyApplication *self = MY_APPLICATION (object);
88
97
g_clear_pointer (&self->dart_entrypoint_arguments , g_strfreev);
89
98
G_OBJECT_CLASS (my_application_parent_class)->dispose (object);
90
99
}
91
100
92
- static void my_application_class_init (MyApplicationClass* klass) {
101
+ static void my_application_class_init (MyApplicationClass *klass)
102
+ {
93
103
G_APPLICATION_CLASS (klass)->activate = my_application_activate;
94
104
G_APPLICATION_CLASS (klass)->local_command_line = my_application_local_command_line;
95
105
G_OBJECT_CLASS (klass)->dispose = my_application_dispose;
96
106
}
97
107
98
- static void my_application_init (MyApplication* self) {}
108
+ static void my_application_init (MyApplication * self) {}
99
109
100
- MyApplication* my_application_new () {
110
+ MyApplication *my_application_new ()
111
+ {
101
112
return MY_APPLICATION (g_object_new (my_application_get_type (),
102
113
" application-id" , APPLICATION_ID,
114
+ " flags" , G_APPLICATION_NON_UNIQUE,
103
115
nullptr ));
104
116
}
0 commit comments