Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avoid deprecated 'gtk_style_context_get_background_color'
  • Loading branch information
sc0w committed May 5, 2018
1 parent df750ae commit e88c26a
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 16 deletions.
20 changes: 16 additions & 4 deletions eel/eel-background.c
Expand Up @@ -326,6 +326,7 @@ eel_background_ensure_realized (EelBackground *self)
int width, height;
GdkWindow *window;
GtkStyleContext *style;
GdkRGBA *c;

/* Set the default color */
style = gtk_widget_get_style_context (self->details->widget);
Expand All @@ -334,9 +335,13 @@ eel_background_ensure_realized (EelBackground *self)
if (self->details->use_base) {
gtk_style_context_add_class (style, GTK_STYLE_CLASS_VIEW);
}
gtk_style_context_get_background_color (style,
gtk_style_context_get_state (style),
&self->details->default_color);

gtk_style_context_get (style, gtk_style_context_get_state (style),
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
self->details->default_color = *c;
gdk_rgba_free (c);

gtk_style_context_restore (style);

/* If the window size is the same as last time, don't update */
Expand Down Expand Up @@ -1079,7 +1084,14 @@ eel_background_set_dropped_color (EelBackground *self,

GtkStyleContext *style = gtk_widget_get_style_context (widget);
GdkRGBA bg;
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &bg);
GdkRGBA *c;

gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
bg = *c;
gdk_rgba_free (c);

gradient_spec = gdk_rgba_to_string (&bg);

}
Expand Down
9 changes: 8 additions & 1 deletion eel/eel-canvas.c
Expand Up @@ -3024,14 +3024,21 @@ eel_canvas_draw_background (EelCanvas *canvas,
cairo_rectangle_int_t rect;
GtkStyleContext *style_context;
GdkRGBA color;
GdkRGBA *c;

if (!gdk_cairo_get_clip_rectangle (cr, &rect))
return;

cairo_save (cr);
/* By default, we use the style background. */
style_context = gtk_widget_get_style_context (GTK_WIDGET (canvas));
gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &color);

gtk_style_context_get (style_context, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
color = *c;
gdk_rgba_free (c);

gdk_cairo_set_source_rgba (cr, &color);
gdk_cairo_rectangle (cr, &rect);
cairo_fill (cr);
Expand Down
16 changes: 13 additions & 3 deletions eel/eel-editable-label.c
Expand Up @@ -1517,6 +1517,7 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, cairo_t *cr, gint xoff
if (!block_at_line_end)
{
GdkRGBA color;
GdkRGBA *c;

clip = gdk_pango_layout_get_clip_region (label->layout,
xoffset, yoffset,
Expand All @@ -1525,8 +1526,11 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, cairo_t *cr, gint xoff
gdk_cairo_region (cr, clip);
cairo_clip (cr);

gtk_style_context_get_background_color (context, GTK_STATE_FLAG_FOCUSED,
&color);
gtk_style_context_get (context, GTK_STATE_FLAG_FOCUSED,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
color = *c;
gdk_rgba_free (c);

gdk_cairo_set_source_rgba (cr,
&color);
Expand Down Expand Up @@ -1580,6 +1584,7 @@ eel_editable_label_draw (GtkWidget *widget,
GtkStateType state;

GdkRGBA background_color;
GdkRGBA *c;

range[0] = label->selection_anchor;
range[1] = label->selection_end;
Expand Down Expand Up @@ -1612,7 +1617,12 @@ eel_editable_label_draw (GtkWidget *widget,
state = gtk_widget_get_state_flags (widget);
state |= GTK_STATE_FLAG_SELECTED;

gtk_style_context_get_background_color (style, state, &background_color);
gtk_style_context_get (style, state,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
background_color = *c;
gdk_rgba_free (c);

gdk_cairo_set_source_rgba (cr, &background_color);
cairo_paint (cr);

Expand Down
12 changes: 10 additions & 2 deletions libcaja-private/caja-icon-canvas-item.c
Expand Up @@ -1701,6 +1701,7 @@ real_map_surface (CajaIconCanvasItem *icon_item)
int emblem_size;
GtkStyleContext *style;
GdkRGBA color;
GdkRGBA *c;
cairo_surface_t *surface;

temp_pixbuf = icon_item->details->pixbuf;
Expand Down Expand Up @@ -1768,11 +1769,18 @@ real_map_surface (CajaIconCanvasItem *icon_item)
style = gtk_widget_get_style_context (GTK_WIDGET (canvas));

if (gtk_widget_has_focus (GTK_WIDGET (canvas))) {
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
gtk_style_context_get (style, GTK_STATE_FLAG_SELECTED,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
} else {
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);
gtk_style_context_get (style, GTK_STATE_FLAG_ACTIVE,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
}

color = *c;
gdk_rgba_free (c);

old_pixbuf = temp_pixbuf;
temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, &color);

Expand Down
8 changes: 7 additions & 1 deletion libcaja-private/caja-icon-container.c
Expand Up @@ -2865,6 +2865,7 @@ start_rubberbanding (CajaIconContainer *container,
CajaIconContainerDetails *details;
CajaIconRubberbandInfo *band_info;
GdkRGBA bg_color, border_color;
GdkRGBA *c;
GList *p;
CajaIcon *icon;
GtkStyleContext *context;
Expand All @@ -2888,7 +2889,12 @@ start_rubberbanding (CajaIconContainer *container,
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);

gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_color);
gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
bg_color = *c;
gdk_rgba_free (c);

gtk_style_context_get_border_color (context, GTK_STATE_FLAG_NORMAL, &border_color);

gtk_style_context_restore (context);
Expand Down
9 changes: 8 additions & 1 deletion src/caja-location-bar.c
Expand Up @@ -605,9 +605,16 @@ caja_location_bar_set_active(CajaLocationBar *location_bar, gboolean is_active)
{
GtkStyleContext *style;
GdkRGBA color;
GdkRGBA *c;

style = gtk_widget_get_style_context (GTK_WIDGET (location_bar->details->entry));
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_INSENSITIVE, &color);

gtk_style_context_get (style, GTK_STATE_FLAG_INSENSITIVE,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
color = *c;
gdk_rgba_free (c);

gtk_widget_override_background_color (GTK_WIDGET (location_bar->details->entry), GTK_STATE_FLAG_ACTIVE, &color);
}
}
Expand Down
20 changes: 17 additions & 3 deletions src/caja-sidebar-title.c
Expand Up @@ -244,6 +244,7 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
GdkRGBA *light_info_color, *dark_info_color;
GtkStyleContext *style;
GdkRGBA color;
GdkRGBA *c;

g_assert (CAJA_IS_SIDEBAR_TITLE (sidebar_title));
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (sidebar_title)));
Expand Down Expand Up @@ -276,11 +277,19 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
gtk_style_context_get_color (style, GTK_STATE_FLAG_PRELIGHT, &color);
setup_gc_with_fg (sidebar_title, LABEL_COLOR_PRELIGHT, &color);

gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
gtk_style_context_get (style, GTK_STATE_FLAG_SELECTED,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
color = *c;

setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_HIGHLIGHT,
eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color);

gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);
gtk_style_context_get (style, GTK_STATE_FLAG_ACTIVE,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
color = *c;

setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_ACTIVE,
eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color);

Expand All @@ -293,7 +302,11 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color);
setup_gc_with_fg (sidebar_title, LABEL_COLOR, &color);

gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color);
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&color, NULL);
color = *c;

setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR,
eel_gdk_rgba_is_dark (&color) ?
light_info_color : dark_info_color);
Expand All @@ -315,6 +328,7 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, dark_info_color);
}

gdk_rgba_free (c);
gdk_rgba_free (dark_info_color);
gdk_rgba_free (light_info_color);
}
Expand Down
9 changes: 8 additions & 1 deletion src/file-manager/fm-list-view.c
Expand Up @@ -3276,6 +3276,7 @@ real_set_is_active (FMDirectoryView *view,
GtkWidget *tree_view;
GtkStyleContext *style;
GdkRGBA color;
GdkRGBA *c;

tree_view = GTK_WIDGET (fm_list_view_get_tree_view (FM_LIST_VIEW (view)));

Expand All @@ -3286,7 +3287,13 @@ real_set_is_active (FMDirectoryView *view,
else
{
style = gtk_widget_get_style_context (tree_view);
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_INSENSITIVE, &color);

gtk_style_context_get (style, GTK_STATE_FLAG_INSENSITIVE,
GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
&c, NULL);
color = *c;
gdk_rgba_free (c);

gtk_widget_override_background_color (tree_view, GTK_STATE_FLAG_NORMAL, &color);
}

Expand Down

0 comments on commit e88c26a

Please sign in to comment.