Code

Introduce verb, menu item and shortcut for the global snapping toggle
authordvlierop2 <dvlierop2@users.sourceforge.net>
Tue, 18 Dec 2007 21:23:15 +0000 (21:23 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Tue, 18 Dec 2007 21:23:15 +0000 (21:23 +0000)
share/keys/default.xml
share/keys/inkscape.xml
src/menus-skeleton.h
src/snap.h
src/verbs.cpp
src/verbs.h

index acf45b311cc356a836c57f5c590b285c608dacfc..74f7682ede055dd2440b226d2feda37f2e64cc46 100644 (file)
@@ -121,10 +121,7 @@ override) the bindings in the main default.xml.
 
   <bind action="ArcPrefs" />
 
-  <bind key="F9" modifiers="Shift" action="ToolStar" />
-  <bind key="asterisk" modifiers="Shift" action="ToolStar" />
-  <bind key="asterisk" action="ToolStar" />
-  <bind key="KP_Multiply" action="ToolStar" display="true"/>
+  <bind key="F9" modifiers="Shift" action="ToolStar" display="true"/>
 
   <bind action="StarPrefs" />
 
@@ -232,6 +229,10 @@ override) the bindings in the main default.xml.
 
   <bind key="numbersign" modifiers="Shift" action="ToggleGrid" /> <!-- # -->
   <bind key="numbersign" action="ToggleGrid" display="true"/>
+  
+  <bind key="KP_Multiply" action="ToggleSnapping" display="true"/> <!-- # -->
+  <bind key="asterisk" modifiers="Shift" action="ToggleSnapping" />
+  <bind key="asterisk" action="ToggleSnapping" />
 
   <bind action="ViewNew"/>
   <bind action="ViewNewPreview"/>
index e877c344b03baf6b3266dd1e7b3cf34add420397..b39b02e9f6774929f96c591a686cd123710fa55d 100644 (file)
@@ -121,10 +121,7 @@ override) the bindings in the main default.xml.
 
   <bind action="ArcPrefs" />
 
-  <bind key="F9" modifiers="Shift" action="ToolStar" />
-  <bind key="asterisk" modifiers="Shift" action="ToolStar" />
-  <bind key="asterisk" action="ToolStar" />
-  <bind key="KP_Multiply" action="ToolStar" display="true"/>
+  <bind key="F9" modifiers="Shift" action="ToolStar" display="true"/>
 
   <bind action="StarPrefs" />
 
@@ -233,6 +230,10 @@ override) the bindings in the main default.xml.
   <bind key="numbersign" modifiers="Shift" action="ToggleGrid" /> <!-- # -->
   <bind key="numbersign" action="ToggleGrid" display="true"/>
 
+  <bind key="KP_Multiply" action="ToggleSnapping" display="true"/> <!-- # -->
+  <bind key="asterisk" modifiers="Shift" action="ToggleSnapping" />
+  <bind key="asterisk" action="ToggleSnapping" />
+
   <bind action="ViewNew"/>
   <bind action="ViewNewPreview"/>
   <bind action="ViewIconPreview"/>
index 7bff62c29fa9ba03cc94df7a03e7388f654b31e8..c039dcefd838956798ead611a6275c9a4f178aef 100644 (file)
@@ -118,6 +118,7 @@ static char const menus_skeleton[] =
 "       <separator/>\n"
 "       <verb verb-id=\"ToggleGrid\" />\n"
 "       <verb verb-id=\"ToggleGuides\" />\n"
+"       <verb verb-id=\"ToggleSnapping\" />\n"
 "       <verb verb-id=\"ViewCmsToggle\" />\n"
 "       <separator/>\n"
 "       <submenu name=\"" N_("Show/Hide") "\">\n"
index 1f2b85974fe237a028d9160203e2959bb95bf68a..f7882fc619e1a11ea56a7a09756b7bba6d2c9e13 100644 (file)
@@ -148,6 +148,10 @@ public:
     bool getSnapEnabledGlobally() const {
         return _snap_enabled_globally;   
     }
+    
+    void toggleSnapEnabledGlobally() {
+        _snap_enabled_globally = !_snap_enabled_globally;   
+    }
         
 protected:
     SPNamedView const *_named_view;
index f5ff45a0b519d68a43bd7ecac1bfa65667457a4a..2c2da7093b739e04073c974be98e927ea7577495 100644 (file)
@@ -1611,6 +1611,9 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/)
         case SP_VERB_TOGGLE_GUIDES:
             sp_namedview_toggle_guides(doc, repr);
             break;
+        case SP_VERB_TOGGLE_SNAPPING:
+            dt->namedview->snap_manager.toggleSnapEnabledGlobally();
+            break;        
         case SP_VERB_TOGGLE_GRID:
             dt->toggleGrids();
             break;
@@ -2439,6 +2442,7 @@ Verb *Verb::_base_verbs[] = {
     new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), "scrollbars"),
     new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), "grid"),
     new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), "guides"),
+    new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapping", N_("Snap"), N_("Toggle snapping on or off"), NULL),
     new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"),
                  "zoom_next"),
     new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"),
index a9abc02ed613543ab0a2ff57f7ac4f9af91d4c26..fce826c8f82c92147c34b247a1719c62aee48707 100644 (file)
@@ -182,6 +182,7 @@ enum {
     SP_VERB_TOGGLE_SCROLLBARS,
     SP_VERB_TOGGLE_GRID,
     SP_VERB_TOGGLE_GUIDES,
+    SP_VERB_TOGGLE_SNAPPING,
     SP_VERB_ZOOM_NEXT,
     SP_VERB_ZOOM_PREV,
     SP_VERB_ZOOM_1_1,