diff --git a/Gtk4/gtk160_wayland_test/CMakeLists.txt b/Gtk4/gtk160_wayland_test/CMakeLists.txt
index 65b4213..e5a1163 100644
--- a/Gtk4/gtk160_wayland_test/CMakeLists.txt
+++ b/Gtk4/gtk160_wayland_test/CMakeLists.txt
@@ -31,7 +31,10 @@ set(SOURCE_FILE src/main.cpp src/MainWin.cpp)
#Compile Resource
set(RESOURCE_LIST
- style.css)
+ style.css
+ icons/scalable/status/win_close.svg
+ icons/scalable/status/win_maximize.svg
+ icons/scalable/status/win_minimize.svg)
compile_gresources(RESOURCE_FILE
XML_OUT
diff --git a/Gtk4/gtk160_wayland_test/res/icons/16x16/actions/win_close.png b/Gtk4/gtk160_wayland_test/res/icons/16x16/actions/win_close.png
new file mode 100644
index 0000000..e6a5ff8
Binary files /dev/null and b/Gtk4/gtk160_wayland_test/res/icons/16x16/actions/win_close.png differ
diff --git a/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_close.svg b/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_close.svg
new file mode 100644
index 0000000..a18c96e
--- /dev/null
+++ b/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_close.svg
@@ -0,0 +1,3 @@
+
diff --git a/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_maximize.svg b/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_maximize.svg
new file mode 100644
index 0000000..99598ec
--- /dev/null
+++ b/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_maximize.svg
@@ -0,0 +1,3 @@
+
diff --git a/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_minimize.svg b/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_minimize.svg
new file mode 100644
index 0000000..5474ea3
--- /dev/null
+++ b/Gtk4/gtk160_wayland_test/res/icons/scalable/status/win_minimize.svg
@@ -0,0 +1,3 @@
+
diff --git a/Gtk4/gtk160_wayland_test/res/style.css b/Gtk4/gtk160_wayland_test/res/style.css
index edbfbed..8c2a340 100644
--- a/Gtk4/gtk160_wayland_test/res/style.css
+++ b/Gtk4/gtk160_wayland_test/res/style.css
@@ -1,5 +1,11 @@
/* A slim headerbar style for widgets */
headerbar{
- min-height:20px;
+ min-height:10px;
+ margin:0px;
+}
+
+button{
+ min-height: 8px;
+ margin: 0px;
}
\ No newline at end of file
diff --git a/Gtk4/gtk160_wayland_test/src/main.cpp b/Gtk4/gtk160_wayland_test/src/main.cpp
index 7045c53..256edd7 100644
--- a/Gtk4/gtk160_wayland_test/src/main.cpp
+++ b/Gtk4/gtk160_wayland_test/src/main.cpp
@@ -3,12 +3,27 @@
static void gtkmain(GtkApplication *app, gpointer user_data)
{
GtkWidget *window, *header;
+ GtkWidget *btn_close, *btn_mini;
+ GtkWidget *img_close, *img_mini;
// Create widgets
window = gtk_application_window_new(app);
header = gtk_header_bar_new();
gtk_window_set_titlebar(GTK_WINDOW(window), header);
+ // Initalize headerbar
+ gtk_header_bar_set_show_title_buttons(GTK_HEADER_BAR(header), FALSE);
+
+ // Add a close button
+ btn_close = gtk_button_new();
+
+ gtk_header_bar_pack_start(GTK_HEADER_BAR(header), btn_close);
+
+ // Add a minimize button
+ btn_mini = gtk_button_new();
+
+ gtk_header_bar_pack_start(GTK_HEADER_BAR(header), btn_mini);
+
// Add style for headerbar
GtkCssProvider *provider = gtk_css_provider_new();
gtk_css_provider_load_from_resource(provider, "/org/gtk/daleclack/style.css");
@@ -16,8 +31,23 @@ static void gtkmain(GtkApplication *app, gpointer user_data)
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_signal_connect_swapped(btn_close, "clicked", G_CALLBACK(gtk_window_close), window);
+ g_signal_connect_swapped(btn_mini, "clicked", G_CALLBACK(gtk_window_minimize), window);
// show the window
gtk_window_present(GTK_WINDOW(window));
+
+ // Get Scale factor
+ GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(window));
+ double scale = gdk_surface_get_scale(surface);
+ g_print("%f\n", scale);
+
+ img_close = gtk_image_new_from_icon_name("win_close");
+ gtk_image_set_pixel_size(GTK_IMAGE(img_close), 12 / scale);
+ gtk_button_set_child(GTK_BUTTON(btn_close), img_close);
+
+ img_mini = gtk_image_new_from_icon_name("win_minimize");
+ gtk_image_set_pixel_size(GTK_IMAGE(img_mini), 12 / scale);
+ gtk_button_set_child(GTK_BUTTON(btn_mini), img_mini);
}
int main(int argc, char **argv)