Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / ui / view / view.cpp
index 48c48c750ae3d07e74b7ca0e1484deb27b3ed38c..f05e024d19fd871971114fafe61deb5d10972782 100644 (file)
@@ -1,11 +1,10 @@
-#define __SP_VIEW_C__
-
 /** \file
  * View implementation
  *
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   Ralf Stephan <ralf@ark.in-berlin.de>
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2001-2002 Lauris Kaplinski
  * Copyright (C) 2001 Ximian, Inc.
@@ -23,6 +22,7 @@
 #include "message-stack.h"
 #include "message-context.h"
 #include "verbs.h"
+#include "inkscape-private.h"
 
 namespace Inkscape {
 namespace UI {
@@ -97,8 +97,11 @@ void View::_close() {
     if (_doc) {
         _document_uri_set_connection.disconnect();
         _document_resized_connection.disconnect();
-        sp_document_unref(_doc);
-        _doc = 0;
+        if (inkscape_remove_document(_doc)) {
+            // this was the last view of this document, so delete it
+            delete _doc;
+        }
+        _doc = NULL;
     }
     
    Inkscape::Verb::delete_all_view (this);
@@ -109,9 +112,9 @@ void View::setPosition (double x, double y)
     _position_set_signal.emit (x,y);
 }
 
-void View::setPosition(NR::Point const &p) 
+void View::setPosition(Geom::Point const &p) 
 { 
-    setPosition (double(p[NR::X]), double(p[NR::Y])); 
+    setPosition (double(p[Geom::X]), double(p[Geom::Y])); 
 }
 
 void View::emitResized (double width, double height)
@@ -139,15 +142,20 @@ void View::setDocument(SPDocument *doc) {
     if (_doc) {
         _document_uri_set_connection.disconnect();
         _document_resized_connection.disconnect();
-        sp_document_unref (_doc);
+        if (inkscape_remove_document(_doc)) {
+            // this was the last view of this document, so delete it
+            delete _doc;
+        }
     }
 
-    _doc = sp_document_ref (doc);
+    inkscape_add_document(doc);
+
+    _doc = doc;
     _document_uri_set_connection = 
         _doc->connectURISet(sigc::bind(sigc::ptr_fun(&_onDocumentURISet), this));
     _document_resized_connection = 
         _doc->connectResized(sigc::bind(sigc::ptr_fun(&_onDocumentResized), this));
-    _document_uri_set_signal.emit (SP_DOCUMENT_URI(_doc));
+    _document_uri_set_signal.emit( _doc->getURI() );
 }
 
 }}}