44#ifdef GDK_WINDOWING_X11
55#include < gdk/gdkx.h>
66#endif
7+ #include < handy.h>
78
89#include " flutter/generated_plugin_registrant.h"
910
@@ -17,35 +18,18 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1718// Implements GApplication::activate.
1819static void my_application_activate(GApplication* application) {
1920 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 );
4933
5034 GdkGeometry geometry;
5135 geometry.min_width = 600 ;
@@ -60,7 +44,7 @@ static void my_application_activate(GApplication* application) {
6044
6145 FlView* view = fl_view_new (project);
6246 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 );
6448
6549 fl_register_plugins (FL_PLUGIN_REGISTRY (view));
6650
@@ -80,6 +64,8 @@ static gboolean my_application_local_command_line(GApplication* application, gch
8064 return TRUE ;
8165 }
8266
67+ hdy_init ();
68+
8369 g_application_activate (application);
8470 *exit_status = 0 ;
8571
@@ -99,7 +85,7 @@ static void my_application_class_init(MyApplicationClass* klass) {
9985 G_OBJECT_CLASS (klass)->dispose = my_application_dispose;
10086}
10187
102- static void my_application_init (MyApplication* self) {}
88+ static void my_application_init (MyApplication* self) { }
10389
10490MyApplication* my_application_new () {
10591 return MY_APPLICATION (g_object_new (my_application_get_type (),
0 commit comments