4
4
#ifdef GDK_WINDOWING_X11
5
5
#include < gdk/gdkx.h>
6
6
#endif
7
+ #include < handy.h>
7
8
8
9
#include " flutter/generated_plugin_registrant.h"
9
10
@@ -17,35 +18,18 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
17
18
// Implements GApplication::activate.
18
19
static void my_application_activate(GApplication* application) {
19
20
MyApplication* self = MY_APPLICATION (application);
20
- GtkWindow* window =
21
- GTK_WINDOW (gtk_application_window_new (GTK_APPLICATION (application)));
22
-
23
- // Use a header bar when running in GNOME as this is the common style used
24
- // by applications and is the setup most users will be using (e.g. Ubuntu
25
- // desktop).
26
- // If running on X and not using GNOME then just use a traditional title bar
27
- // in case the window manager does more exotic layout, e.g. tiling.
28
- // If running on Wayland assume the header bar will work (may need changing
29
- // if future cases occur).
30
- gboolean use_header_bar = TRUE ;
31
- #ifdef GDK_WINDOWING_X11
32
- 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
- }
38
- }
39
- #endif
40
- if (use_header_bar) {
41
- GtkHeaderBar* header_bar = GTK_HEADER_BAR (gtk_header_bar_new ());
42
- gtk_widget_show (GTK_WIDGET (header_bar));
43
- gtk_header_bar_set_title (header_bar, " Ubuntu Settings" );
44
- gtk_header_bar_set_show_close_button (header_bar, TRUE );
45
- gtk_window_set_titlebar (window, GTK_WIDGET (header_bar));
46
- } else {
47
- gtk_window_set_title (window, " Ubuntu Settings" );
48
- }
21
+ GtkWindow* window = GTK_WINDOW (hdy_application_window_new ());
22
+ gtk_window_set_application (window, GTK_APPLICATION (application));
23
+
24
+ GtkBox* box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0 ));
25
+ gtk_widget_show (GTK_WIDGET (box));
26
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (box));
27
+
28
+ HdyHeaderBar* header_bar = HDY_HEADER_BAR (hdy_header_bar_new ());
29
+ gtk_widget_show (GTK_WIDGET (header_bar));
30
+ hdy_header_bar_set_title (header_bar, " Ubuntu Settings" );
31
+ hdy_header_bar_set_show_close_button (header_bar, TRUE );
32
+ gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (header_bar), false , true , 0 );
49
33
50
34
GdkGeometry geometry;
51
35
geometry.min_width = 600 ;
@@ -60,7 +44,7 @@ static void my_application_activate(GApplication* application) {
60
44
61
45
FlView* view = fl_view_new (project);
62
46
gtk_widget_show (GTK_WIDGET (view));
63
- gtk_container_add ( GTK_CONTAINER (window ), GTK_WIDGET (view));
47
+ gtk_box_pack_end ( GTK_BOX (box ), GTK_WIDGET (view), true , true , 0 );
64
48
65
49
fl_register_plugins (FL_PLUGIN_REGISTRY (view));
66
50
@@ -80,6 +64,8 @@ static gboolean my_application_local_command_line(GApplication* application, gch
80
64
return TRUE ;
81
65
}
82
66
67
+ hdy_init ();
68
+
83
69
g_application_activate (application);
84
70
*exit_status = 0 ;
85
71
@@ -99,7 +85,7 @@ static void my_application_class_init(MyApplicationClass* klass) {
99
85
G_OBJECT_CLASS (klass)->dispose = my_application_dispose;
100
86
}
101
87
102
- static void my_application_init (MyApplication* self) {}
88
+ static void my_application_init (MyApplication* self) { }
103
89
104
90
MyApplication* my_application_new () {
105
91
return MY_APPLICATION (g_object_new (my_application_get_type (),
0 commit comments