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.
This commit is contained in:
Tim Allen 2021-04-01 19:05:49 +11:00 committed by Screwtapello
parent f57657f27d
commit 83e76c87eb
1 changed files with 12 additions and 1 deletions

View File

@ -169,7 +169,18 @@ auto pApplication::initialize() -> void {
widget_class "*.<GtkNotebook>.<GtkHBox>.<GtkButton>" 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();