diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2017-02-02 18:54:48 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2017-02-02 18:54:48 +0000 |
| commit | 6e066700edff2734fa5f6a4cf225dd2733eaaed9 (patch) | |
| tree | d3698ae6d0878e20a038bfd5e93ac60ef5e0eaa4 | |
| parent | Fix line-height conversions between no unit and 'em' unit. (diff) | |
| download | inkscape-6e066700edff2734fa5f6a4cf225dd2733eaaed9.tar.gz inkscape-6e066700edff2734fa5f6a4cf225dd2733eaaed9.zip | |
Add GUI support for 'direction' property (right to left vs. left to right text).
(bzr r15466)
| -rw-r--r-- | share/icons/icons.svg | 87 | ||||
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 103 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 2 |
3 files changed, 192 insertions, 0 deletions
diff --git a/share/icons/icons.svg b/share/icons/icons.svg index fa5ea4626..3d33a2c55 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -1756,6 +1756,93 @@ http://www.inkscape.org/</dc:description> xlink:href="#path6550" /> </g> <g + transform="translate(-165.5246,375)" + inkscape:label="#writing_mode_rl" + id="format-text-direction-r2l"> + <!-- Note "format-text-direction-rtl" is the GTK icon name but we want to use our own. --> + <g + transform="translate(-0.4754,0)" + id="g10375"> + <path + inkscape:connector-curvature="0" + style="color:#000000;fill:#000000;fill-opacity:0.06666673;fill-rule:evenodd" + d="m 841,26 h 22 l 1,1 v 20 l -2,2 h -20 l -1,-1 z" + id="path10356" + sodipodi:nodetypes="cccccccc" /> + <path + inkscape:connector-curvature="0" + id="path10358" + d="m 840,26 h 1 v 20 h -1 z" + style="color:#000000;fill:#000000;fill-rule:evenodd" /> + <rect + style="color:#000000;fill:#000000;fill-rule:evenodd" + id="rect10361" + width="1" + height="20" + x="861" + y="26" /> + <rect + style="color:#000000;fill:#000000;fill-rule:evenodd" + id="rect10363" + width="1" + height="20" + x="-26" + y="841" + transform="rotate(-90)" /> + <rect + style="color:#000000;fill:#000000;fill-rule:evenodd" + id="rect10365" + width="1" + height="20" + x="-47" + y="841" + transform="rotate(-90)" /> + <rect + style="color:#000000;fill:url(#linearGradient10389);fill-rule:evenodd" + id="rect10367" + width="20" + height="20" + x="841" + y="26" /> + <path + inkscape:connector-curvature="0" + id="path10369" + d="m 842,46 h -1 V 26 h 20 v 1 h -19 z" + style="fill:#ffffff;fill-rule:evenodd" /> + <path + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" + id="path10371" + d="m 858.5246,34.75 v -4 c 0,-3 -5,-3 -5,0 v 4" + style="fill:none;stroke:#383838;stroke-linecap:round" /> + <path + inkscape:connector-curvature="0" + id="path10373" + d="m 858.5246,32 h -5.1429" + style="fill:none;stroke:#383838" /> + </g> + <path + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccc" + id="path10377" + d="m 841.5246,30.4982 3.0246,-2.4991 v 2 h 7 v 1 h -7 v 2 z" + style="fill:#5a5a5a;fill-rule:evenodd" /> + <path + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccc" + id="path10379" + d="m 841.5246,36.4982 3.0246,-2.4991 v 2 h 15 v 1 h -15 v 2 z" + style="fill:#5a5a5a;fill-rule:evenodd" /> + <use + x="0" + y="0" + id="use10381" + transform="matrix(-1,0,0,1,1701.0738,6)" + width="1250" + height="1250" + xlink:href="#path6497" /> +</g> +<g id="text-orientation-auto" inkscape:label="#text_orientation_auto"> <path diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index e070c84d9..24665be37 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1140,6 +1140,54 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } +static void sp_text_direction_changed( EgeSelectOneAction *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) ); + + int mode = ege_select_one_action_get_active( act ); + + SPCSSAttr *css = sp_repr_css_attr_new (); + switch (mode) + { + case 0: + { + sp_repr_css_set_property (css, "direction", "ltr"); + break; + } + + case 1: + { + sp_repr_css_set_property (css, "direction", "rtl"); + break; + } + } + + SPStyle query(SP_ACTIVE_DOCUMENT); + int result_numbers = + sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS); + + // If querying returned nothing, update default style. + if (result_numbers == QUERY_STYLE_NOTHING) + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->mergeStyle("/tools/text/style", css); + } + + sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true); + if(result_numbers != QUERY_STYLE_NOTHING) + { + DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_TEXT, + _("Text: Change direction")); + } + sp_repr_css_attr_unref (css); + + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); +} + /* * Set the default list of font sizes, scaled to the users preferred unit */ @@ -1503,6 +1551,15 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ ege_select_one_action_update_sensitive( textOrientationAction ); + // Direction + int activeButton4 = 0; + if (query.direction.computed == SP_CSS_DIRECTION_LTR ) activeButton4 = 0; + if (query.direction.computed == SP_CSS_DIRECTION_RTL ) activeButton4 = 1; + + EgeSelectOneAction* textDirectionAction = + EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextDirectionAction" ) ); + ege_select_one_action_set_active( textDirectionAction, activeButton4 ); + } #ifdef DEBUG_TEXT @@ -1935,6 +1992,52 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_changed), holder ); } + + // Text direction (predominant direction of horizontal text). + { + GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN ); + + GtkTreeIter iter; + + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("LTR"), + 1, _("Left to right text"), + 2, INKSCAPE_ICON("format-text-direction-horizontal"), + 3, true, + -1 ); + + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("RTL"), + 1, _("Right to left text"), + 2, INKSCAPE_ICON("format-text-direction-r2l"), + 3, true, + -1 ); + + EgeSelectOneAction* act = ege_select_one_action_new( "TextDirectionAction", // Name + _("Text direction"), // Label + _("Text direction for normally horizontal text."), // Tooltip + NULL, // Icon name + GTK_TREE_MODEL(model) ); // Model + + g_object_set( act, "short_label", "NotUsed", NULL ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + g_object_set_data( holder, "TextDirectAction", act ); + + ege_select_one_action_set_appearance( act, "full" ); + ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); + g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); + ege_select_one_action_set_icon_column( act, 2 ); + ege_select_one_action_set_icon_size( act, secondarySize ); + ege_select_one_action_set_tooltip_column( act, 1 ); + ege_select_one_action_set_sensitive_column( act, 3 ); + + gint mode = prefs->getInt("/tools/text/text_direction", 0); + ege_select_one_action_set_active( act, mode ); + g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_direction_changed), holder ); + } + /* Line height unit tracker */ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); tracker->prependUnit(unit_table.getUnit("")); // No unit diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f34b4625d..016eafdaa 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -530,6 +530,8 @@ static gchar const * ui_descr = " <toolitem action='TextWritingModeAction' />" " <separator />" " <toolitem action='TextOrientationAction' />" + " <separator />" + " <toolitem action='TextDirectionAction' />" " </toolbar>" " <toolbar name='LPEToolToolbar'>" |
