From 83e76c87eb0b45b3265893337960218b5a9ca94e Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 1 Apr 2021 19:05:49 +1100 Subject: [PATCH] hiro: Disable padding for the GTK+3 backend. GTK+3 is designed for automatic layout, where widgets are automatically sized and positioned according to the size of their contents. However, hiro has to be compatible with Windows, which lacks an automatic layout system, so hiro apps tend to position widgets manually. Unfortunately, the GTK+3 default theme uses much bigger widgets than GTK+2 or Windows, so hiro apps using the GTK+3 backend tend to have ugly, overlapping widgets. To make GTK+3 behave more like other hiro targets, we add custom CSS and override the default theme at runtime. Fixes #168. --- hiro/gtk/application.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hiro/gtk/application.cpp b/hiro/gtk/application.cpp index 63f6823a..fe44a383 100755 --- a/hiro/gtk/application.cpp +++ b/hiro/gtk/application.cpp @@ -169,7 +169,18 @@ auto pApplication::initialize() -> void { widget_class "*..." style "HiroTabFrameCloseButton" )"); #elif HIRO_GTK==3 - //TODO: is there any alternative here with GTK3? + GtkCssProvider *provider; + GdkScreen *screen; + + provider = gtk_css_provider_new(); + gtk_css_provider_load_from_data(GTK_CSS_PROVIDER (provider), R"( + scale { padding-top: 0; padding-bottom: 0; } + entry { min-height: 0; } + button { padding: 0; } + )", -1, NULL); + + screen = gdk_screen_get_default(); + gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); #endif pKeyboard::initialize();