From: mental Date: Thu, 8 May 2008 13:05:51 +0000 (+0000) Subject: merge inline patch from Jimmy X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=973c92f3bdd6e7877e29e556eff3d9675df1be35;p=inkscape.git merge inline patch from Jimmy --- diff --git a/inkscape.desktop.in b/inkscape.desktop.in index 648989800..22851c1f6 100644 --- a/inkscape.desktop.in +++ b/inkscape.desktop.in @@ -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 diff --git a/src/dialogs/sp-attribute-widget.cpp b/src/dialogs/sp-attribute-widget.cpp index 92da747a4..4424aaa1b 100644 --- a/src/dialogs/sp-attribute-widget.cpp +++ b/src/dialogs/sp-attribute-widget.cpp @@ -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; diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 1bc28b328..2d1b4c4b1 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -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 %s: Another element with value %s 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); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index b6567a012..d43d950fb 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -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)); diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp index b2b3efeb7..a8f358faf 100644 --- a/src/prefs-utils.cpp +++ b/src/prefs-utils.cpp @@ -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); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 09c086f46..0f8946441 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -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); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 99d739700..f6ddf27df 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -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 */ diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index afa0ca2ef..888250c40 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -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(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); } diff --git a/src/xml/repr.h b/src/xml/repr.h index 67616df29..162451a0f 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -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) {