[glom] Print Layout: Prevent rule line dragging if rules are not shown.



commit 2ba42ce81ce3441493157c2bfd0c2cf8be4f7d39
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Aug 11 14:20:52 2011 +0200

    Print Layout: Prevent rule line dragging if rules are not shown.
    
    * glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
    on_menu_view_show_rules(): If rules are not shown, unset the GimpRulers
    as drag sources.
    on_canvas_drag_motion(), on_canvas_drag_data_received(): Prevent
    showing the temp rule or dropping a real rule too.
    Also remove the unused (though set) m_dragging_temp_rule variable.

 ChangeLog                                          |   11 +++++++
 .../print_layouts/window_print_layout_edit.cc      |   29 +++++++++++++++-----
 .../print_layouts/window_print_layout_edit.h       |    1 -
 3 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 37f1446..79a03de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-08-11  Murray Cumming  <murrayc murrayc com>
 
+	Print Layout: Prevent rule line dragging if rules are not shown.
+
+	* glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
+	on_menu_view_show_rules(): If rules are not shown, unset the GimpRulers 
+	as drag sources.
+	on_canvas_drag_motion(), on_canvas_drag_data_received(): Prevent 
+	showing the temp rule or dropping a real rule too.
+	Also remove the unused (though set) m_dragging_temp_rule variable.
+
+2011-08-11  Murray Cumming  <murrayc murrayc com>
+
 	Print Layout: Add a Print Preview menu item.
 
 	* glom/frame_glom.[h|cc]: on_menu_print_layout_selected(): 
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index baaaacc..79341a5 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -54,7 +54,6 @@ Window_PrintLayout_Edit::Window_PrintLayout_Edit(BaseObjectType* cobject, const
   m_spinbutton_height(0),
   m_ignore_spinbutton_signals(false),
   m_drag_preview_requested(false),
-  m_dragging_temp_rule(false),
   m_temp_rule_horizontal(false),
   m_vruler(0),
   m_hruler(0),
@@ -354,6 +353,9 @@ bool Window_PrintLayout_Edit::on_canvas_drag_motion(const Glib::RefPtr<Gdk::Drag
   //Handle dragging of the rule from the GimpRuler widget:
   if(target == DRAG_TARGET_NAME_RULE)
   {
+    if(!m_action_showrules->get_active())
+      return false; //Don't allow the drop.
+
     if(m_temp_rule_horizontal)
        m_canvas.show_temp_rule(0, item_y);
     else
@@ -469,6 +471,9 @@ void Window_PrintLayout_Edit::on_canvas_drag_data_received(const Glib::RefPtr<Gd
   //Handle dragging of the rule from the GimpRuler widget:
   if(target == DRAG_TARGET_NAME_RULE)
   {
+    if(!m_action_showrules->get_active())
+      return;
+
     m_canvas.show_temp_rule(0, 0, false);
  
     if(m_temp_rule_horizontal)
@@ -478,7 +483,6 @@ void Window_PrintLayout_Edit::on_canvas_drag_data_received(const Glib::RefPtr<Gd
 
     drag_context->drag_finish(true, false, timestamp);
 
-    m_dragging_temp_rule = false;
     return;
   }
   
@@ -553,7 +557,6 @@ void Window_PrintLayout_Edit::on_canvas_drag_leave(const Glib::RefPtr<Gdk::DragC
   }
 
   m_canvas.show_temp_rule(0, 0, false); //Remove it.
-  m_dragging_temp_rule = false;
 }
 
 Window_PrintLayout_Edit::~Window_PrintLayout_Edit()
@@ -868,8 +871,22 @@ void Window_PrintLayout_Edit::on_menu_view_show_grid()
 
 void Window_PrintLayout_Edit::on_menu_view_show_rules()
 {
-  m_canvas.set_rules_visibility(
-    m_action_showrules->get_active());
+  const bool active = m_action_showrules->get_active();
+  m_canvas.set_rules_visibility(active);
+
+  Gtk::Widget* hruler = Glib::wrap(GTK_WIDGET(m_hruler));
+  Gtk::Widget* vruler = Glib::wrap(GTK_WIDGET(m_vruler));
+
+  if(active)
+  {
+    hruler->drag_source_set(m_drag_targets_rule);
+    vruler->drag_source_set(m_drag_targets_rule);
+  }
+  else
+  {
+    hruler->drag_source_unset();
+    vruler->drag_source_unset();
+  }
 }
 
 
@@ -1343,7 +1360,6 @@ bool Window_PrintLayout_Edit::on_hruler_button_press_event(GdkEventButton* event
   if(event->button != 1)
     return true;
 
-  m_dragging_temp_rule = true;
   m_temp_rule_horizontal = true;
  
   return false;
@@ -1354,7 +1370,6 @@ bool Window_PrintLayout_Edit::on_vruler_button_press_event(GdkEventButton* event
   if(event->button != 1)
     return true;
 
-  m_dragging_temp_rule = true;
   m_temp_rule_horizontal = false; //vertical.
 
   return false;
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.h b/glom/mode_design/print_layouts/window_print_layout_edit.h
index b975c3f..6ac0a45 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.h
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.h
@@ -153,7 +153,6 @@ private:
   bool m_drag_preview_requested;
   Glib::RefPtr<CanvasLayoutItem> m_layout_item_dropping;
 
-  bool m_dragging_temp_rule;
   bool m_temp_rule_horizontal; //Otherwise vertical.
 
   //A cache of the selected item,



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