Code

Refactoring SPColor to C++ and removing legacy CMYK implementation
[inkscape.git] / src / dialogs / swatches.cpp
index 900b83cc1f18c3e1905a8e60e82c188388a46245..3a41c1ec4a4629b096f828952bd921657a997711 100644 (file)
@@ -113,6 +113,9 @@ void ColorItem::_dragGetColorData( GtkWidget *widget,
                                    guint time,
                                    gpointer user_data)
 {
+    (void)widget;
+    (void)drag_context;
+    (void)time;
     static GdkAtom typeXColor = gdk_atom_intern("application/x-color", FALSE);
     static GdkAtom typeText = gdk_atom_intern("text/plain", FALSE);
 
@@ -188,6 +191,7 @@ void ColorItem::_dragGetColorData( GtkWidget *widget,
 
 static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
 {
+    (void)widget;
     ColorItem* item = reinterpret_cast<ColorItem*>(data);
     if ( item )
     {
@@ -214,18 +218,31 @@ static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
 //     return TRUE;
 // }
 
-static void bouncy( GtkWidget* widget, gpointer callback_data ) {
-    ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
-    if ( item ) {
-        item->buttonClicked(false);
+static gboolean onButtonPressed (GtkWidget *widget, GdkEventButton *event, gpointer userdata)
+{
+    (void)widget;
+    /* single click with the right mouse button? */
+    if(event->type == GDK_BUTTON_RELEASE)
+    {
+        ColorItem* item = reinterpret_cast<ColorItem*>(userdata);
+        if(item)
+        {
+            if (event->button == 1)
+            { 
+                               if(event->state & GDK_SHIFT_MASK)
+                                       item->buttonClicked(true);      /* the button was pressed with shift held down. set the stroke */
+                else item->buttonClicked(false);
+                return TRUE; /* we handled this */    
+            }
+            else if (event->button == 3)
+            {
+                item->buttonClicked(true);
+                return TRUE; /* we handled this */
+            }
+        }
     }
-}
 
-static void bouncy2( GtkWidget* widget, gint arg1, gpointer callback_data ) {
-    ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
-    if ( item ) {
-        item->buttonClicked(true);
-    }
+    return FALSE; /* we did not handle this */
 }
 
 static void dieDieDie( GtkObject *obj, gpointer user_data )
@@ -251,6 +268,11 @@ void ColorItem::_dropDataIn( GtkWidget *widget,
                              guint event_time,
                              gpointer user_data)
 {
+    (void)widget;
+    (void)drag_context;
+    (void)x;
+    (void)y;
+    (void)event_time;
 //     g_message("    droppy droppy   %d", info);
      switch (info) {
          case APP_X_INKY_COLOR:
@@ -479,15 +501,10 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::
         sigc::signal<void> type_signal_something;
 */
         g_signal_connect( G_OBJECT(newBlot->gobj()),
-                          "clicked",
-                          G_CALLBACK(bouncy),
+                          "button-release-event",
+                          G_CALLBACK(onButtonPressed),
                           this);
-
-        g_signal_connect( G_OBJECT(newBlot->gobj()),
-                          "alt-clicked",
-                          G_CALLBACK(bouncy2),
-                          this);
-
+                          
         gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
                              GDK_BUTTON1_MASK,
                              sourceColorEntries,