From 2fb26289a19a3566ebc9bb9decb087dd0360520a Mon Sep 17 00:00:00 2001 From: daleclack Date: Wed, 20 Mar 2024 17:33:16 +0800 Subject: [PATCH] Add style --- Gtk4/gtk160_wayland_test/res/style.css | 7 ++++++- Gtk4/gtk160_wayland_test/src/main.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gtk4/gtk160_wayland_test/res/style.css b/Gtk4/gtk160_wayland_test/res/style.css index 1bdf263..a5b29f6 100644 --- a/Gtk4/gtk160_wayland_test/res/style.css +++ b/Gtk4/gtk160_wayland_test/res/style.css @@ -1,10 +1,15 @@ /* A slim headerbar style for widgets */ -headerbar{ +.titlebar{ min-height:10px; margin:0px; } +label{ + margin: 0px; + min-height: 8px; +} + .ctrl_btn{ min-height: 8px; min-width: 8px; diff --git a/Gtk4/gtk160_wayland_test/src/main.cpp b/Gtk4/gtk160_wayland_test/src/main.cpp index 3dce38e..2fc8bad 100644 --- a/Gtk4/gtk160_wayland_test/src/main.cpp +++ b/Gtk4/gtk160_wayland_test/src/main.cpp @@ -13,19 +13,23 @@ static void gtkmain(GtkApplication *app, gpointer user_data) // Create widgets window = gtk_application_window_new(app); header = gtk_header_bar_new(); + + const char *title_classes[] = {"titlebar", ""}; + gtk_widget_set_css_classes(header, title_classes); gtk_window_set_titlebar(GTK_WINDOW(window), header); // Initalize headerbar gtk_header_bar_set_show_title_buttons(GTK_HEADER_BAR(header), FALSE); + const char *btn_classes[] = {"ctrl_btn",""}; // Add a close button btn_close = gtk_button_new_with_label("\u00d7"); - gtk_widget_add_css_class(btn_close, "ctrl_btn"); + gtk_widget_set_css_classes(btn_close, btn_classes); gtk_header_bar_pack_start(GTK_HEADER_BAR(header), btn_close); // Add a minimize button btn_mini = gtk_button_new_with_label("-"); - gtk_widget_add_css_class(btn_mini, "ctrl_btn"); + gtk_widget_set_css_classes(btn_mini, btn_classes); gtk_header_bar_pack_start(GTK_HEADER_BAR(header), btn_mini); // Add style for headerbar