Code

Fix ef spam when adjusting pattern on text - patch from Adonis Papaderos
[inkscape.git] / src / sp-namedview.cpp
index 9b72a41578492440ac2257540e8a4caf893b2f5a..be2bcd478781ef9d9be4535f15116e4e50131ef4 100644 (file)
@@ -218,6 +218,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
     }
 
     sp_object_read_attr(object, "inkscape:document-units");
+    sp_object_read_attr(object, "units");
     sp_object_read_attr(object, "viewonly");
     sp_object_read_attr(object, "showguides");
     sp_object_read_attr(object, "showgrid");
@@ -572,6 +573,30 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     }
+    case SP_ATTR_UNITS: {
+            SPUnit const *new_unit = NULL;
+
+            if (value) {
+                SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value);
+                if ( req_unit == NULL ) {
+                    g_warning("Unrecognized unit `%s'", value);
+                    /* fixme: Document errors should be reported in the status bar or
+                     * the like (e.g. as per
+                     * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log
+                     * should be only for programmer errors. */
+                } else if ( req_unit->base == SP_UNIT_ABSOLUTE ||
+                            req_unit->base == SP_UNIT_DEVICE     ) {
+                    new_unit = req_unit;
+                } else {
+                    g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'",
+                              value);
+                    /* fixme: Don't use g_log (see above). */
+                }
+            }
+            nv->units = new_unit;
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            break;
+    }
     default:
             if (((SPObjectClass *) (parent_class))->set) {
                 ((SPObjectClass *) (parent_class))->set(object, key, value);
@@ -829,7 +854,7 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
         sp_repr_set_int(view, "inkscape:window-maximized", desktop->is_maximized());
     }
 
-    view->setAttribute("inkscape:current-layer", SP_OBJECT_ID(desktop->currentLayer()));
+    view->setAttribute("inkscape:current-layer", desktop->currentLayer()->getId());
 
     // restore undoability
     sp_document_set_undo_sensitive(sp_desktop_document(desktop), saved);
@@ -978,7 +1003,7 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id)
         return (SPNamedView *) nv;
     }
 
-    while (nv && strcmp(nv->id, id)) {
+    while (nv && strcmp(nv->getId(), id)) {
         nv = sp_item_group_get_child_by_name((SPGroup *) document->root, nv, "sodipodi:namedview");
     }
 
@@ -1038,4 +1063,4 @@ void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) {
   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 :