display: Don't use deprecated GTK+ api

This commit is contained in:
Matthias Clasen 2011-01-25 00:53:09 -05:00
parent 86bff4b953
commit e45b813079
2 changed files with 38 additions and 27 deletions

View file

@ -56,7 +56,8 @@ INCLUDES = $(DISPLAY_CAPPLET_CFLAGS) \
-DSBINDIR="\"$(sbindir)\"" \ -DSBINDIR="\"$(sbindir)\"" \
-DUIDIR="\"$(uidir)\"" \ -DUIDIR="\"$(uidir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
$(DISABLE_DEPRECATED)
CLEANFILES = $(Desktop_in_files) $(desktop_DATA) CLEANFILES = $(Desktop_in_files) $(desktop_DATA)

View file

@ -490,23 +490,31 @@ rebuild_current_monitor_label (App *app)
if (use_color) if (use_color)
{ {
GdkColor black = { 0, 0, 0, 0 }; GdkRGBA black = { 0, 0, 0, 1.0 };
GdkRGBA light;
gtk_widget_modify_bg (app->current_monitor_event_box, gtk_widget_get_state (app->current_monitor_event_box), &color); light.red = color.red / 65535.0;
light.green = color.green / 65535.0;
light.blue = color.blue / 65535.0;
light.alpha = 1.0;
gtk_widget_override_background_color (app->current_monitor_event_box,
gtk_widget_get_state_flags (app->current_monitor_event_box),
&light);
/* Make the label explicitly black. We don't want it to follow the /* Make the label explicitly black. We don't want it to follow the
* theme's colors, since the label is always shown against a light * theme's colors, since the label is always shown against a light
* pastel background. See bgo#556050 * pastel background. See bgo#556050
*/ */
gtk_widget_modify_fg (app->current_monitor_label, gtk_widget_get_state (app->current_monitor_label), &black); gtk_widget_override_color (app->current_monitor_label,
gtk_widget_get_state_flags (app->current_monitor_label),
&black);
} }
else else
{ {
/* Remove any modifications we did on the label's color */ /* Remove any modifications we did on the label's color */
GtkRcStyle *reset_rc_style; gtk_widget_override_color (app->current_monitor_label,
gtk_widget_get_state_flags (app->current_monitor_label),
reset_rc_style = gtk_rc_style_new (); NULL);
gtk_widget_modify_style (app->current_monitor_label, reset_rc_style); /* takes ownership of, and destroys, the rc style */
} }
gtk_event_box_set_visible_window (GTK_EVENT_BOX (app->current_monitor_event_box), use_color); gtk_event_box_set_visible_window (GTK_EVENT_BOX (app->current_monitor_event_box), use_color);
@ -1483,7 +1491,7 @@ set_cursor (GtkWidget *widget, GdkCursorType type)
gdk_window_set_cursor (window, cursor); gdk_window_set_cursor (window, cursor);
if (cursor) if (cursor)
gdk_cursor_unref (cursor); g_object_unref (cursor);
} }
static void static void
@ -1731,17 +1739,21 @@ paint_background (FooScrollArea *area,
{ {
GdkRectangle viewport; GdkRectangle viewport;
GtkWidget *widget; GtkWidget *widget;
GtkStyle *widget_style; GtkStyleContext *context;
GdkRGBA fg, bg;
widget = GTK_WIDGET (area); widget = GTK_WIDGET (area);
foo_scroll_area_get_viewport (area, &viewport); foo_scroll_area_get_viewport (area, &viewport);
widget_style = gtk_widget_get_style (widget); context = gtk_widget_get_style_context (widget);
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg);
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
cairo_set_source_rgb (cr, cairo_set_source_rgba (cr,
widget_style->mid[GTK_STATE_NORMAL].red / 65535.0, (fg.red + bg.red) / 2,
widget_style->mid[GTK_STATE_NORMAL].green / 65535.0, (fg.green + bg.green) / 2,
widget_style->mid[GTK_STATE_NORMAL].blue / 65535.0); (fg.blue + bg.blue) / 2,
(fg.alpha + bg.alpha) / 2);
cairo_rectangle (cr, cairo_rectangle (cr,
viewport.x, viewport.y, viewport.x, viewport.y,
@ -1751,10 +1763,11 @@ paint_background (FooScrollArea *area,
foo_scroll_area_add_input_from_fill (area, cr, on_canvas_event, NULL); foo_scroll_area_add_input_from_fill (area, cr, on_canvas_event, NULL);
cairo_set_source_rgb (cr, cairo_set_source_rgba (cr,
widget_style->dark[GTK_STATE_NORMAL].red / 65535.0, 0.7 * bg.red,
widget_style->dark[GTK_STATE_NORMAL].green / 65535.0, 0.7 * bg.green,
widget_style->dark[GTK_STATE_NORMAL].blue / 65535.0); 0.7 * bg.blue,
0.7 * bg.alpha);
cairo_stroke (cr); cairo_stroke (cr);
} }
@ -1847,19 +1860,16 @@ paint_output (App *app, cairo_t *cr, int i)
if (output == app->current_output) if (output == app->current_output)
{ {
GtkStyle *style; GtkStyleContext *context;
GdkColor color; GdkRGBA color;
style = gtk_widget_get_style (app->area); context = gtk_widget_get_style_context (app->area);
color = style->bg[GTK_STATE_SELECTED]; gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color);
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
cairo_rectangle (cr, x - 2, y - 2, w * scale + 0.5 + 4, h * scale + 0.5 + 4); cairo_rectangle (cr, x - 2, y - 2, w * scale + 0.5 + 4, h * scale + 0.5 + 4);
cairo_set_line_width (cr, 4); cairo_set_line_width (cr, 4);
cairo_set_source_rgba (cr, r, g, b, 0.5); cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5);
cairo_stroke (cr); cairo_stroke (cr);
} }