mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
Handle GTK themes that don't use the revealer
This commit is contained in:
parent
db56d51838
commit
8ab5d95d1b
@ -69,28 +69,46 @@ void KIPLATFORM::UI::GetInfoBarColours( wxColour& aFgColour, wxColour& aBgColour
|
||||
// The GTK3.24 way of getting the colours is to use the style context
|
||||
// Earlier GTKs should be able to use the system settings
|
||||
#if( GTK_CHECK_VERSION( 3, 24, 0 ) )
|
||||
GdkRGBA* rgba;
|
||||
GdkRGBA* rgba;
|
||||
GtkWidgetPath* path = gtk_widget_path_new();
|
||||
GtkStyleContext* sc = gtk_style_context_new();
|
||||
|
||||
gtk_widget_path_append_type( path, GTK_TYPE_WINDOW );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "infobar" );
|
||||
gtk_widget_path_iter_add_class( path, -1, "background" );
|
||||
gtk_widget_path_iter_add_class( path, -1, "info" );
|
||||
gtk_widget_path_append_type( path, G_TYPE_NONE );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "revealer" );
|
||||
gtk_widget_path_append_type( path, G_TYPE_NONE );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "box" );
|
||||
|
||||
gtk_style_context_set_path( sc, path );
|
||||
gtk_style_context_set_state( sc, GTK_STATE_FLAG_NORMAL );
|
||||
|
||||
gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL, "background-color", &rgba, NULL );
|
||||
aBgColour = wxColour(*rgba);
|
||||
gdk_rgba_free(rgba);
|
||||
aBgColour = wxColour( *rgba );
|
||||
gdk_rgba_free( rgba );
|
||||
|
||||
gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL, "color", &rgba, NULL );
|
||||
aFgColour = wxColour(*rgba);
|
||||
gdk_rgba_free(rgba);
|
||||
aFgColour = wxColour( *rgba );
|
||||
gdk_rgba_free( rgba );
|
||||
|
||||
// Some GTK themes use the plain infobar style, but if they don't, the background alpha
|
||||
// is generally 0. In this case, try the revealer and box as these are used for Adwaita
|
||||
// and other themes.
|
||||
if( aBgColour.Alpha() == 0 )
|
||||
{
|
||||
gtk_widget_path_append_type( path, G_TYPE_NONE );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "revealer" );
|
||||
gtk_widget_path_append_type( path, G_TYPE_NONE );
|
||||
gtk_widget_path_iter_set_object_name( path, -1, "box" );
|
||||
|
||||
gtk_style_context_set_path( sc, path );
|
||||
gtk_style_context_set_state( sc, GTK_STATE_FLAG_NORMAL );
|
||||
|
||||
gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL, "background-color", &rgba, NULL );
|
||||
aBgColour = wxColour( *rgba );
|
||||
gdk_rgba_free( rgba );
|
||||
|
||||
gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL, "color", &rgba, NULL );
|
||||
aFgColour = wxColour( *rgba );
|
||||
gdk_rgba_free( rgba );
|
||||
}
|
||||
|
||||
gtk_widget_path_free( path );
|
||||
g_object_unref( sc );
|
||||
|
Loading…
Reference in New Issue
Block a user