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)); }
static void sp_text_edit_dialog_set_default( GtkButton */*button*/, GtkWidget *dlg ) { GtkWidget *def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); SPCSSAttr *css = sp_get_text_dialog_style (); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); prefs->mergeStyle("/tools/text/style", css); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE)); sp_repr_css_attr_unref (css); gtk_widget_set_sensitive (def, FALSE); }