diff options
Diffstat (limited to 'libcaja-private')
-rw-r--r-- | libcaja-private/caja-icon-canvas-item.c | 282 | ||||
-rw-r--r-- | libcaja-private/caja-icon-canvas-item.h | 8 | ||||
-rw-r--r-- | libcaja-private/caja-icon-container.c | 16 | ||||
-rw-r--r-- | libcaja-private/caja-icon-dnd.c | 56 | ||||
-rw-r--r-- | libcaja-private/caja-tree-view-drag-dest.c | 44 |
5 files changed, 325 insertions, 81 deletions
diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index d6bba70b..e8b1762c 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -215,41 +215,57 @@ G_DEFINE_TYPE_WITH_CODE (CajaIconCanvasItem, caja_icon_canvas_item, EEL_TYPE_CAN /* private */ static void draw_label_text (CajaIconCanvasItem *item, - GdkDrawable *drawable, - gboolean create_mask, - EelIRect icon_rect); +#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); static void get_icon_canvas_rectangle (CajaIconCanvasItem *item, - EelIRect *rect); -static void emblem_layout_reset (EmblemLayout *layout, - CajaIconCanvasItem *icon_item, - EelIRect icon_rect, - gboolean is_rtl); -static gboolean emblem_layout_next (EmblemLayout *layout, - GdkPixbuf **emblem_pixbuf, - EelIRect *emblem_rect, - gboolean is_rtl); -static void draw_pixbuf (GdkPixbuf *pixbuf, - GdkDrawable *drawable, - int x, - int y); -static PangoLayout *get_label_layout (PangoLayout **layout, - CajaIconCanvasItem *item, - const char *text); + EelIRect *rect); +static void emblem_layout_reset (EmblemLayout *layout, + CajaIconCanvasItem *icon_item, + EelIRect icon_rect, + gboolean is_rtl); +static gboolean emblem_layout_next (EmblemLayout *layout, + GdkPixbuf **emblem_pixbuf, + 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); static void draw_label_layout (CajaIconCanvasItem *item, - GdkDrawable *drawable, - PangoLayout *layout, - gboolean highlight, - GdkColor *label_color, - int x, - int y); +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkDrawable *drawable, +#endif + PangoLayout *layout, + gboolean highlight, + GdkColor *label_color, + int x, + int y); static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item, - EelIRect canvas_rect, - GtkCornerType *corner); + EelIRect canvas_rect, + GtkCornerType *corner); static void draw_embedded_text (CajaIconCanvasItem *icon_item, - GdkDrawable *drawable, - int x, - int y); +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkDrawable *drawable, +#endif + int x, + int y); static void caja_icon_canvas_item_ensure_bounds_up_to_date (CajaIconCanvasItem *icon_item); @@ -538,12 +554,21 @@ 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; +#endif EelCanvas *canvas; GdkScreen *screen; int width, height; @@ -560,7 +585,11 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, 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)); +#else screen = gdk_colormap_get_screen (colormap); +#endif /* Assume we're updated so canvas item data is right */ @@ -577,10 +606,16 @@ 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); +#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 (GDK_DRAWABLE (pixmap), colormap); +#endif pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, @@ -616,12 +651,23 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, } /* draw pixbuf to mask and pixmap */ +#if GTK_CHECK_VERSION(3,0,0) + cr = cairo_create (surface); +#else cr = gdk_cairo_create (pixmap); +#endif cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_paint (cr); + +#if GTK_CHECK_VERSION(3,0,0) + draw_embedded_text (item, cr, + item_offset_x, item_offset_y); + draw_label_text (item, cr, FALSE, icon_rect); +#endif cairo_destroy (cr); +#if !GTK_CHECK_VERSION(3,0,0) *mask = gdk_pixmap_new (gdk_screen_get_root_window (screen), width, height, 1); @@ -636,10 +682,15 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, draw_label_text (item, GDK_DRAWABLE (pixmap), FALSE, icon_rect); draw_label_text (item, GDK_DRAWABLE (*mask), TRUE, icon_rect); +#endif g_object_unref (pixbuf); +#if GTK_CHECK_VERSION(3,0,0) + return surface; +#else return pixmap; +#endif } void @@ -1016,7 +1067,11 @@ make_round_rect (cairo_t *cr, static void draw_frame (CajaIconCanvasItem *item, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else GdkDrawable *drawable, +#endif guint color, gboolean create_mask, int x, @@ -1025,12 +1080,14 @@ draw_frame (CajaIconCanvasItem *item, int height) { CajaIconContainer *container; - cairo_t *cr; container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); - /* Get a cairo context */ - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); +#endif /* Set the rounded rect clip region. Magic rounding value taken * from old code. @@ -1054,8 +1111,11 @@ draw_frame (CajaIconCanvasItem *item, /* Paint into drawable now that we have set up the color and opacity */ cairo_fill (cr); - /* Clean up now that drawing is complete */ +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } /* Keep these for a bit while we work on performance of draw_or_measure_label_text. */ @@ -1363,7 +1423,11 @@ measure_label_text (CajaIconCanvasItem *item) 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) { @@ -1414,7 +1478,11 @@ draw_label_text (CajaIconCanvasItem *item, if (needs_highlight && !details->is_renaming) { draw_frame (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif 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, @@ -1427,11 +1495,24 @@ draw_label_text (CajaIconCanvasItem *item, details->is_highlighted_as_keyboard_focus)) { /* clear the underlying icons, where the text or overlaps them. */ +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); + /* FIMXEchpe draw the background here? */ + cairo_set_source_rgb (cr, 1., 1., 1.); + cairo_rectangle (cr, + text_rect.x0, + text_rect.y0, + text_rect.x1 - text_rect.x0, + text_rect.y1 - text_rect.y0); + cairo_fill (cr); + cairo_restore (cr); +#else 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); +#endif } if (container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE) @@ -1457,7 +1538,11 @@ draw_label_text (CajaIconCanvasItem *item, if (!(prelight_label && item->details->is_prelit)) { draw_frame (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif container->details->normal_color_rgba, create_mask, text_rect.x0, @@ -1468,7 +1553,11 @@ draw_label_text (CajaIconCanvasItem *item, else { draw_frame (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif container->details->prelight_color_rgba, create_mask, text_rect.x0, @@ -1483,7 +1572,12 @@ draw_label_text (CajaIconCanvasItem *item, &label_color, TRUE, needs_highlight, prelight_label & item->details->is_prelit); - draw_label_layout (item, drawable, + draw_label_layout (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else + drawable, +#endif editable_layout, needs_highlight, label_color, x, @@ -1500,7 +1594,12 @@ draw_label_text (CajaIconCanvasItem *item, &label_color, FALSE, needs_highlight, FALSE); - draw_label_layout (item, drawable, + draw_label_layout (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else + drawable, +#endif additional_layout, needs_highlight, label_color, x, @@ -1510,7 +1609,11 @@ draw_label_text (CajaIconCanvasItem *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)), +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL, NULL, GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas), @@ -1592,14 +1695,18 @@ get_knob_pixbuf (void) } static void +#if GTK_CHECK_VERSION(3,0,0) +draw_stretch_handles (CajaIconCanvasItem *item, + cairo_t *cr, +#else draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, +#endif const EelIRect *rect) { GtkWidget *widget; GdkPixbuf *knob_pixbuf; int knob_width, knob_height; double dash = { 2.0 }; - cairo_t *cr; if (!item->details->show_stretch_handles) { @@ -1608,7 +1715,11 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas); - cr = gdk_cairo_create (drawable); +#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); @@ -1624,13 +1735,22 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, rect->y1 - rect->y0 - 1); cairo_stroke (cr); - cairo_destroy (cr); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); /* draw the stretch handles themselves */ + draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y0); + 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); } @@ -1793,15 +1913,25 @@ 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) +{ + cairo_save (cr); + gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); + 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 * @@ -1967,13 +2097,16 @@ 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; - cairo_t *cr; if (item->details->embedded_text == NULL || item->details->embedded_text_rect.width == 0 || @@ -2002,7 +2135,11 @@ draw_embedded_text (CajaIconCanvasItem *item, } } - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); +#endif cairo_rectangle (cr, x + item->details->embedded_text_rect.x, @@ -2017,13 +2154,23 @@ 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 } /* 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) +#else caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) +#endif { CajaIconCanvasItem *icon_item; CajaIconCanvasItemDetails *details; @@ -2032,7 +2179,6 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkPixbuf *emblem_pixbuf, *temp_pixbuf; GdkRectangle pixbuf_rect; gboolean is_rtl; - cairo_t *cr; icon_item = CAJA_ICON_CANVAS_ITEM (item); details = icon_item->details; @@ -2053,16 +2199,28 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf); pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf); - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); gdk_cairo_rectangle (cr, &expose->area); cairo_clip (cr); +#endif gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y); gdk_cairo_rectangle (cr, &pixbuf_rect); cairo_fill (cr); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif g_object_unref (temp_pixbuf); +#if GTK_CHECK_VERSION(3,0,0) + draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0); +#else 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)); @@ -2070,14 +2228,23 @@ 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); +#else draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0); +#endif } +#if GTK_CHECK_VERSION(3,0,0) /* Draw stretching handles (if necessary). */ - draw_stretch_handles (icon_item, drawable, &icon_rect); + draw_stretch_handles (icon_item, cr, &icon_rect); /* Draw the label text. */ + draw_label_text (icon_item, cr, FALSE, icon_rect); +#else + 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" @@ -2195,17 +2362,20 @@ get_label_layout (PangoLayout **layout_cache, static void draw_label_layout (CajaIconCanvasItem *item, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else GdkDrawable *drawable, +#endif PangoLayout *layout, gboolean highlight, GdkColor *label_color, int x, int y) { - if (drawable == NULL) - { - return; - } +#if !GTK_CHECK_VERSION(3,0,0) + g_return_if_fail (drawable != NULL); +#endif if (item->details->is_renaming) { @@ -2215,7 +2385,11 @@ draw_label_layout (CajaIconCanvasItem *item, if (!highlight && (CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows)) { /* draw a drop shadow */ +#if GTK_CHECK_VERSION(3,0,0) + eel_cairo_draw_layout_with_drop_shadow (cr, +#else eel_gdk_draw_layout_with_drop_shadow (drawable, +#endif label_color, >k_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black, x, y, @@ -2223,12 +2397,20 @@ draw_label_layout (CajaIconCanvasItem *item, } else { +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else cairo_t *cr = gdk_cairo_create (drawable); +#endif gdk_cairo_set_source_color (cr, label_color); cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, layout); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } } diff --git a/libcaja-private/caja-icon-canvas-item.h b/libcaja-private/caja-icon-canvas-item.h index 27d01867..14b93b63 100644 --- a/libcaja-private/caja-icon-canvas-item.h +++ b/libcaja-private/caja-icon-canvas-item.h @@ -74,9 +74,13 @@ extern "C" { /* attributes */ void caja_icon_canvas_item_set_image (CajaIconCanvasItem *item, GdkPixbuf *image); +#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); + GdkBitmap **mask, + GdkColormap *colormap); +#endif void caja_icon_canvas_item_set_emblems (CajaIconCanvasItem *item, GList *emblem_pixbufs); void caja_icon_canvas_item_set_show_stretch_handles (CajaIconCanvasItem *item, diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 1ae2cb2a..f3e1ccf8 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -5246,7 +5246,7 @@ caja_icon_container_search_position_func (CajaIconContainer *container, cont_window = gtk_widget_get_window (GTK_WIDGET (container)); - screen = gdk_drawable_get_screen (cont_window); + screen = gdk_window_get_screen (cont_window); monitor_num = gdk_screen_get_monitor_at_window (screen, cont_window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); @@ -5256,10 +5256,10 @@ caja_icon_container_search_position_func (CajaIconContainer *container, gdk_window_get_origin (cont_window, &cont_x, &cont_y); #if GTK_CHECK_VERSION(3, 0, 0) - cont_width = gdk_window_get_width(GDK_WINDOW(cont_window)); - cont_height = gdk_window_get_height(GDK_WINDOW(cont_window)); + cont_width = gdk_window_get_width (cont_window); + cont_height = gdk_window_get_height (cont_window); #else - gdk_drawable_get_size(cont_window, &cont_width, &cont_height); + gdk_drawable_get_size (cont_window, &cont_width, &cont_height); #endif gtk_widget_size_request (search_dialog, &requisition); @@ -6110,12 +6110,17 @@ popup_menu (GtkWidget *widget) static void draw_canvas_background (EelCanvas *canvas, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr) +#else int x, int y, int width, int height) +#endif { /* Don't chain up to the parent to avoid clearing and redrawing */ } +#if !GTK_CHECK_VERSION(3,0,0) static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event) @@ -6127,6 +6132,7 @@ expose_event (GtkWidget *widget, return GTK_WIDGET_CLASS (caja_icon_container_parent_class)->expose_event (widget, event); } +#endif static AtkObject * get_accessible (GtkWidget *widget) @@ -6585,7 +6591,9 @@ caja_icon_container_class_init (CajaIconContainerClass *class) widget_class->popup_menu = popup_menu; widget_class->get_accessible = get_accessible; widget_class->style_set = style_set; +#if !GTK_CHECK_VERSION(3,0,0) widget_class->expose_event = expose_event; +#endif widget_class->grab_notify = grab_notify_cb; canvas_class = EEL_CANVAS_CLASS (class); diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 470a767e..67e0dd32 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -1495,18 +1495,23 @@ drag_begin_callback (GtkWidget *widget, GdkDragContext *context, gpointer data) { +#if GTK_CHECK_VERSION(3,0,0) + cairo_surface_t *surface; +#else CajaIconContainer *container; GdkScreen *screen; GdkColormap *colormap; GdkPixmap *pixmap; GdkBitmap *mask; + gboolean use_mask; +#endif double x1, y1, x2, y2, winx, winy; int x_offset, y_offset; int start_x, start_y; - gboolean use_mask; container = CAJA_ICON_CONTAINER (widget); +#if !GTK_CHECK_VERSION(3,0,0) screen = gtk_widget_get_screen (widget); colormap = NULL; if (gdk_screen_is_composited (screen)) @@ -1524,12 +1529,17 @@ drag_begin_callback (GtkWidget *widget, colormap = gtk_widget_get_colormap (widget); use_mask = TRUE; } +#endif start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); /* create a pixmap and mask to drag with */ +#if GTK_CHECK_VERSION(3,0,0) + surface = caja_icon_canvas_item_get_drag_surface (container->details->drag_icon->item); +#else pixmap = caja_icon_canvas_item_get_image (container->details->drag_icon->item, &mask, colormap); +#endif /* we want to drag semi-transparent pixbufs, but X is too slow dealing with stippled masks, so we had to remove the code; this comment is left as a memorial @@ -1543,6 +1553,11 @@ drag_begin_callback (GtkWidget *widget, x_offset = start_x - winx; y_offset = start_y - winy; +#if GTK_CHECK_VERSION(3,0,0) + cairo_surface_set_device_offset (surface, x_offset, y_offset); + gtk_drag_set_icon_surface (context, surface); + cairo_surface_destroy (surface); +#else if (!use_mask && pixmap != NULL) { cairo_t *cr; @@ -1559,6 +1574,7 @@ drag_begin_callback (GtkWidget *widget, colormap, pixmap, (use_mask ? mask : NULL), x_offset, y_offset); +#endif } void @@ -1593,37 +1609,50 @@ caja_icon_dnd_begin_drag (CajaIconContainer *container, } static gboolean +#if GTK_CHECK_VERSION(3,0,0) +drag_highlight_draw (GtkWidget *widget, + cairo_t *cr, + gpointer user_data) +#else drag_highlight_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) +#endif { gint x, y, width, height; GdkWindow *window; - cairo_t *cr; x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget))); y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget))); + window = gtk_widget_get_window (widget); #if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(GDK_WINDOW(gtk_widget_get_window(widget))); - height = gdk_window_get_height(GDK_WINDOW(gtk_widget_get_window(widget))); -#else - gdk_drawable_get_size(gtk_widget_get_window(widget), &width, &height); -#endif + width = gdk_window_get_width (window); + height = gdk_window_get_height (window); - window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); + gtk_paint_shadow (gtk_widget_get_style (widget), + cr, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + widget, "dnd", + x, y, width, height); +#else + gdk_drawable_get_size(window, &width, &height); gtk_paint_shadow (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, "dnd", x, y, width, height); - cr = gdk_cairo_create (window); + cairo_t *cr = gdk_cairo_create (window); +#endif + cairo_set_line_width (cr, 1.0); cairo_set_source_rgb (cr, 0, 0, 0); cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1); cairo_stroke (cr); +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif return FALSE; } @@ -1682,8 +1711,13 @@ start_dnd_highlight (GtkWidget *widget) if (!dnd_info->highlighted) { dnd_info->highlighted = TRUE; +#if GTK_CHECK_VERSION(3,0,0) + g_signal_connect_after (widget, "draw", + G_CALLBACK (drag_highlight_draw), +#else g_signal_connect_after (widget, "expose_event", G_CALLBACK (drag_highlight_expose), +#endif NULL); dnd_highlight_queue_redraw (widget); } @@ -1699,7 +1733,11 @@ stop_dnd_highlight (GtkWidget *widget) if (dnd_info->highlighted) { g_signal_handlers_disconnect_by_func (widget, +#if GTK_CHECK_VERSION(3,0,0) + drag_highlight_draw, +#else drag_highlight_expose, +#endif NULL); dnd_highlight_queue_redraw (widget); dnd_info->highlighted = FALSE; diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c index 1c25c452..d7a8d2b6 100644 --- a/libcaja-private/caja-tree-view-drag-dest.c +++ b/libcaja-private/caja-tree-view-drag-dest.c @@ -186,35 +186,42 @@ remove_expand_timeout (CajaTreeViewDragDest *dest) } static gboolean +#if GTK_CHECK_VERSION(3,0,0) +highlight_draw (GtkWidget *widget, + cairo_t *cr, + gpointer data) +#else highlight_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) +#endif { GdkWindow *bin_window; int width; int height; - if (gtk_widget_is_drawable (widget)) - { - bin_window = - gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); + /* FIXMEchpe: is bin window right here??? */ + bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); #if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(GDK_WINDOW(bin_window)); - height = gdk_window_get_height(GDK_WINDOW(bin_window)); + width = gdk_window_get_width(bin_window); + height = gdk_window_get_height(bin_window); #else - gdk_drawable_get_size(bin_window, &width, &height); + gdk_drawable_get_size(bin_window, &width, &height); #endif - - gtk_paint_focus (gtk_widget_get_style (widget), - bin_window, - gtk_widget_get_state (widget), - NULL, - widget, - "treeview-drop-indicator", - 0, 0, width, height); - } + gtk_paint_focus (gtk_widget_get_style (widget), +#if GTK_CHECK_VERSION(3,0,0) + cr, + gtk_widget_get_state (widget), +#else + bin_window, + gtk_widget_get_state (widget), + NULL, +#endif + widget, + "treeview-drop-indicator", + 0, 0, width, height); return FALSE; } @@ -234,8 +241,13 @@ set_widget_highlight (CajaTreeViewDragDest *dest, gboolean highlight) { dest->details->highlight_id = g_signal_connect_object (dest->details->tree_view, +#if GTK_CHECK_VERSION(3,0,0) + "draw", + G_CALLBACK (highlight_draw), +#else "expose_event", G_CALLBACK (highlight_expose), +#endif dest, 0); gtk_widget_queue_draw (GTK_WIDGET (dest->details->tree_view)); } |