Don't get properties of a non-current style state to please GTK 3.20

GTK 3.20 doesn't like getting a style property for a non-current state,
unless the call is wrapped in a save()/restore() pair.

So, fix the code to either use the current state or temporarily save
the context.

gb.c now uses different states, but it shouldn't really matter given
how they are used, and even gives a native behavior when the window
loses focus, as it now properly reacts to BACKDROP state.
This commit is contained in:
Colomban Wendling 2016-05-02 23:38:21 +02:00
parent 75063e9159
commit f948916ad0
3 changed files with 12 additions and 5 deletions

View File

@ -1805,7 +1805,13 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gui
label = gtk_label_new(text);
g_free(text);
#if GTK_CHECK_VERSION(3,0,0)
gtk_style_context_get_color(gtk_widget_get_style_context(label), GTK_STATE_FLAG_INSENSITIVE, &insensitive_color);
{
GtkStyleContext *ctx = gtk_widget_get_style_context(label);
gtk_style_context_save(ctx);
gtk_style_context_get_color(ctx, GTK_STATE_FLAG_INSENSITIVE, &insensitive_color);
gtk_style_context_restore(ctx);
}
#else
insensitive_color = gtk_widget_get_style(label)->text[GTK_STATE_INSENSITIVE];
#endif

View File

@ -3269,7 +3269,7 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
gtk_widget_path_iter_set_name(path, -1, document_status_styles[status].name);
gtk_style_context_set_screen(ctx, gtk_widget_get_screen(GTK_WIDGET(doc->editor->sci)));
gtk_style_context_set_path(ctx, path);
gtk_style_context_get_color(ctx, GTK_STATE_FLAG_NORMAL, &color);
gtk_style_context_get_color(ctx, gtk_style_context_get_state(ctx), &color);
document_status_styles[status].color.red = 0xffff * color.red;
document_status_styles[status].color.green = 0xffff * color.green;
document_status_styles[status].color.blue = 0xffff * color.blue;

View File

@ -99,10 +99,11 @@ static gboolean geany_pong_area_draw(GtkWidget *area, cairo_t *cr, GeanyPong *se
/* we use the window style context because the area one has a transparent
* background and we want something to paint for the overlay */
GtkStyleContext *ctx = gtk_widget_get_style_context(GTK_WIDGET(self));
GtkStateFlags state = gtk_style_context_get_state(ctx);
GdkRGBA fg, bg;
gtk_style_context_get_color(ctx, GTK_STATE_FLAG_ACTIVE, &fg);
gtk_style_context_get_background_color(ctx, GTK_STATE_FLAG_BACKDROP, &bg);
gtk_style_context_get_color(ctx, state, &fg);
gtk_style_context_get_background_color(ctx, state, &bg);
#else
GtkStyle *style = gtk_widget_get_style(area);
GdkColor fg = style->fg[GTK_STATE_NORMAL];
@ -144,7 +145,7 @@ static gboolean geany_pong_area_draw(GtkWidget *area, cairo_t *cr, GeanyPong *se
layout = pango_cairo_create_layout(cr);
#if GTK_CHECK_VERSION(3, 0, 0)
PangoFontDescription *font = NULL;
gtk_style_context_get(ctx, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
gtk_style_context_get(ctx, state, GTK_STYLE_PROPERTY_FONT, &font, NULL);
if (font)
{
pango_layout_set_font_description(layout, font);