Code

merge inline patch from Jimmy
authormental <mental@users.sourceforge.net>
Thu, 8 May 2008 13:05:51 +0000 (13:05 +0000)
committermental <mental@users.sourceforge.net>
Thu, 8 May 2008 13:05:51 +0000 (13:05 +0000)
inkscape.desktop.in
src/dialogs/sp-attribute-widget.cpp
src/dialogs/xml-tree.cpp
src/path-chemistry.cpp
src/prefs-utils.cpp
src/selection-chemistry.cpp
src/sp-object.cpp
src/xml/repr-css.cpp
src/xml/repr.h

index 648989800c9040aea0f4f30ac86bfd4f1b4eb7c2..22851c1f60891528f41a6fb00164ae83c1a1861a 100644 (file)
@@ -1,18 +1,15 @@
 [Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=No name
 _Name=Inkscape Vector Graphics Editor
 _Comment=Create and edit Scalable Vector Graphics images
-
-Version=1.0
-
 Type=Application
 Categories=Graphics;VectorGraphics;GTK;
-
 MimeType=image/svg+xml;image/svg+xml-compressed;
-
-FilePattern=inkscape
+FilePattern=inkscape;
 Exec=inkscape %F
 TryExec=inkscape
 Terminal=false
 StartupNotify=true
-
 Icon=inkscape
index 92da747a42db484478a219860461ef3ba18bf4ff..4424aaa1bf7b10a8cfe68997dcfb295ceece838e 100644 (file)
@@ -158,25 +158,14 @@ sp_attribute_widget_changed (GtkEditable *editable)
             text = NULL;
 
         if (spaw->hasobj && spaw->src.object) {
-
-            if (!sp_repr_set_attr ( SP_OBJECT_REPR (spaw->src.object),
-                                    spaw->attribute, text) )
-            {
-                /* Cannot set attribute */
-                text = SP_OBJECT_REPR (spaw->src.object)->attribute(spaw->attribute);
-                gtk_entry_set_text (GTK_ENTRY (spaw), text ? text : "");
-            }
+        
+            SP_OBJECT_REPR (spaw->src.object)->setAttribute(spaw->attribute, text, false);
             sp_document_done (SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE,
                               _("Set attribute"));
 
         } else if (spaw->src.repr) {
 
-            if (!sp_repr_set_attr (spaw->src.repr, spaw->attribute, text))
-            {
-                /* Cannot set attribute */
-                text = spaw->src.repr->attribute(spaw->attribute);
-                gtk_entry_set_text (GTK_ENTRY (spaw), text ? text : "");
-            }
+            spaw->src.repr->setAttribute(spaw->attribute, text, false);
             /* TODO: Warning! Undo will not be flushed in given case */
         }
         spaw->blocked = FALSE;
@@ -775,27 +764,13 @@ sp_attribute_table_entry_changed ( GtkEditable *editable,
                     text = NULL;
 
                 if (spat->hasobj && spat->src.object) {
-                    if (!sp_repr_set_attr ( SP_OBJECT_REPR (spat->src.object),
-                                            spat->attributes[i], text))
-                    {
-                        /* Cannot set attribute */
-                        text = SP_OBJECT_REPR (spat->src.object)->attribute(spat->attributes[i]);
-                        gtk_entry_set_text ( GTK_ENTRY (spat->entries[i]),
-                                             text ? text : (const gchar *) "");
-                    }
+                    SP_OBJECT_REPR (spat->src.object)->setAttribute(spat->attributes[i], text, false);
                     sp_document_done (SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE,
                                       _("Set attribute"));
 
                 } else if (spat->src.repr) {
 
-                    if (!sp_repr_set_attr (spat->src.repr,
-                                           spat->attributes[i], text))
-                    {
-                        /* Cannot set attribute */
-                        text = spat->src.repr->attribute(spat->attributes[i]);
-                        gtk_entry_set_text ( GTK_ENTRY (spat->entries[i]),
-                                             text ? text : (const gchar *) "" );
-                    }
+                    spat->src.repr->setAttribute(spat->attributes[i], text, false);
                     /* TODO: Warning! Undo will not be flushed in given case */
                 }
                 spat->blocked = FALSE;
index 1bc28b3281930f93a1dbf8f983acd335fe0bdf67..2d1b4c4b17e983baf1f8aea978e38af5dbc8e09e 100644 (file)
@@ -1463,11 +1463,7 @@ void cmd_set_attr(GtkObject */*object*/, gpointer /*data*/)
     gchar *value = gtk_text_buffer_get_text( gtk_text_view_get_buffer(attr_value),
                                        &start, &end, TRUE );
 
-    if (!sp_repr_set_attr(selected_repr, name, value)) {
-        gchar *message = g_strdup_printf(_("Cannot set <b>%s</b>: Another element with value <b>%s</b> already exists!"), name, value);
-        _message_stack->flash(Inkscape::WARNING_MESSAGE, message);
-        g_free(message);
-    }
+    selected_repr->setAttribute(name, value, false);
 
     g_free(name);
     g_free(value);
index b6567a012dc4847f48bcd4f0f037911aeef033b9..d43d950fb999e3a593b37ac2c539fdf72ae8ad8e 100644 (file)
@@ -462,8 +462,8 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
         repr->setAttribute("clip-path", clip_path_str);
 
     /* Rotation center */
-    sp_repr_set_attr(repr, "inkscape:transform-center-x", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-x"));
-    sp_repr_set_attr(repr, "inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y"));
+    repr->setAttribute("inkscape:transform-center-x", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-x"), false);
+    repr->setAttribute("inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y"), false);
 
     /* Definition */
     gchar *def_str = sp_svg_write_path(SP_CURVE_BPATH(curve));
index b2b3efeb7080c8c5a5d95cf215befd873f8178bc..a8f358fafec42904b28303b02fec191bffd10bff 100644 (file)
@@ -46,7 +46,7 @@ gchar * create_pref(gchar const *father_path, gchar const *child){
     Inkscape::XML::Node *father = inkscape_get_repr(INKSCAPE, father_path);
     if (! father ) return NULL;
     Inkscape::XML::Node *repr = father->document()->createElement("group");
-    sp_repr_set_attr(repr, "id", child);
+    repr->setAttribute("id", child, false);
     father->appendChild(repr);
     return g_strdup_printf("%s.%s", father_path,child);
 }
index 09c086f468a405136c93aa8fdb5842cd6888b22f..0f89464411e395c9a6235bdd24fd5d1b80b54418 100644 (file)
@@ -1203,7 +1203,7 @@ void sp_selection_remove_transform()
 
     GSList const *l = (GSList *) selection->reprList();
     while (l != NULL) {
-        sp_repr_set_attr((Inkscape::XML::Node*)l->data, "transform", NULL);
+        ((Inkscape::XML::Node*)l->data)->setAttribute("transform", NULL, false);
         l = l->next;
     }
 
@@ -1810,12 +1810,12 @@ sp_selection_clone()
         Inkscape::XML::Node *parent = sp_repr_parent(sel_repr);
 
         Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
-        sp_repr_set_attr(clone, "x", "0");
-        sp_repr_set_attr(clone, "y", "0");
-        sp_repr_set_attr(clone, "xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id")));
-
-        sp_repr_set_attr(clone, "inkscape:transform-center-x", sel_repr->attribute("inkscape:transform-center-x"));
-        sp_repr_set_attr(clone, "inkscape:transform-center-y", sel_repr->attribute("inkscape:transform-center-y"));
+        clone->setAttribute("x", "0", false);
+        clone->setAttribute("y", "0", false);
+        clone->setAttribute("xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id")), false);
+        
+        clone->setAttribute("inkscape:transform-center-x", sel_repr->attribute("inkscape:transform-center-x"), false);
+        clone->setAttribute("inkscape:transform-center-y", sel_repr->attribute("inkscape:transform-center-y"), false);
 
         // add the new clone to the top of the original's parent
         parent->appendChild(clone);
index 99d73970061b9389ebdca9848c2bb8b5814991ac..f6ddf27dfa0aae1414a756e7ddf5c2c0ac260e63 100644 (file)
@@ -1423,9 +1423,7 @@ sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, S
     g_return_if_fail(SP_EXCEPTION_IS_OK(ex));
 
     /// \todo fixme: Exception if object is NULL? */
-    if (!sp_repr_set_attr(object->repr, key, value)) {
-        ex->code = SP_NO_MODIFICATION_ALLOWED_ERR;
-    }
+    object->repr->setAttribute(key, value, false);
 }
 
 void
@@ -1435,9 +1433,7 @@ sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex)
     g_return_if_fail(SP_EXCEPTION_IS_OK(ex));
 
     /// \todo fixme: Exception if object is NULL? */
-    if (!sp_repr_set_attr(object->repr, key, NULL)) {
-        ex->code = SP_NO_MODIFICATION_ALLOWED_ERR;
-    }
+    object->repr->setAttribute(key, NULL, false);
 }
 
 /* Helper */
index afa0ca2ef36a8b439443cc36a8f58886eca162f0..888250c4024597cde3330800dcc9351bbb72de2c 100644 (file)
@@ -120,7 +120,7 @@ sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
     g_assert(css != NULL);
     g_assert(name != NULL);
 
-    sp_repr_set_attr((Node *) css, name, value);
+    ((Node *) css)->setAttribute(name, value, false);
 }
 
 void
@@ -129,7 +129,7 @@ sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name)
     g_assert(css != NULL);
     g_assert(name != NULL);
 
-    sp_repr_set_attr((Node *) css, name, "inkscape:unset");
+    ((Node *) css)->setAttribute(name, "inkscape:unset", false);
 }
 
 double
@@ -219,7 +219,7 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl)
     guchar *const str_value_unsigned = cr_term_to_string(decl->value);
     gchar *const str_value = reinterpret_cast<gchar *>(str_value_unsigned);
     gchar *value_unquoted = attribute_unquote (str_value); // libcroco returns strings quoted in ""
-    sp_repr_set_attr((Node *) css, decl->property->stryng->str, value_unquoted);
+    ((Node *) css)->setAttribute(decl->property->stryng->str, value_unquoted, false);
     g_free(value_unquoted);
     g_free(str_value);
 }
index 67616df294308cdd9f09af27708d76878dd4d5d4..162451a0fb304f61c22238a7b7a4c1f831e846be 100644 (file)
@@ -140,14 +140,6 @@ char const *sp_xml_ns_prefix_uri(gchar const *prefix);
 
 Inkscape::XML::Document *sp_repr_document_new(gchar const *rootname);
 
-/* Contents */
-/// Sets the node's \a key attribute to \a value.
-inline unsigned sp_repr_set_attr(Inkscape::XML::Node *repr, gchar const *key, gchar const *value,
-                                 bool is_interactive = false) {
-    repr->setAttribute(key, value, is_interactive);
-    return true;
-}
-
 /* Tree */
 /// Returns the node's parent.
 inline Inkscape::XML::Node *sp_repr_parent(Inkscape::XML::Node const *repr) {