diff options
Diffstat (limited to 'gtk/PlatGTK.cxx')
| -rw-r--r-- | gtk/PlatGTK.cxx | 44 | 
1 files changed, 42 insertions, 2 deletions
| diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index ad12aa150..d7944e5a0 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -12,6 +12,7 @@  #include <string>  #include <vector>  #include <map> +#include <sstream>  #include <glib.h>  #include <gmodule.h> @@ -1438,6 +1439,9 @@ class ListBoxX : public ListBox {  	int desiredVisibleRows;  	unsigned int maxItemCharacters;  	unsigned int aveCharWidth; +#if GTK_CHECK_VERSION(3,0,0) +	GtkCssProvider *cssProvider; +#endif  public:  	CallBackAction doubleClickAction;  	void *doubleClickActionData; @@ -1445,7 +1449,11 @@ public:  	ListBoxX() : widCached(0), frame(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0),  		renderer(0),  		desiredVisibleRows(5), maxItemCharacters(0), -		aveCharWidth(1), doubleClickAction(NULL), doubleClickActionData(NULL) { +		aveCharWidth(1), +#if GTK_CHECK_VERSION(3,0,0) +		cssProvider(NULL), +#endif +		doubleClickAction(NULL), doubleClickActionData(NULL) {  	}  	virtual ~ListBoxX() {  		if (pixhash) { @@ -1456,6 +1464,12 @@ public:  			gtk_widget_destroy(GTK_WIDGET(widCached));  			wid = widCached = 0;  		} +#if GTK_CHECK_VERSION(3,0,0) +		if (cssProvider) { +			g_object_unref(cssProvider); +			cssProvider = NULL; +		} +#endif  	}  	virtual void SetFont(Font &font);  	virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_); @@ -1599,6 +1613,12 @@ void ListBoxX::Create(Window &, int, Point, int, bool, int) {  		return;  	} +#if GTK_CHECK_VERSION(3,0,0) +	if (!cssProvider) { +		cssProvider = gtk_css_provider_new(); +	} +#endif +	  	wid = widCached = gtk_window_new(GTK_WINDOW_POPUP);  	frame = gtk_frame_new(NULL); @@ -1621,6 +1641,14 @@ void ListBoxX::Create(Window &, int, Point, int, bool, int) {  	list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));  	g_signal_connect(G_OBJECT(list), "style-set", G_CALLBACK(StyleSet), NULL); +#if GTK_CHECK_VERSION(3,0,0) +	GtkStyleContext *styleContext = gtk_widget_get_style_context(GTK_WIDGET(list)); +	if (styleContext) { +		gtk_style_context_add_provider(styleContext, GTK_STYLE_PROVIDER(cssProvider), +			GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +	} +#endif +  	GtkTreeSelection *selection =  		gtk_tree_view_get_selection(GTK_TREE_VIEW(list));  	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); @@ -1660,7 +1688,19 @@ void ListBoxX::SetFont(Font &scint_font) {  	if (Created() && PFont(scint_font)->pfd) {  		// Current font is Pango font  #if GTK_CHECK_VERSION(3,0,0) -		gtk_widget_override_font(PWidget(list), PFont(scint_font)->pfd); +		if (cssProvider) { +			PangoFontDescription *pfd = PFont(scint_font)->pfd; +			std::ostringstream ssFontSetting; +			ssFontSetting << "GtkTreeView { "; +			ssFontSetting << "font-family: " << pango_font_description_get_family(pfd) <<  "; "; +			ssFontSetting << "font-size:"; +			ssFontSetting << static_cast<double>(pango_font_description_get_size(pfd)) / PANGO_SCALE; +			ssFontSetting << "px; "; +			ssFontSetting << "font-weight:"<< pango_font_description_get_weight(pfd) << "; "; +			ssFontSetting << "}"; +			gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(cssProvider), +				ssFontSetting.str().c_str(), -1, NULL); +		}  		gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer), -1);  		gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer), 1);  #else | 
