Remove commented out code.
[geeqie.git] / src / dnd.c
index 8b5f70e..5394d82 100644 (file)
--- a/src/dnd.c
+++ b/src/dnd.c
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -17,6 +17,7 @@
 #include "collect.h"
 #include "image.h"
 #include "ui_fileops.h"
+#include "pixbuf_util.h"
 
 
 GtkTargetEntry dnd_file_drag_types[] = {
@@ -27,9 +28,10 @@ gint dnd_file_drag_types_count = 2;
 
 GtkTargetEntry dnd_file_drop_types[] = {
        { TARGET_APP_COLLECTION_MEMBER_STRING, 0, TARGET_APP_COLLECTION_MEMBER },
-       { "text/uri-list", 0, TARGET_URI_LIST }
+       { "text/uri-list", 0, TARGET_URI_LIST },
+       { "text/plain", 0, TARGET_TEXT_PLAIN },
 };
-gint dnd_file_drop_types_count = 2;
+gint dnd_file_drop_types_count = 3;
 
 
 #define DND_ICON_SIZE (options->dnd_icon_size)
@@ -37,7 +39,7 @@ gint dnd_file_drop_types_count = 2;
 
 static void pixbuf_draw_border(GdkPixbuf *pixbuf, gint w, gint h)
 {
-       gint alpha;
+       gboolean alpha;
        gint rs;
        guchar *pix;
        guchar *p;
@@ -71,9 +73,10 @@ static void pixbuf_draw_border(GdkPixbuf *pixbuf, gint w, gint h)
                }
 }
 
+/*
 static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h, guint8 val)
 {
-       gint alpha;
+       gboolean alpha;
        gint rs;
        guchar *pix;
        guchar *p;
@@ -95,11 +98,9 @@ static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h,
                        }
                }
 }
-
+*/
 void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pixbuf, gint items)
 {
-       GdkPixmap *pixmap;
-       GdkBitmap *mask;
        GdkPixbuf *dest;
        gint w, h;
        gint sw, sh;
@@ -147,22 +148,44 @@ void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pi
                lw = CLAMP(lw, 0, w - x - 1);
                lh = CLAMP(lh, 0, h - y - 1);
 
-               pixbuf_draw_rect(dest, x, y, lw, lh, 128);
+               pixbuf_draw_rect_fill(dest, x, y, lw, lh, 128, 128, 128, 255);
                }
 
-       gdk_pixbuf_render_pixmap_and_mask(dest, &pixmap, &mask, 128);
-       g_object_unref(dest);
-
        if (layout)
                {
-               gdk_draw_layout(pixmap, widget->style->black_gc, x+1, y+1, layout);
-               gdk_draw_layout(pixmap, widget->style->white_gc, x, y, layout);
+               pixbuf_draw_layout(dest, layout, NULL, x+1, y+1, 0, 0, 0, 255);
+               pixbuf_draw_layout(dest, layout, NULL, x, y, 255, 255, 255, 255);
 
                g_object_unref(G_OBJECT(layout));
                }
 
-       gtk_drag_set_icon_pixmap(context, gtk_widget_get_colormap(widget), pixmap, mask, -8, -6);
+       gtk_drag_set_icon_pixbuf(context, dest, -8, -6);
+
+       g_object_unref(dest);
+}
+
+static void dnd_set_drag_label_end_cb(GtkWidget *widget, GdkDragContext *context, gpointer data)
+{
+       GtkWidget *window = data;
+       g_signal_handlers_disconnect_by_func(widget, dnd_set_drag_label_end_cb, data);
+       gtk_widget_destroy(window);
+}
 
-       g_object_unref(pixmap);
-       if (mask) g_object_unref(mask);
+void dnd_set_drag_label(GtkWidget *widget, GdkDragContext *context, const gchar *text)
+{
+       GtkWidget *window;
+       GtkWidget *label;
+
+       window = gtk_window_new(GTK_WINDOW_POPUP);
+       gtk_widget_realize (window);
+
+       label = gtk_label_new(text);
+       gtk_container_add(GTK_CONTAINER (window), label);
+       gtk_widget_show(label);
+       gtk_drag_set_icon_widget(context, window, -15, 10);
+       g_signal_connect(G_OBJECT(widget), "drag_end",
+                        G_CALLBACK(dnd_set_drag_label_end_cb), window);
 }
+
+
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */