static void sp_text_edit_dialog_apply( GtkButton */*button*/, GtkWidget *dlg ) { g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); GtkWidget *apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); GtkWidget *def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; const GSList *item_list = sp_desktop_selection(desktop)->itemList(); SPCSSAttr *css = sp_get_text_dialog_style (); sp_desktop_set_style(desktop, css, true); for (; item_list != NULL; item_list = item_list->next) { // apply style to the reprs of all text objects in the selection if (SP_IS_TEXT (item_list->data)) { // backwards compatibility: SP_OBJECT_REPR(item_list->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } else if (SP_IS_FLOWTEXT (item_list->data)) // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext ++items; } if (items == 0) { // no text objects; apply style to prefs for new objects Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->mergeStyle("/tools/text/style", css); gtk_widget_set_sensitive (def, FALSE); } else if (items == 1) { /* exactly one text object; now set its text, too */ SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT(item)) { sp_text_edit_dialog_update_object_text (item); } } // complete the transaction sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Set text style")); gtk_widget_set_sensitive (apply, FALSE); sp_repr_css_attr_unref (css); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE)); }
/** * Given a repr, this sets the data items in the path object such as * fill & style attributes, markers, and CSS properties. */ static void sp_path_build (SPObject *object, SPDocument *document, SPRepr *repr) { SPPath *path; SPVersion version; const gchar* marker_value; path = SP_PATH (object); version = sp_object_get_sodipodi_version (object); /* Fixes old Sodipodi nodetype to namespaced parameter */ if (sp_version_inside_range (version, 0, 0, 0, 25)) { const gchar *str; str = sp_repr_attr (repr, "INKSCAPE-PATH-NODE-TYPES"); sp_repr_set_attr (repr, "sodipodi:nodetypes", str); sp_repr_set_attr (repr, "INKSCAPE-PATH-NODE-TYPES", NULL); } sp_object_read_attr (object, "d"); /* Are these calls actually necessary? */ sp_object_read_attr (object, "marker"); sp_object_read_attr (object, "marker-start"); sp_object_read_attr (object, "marker-mid"); sp_object_read_attr (object, "marker-end"); if (sp_version_inside_range (version, 0, 0, 0, 25)) { SPShape *shape; SPCSSAttr *css; const gchar *val; gboolean changed; gboolean open; shape = (SPShape *) path; /* Remove fill from open paths for compatibility with inkscape < 0.25 */ /* And set fill-rule of closed paths to evenodd */ /* We force style rewrite at moment (Lauris) */ changed = TRUE; open = FALSE; if (shape->curve && shape->curve->bpath) { ArtBpath *bp; for (bp = shape->curve->bpath; bp->code != ART_END; bp++) { if (bp->code == ART_MOVETO_OPEN) { open = TRUE; break; } } } css = sp_repr_css_attr (repr, "style"); if (open) { val = sp_repr_css_property (css, "fill", NULL); if (val && strcmp (val, "none")) { sp_repr_css_set_property (css, "fill", "none"); changed = TRUE; } } else { val = sp_repr_css_property (css, "fill-rule", NULL); if (!val) { sp_repr_css_set_property (css, "fill-rule", "evenodd"); changed = TRUE; } } if (changed) { sp_repr_css_set (repr, css, "style"); } sp_repr_css_attr_unref (css); } if (((SPObjectClass *) parent_class)->build) { ((SPObjectClass *) parent_class)->build (object, document, repr); } }