[nautilus/gtk-style-context] Make things build with GtkStyleContext
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gtk-style-context] Make things build with GtkStyleContext
- Date: Tue, 16 Nov 2010 02:11:14 +0000 (UTC)
commit aa6266a947e73914e1e2590ffaed9cee829f23b3
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Nov 13 00:02:11 2010 -0500
Make things build with GtkStyleContext
This is just a very rough first attempt to fix the build, things
will need tweaking to render nicely.
eel/eel-editable-label.c | 46 ++++++++++---------
libnautilus-private/nautilus-icon-canvas-item.c | 5 +--
libnautilus-private/nautilus-icon-dnd.c | 7 +--
libnautilus-private/nautilus-tree-view-drag-dest.c | 8 +---
src/file-manager/fm-properties-window.c | 19 ++++++--
5 files changed, 44 insertions(+), 41 deletions(-)
---
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index 7e5c5e8..7222aec 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -1531,13 +1531,13 @@ eel_editable_label_draw (GtkWidget *widget,
cairo_t *cr)
{
EelEditableLabel *label;
- GtkStyle *style;
+ GtkStyleContext *context;
gint x, y;
g_assert (EEL_IS_EDITABLE_LABEL (widget));
label = EEL_EDITABLE_LABEL (widget);
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
eel_editable_label_ensure_layout (label, TRUE);
@@ -1546,21 +1546,15 @@ eel_editable_label_draw (GtkWidget *widget,
{
get_layout_location (label, &x, &y);
- gtk_paint_layout (style,
- cr,
- gtk_widget_get_state (widget),
- TRUE,
- widget,
- "label",
- x, y,
- label->layout);
+ gtk_render_layout (context, cr, x, y, label->layout);
if (label->selection_anchor != label->selection_end)
{
gint range[2];
const char *text;
cairo_region_t *clip;
- GtkStateType state;
+ GtkStateFlags state;
+ GdkRGBA fg, bg;
range[0] = label->selection_anchor;
range[1] = label->selection_end;
@@ -1589,14 +1583,18 @@ eel_editable_label_draw (GtkWidget *widget,
gdk_cairo_region (cr, clip);
cairo_clip (cr);
- state = GTK_STATE_SELECTED;
+ state = GTK_STATE_FLAG_SELECTED;
if (!gtk_widget_has_focus (widget))
- state = GTK_STATE_ACTIVE;
-
- gdk_cairo_set_source_color (cr, &style->base[state]);
+ state = GTK_STATE_FLAG_ACTIVE;
+
+ gtk_style_context_get (context, state,
+ "color", &fg,
+ "background-color", &bg,
+ NULL);
+ gdk_cairo_set_source_rgba (cr, &bg);
cairo_paint (cr);
- gdk_cairo_set_source_color (cr, &style->text[state]);
+ gdk_cairo_set_source_rgba (cr, &fg);
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, label->layout);
@@ -1608,9 +1606,13 @@ eel_editable_label_draw (GtkWidget *widget,
if (label->draw_outline) {
GtkAllocation allocation;
+ GdkRGBA fg;
gtk_widget_get_allocation (widget, &allocation);
- gdk_cairo_set_source_color (cr, &style->text [gtk_widget_get_state (widget)]);
+ gtk_style_context_get (context, gtk_widget_get_state_flags (widget),
+ "color", &fg,
+ NULL);
+ gdk_cairo_set_source_rgba (cr, &fg);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr, 0.5, 0.5,
allocation.width - 1,
@@ -1630,7 +1632,7 @@ eel_editable_label_realize (GtkWidget *widget)
gint attributes_mask;
GtkAllocation allocation;
GdkWindow *window;
- GtkStyle *style;
+ GtkStyleContext *context;
gtk_widget_set_realized (widget, TRUE);
label = EEL_EDITABLE_LABEL (widget);
@@ -1664,10 +1666,10 @@ eel_editable_label_realize (GtkWidget *widget)
gdk_cursor_unref (attributes.cursor);
- style = gtk_style_attach (gtk_widget_get_style (widget) , gtk_widget_get_window (widget));
- gtk_widget_set_style (widget, style);
-
- gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]);
+ gtk_widget_style_attach (widget);
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_set_background (context, gtk_widget_get_window (widget));
gtk_im_context_set_client_window (label->im_context, gtk_widget_get_window (widget));
}
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index 8e9114e..0cf4e4a 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -1285,11 +1285,8 @@ draw_label_text (NautilusIconCanvasItem *item,
}
if (!create_mask && item->details->is_highlighted_as_keyboard_focus) {
- gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)),
+ gtk_render_focus (gtk_widget_get_style_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)),
cr,
- needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
- GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas),
- "icon-container",
text_rect.x0,
text_rect.y0,
text_rect.x1 - text_rect.x0,
diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c
index 78fc182..6f8d9f4 100644
--- a/libnautilus-private/nautilus-icon-dnd.c
+++ b/libnautilus-private/nautilus-icon-dnd.c
@@ -1366,11 +1366,8 @@ drag_highlight_draw (GtkWidget *widget,
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
- gtk_paint_shadow (gtk_widget_get_style (widget),
- cr,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- widget, "dnd",
- x, y, width, height);
+ gtk_render_frame (gtk_widget_get_style_context (widget),
+ cr, x, y, width, height);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgb (cr, 0, 0, 0);
diff --git a/libnautilus-private/nautilus-tree-view-drag-dest.c b/libnautilus-private/nautilus-tree-view-drag-dest.c
index f11d075..6e65e1e 100644
--- a/libnautilus-private/nautilus-tree-view-drag-dest.c
+++ b/libnautilus-private/nautilus-tree-view-drag-dest.c
@@ -186,12 +186,8 @@ highlight_draw (GtkWidget *widget,
width = gdk_window_get_width (bin_window);
height = gdk_window_get_height (bin_window);
- gtk_paint_focus (gtk_widget_get_style (widget),
- cr,
- gtk_widget_get_state (widget),
- widget,
- "treeview-drop-indicator",
- 0, 0, width, height);
+ gtk_render_focus (gtk_widget_get_style_context (widget),
+ cr, 0, 0, width, height);
return FALSE;
}
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index e10b024..d1f718f 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -2921,7 +2921,7 @@ create_pie_widget (FMPropertiesWindow *window)
{
NautilusFile *file;
GtkTable *table;
- GtkStyle *style;
+ GtkStyleContext *context;
GtkWidget *pie_canvas;
GtkWidget *used_canvas;
GtkWidget *used_label;
@@ -2936,6 +2936,7 @@ create_pie_widget (FMPropertiesWindow *window)
gchar *uri;
GFile *location;
GFileInfo *info;
+ GdkRGBA rgba;
capacity = g_format_size_for_display (window->details->volume_capacity);
free = g_format_size_for_display (window->details->volume_free);
@@ -2947,19 +2948,29 @@ create_pie_widget (FMPropertiesWindow *window)
table = GTK_TABLE (gtk_table_new (4, 3, FALSE));
- style = gtk_rc_get_style (GTK_WIDGET(table));
+ context = gtk_widget_get_style_context (GTK_WIDGET(table));
- if (!gtk_style_lookup_color (style, "chart_color_1", &window->details->used_color)) {
+ if (!gtk_style_context_lookup_color (context, "chart_color_1", &rgba)) {
window->details->used_color.red = USED_FILL_R;
window->details->used_color.green = USED_FILL_G;
window->details->used_color.blue = USED_FILL_B;
}
+ else {
+ window->details->used_color.red = rgba.red * 65535;
+ window->details->used_color.green = rgba.green * 65535;
+ window->details->used_color.blue = rgba.blue * 65535;
+ }
- if (!gtk_style_lookup_color (style, "chart_color_2", &window->details->free_color)) {
+ if (!gtk_style_context_lookup_color (context, "chart_color_2", &rgba)) {
window->details->free_color.red = FREE_FILL_R;
window->details->free_color.green = FREE_FILL_G;
window->details->free_color.blue = FREE_FILL_B;
}
+ else {
+ window->details->free_color.red = rgba.red * 65535;
+ window->details->free_color.green = rgba.green * 65535;
+ window->details->free_color.blue = rgba.blue * 65535;
+ }
_pie_style_shade (&window->details->used_color, &window->details->used_stroke_color, 0.7);
_pie_style_shade (&window->details->free_color, &window->details->free_stroke_color, 0.7);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]