summaryrefslogtreecommitdiff
path: root/libcaja-private/caja-icon-canvas-item.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcaja-private/caja-icon-canvas-item.c')
-rw-r--r--libcaja-private/caja-icon-canvas-item.c568
1 files changed, 7 insertions, 561 deletions
diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c
index dbe6a7ff..afca12bd 100644
--- a/libcaja-private/caja-icon-canvas-item.c
+++ b/libcaja-private/caja-icon-canvas-item.c
@@ -194,11 +194,7 @@ G_DEFINE_TYPE_WITH_CODE (CajaIconCanvasItem, caja_icon_canvas_item, EEL_TYPE_CAN
/* private */
static void draw_label_text (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
-#else
- GdkDrawable *drawable,
-#endif
gboolean create_mask,
EelIRect icon_rect);
static void measure_label_text (CajaIconCanvasItem *item);
@@ -213,34 +209,18 @@ static gboolean emblem_layout_next (EmblemLayout
EelIRect *emblem_rect,
gboolean is_rtl);
static void draw_pixbuf (GdkPixbuf *pixbuf,
-#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
-#else
- GdkDrawable *drawable,
-#endif
int x,
int y);
static PangoLayout *get_label_layout (PangoLayout **layout,
CajaIconCanvasItem *item,
const char *text);
-#if !GTK_CHECK_VERSION(3,0,0)
-static void draw_label_layout (CajaIconCanvasItem *item,
- GdkDrawable *drawable,
- PangoLayout *layout,
- gboolean highlight,
- GdkColor *label_color,
- int x,
- int y);
-#endif
+
static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item,
EelIRect canvas_rect,
GtkCornerType *corner);
static void draw_embedded_text (CajaIconCanvasItem *icon_item,
-#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
-#else
- GdkDrawable *drawable,
-#endif
int x,
int y);
@@ -512,22 +492,11 @@ caja_icon_canvas_item_get_property (GObject *object,
}
}
-#if GTK_CHECK_VERSION(3,0,0)
cairo_surface_t *
caja_icon_canvas_item_get_drag_surface (CajaIconCanvasItem *item)
-#else
-GdkPixmap *
-caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
- GdkBitmap **mask,
- GdkColormap *colormap)
-#endif
{
-#if GTK_CHECK_VERSION(3,0,0)
cairo_surface_t *surface;
-#else
- GdkPixmap *pixmap;
- GdkPixbuf *pixbuf;
-#endif
+
EelCanvas *canvas;
GdkScreen *screen;
int width, height;
@@ -539,22 +508,16 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
double item_x, item_y;
gboolean is_rtl;
cairo_t *cr;
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context;
-#endif
g_return_val_if_fail (CAJA_IS_ICON_CANVAS_ITEM (item), NULL);
canvas = EEL_CANVAS_ITEM (item)->canvas;
-#if GTK_CHECK_VERSION(3,0,0)
screen = gtk_widget_get_screen (GTK_WIDGET (canvas));
context = gtk_widget_get_style_context (GTK_WIDGET (canvas));
gtk_style_context_save (context);
gtk_style_context_add_class (context, "caja-canvas-item");
-#else
- screen = gdk_colormap_get_screen (colormap);
-#endif
/* Assume we're updated so canvas item data is right */
@@ -571,7 +534,6 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
width = EEL_CANVAS_ITEM (item)->x2 - EEL_CANVAS_ITEM (item)->x1;
height = EEL_CANVAS_ITEM (item)->y2 - EEL_CANVAS_ITEM (item)->y1;
-#if GTK_CHECK_VERSION(3,0,0)
surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
@@ -580,25 +542,7 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
gtk_render_icon (context, cr, item->details->pixbuf,
item_offset_x, item_offset_y);
-#else
- pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
- width, height,
- gdk_visual_get_depth (gdk_colormap_get_visual (colormap)));
- gdk_drawable_set_colormap (pixmap, colormap);
-
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE,
- gdk_pixbuf_get_bits_per_sample (item->details->pixbuf),
- width, height);
- gdk_pixbuf_fill (pixbuf, 0x00000000);
-
- gdk_pixbuf_composite (item->details->pixbuf, pixbuf,
- item_offset_x, item_offset_y,
- gdk_pixbuf_get_width (item->details->pixbuf),
- gdk_pixbuf_get_height (item->details->pixbuf),
- item_offset_x, item_offset_y, 1.0, 1.0,
- GDK_INTERP_BILINEAR, 255);
-#endif
+
icon_rect.x0 = item_offset_x;
icon_rect.y0 = item_offset_y;
@@ -608,7 +552,7 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
is_rtl = caja_icon_container_is_layout_rtl (CAJA_ICON_CONTAINER (canvas));
emblem_layout_reset (&emblem_layout, item, icon_rect, is_rtl);
-#if GTK_CHECK_VERSION(3,0,0)
+
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
{
gdk_cairo_set_source_pixbuf (cr, emblem_pixbuf, emblem_rect.x0, emblem_rect.y0);
@@ -626,44 +570,7 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
gtk_style_context_restore (context);
return surface;
-#else
- while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
- {
- gdk_pixbuf_composite (emblem_pixbuf, pixbuf,
- emblem_rect.x0, emblem_rect.y0,
- gdk_pixbuf_get_width (emblem_pixbuf),
- gdk_pixbuf_get_height (emblem_pixbuf),
- emblem_rect.x0, emblem_rect.y0,
- 1.0, 1.0,
- GDK_INTERP_BILINEAR, 255);
- }
-
- /* draw pixbuf to mask and pixmap */
- cr = gdk_cairo_create (pixmap);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
- *mask = gdk_pixmap_new (gdk_screen_get_root_window (screen),
- width, height,
- 1);
- cr = gdk_cairo_create (*mask);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- draw_embedded_text (item, pixmap,
- item_offset_x, item_offset_y);
-
- draw_label_text (item, pixmap, FALSE, icon_rect);
- draw_label_text (item, *mask, TRUE, icon_rect);
-
- g_object_unref (pixbuf);
-
- return pixmap;
-#endif
}
void
@@ -996,85 +903,7 @@ in_single_click_mode (void)
return click_policy_auto_value == CAJA_CLICK_POLICY_SINGLE;
}
-#if !GTK_CHECK_VERSION(3,0,0)
-/* Utility routine to create a rectangle with rounded corners.
- * This could possibly move to Eel as a general purpose routine.
- */
-static void
-make_round_rect (cairo_t *cr,
- double x,
- double y,
- double width,
- double height,
- double radius)
-{
- double cx, cy;
-
- width -= 2 * radius;
- height -= 2 * radius;
-
- cairo_move_to (cr, x + radius, y);
-
- cairo_rel_line_to (cr, width, 0.0);
-
- cairo_get_current_point (cr, &cx, &cy);
- cairo_arc (cr, cx, cy + radius, radius, 3.0 * G_PI_2, 0);
-
- cairo_rel_line_to (cr, 0.0, height);
-
- cairo_get_current_point (cr, &cx, &cy);
- cairo_arc (cr, cx - radius, cy, radius, 0, G_PI_2);
-
- cairo_rel_line_to (cr, - width, 0.0);
-
- cairo_get_current_point (cr, &cx, &cy);
- cairo_arc (cr, cx, cy - radius, radius, G_PI_2, G_PI);
-
- cairo_rel_line_to (cr, 0.0, -height);
-
- cairo_get_current_point (cr, &cx, &cy);
- cairo_arc (cr, cx + radius, cy, radius, G_PI, 3.0 * G_PI_2);
-
- cairo_close_path (cr);
-}
-
-static void
-draw_frame (CajaIconCanvasItem *item,
- GdkDrawable *drawable,
- guint color,
- gboolean create_mask,
- int x,
- int y,
- int width,
- int height)
-{
- cairo_t *cr = gdk_cairo_create (drawable);
-
- /* Set the rounded rect clip region. Magic rounding value taken
- * from old code.
- */
- make_round_rect (cr, x, y, width, height, 5);
-
- if (create_mask)
- {
- /* Dunno how to do this with cairo...
- * It used to threshold the rendering so that the
- * bitmask didn't show white where alpha < 0.5
- */
- }
-
- cairo_set_source_rgba (cr,
- EEL_RGBA_COLOR_GET_R (color) / 255.0,
- EEL_RGBA_COLOR_GET_G (color) / 255.0,
- EEL_RGBA_COLOR_GET_B (color) / 255.0,
- EEL_RGBA_COLOR_GET_A (color) / 255.0);
- /* Paint into drawable now that we have set up the color and opacity */
- cairo_fill (cr);
-
- cairo_destroy (cr);
-}
-#endif
/* Keep these for a bit while we work on performance of draw_or_measure_label_text. */
/*
#define PERFORMANCE_TEST_DRAW_DISABLE
@@ -1373,7 +1202,6 @@ measure_label_text (CajaIconCanvasItem *item)
static void
draw_label_text (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
gboolean create_mask,
EelIRect icon_rect)
@@ -1554,177 +1382,6 @@ draw_label_text (CajaIconCanvasItem *item,
g_object_unref (additional_layout);
}
}
-#else
- GdkDrawable *drawable,
- gboolean create_mask,
- EelIRect icon_rect)
-{
- EelCanvasItem *canvas_item;
- CajaIconCanvasItemDetails *details;
- CajaIconContainer *container;
- PangoLayout *editable_layout;
- PangoLayout *additional_layout;
- GdkColor *label_color;
- gboolean have_editable, have_additional;
- gboolean needs_frame, needs_highlight, prelight_label, is_rtl_label_beside;
- EelIRect text_rect;
- int x;
- int max_text_width;
-
-#ifdef PERFORMANCE_TEST_DRAW_DISABLE
- return;
-#endif
-
- details = item->details;
-
- measure_label_text (item);
- if (details->text_height == 0 ||
- details->text_width == 0)
- {
- return;
- }
-
- container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas);
- canvas_item = EEL_CANVAS_ITEM (item);
-
- text_rect = compute_text_rectangle (item, icon_rect, TRUE, BOUNDS_USAGE_FOR_DISPLAY);
-
- needs_highlight = details->is_highlighted_for_selection || details->is_highlighted_for_drop;
- is_rtl_label_beside = caja_icon_container_is_layout_rtl (container) &&
- container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE;
-
- editable_layout = NULL;
- additional_layout = NULL;
-
- have_editable = details->editable_text != NULL && details->editable_text[0] != '\0';
- have_additional = details->additional_text != NULL && details->additional_text[0] != '\0';
- g_assert (have_editable || have_additional);
-
- max_text_width = floor (caja_icon_canvas_item_get_max_text_width (item));
-
- if (needs_highlight && !details->is_renaming)
- {
- draw_frame (item,
- drawable,
- gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
- create_mask,
- is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0,
- text_rect.y0,
- is_rtl_label_beside ? text_rect.x1 - text_rect.x0 - item->details->text_dx : text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
- }
- else if (!needs_highlight && !details->is_renaming &&
- (details->is_prelit ||
- details->is_highlighted_as_keyboard_focus))
- {
- /* clear the underlying icons, where the text or overlaps them. */
- gdk_window_clear_area (gtk_layout_get_bin_window (&EEL_CANVAS (container)->layout),
- text_rect.x0,
- text_rect.y0,
- text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
- }
-
- if (container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE)
- {
- x = text_rect.x0 + 2;
- }
- else
- {
- x = text_rect.x0 + ((text_rect.x1 - text_rect.x0) - max_text_width) / 2;
- }
-
- if (have_editable)
- {
- editable_layout = get_label_layout (&item->details->editable_text_layout, item, item->details->editable_text);
- prepare_pango_layout_for_draw (item, editable_layout);
-
- gtk_widget_style_get (GTK_WIDGET (container),
- "frame_text", &needs_frame,
- "activate_prelight_icon_label", &prelight_label,
- NULL);
- if (needs_frame && !needs_highlight && details->text_width > 0 && details->text_height > 0)
- {
- if (!(prelight_label && item->details->is_prelit))
- {
- draw_frame (item,
- drawable,
- container->details->normal_color_rgba,
- create_mask,
- text_rect.x0,
- text_rect.y0,
- text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
- }
- else
- {
- draw_frame (item,
- drawable,
- container->details->prelight_color_rgba,
- create_mask,
- text_rect.x0,
- text_rect.y0,
- text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
- }
- }
-
- caja_icon_container_get_label_color
- (CAJA_ICON_CONTAINER (canvas_item->canvas),
- &label_color, TRUE, needs_highlight,
- prelight_label & item->details->is_prelit);
-
- draw_label_layout (item,
- drawable,
- editable_layout, needs_highlight,
- label_color,
- x,
- text_rect.y0 + TEXT_BACK_PADDING_Y);
- }
-
- if (have_additional)
- {
- additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text);
- prepare_pango_layout_for_draw (item, additional_layout);
-
- caja_icon_container_get_label_color
- (CAJA_ICON_CONTAINER (canvas_item->canvas),
- &label_color, FALSE, needs_highlight,
- FALSE);
-
- draw_label_layout (item,
- drawable,
- additional_layout, needs_highlight,
- label_color,
- x,
- text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y);
- }
-
- if (!create_mask && item->details->is_highlighted_as_keyboard_focus)
- {
- gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)),
- drawable,
- needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
- NULL,
- GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas),
- "icon-container",
- text_rect.x0,
- text_rect.y0,
- text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
- }
-
- if (editable_layout != NULL)
- {
- g_object_unref (editable_layout);
- }
-
- if (additional_layout != NULL)
- {
- g_object_unref (additional_layout);
- }
-}
-#endif
void
caja_icon_canvas_item_set_is_visible (CajaIconCanvasItem *item,
@@ -1787,21 +1444,15 @@ get_knob_pixbuf (void)
static void
draw_stretch_handles (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
-#else
- GdkDrawable *drawable,
-#endif
const EelIRect *rect)
{
GtkWidget *widget;
GdkPixbuf *knob_pixbuf;
int knob_width, knob_height;
double dash = { 2.0 };
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *style;
GdkRGBA color;
-#endif
if (!item->details->show_stretch_handles)
{
@@ -1809,26 +1460,18 @@ draw_stretch_handles (CajaIconCanvasItem *item,
}
widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
-#if GTK_CHECK_VERSION(3,0,0)
style = gtk_widget_get_style_context (widget);
-#endif
-#if GTK_CHECK_VERSION(3,0,0)
cairo_save (cr);
-#else
- cairo_t *cr = gdk_cairo_create (drawable);
-#endif
+
knob_pixbuf = get_knob_pixbuf ();
knob_width = gdk_pixbuf_get_width (knob_pixbuf);
knob_height = gdk_pixbuf_get_height (knob_pixbuf);
/* first draw the box */
-#if GTK_CHECK_VERSION(3,0,0)
gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &color);
gdk_cairo_set_source_rgba (cr, &color);
-#else
- cairo_set_source_rgb (cr, 0, 0, 0);
-#endif
+
cairo_set_dash (cr, &dash, 1, 0);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr,
@@ -1838,7 +1481,6 @@ draw_stretch_handles (CajaIconCanvasItem *item,
rect->y1 - rect->y0 - 1);
cairo_stroke (cr);
-#if GTK_CHECK_VERSION(3,0,0)
cairo_restore (cr);
/* draw the stretch handles themselves */
@@ -1846,14 +1488,6 @@ draw_stretch_handles (CajaIconCanvasItem *item,
draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y1 - knob_height);
draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y0);
draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y1 - knob_height);
-#else
- cairo_destroy (cr);
-
- draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y0);
- draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height);
- draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0);
- draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height);
-#endif
g_object_unref (knob_pixbuf);
}
@@ -2016,7 +1650,6 @@ emblem_layout_next (EmblemLayout *layout,
}
static void
-#if GTK_CHECK_VERSION(3,0,0)
draw_pixbuf (GdkPixbuf *pixbuf,
cairo_t *cr,
int x, int y)
@@ -2026,15 +1659,6 @@ draw_pixbuf (GdkPixbuf *pixbuf,
cairo_paint (cr);
cairo_restore (cr);
}
-#else
-draw_pixbuf (GdkPixbuf *pixbuf, GdkDrawable *drawable, int x, int y)
-{
- cairo_t *cr = gdk_cairo_create (drawable);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
- cairo_paint (cr);
- cairo_destroy (cr);
-}
-#endif
/* shared code to highlight or dim the passed-in pixbuf */
static GdkPixbuf *
@@ -2045,12 +1669,8 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
CajaIconContainer *container;
GdkPixbuf *temp_pixbuf, *old_pixbuf, *audio_pixbuf;
int emblem_size;
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *style;
GdkRGBA color;
-#else
- guint render_mode, saturation, brightness, lighten;
-#endif
temp_pixbuf = icon_item->details->pixbuf;
canvas = EEL_CANVAS_ITEM(icon_item)->canvas;
@@ -2063,28 +1683,8 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
{
old_pixbuf = temp_pixbuf;
-#if GTK_CHECK_VERSION(3,0,0)
temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
g_object_unref (old_pixbuf);
-#else
- gtk_widget_style_get (GTK_WIDGET (container),
- "prelight_icon_render_mode", &render_mode,
- "prelight_icon_saturation", &saturation,
- "prelight_icon_brightness", &brightness,
- "prelight_icon_lighten", &lighten,
- NULL);
-
- if (render_mode > 0 || saturation < 255 || brightness < 255)
- {
- temp_pixbuf = eel_gdk_pixbuf_render (temp_pixbuf,
- render_mode,
- saturation,
- brightness,
- lighten,
- container->details->prelight_icon_color_rgba);
- g_object_unref (old_pixbuf);
- }
-#endif
/* FIXME bugzilla.gnome.org 42471: This hard-wired image is inappropriate to
* this level of code, which shouldn't know that the
@@ -2134,7 +1734,6 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
if (icon_item->details->is_highlighted_for_selection
|| icon_item->details->is_highlighted_for_drop)
{
-#if GTK_CHECK_VERSION(3,0,0)
style = gtk_widget_get_style_context (GTK_WIDGET (canvas));
if (gtk_widget_has_focus (GTK_WIDGET (canvas))) {
@@ -2145,50 +1744,10 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
old_pixbuf = temp_pixbuf;
temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, &color);
-#else
- guint color;
-
- old_pixbuf = temp_pixbuf;
-
- color = gtk_widget_has_focus (GTK_WIDGET (canvas)) ? CAJA_ICON_CONTAINER (canvas)->details->highlight_color_rgba : CAJA_ICON_CONTAINER (canvas)->details->active_color_rgba;
-
- temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf,
- EEL_RGBA_COLOR_GET_R (color),
- EEL_RGBA_COLOR_GET_G (color),
- EEL_RGBA_COLOR_GET_B (color));
-#endif
g_object_unref (old_pixbuf);
}
-#if !GTK_CHECK_VERSION(3,0,0)
- if (!icon_item->details->is_active
- && !icon_item->details->is_prelit
- && !icon_item->details->is_highlighted_for_selection
- && !icon_item->details->is_highlighted_for_drop)
- {
- old_pixbuf = temp_pixbuf;
-
- gtk_widget_style_get (GTK_WIDGET (container),
- "normal_icon_render_mode", &render_mode,
- "normal_icon_saturation", &saturation,
- "normal_icon_brightness", &brightness,
- "normal_icon_lighten", &lighten,
- NULL);
- if (render_mode > 0 || saturation < 255 || brightness < 255)
- {
- /* if theme requests colorization */
- temp_pixbuf = eel_gdk_pixbuf_render (temp_pixbuf,
- render_mode,
- saturation,
- brightness,
- lighten,
- container->details->normal_icon_color_rgba);
- g_object_unref (old_pixbuf);
- }
- }
-#endif
-
return temp_pixbuf;
}
@@ -2223,20 +1782,14 @@ map_pixbuf (CajaIconCanvasItem *icon_item)
static void
draw_embedded_text (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
-#else
- GdkDrawable *drawable,
-#endif
int x, int y)
{
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,9 +1798,7 @@ 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)
{
@@ -2255,11 +1806,7 @@ draw_embedded_text (CajaIconCanvasItem *item,
}
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);
@@ -2273,7 +1820,6 @@ 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");
@@ -2294,54 +1840,25 @@ draw_embedded_text (CajaIconCanvasItem *item,
gtk_style_context_restore (style_context);
cairo_restore (cr);
-#else
- cairo_t *cr = gdk_cairo_create (drawable);
-
- 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);
-
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_move_to (cr,
- x + item->details->embedded_text_rect.x,
- y + item->details->embedded_text_rect.y);
- pango_cairo_show_layout (cr, layout);
-
- cairo_destroy (cr);
-#endif
}
/* Draw the icon item for non-anti-aliased mode. */
static void
-#if GTK_CHECK_VERSION(3,0,0)
caja_icon_canvas_item_draw (EelCanvasItem *item,
cairo_t *cr,
cairo_region_t *region)
{
CajaIconContainer *container;
-#else
-caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
- GdkEventExpose *expose)
-{
-#endif
CajaIconCanvasItem *icon_item;
CajaIconCanvasItemDetails *details;
EelIRect icon_rect, emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf, *temp_pixbuf;
-#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context;
container = CAJA_ICON_CONTAINER (item->canvas);
gboolean is_rtl;
-#else
- GdkRectangle pixbuf_rect;
- gboolean is_rtl;
-#endif
icon_item = CAJA_ICON_CANVAS_ITEM (item);
details = icon_item->details;
@@ -2351,14 +1868,12 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
return;
}
-#if GTK_CHECK_VERSION(3,0,0)
context = gtk_widget_get_style_context (GTK_WIDGET (container));
gtk_style_context_save (context);
gtk_style_context_add_class (context, "caja-canvas-item");
-#endif
icon_rect = icon_item->details->canvas_rect;
-#if GTK_CHECK_VERSION(3,0,0)
+
temp_pixbuf = map_pixbuf (icon_item);
gtk_render_icon (context, cr,
@@ -2367,26 +1882,6 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
g_object_unref (temp_pixbuf);
draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0);
-#else
- /* if the pre-lit or selection flag is set, make a pre-lit or darkened pixbuf and draw that instead */
- /* and colorize normal pixbuf if rc wants that */
- temp_pixbuf = map_pixbuf (icon_item);
- pixbuf_rect.x = icon_rect.x0;
- pixbuf_rect.y = icon_rect.y0;
- pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf);
- pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf);
-
- cairo_t *cr = gdk_cairo_create (drawable);
- gdk_cairo_rectangle (cr, &expose->area);
- cairo_clip (cr);
- gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y);
- gdk_cairo_rectangle (cr, &pixbuf_rect);
- cairo_fill (cr);
- cairo_destroy (cr);
- g_object_unref (temp_pixbuf);
-
- draw_embedded_text (icon_item, drawable, icon_rect.x0, icon_rect.y0);
-#endif
is_rtl = caja_icon_container_is_layout_rtl (CAJA_ICON_CONTAINER (item->canvas));
@@ -2394,7 +1889,6 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
emblem_layout_reset (&emblem_layout, icon_item, icon_rect, is_rtl);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
{
-#if GTK_CHECK_VERSION(3,0,0)
draw_pixbuf (emblem_pixbuf, cr, emblem_rect.x0, emblem_rect.y0);
}
@@ -2405,13 +1899,6 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
draw_label_text (icon_item, cr, FALSE, icon_rect);
gtk_style_context_restore (context);
-#else
- draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0);
- }
-
- draw_stretch_handles (icon_item, drawable, &icon_rect);
- draw_label_text (icon_item, drawable, FALSE, icon_rect);
-#endif
}
#define ZERO_WIDTH_SPACE "\xE2\x80\x8B"
@@ -2527,45 +2014,8 @@ get_label_layout (PangoLayout **layout_cache,
return layout;
}
-#if !GTK_CHECK_VERSION(3,0,0)
-static void
-draw_label_layout (CajaIconCanvasItem *item,
- GdkDrawable *drawable,
- PangoLayout *layout,
- gboolean highlight,
- GdkColor *label_color,
- int x,
- int y)
-{
- g_return_if_fail (drawable != NULL);
-
- if (item->details->is_renaming)
- {
- return;
- }
-
- if (!highlight && (CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows))
- {
- /* draw a drop shadow */
- eel_gdk_draw_layout_with_drop_shadow (drawable,
- label_color,
- &gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black,
- x, y,
- layout);
- }
- else
- {
- cairo_t *cr = gdk_cairo_create (drawable);
- gdk_cairo_set_source_color (cr, label_color);
- cairo_move_to (cr, x, y);
- pango_cairo_show_layout (cr, layout);
- cairo_destroy (cr);
- }
-}
-#endif
/* handle events */
-
static int
caja_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event)
{
@@ -2591,11 +2041,7 @@ caja_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event)
cursor = gdk_cursor_new_for_display (gdk_display_get_default(),
GDK_HAND2);
gdk_window_set_cursor (((GdkEventAny *)event)->window, cursor);
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref (cursor);
-#else
- gdk_cursor_unref (cursor);
-#endif
}
/* FIXME bugzilla.gnome.org 42473: