Code

Make color drag to minibar only work when a styled item is selected.
authorjoncruz <joncruz@users.sourceforge.net>
Sat, 4 Mar 2006 10:11:11 +0000 (10:11 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Sat, 4 Mar 2006 10:11:11 +0000 (10:11 +0000)
ChangeLog
src/ui/widget/selected-style.cpp
src/ui/widget/selected-style.h

index bcd28a2f8645228088512cdeabb02151dfd090e1..aef3dcd009a7f8c138bd4848781abee9ed2a29a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-04  Jon A. Cruz  <jon@joncruz.org>
+       * src/ui/widget/selected-style.h, src/ui/widget/selected-style.cpp:
+
+         Style minibar now only accepts color drag-n-drop when not N/A.
+         Final tweak for completing RFE #1429027.
+       
 2006-02-28  Jon A. Cruz  <jon@joncruz.org>
        * src/ui/widget/selected-style.h, src/ui/widget/selected-style.cpp:
 
index 8a5aa1f46b329ddfb1ced1bfd9ad9ec98ebb4ce2..be707e15ee45b5487c9acb7b6770fa1335d82655 100644 (file)
@@ -111,8 +111,8 @@ SelectedStyle::SelectedStyle(bool layout)
 
       _tooltips (),
 
-      _dropF(0),
-      _dropS(0)
+      _drop((void*[]){0,0}),
+      _dropEnabled((bool[]){false, false})
 {
     _fill_label.set_alignment(0.0, 0.5);
     _fill_label.set_padding(0, 0);
@@ -331,35 +331,23 @@ SelectedStyle::SelectedStyle(bool layout)
     sp_set_font_size_smaller (GTK_WIDGET(_fill_label.gobj()));
     sp_set_font_size_smaller (GTK_WIDGET(_stroke_label.gobj()));
 
-    _dropF = new DropTracker();
-    ((DropTracker*)_dropF)->parent = this;
-    ((DropTracker*)_dropF)->item = SS_FILL;
+    _drop[SS_FILL] = new DropTracker();
+    ((DropTracker*)_drop[SS_FILL])->parent = this;
+    ((DropTracker*)_drop[SS_FILL])->item = SS_FILL;
 
-    _dropS = new DropTracker();
-    ((DropTracker*)_dropS)->parent = this;
-    ((DropTracker*)_dropS)->item = SS_STROKE;
+    _drop[SS_STROKE] = new DropTracker();
+    ((DropTracker*)_drop[SS_STROKE])->parent = this;
+    ((DropTracker*)_drop[SS_STROKE])->item = SS_STROKE;
 
-    {
-        gtk_drag_dest_set(GTK_WIDGET(_stroke_place.gobj()),
-                          GTK_DEST_DEFAULT_ALL,
-                          ui_drop_target_entries,
-                          nui_drop_target_entries,
-                          GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
-        g_signal_connect(_stroke_place.gobj(),
-                         "drag_data_received",
-                         G_CALLBACK(dragDataReceived),
-                         _dropS);
-
-        gtk_drag_dest_set(GTK_WIDGET(_fill_place.gobj()),
-                          GTK_DEST_DEFAULT_ALL,
-                          ui_drop_target_entries,
-                          nui_drop_target_entries,
-                          GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
-        g_signal_connect(_fill_place.gobj(),
-                         "drag_data_received",
-                         G_CALLBACK(dragDataReceived),
-                         _dropF);
-    }
+    g_signal_connect(_stroke_place.gobj(),
+                     "drag_data_received",
+                     G_CALLBACK(dragDataReceived),
+                     _drop[SS_STROKE]);
+
+    g_signal_connect(_fill_place.gobj(),
+                     "drag_data_received",
+                     G_CALLBACK(dragDataReceived),
+                     _drop[SS_FILL]);
 }
 
 SelectedStyle::~SelectedStyle()
@@ -375,8 +363,8 @@ SelectedStyle::~SelectedStyle()
         delete _color_preview[i];
     }
 
-    delete (DropTracker*)_dropF;
-    delete (DropTracker*)_dropS;
+    delete (DropTracker*)_drop[SS_FILL];
+    delete (DropTracker*)_drop[SS_STROKE];
 }
 
 void
@@ -678,6 +666,8 @@ void SelectedStyle::on_stroke_paste() {
 void SelectedStyle::on_fillstroke_swap() {
     SPCSSAttr *css = sp_repr_css_attr_new ();
 
+    g_message("on_fillstroke_swap()");
+
     switch (_mode[SS_FILL]) {
     case SS_NA:
     case SS_MANY:
@@ -859,10 +849,22 @@ SelectedStyle::update()
             place->add(_na[i]);
             _tooltips.set_tip(*place, __na[i]);
             _mode[i] = SS_NA;
+            if ( _dropEnabled[i] ) {
+                gtk_drag_dest_unset( GTK_WIDGET((i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()) );
+                _dropEnabled[i] = false;
+            }
             break;
         case QUERY_STYLE_SINGLE:
         case QUERY_STYLE_MULTIPLE_AVERAGED:
         case QUERY_STYLE_MULTIPLE_SAME: 
+            if ( !_dropEnabled[i] ) {
+                gtk_drag_dest_set( GTK_WIDGET( (i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()),
+                                   GTK_DEST_DEFAULT_ALL,
+                                   ui_drop_target_entries,
+                                   nui_drop_target_entries,
+                                   GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE) );
+                _dropEnabled[i] = true;
+            }
             SPIPaint *paint;
             if (i == SS_FILL) {
                 paint = &(query->fill);
index 807d4ea949b67c6cb45ef78b39aba0dde40c49ed..4ea74925a6bd20a2e62a54d391ee17e86cda0bc9 100644 (file)
@@ -200,8 +200,8 @@ protected:
 
     Gtk::Tooltips _tooltips;
 
-    void *_dropF;
-    void *_dropS;
+    void *_drop[2];
+    bool _dropEnabled[2];
 };