Commit b6962834 authored by Tavmjong Bah's avatar Tavmjong Bah

Backport GUI for 'direction' property' (support right-to-left text).

(6e066700, 32ffd60f, 4dfbde56)
parent b9afc287
Pipeline #11952206 passed with stage
......@@ -1744,6 +1744,93 @@ http://www.inkscape.org/</dc:description>
<path style="fill:#5a5a5a;fill-rule:evenodd" d="M 851.4754,45 849,42 851,42 851,27 852,27 852,42 854,42 851.4754,45 Z" id="path6550" sodipodi:nodetypes="cccccccc" inkscape:connector-curvature="0" />
<use xlink:href="#path6550" height="1250" width="1250" transform="translate(-5.9754)" id="use5600" y="0" x="0" />
</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 transform="translate(-196,375)" inkscape:label="#writing_mode_tb_lr" id="format-text-direction-vertical-lr">
<path inkscape:connector-curvature="0" style="color:#000000;fill:#000000;fill-opacity:0.06666673;fill-rule:evenodd" d="m 841,26 22,0 1,1 0,20 -2,2 -20,0 -1,-1 0,-22 z" id="path10109" sodipodi:nodetypes="cccccccc" />
<path inkscape:connector-curvature="0" id="path10111" d="m 840,26 1,0 0,20 -1,0 0,-20 z" style="color:#000000;fill:#000000;fill-rule:evenodd" />
......
......@@ -1160,7 +1160,6 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
// FIXME: we must detect MULTIPLE_DIFFERENT for these too
style_res->text_anchor.computed = style->text_anchor.computed;
style_res->writing_mode.computed = style->writing_mode.computed;
}
if (texts == 0)
......@@ -1397,13 +1396,15 @@ objects_query_writing_modes (const std::vector<SPItem*> &objects, SPStyle *style
texts ++;
if (set &&
( ( style_res->writing_mode.computed != style->writing_mode.computed ) ||
( ( style_res->writing_mode.computed != style->writing_mode.computed ) ||
( style_res->direction.computed != style->direction.computed ) ||
( style_res->text_orientation.computed != style->text_orientation.computed ) ) ) {
different = true; // different styles
}
set = true;
style_res->writing_mode.computed = style->writing_mode.computed;
style_res->direction.computed = style->direction.computed;
style_res->text_orientation.computed = style->text_orientation.computed;
}
......
......@@ -1071,7 +1071,7 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl )
SPStyle query(SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_WRITINGMODES);
// If querying returned nothing, update default style.
if (result_numbers == QUERY_STYLE_NOTHING)
......@@ -1125,7 +1125,7 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl )
SPStyle query(SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_WRITINGMODES);
// If querying returned nothing, update default style.
if (result_numbers == QUERY_STYLE_NOTHING)
......@@ -1145,6 +1145,53 @@ 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_WRITINGMODES);
// 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
*/
......@@ -1509,6 +1556,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
......@@ -1960,6 +2016,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, "TextDirectionAction", 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
......
......@@ -529,6 +529,8 @@ static gchar const * ui_descr =
" <toolitem action='TextWritingModeAction' />"
" <separator />"
" <toolitem action='TextOrientationAction' />"
" <separator />"
" <toolitem action='TextDirectionAction' />"
" </toolbar>"
" <toolbar name='LPEToolToolbar'>"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment