Code

New menu command to quickly create guides around page
authorcilix42 <cilix42@users.sourceforge.net>
Wed, 5 Mar 2008 18:57:01 +0000 (18:57 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Wed, 5 Mar 2008 18:57:01 +0000 (18:57 +0000)
src/menus-skeleton.h
src/sp-guide.cpp
src/sp-guide.h
src/verbs.cpp
src/verbs.h

index 208bc799429948e02c469ce71d76004b81f2ebb8..56542e79e90dc2f55a95ff114d5a36422a1d4186 100644 (file)
@@ -84,6 +84,8 @@ static char const menus_skeleton[] =
 "       <verb verb-id=\"EditInvert\" />\n"
 "       <verb verb-id=\"EditDeselect\" />\n"
 "       <separator/>\n"
+"       <verb verb-id=\"EditGuidesAroundPage\" />\n"
+"       <separator/>\n"
 "       <verb verb-id=\"DialogXMLEditor\" />\n"
 "   </submenu>\n"
 "   <submenu name=\"" N_("_View") "\">\n"
index 81109c4fb3f90376465c57bbab6a01e236bfc98f..2f91a17cfedeb6375f3e265c03541f36edfab279 100644 (file)
@@ -266,6 +266,25 @@ sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Ge
     }
 }
 
+void
+sp_guide_create_guides_around_page(SPDocument *doc) {
+    std::list<std::pair<Geom::Point, Geom::Point> > pts;
+
+    Geom::Point A(0, 0);
+    Geom::Point C(sp_document_width(doc), sp_document_height(doc));
+    Geom::Point B(C[Geom::X], 0);
+    Geom::Point D(0, C[Geom::Y]);
+
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(A, B));
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(B, C));
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(C, D));
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(D, A));
+
+    sp_guide_pt_pairs_to_guides(doc, pts);
+
+    sp_document_done (doc, SP_VERB_NONE, _("Guides around page"));
+}
+
 void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler)
 {
     SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line.to_2geom());
index a9b04dfaa99b10195df611e4b76f19798905d1a9..502cf2c5b7b7af2bc3b58f4cb199b585e00e90c0 100644 (file)
@@ -47,6 +47,7 @@ GType sp_guide_get_type();
 
 SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
 void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
+void sp_guide_create_guides_around_page(SPDocument *doc);
 
 void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler);
 void sp_guide_hide(SPGuide *guide, SPCanvas *canvas);
index 08f1bb124241362ba928d87d0bb6dccf19ba22db..674ccdd82bc8996065bb18922a0a956e1119b85e 100644 (file)
@@ -81,6 +81,7 @@
 #include "shape-editor.h"
 #include "draw-context.h"
 #include "gradient-drag.h"
+#include "sp-guide.h"
 
 
 /**
@@ -964,6 +965,10 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
             }
             break;
 
+        case SP_VERB_EDIT_GUIDES_AROUND_PAGE:
+            sp_guide_create_guides_around_page(sp_desktop_document(dt));
+            break;
+
         case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER:
             sp_selection_next_patheffect_param(dt);
             break;
@@ -2231,6 +2236,8 @@ Verb *Verb::_base_verbs[] = {
                  N_("Select previous object or node"), NULL),
     new EditVerb(SP_VERB_EDIT_DESELECT, "EditDeselect", N_("D_eselect"),
                  N_("Deselect any selected objects or nodes"), "selection_deselect"),
+    new EditVerb(SP_VERB_EDIT_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("_Guides around page"),
+                 N_("Create four guides aligned with the page borders"), NULL),
     new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next Path Effect Parameter"),
                  N_("Show next Path Effect parameter for editing"), "edit_next_parameter"),
 
index 6576c96527685bb782f00a48b2ea12118e227679..6924a4bfd0c725b630d8999ea8194edc31d9de4d 100644 (file)
@@ -81,6 +81,7 @@ enum {
     SP_VERB_EDIT_SELECT_NEXT,
     SP_VERB_EDIT_SELECT_PREV,
     SP_VERB_EDIT_DESELECT,
+    SP_VERB_EDIT_GUIDES_AROUND_PAGE,
     SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER,
     /* Selection */
     SP_VERB_SELECTION_TO_FRONT,