Code

guard callback, catch release event, set _rgba: fixes #1491876, #1492332
authorrwst <rwst@users.sourceforge.net>
Sun, 21 May 2006 15:50:27 +0000 (15:50 +0000)
committerrwst <rwst@users.sourceforge.net>
Sun, 21 May 2006 15:50:27 +0000 (15:50 +0000)
src/ui/widget/color-picker.cpp

index 883370aec00d63e0f5531794810be3d37a1ab5ff..f79334e317d293d94c87bce0ca409d825ac58177 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "color-picker.h"
 
+static bool _in_use = false;
+
 namespace Inkscape {
 namespace UI {
 namespace Widget {
@@ -58,6 +60,8 @@ ColorPicker::setupDialog(const Glib::ustring &title)
 
     g_signal_connect(G_OBJECT(_colorSelector), "dragged",
                          G_CALLBACK(sp_color_picker_color_mod), (void *)this);
+    g_signal_connect(G_OBJECT(_colorSelector), "released",
+                         G_CALLBACK(sp_color_picker_color_mod), (void *)this);
     g_signal_connect(G_OBJECT(_colorSelector), "changed",
                          G_CALLBACK(sp_color_picker_color_mod), (void *)this);
 
@@ -71,6 +75,8 @@ ColorPicker::setupDialog(const Glib::ustring &title)
 void
 ColorPicker::setRgba32 (guint32 rgba)
 {
+    if (_in_use) return;
+
     _preview.setRgba32 (rgba);
     _rgba = rgba;
     if (_colorSelector)
@@ -107,6 +113,9 @@ ColorPicker::on_changed (guint32)
 void
 sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp)
 {
+    if (_in_use) return;
+    else _in_use = true;
+    
     SPColor color;
     float alpha;
     csel->base->getColorAlpha(color, &alpha);
@@ -120,7 +129,9 @@ sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp)
         sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP));
 
     ptr->on_changed (rgba);
+    _in_use = false;
     ptr->_changed_signal.emit (rgba);
+    ptr->_rgba = rgba;
 }