summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2006-03-10 09:29:33 +0000
committerjoncruz <joncruz@users.sourceforge.net>2006-03-10 09:29:33 +0000
commit9cfd3fd093919149a6959acc8f91fa735f671f0c (patch)
treea2ca35dcab4ec8a73711c42548e22047a5cd3bf2 /src
parentInitial cut of color drag-n-drop to items on canvas. (diff)
downloadinkscape-9cfd3fd093919149a6959acc8f91fa735f671f0c.tar.gz
inkscape-9cfd3fd093919149a6959acc8f91fa735f671f0c.zip
Changed color dragging to have a color preview.
(bzr r221)
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/swatches.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp
index 3063e2280..5ed09b3e0 100644
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
@@ -18,6 +18,7 @@
#include <gtk/gtkdnd.h>
#include <glibmm/i18n.h>
+#include <gdkmm/pixbuf.h>
#include "inkscape.h"
#include "document.h"
#include "desktop-handles.h"
@@ -114,6 +115,21 @@ static void dragGetColorData( GtkWidget *widget,
}
}
+static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
+{
+ ColorItem* item = reinterpret_cast<ColorItem*>(data);
+ if ( item )
+ {
+ Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, 32, 24 );
+ guint32 fillWith = (0xff000000 & (item->_r << 24))
+ | (0x00ff0000 & (item->_g << 16))
+ | (0x0000ff00 & (item->_b << 8));
+ thumb->fill( fillWith );
+ gtk_drag_set_icon_pixbuf( dc, thumb->gobj(), 0, 0 );
+ }
+
+}
+
//"drag-drop"
gboolean dragDropColorData( GtkWidget *widget,
GdkDragContext *drag_context,
@@ -207,6 +223,11 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built
this);
g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "drag-begin",
+ G_CALLBACK(dragBegin),
+ this );
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
"drag-drop",
G_CALLBACK(dragDropColorData),
this);