[glom] CanvasItemMovable: set_selected(): Do not emit the signal here.



commit 3261e9556b284e3925a1b80f4619efe4afa968b1
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Aug 6 23:04:39 2011 +0200

    CanvasItemMovable: set_selected(): Do not emit the signal here.
    
    	* glom/utility_widgets/canvas/canvas_item_movable.cc:
    	set_selected(): Do not emit signal_selected here, because it should
    	only be emitted when the user causes it.
    	on_button_release_event(), on_motion_notify_event():
    	Emit the signal if necessary.

 ChangeLog                                          |   10 ++++++++++
 glom/utility_widgets/canvas/canvas_item_movable.cc |   19 +++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b4da5b4..ebe0a01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-08-06  Murray Cumming  <murrayc murrayc com>
 
+	CanvasItemMovable: set_selected(): Do not emit the signal here.
+
+	* glom/utility_widgets/canvas/canvas_item_movable.cc:
+	set_selected(): Do not emit signal_selected here, because it should 
+	only be emitted when the user causes it.
+	on_button_release_event(), on_motion_notify_event():
+	Emit the signal if necessary.
+
+2011-08-06  Murray Cumming  <murrayc murrayc com>
+
 	Canvas_PrintLayout: Edit menu: Support multiple items.
 
 	* glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
diff --git a/glom/utility_widgets/canvas/canvas_item_movable.cc b/glom/utility_widgets/canvas/canvas_item_movable.cc
index 2e980ca..334370b 100644
--- a/glom/utility_widgets/canvas/canvas_item_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_item_movable.cc
@@ -153,7 +153,10 @@ bool CanvasItemMovable::on_motion_notify_event(const Glib::RefPtr<Goocanvas::Ite
     // A click with a move should always select:
     // We emit this before signal_moved,
     // so that its signal handler can know about the selection.
+    const bool old_selected = get_selected();
     set_selected(true);
+    if(!old_selected)
+      m_signal_selected.emit();
 
     m_signal_moved.emit();
 
@@ -193,8 +196,15 @@ bool CanvasItemMovable::on_button_release_event(const Glib::RefPtr<Goocanvas::It
   }
 
   //This will also ask derived classes to indicate it visually:
+
   set_selected(selected);
 
+  //Notify of the selection change, if any:
+  if(selected != old_selected)
+  {
+    m_signal_selected.emit();
+  }
+
   return true;
 }
 
@@ -407,15 +417,8 @@ Glib::RefPtr<const Goocanvas::Item> CanvasItemMovable::cast_const_to_item(const
 
 void CanvasItemMovable::set_selected(bool selected)
 {
-  const bool old_selected = m_selected;
   m_selected = selected;
-  show_selected(); //Let derived classes indicate it visually.
-
-  //Notify of the selection change, if any:
-  if(m_selected != old_selected)
-  {
-    m_signal_selected.emit();
-  }
+  show_selected(); //Let derived classes indicate it visually,
 }
 
 bool CanvasItemMovable::get_selected() const



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]