Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / arc-context.cpp
index 2f70e16f361c519fc3fb1b5a0e90af4de5e82761..1c480ecbc6efaeb971230fc2bce45977edf624a8 100644 (file)
@@ -6,6 +6,7 @@
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
  *   Johan Engelen <johan@shouraizou.nl>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2000-2006 Authors
  * Copyright (C) 2000-2001 Ximian, Inc.
@@ -45,6 +46,8 @@
 
 #include "arc-context.h"
 
+using Inkscape::DocumentUndo;
+
 static void sp_arc_context_class_init(SPArcContextClass *klass);
 static void sp_arc_context_init(SPArcContext *arc_context);
 static void sp_arc_context_dispose(GObject *object);
@@ -107,6 +110,7 @@ static void sp_arc_context_init(SPArcContext *arc_context)
     event_context->tolerance = 0;
     event_context->within_tolerance = false;
     event_context->item_to_select = NULL;
+    event_context->tool_url = "/tools/shapes/arc";
 
     arc_context->item = NULL;
 
@@ -251,6 +255,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
                                     GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
                                     NULL, event->button.time);
                 ret = TRUE;
+                m.unSetup();
             }
             break;
         case GDK_MOTION_NOTIFY:
@@ -281,6 +286,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
                 Geom::Point const motion_w(event->motion.x, event->motion.y);
                 Geom::Point motion_dt(desktop->w2d(motion_w));
                 m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
+                m.unSetup();
             }
             break;
         case GDK_BUTTON_RELEASE:
@@ -407,12 +413,12 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state)
             return;
         }
 
-        /* Create object */
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+        // Create object
+        Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
         Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
         repr->setAttribute("sodipodi:type", "arc");
 
-        /* Set style */
+        // Set style
         sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/arc", false);
 
         ac->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
@@ -500,7 +506,7 @@ static void sp_arc_finish(SPArcContext *ac)
         sp_canvas_end_forced_full_redraws(desktop->canvas);
 
         sp_desktop_selection(desktop)->set(ac->item);
-               SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
+               DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
                          _("Create ellipse"));
 
         ac->item = NULL;
@@ -526,7 +532,7 @@ static void sp_arc_cancel(SPArcContext *ac)
 
     sp_canvas_end_forced_full_redraws(desktop->canvas);
 
-    SPDocumentUndo::cancel(sp_desktop_document(desktop));
+    DocumentUndo::cancel(sp_desktop_document(desktop));
 }
 
 
@@ -539,4 +545,4 @@ static void sp_arc_cancel(SPArcContext *ac)
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :