Code

draw red X icon while dragging the "remove color" item
authorJucaBlues <JucaBlues@users.sourceforge.net>
Tue, 27 Jan 2009 21:05:05 +0000 (21:05 +0000)
committerJucaBlues <JucaBlues@users.sourceforge.net>
Tue, 27 Jan 2009 21:05:05 +0000 (21:05 +0000)
src/dialogs/swatches.cpp
src/dialogs/swatches.h

index 13c65f7075b59979216a1759389aa224ad97774a..1a0db9a8a1c0c571b9100c70824a2facf8b24bd4 100644 (file)
@@ -198,6 +198,23 @@ static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
     ColorItem* item = reinterpret_cast<ColorItem*>(data);
     if ( item )
     {
+        if (item->isRemove()){
+            GError *error = NULL;
+            gchar *filepath = (gchar *) g_strdup_printf("%s/remove-color.png", INKSCAPE_PIXMAPDIR);
+            gsize bytesRead = 0;
+            gsize bytesWritten = 0;
+            gchar *localFilename = g_filename_from_utf8( filepath,
+                                                 -1,
+                                                 &bytesRead,
+                                                 &bytesWritten,
+                                                 &error);
+            GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_scale(localFilename, 32, 24, FALSE, &error);
+            g_free(localFilename);
+            g_free(filepath);
+            gtk_drag_set_icon_pixbuf( dc, pixbuf, 0, 0 );
+            return;
+        }
+
         Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, 32, 24 );
         guint32 fillWith = (0xff000000 & (item->def.getR() << 24))
                          | (0x00ff0000 & (item->def.getG() << 16))
index cc0cf89561681ed8591774c0942e5a029bf53e50..00c73ff8497e2b5e1de7b1722a677eafa90f7f07 100644 (file)
@@ -44,7 +44,7 @@ public:
                                     ::PreviewSize size,
                                     guint ratio);
     void buttonClicked(bool secondary = false);
-
+    bool isRemove(){ return _isRemove; }
     ColorDef def;
 
 private: