diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 9f912fd57c..476b68a76a 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -14,6 +14,7 @@ #ifdef __WXGTK3__ typedef struct _cairo cairo_t; typedef struct _GtkStyleProvider GtkStyleProvider; + typedef struct _GtkCssProvider GtkCssProvider; #define WXUNUSED_IN_GTK2(x) x #define WXUNUSED_IN_GTK3(x) #else @@ -409,7 +410,11 @@ protected: // Copies m_children tab order to GTK focus chain: void RealizeTabOrder(); -#ifndef __WXGTK3__ +#ifdef __WXGTK3__ + // Use the given CSS string for styling the widget. The provider must be + // allocated, and remains owned, by the caller. + void ApplyCssStyle(GtkCssProvider* provider, const char* style); +#else // GTK+ < 3 // Called by ApplyWidgetStyle (which is called by SetFont() and // SetXXXColour etc to apply style changed to native widgets) to create // modified GTK style with non-standard attributes. diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index f86dbe21d3..087a0a8d04 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4426,7 +4426,21 @@ PangoContext *wxWindowGTK::GTKGetPangoDefaultContext() return gtk_widget_get_pango_context( m_widget ); } -#ifndef __WXGTK3__ +#ifdef __WXGTK3__ +void wxWindowGTK::ApplyCssStyle(GtkCssProvider* provider, const char* style) +{ + wxCHECK_RET(m_widget, "invalid window"); + + gtk_style_context_remove_provider(gtk_widget_get_style_context(m_widget), + GTK_STYLE_PROVIDER(provider)); + + gtk_css_provider_load_from_data(provider, style, -1, NULL); + + gtk_style_context_add_provider(gtk_widget_get_style_context(m_widget), + GTK_STYLE_PROVIDER(provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +} +#else // GTK+ < 3 GtkRcStyle* wxWindowGTK::GTKCreateWidgetStyle() { GtkRcStyle *style = gtk_rc_style_new();