diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2016-12-11 14:33:49 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2016-12-11 14:33:49 +0000 |
| commit | 401349277d025fb736184e014b636027b412d29e (patch) | |
| tree | 017d267e6dc49165119f9e9b4f60f532fa492ea9 /src/widgets/text-toolbar.cpp | |
| parent | Apply suv patch to handle containers https://bugs.launchpad.net/inkscape/+bug... (diff) | |
| download | inkscape-401349277d025fb736184e014b636027b412d29e.tar.gz inkscape-401349277d025fb736184e014b636027b412d29e.zip | |
Add option to unset 'line-height' (as well as determine where it is set).
(bzr r15321)
Diffstat (limited to 'src/widgets/text-toolbar.cpp')
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 847ebd8c1..784c467f1 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -239,7 +239,7 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje if (dynamic_cast<SPText *>(*i) || dynamic_cast<SPFlowtext *>(*i)) { SPItem *item = *i; - // Scale by inverse of accumulated paraent transform + // Scale by inverse of accumulated parent transform SPCSSAttr *css_set = sp_repr_css_attr_new(); sp_repr_css_merge(css_set, css); Geom::Affine const local(item->i2doc_affine()); @@ -321,6 +321,29 @@ static void sp_text_outer_style_changed( InkToggleAction*act, GObject *tbl ) sp_text_toolbox_selection_changed( NULL, tbl ); } +// Unset line height on selection's inner text objects (tspan, etc.). +static void sp_text_lineheight_unset_changed( InkToggleAction*act, GObject *tbl ) +{ + // quit if run by the _changed callbacks + if (g_object_get_data(G_OBJECT(tbl), "freeze")) { + return; + } + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); + + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_unset_property(css, "line-height"); + + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + sp_desktop_set_style (desktop, css); + + sp_repr_css_attr_unref(css); + + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, + _("Text: Unset line height.")); + + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); +} + // Handles both Superscripts and Subscripts static void sp_text_script_changed( InkToggleAction* act, GObject *tbl ) { @@ -599,7 +622,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) if (dynamic_cast<SPText *>(*i) || dynamic_cast<SPFlowtext *>(*i)) { SPItem *item = *i; - // Scale by inverse of accumulated paraent transform + // Scale by inverse of accumulated parent transform SPCSSAttr *css_set = sp_repr_css_attr_new(); sp_repr_css_merge(css_set, css); Geom::Affine const local(item->i2doc_affine()); @@ -1405,7 +1428,13 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ } // Save unit so we can do convertions between new/old units. g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(line_height_unit)); - + + // Enable and turn on only if selection includes an object with line height set. + InkToggleAction* lineHeightUnset = + INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextLineHeightUnsetAction")); + gtk_action_set_sensitive(GTK_ACTION(lineHeightUnset), query.line_height.set ); + gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(lineHeightUnset), query.line_height.set ); + // Word spacing double wordSpacing; if (query.word_spacing.normal) wordSpacing = 0.0; @@ -2100,6 +2129,19 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje g_object_set( G_OBJECT(eact), "iconId", "text_rotation", NULL ); } + /* Text line height unset */ + { + InkToggleAction* act = ink_toggle_action_new( "TextLineHeightUnsetAction", // Name + _("Unset line height"), // Label + _("If enabled, line height is set on part of selection. Click to unset."), + INKSCAPE_ICON("paint-unknown"), + secondarySize ); // Icon size + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_lineheight_unset_changed), holder ); + gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/line_height_unset", false) ); + g_object_set_data( holder, "TextLineHeightUnsetAction", act ); + } + /* Text outer style */ { InkToggleAction* act = ink_toggle_action_new( "TextOuterStyleAction", // Name |
