summaryrefslogtreecommitdiff
path: root/libcaja-private/caja-icon-canvas-item.c
diff options
context:
space:
mode:
authorWolfgang Ulbrich <[email protected]>2016-01-11 17:48:12 +0100
committerWolfgang Ulbrich <[email protected]>2016-01-13 15:07:35 +0100
commit412486b1f4c8a0a60d9aa07b39e38ed66852ae3d (patch)
treea386496e3546fad12f6aaa3e392359f8af0f712c /libcaja-private/caja-icon-canvas-item.c
parent5ec02960d6f78dd23b02af27e6f3c595ab4e99bc (diff)
downloadcaja-412486b1f4c8a0a60d9aa07b39e38ed66852ae3d.tar.bz2
caja-412486b1f4c8a0a60d9aa07b39e38ed66852ae3d.tar.xz
GTK3 icon-canvas-item: render the additional text with gtk_render_layout()
And add a style class for it. taken from: https://git.gnome.org/browse/nautilus/commit/?id=7732a6b https://git.gnome.org/browse/nautilus/commit/?id=2cb91c0
Diffstat (limited to 'libcaja-private/caja-icon-canvas-item.c')
-rw-r--r--libcaja-private/caja-icon-canvas-item.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c
index d62f2c66..69b06bee 100644
--- a/libcaja-private/caja-icon-canvas-item.c
+++ b/libcaja-private/caja-icon-canvas-item.c
@@ -2237,6 +2237,10 @@ draw_embedded_text (CajaIconCanvasItem *item,
PangoLayout *layout;
PangoContext *context;
PangoFontDescription *desc;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *widget;
+ GtkStyleContext *style_context;
+#endif
if (item->details->embedded_text == NULL ||
item->details->embedded_text_rect.width == 0 ||
@@ -2245,13 +2249,21 @@ draw_embedded_text (CajaIconCanvasItem *item,
return;
}
+#if GTK_CHECK_VERSION(3,0,0)
+ widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
+#endif
+
if (item->details->embedded_text_layout != NULL)
{
layout = g_object_ref (item->details->embedded_text_layout);
}
else
{
+#if GTK_CHECK_VERSION(3,0,0)
+ context = gtk_widget_get_pango_context (widget);
+#else
context = gtk_widget_get_pango_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas));
+#endif
layout = pango_layout_new (context);
pango_layout_set_text (layout, item->details->embedded_text, -1);
@@ -2266,10 +2278,28 @@ draw_embedded_text (CajaIconCanvasItem *item,
}
#if GTK_CHECK_VERSION(3,0,0)
+ style_context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (style_context);
+ gtk_style_context_add_class (style_context, "icon-embedded-text");
+
cairo_save (cr);
+
+ cairo_rectangle (cr,
+ x + item->details->embedded_text_rect.x,
+ y + item->details->embedded_text_rect.y,
+ item->details->embedded_text_rect.width,
+ item->details->embedded_text_rect.height);
+ cairo_clip (cr);
+
+ gtk_render_layout (style_context, cr,
+ x + item->details->embedded_text_rect.x,
+ y + item->details->embedded_text_rect.y,
+ layout);
+
+ gtk_style_context_restore (style_context);
+ cairo_restore (cr);
#else
cairo_t *cr = gdk_cairo_create (drawable);
-#endif
cairo_rectangle (cr,
x + item->details->embedded_text_rect.x,
@@ -2284,9 +2314,6 @@ draw_embedded_text (CajaIconCanvasItem *item,
y + item->details->embedded_text_rect.y);
pango_cairo_show_layout (cr, layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
#endif
}