Code

Filter effects dialog:
[inkscape.git] / src / sp-namedview.cpp
index 809f138a8d28d526dc8b1bfd8412d2197f32e1d3..52d2f1189d3b9c2be4fece48c51bd3a40274d31a 100644 (file)
@@ -431,7 +431,12 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des
     if (!grid) {
         //create grid object
         Inkscape::GridType gridtype = Inkscape::CanvasGrid::getGridTypeFromSVGName(repr->attribute("type"));
-        grid = Inkscape::CanvasGrid::NewGrid(nv, repr, gridtype);
+        SPDocument *doc = NULL;
+        if (desktop)
+            doc = sp_desktop_document(desktop);
+        else
+            doc = sp_desktop_document(static_cast<SPDesktop*>(nv->views->data));
+        grid = Inkscape::CanvasGrid::NewGrid(nv, repr, doc, gridtype);
         nv->grids = g_slist_append(nv->grids, grid);
     }
     
@@ -571,15 +576,16 @@ void SPNamedView::show(SPDesktop *desktop)
 #define MIN_ONSCREEN_DISTANCE 50
 
 /*
- * Restores window geometry from the document settings
+ * Restores window geometry from the document settings or defaults in prefs
  */
 void sp_namedview_window_from_document(SPDesktop *desktop)
 {
     SPNamedView *nv = desktop->namedview;
-    gint save_geometry = prefs_get_int_attribute("options.savewindowgeometry", "value", 0);
+    gint geometry_from_file = 
+        (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
 
-    // restore window size and position
-    if (save_geometry) {
+    // restore window size and position stored with the document
+    if (geometry_from_file) {
         gint w = MIN(gdk_screen_width(), nv->window_width);
         gint h = MIN(gdk_screen_height(), nv->window_height);
         gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
@@ -588,10 +594,12 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
             x = MIN(gdk_screen_width() - w, x);
             y = MIN(gdk_screen_height() - h, y);
         }
-        if (w>0 && h>0)
+        if (w>0 && h>0) {
             desktop->setWindowSize(w, h);
-        if (x>0 && y>0)
+        }
+        if (x>0 && y>0) {
             desktop->setWindowPosition(NR::Point(x, y));
+        }
     }
 
     // restore zoom and view
@@ -641,7 +649,8 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
 
 void sp_namedview_document_from_window(SPDesktop *desktop)
 {
-    gint save_geometry = prefs_get_int_attribute("options.savewindowgeometry", "value", 0);
+    gint save_geometry_in_file = 
+        (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
     Inkscape::XML::Node *view = SP_OBJECT_REPR(desktop->namedview);
     NR::Rect const r = desktop->get_display_area();
 
@@ -653,7 +662,7 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
     sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[NR::X]);
     sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[NR::Y]);
 
-    if (save_geometry) {
+    if (save_geometry_in_file) {
         gint w, h, x, y;
         desktop->getWindowGeometry(x, y, w, h);
         sp_repr_set_int(view, "inkscape:window-width", w);
@@ -866,6 +875,7 @@ SPMetric SPNamedView::getDefaultMetric() const
     }
 }
 
+
 /*
   Local Variables:
   mode:c++
@@ -875,4 +885,4 @@ SPMetric SPNamedView::getDefaultMetric() const
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtab
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :