index bf12310923d010de43c89f1108b6c1b45dcee2b8..f72b0d907100b734808e8def825448093ea47d6f 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
* Josh Andler <scislac@scislac.com>
* Jon A. Cruz <jon@joncruz.org>
* Maximilian Albert <maximilian.albert@gmail.com>
+ * Tavmjong Bah <tavmjong@free.fr>
+ * Abhishek Sharma
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
- * Copyright (C) 1999-2008 authors
+ * Copyright (C) 1999-2010 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
#include "../helper/unit-tracker.h"
#include "icon.h"
#include "../ink-action.h"
+#include "../ink-comboboxentry-action.h"
#include "../inkscape.h"
#include "../interface.h"
#include "../libnrtype/font-instance.h"
#include "../sp-text.h"
#include "../style.h"
#include "../svg/css-ostringstream.h"
+#include "../text-context.h"
+#include "../text-editing.h"
#include "../tools-switch.h"
#include "../tweak-context.h"
#include "../spray-context.h"
#include "toolbox.h"
-#define ENABLE_TASK_SUPPORT 1
+//#define DEBUG_TEXT
using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
+using Inkscape::DocumentUndo;
typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop);
typedef void (*UpdateFunction)(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
static void sp_connector_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
+static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
-namespace { GtkWidget *sp_text_toolbox_new (SPDesktop *desktop); }
-
-
-#if ENABLE_TASK_SUPPORT
-static void fireTaskChange( EgeSelectOneAction *act, SPDesktop *dt )
-{
- gint selected = ege_select_one_action_get_active( act );
- UXManager::getInstance()->setTask(dt, selected);
-}
-#endif // ENABLE_TASK_SUPPORT
-
using Inkscape::UI::ToolboxFactory;
{ "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar",
SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")},
{ "SPSprayContext", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar",
- SP_VERB_CONTEXT_SPRAY_PREFS, "/tools/spray", N_("Color/opacity used for color spraying")},
+ SP_VERB_INVALID, 0, 0},
{ "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar",
SP_VERB_CONTEXT_ERASER_PREFS, "/tools/eraser", _("TBD")},
{ "SPLPEToolContext", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar",
SP_VERB_CONTEXT_LPETOOL_PREFS, "/tools/lpetool", _("TBD")},
- { "SPTextContext", "text_toolbox", sp_text_toolbox_new, 0, 0,
+ { "SPTextContext", "text_toolbox", 0, sp_text_toolbox_prep, "TextToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPDropperContext", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar",
SP_VERB_INVALID, 0, 0},
" <separator />"
" <toolitem action='ObjectEditClipPathAction' />"
" <toolitem action='ObjectEditMaskPathAction' />"
- " <toolitem action='EditNextLPEParameterAction' />"
+ " <toolitem action='EditNextPathEffectParameter' />"
" <separator />"
" <toolitem action='NodesShowTransformHandlesAction' />"
" <toolitem action='NodesShowHandlesAction' />"
" <toolitem action='EraserModeAction' />"
" </toolbar>"
+ " <toolbar name='TextToolbar'>"
+ " <toolitem action='TextFontFamilyAction' />"
+ " <toolitem action='TextFontSizeAction' />"
+ " <toolitem action='TextBoldAction' />"
+ " <toolitem action='TextItalicAction' />"
+ " <separator />"
+ " <toolitem action='TextAlignAction' />"
+ " <separator />"
+ " <toolitem action='TextSuperscriptAction' />"
+ " <toolitem action='TextSubscriptAction' />"
+ " <separator />"
+ " <toolitem action='TextLineHeightAction' />"
+ " <toolitem action='TextLetterSpacingAction' />"
+ " <toolitem action='TextWordSpacingAction' />"
+ " <toolitem action='TextDxAction' />"
+ " <toolitem action='TextDyAction' />"
+ " <toolitem action='TextRotationAction' />"
+ " <separator />"
+ " <toolitem action='TextOrientationAction' />"
+ " </toolbar>"
+
" <toolbar name='LPEToolToolbar'>"
" <toolitem action='LPEToolModeAction' />"
" <separator />"
@@ -741,7 +758,7 @@ PrefPusher::PrefPusher( GtkToggleAction *act, Glib::ustring const &path, void (*
{
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggleCB), this);
freeze = true;
- gtk_toggle_action_set_active( act, Inkscape::Preferences::get()->getBool(observed_path, true) );
+ gtk_toggle_action_set_active( act, Inkscape::Preferences::get()->getBool(observed_path) );
freeze = false;
Inkscape::Preferences::get()->addObserver(*this);
@@ -812,14 +829,14 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc
unsigned int shortcut = sp_shortcut_get_primary(verb);
- if (shortcut) {
- gchar key[256];
- sp_ui_shortcut_string(shortcut, key);
+ if (shortcut != GDK_VoidSymbol) {
+ gchar *key = sp_shortcut_get_label(shortcut);
gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key);
if ( t ) {
gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, tip, 0 );
}
g_free(tip);
+ g_free(key);
} else {
if ( t ) {
gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, action->tip, 0 );
@@ -954,44 +971,6 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
}
}
-#if ENABLE_TASK_SUPPORT
- if ( !mainActions->get_action("TaskSetAction") ) {
- GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
-
- GtkTreeIter iter;
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Default"),
- 1, _("Default interface setup"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Custom"),
- 1, _("Set the custom task"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Wide"),
- 1, _("Setup for widescreen work"),
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "TaskSetAction", _("Task"), (""), NULL, GTK_TREE_MODEL(model) );
- g_object_set( act, "short_label", _("Task:"), NULL );
- mainActions->add(Glib::wrap(GTK_ACTION(act)));
- //g_object_set_data( holder, "mode_action", act );
-
- ege_select_one_action_set_appearance( act, "minimal" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- //ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
-
- //ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(fireTaskChange), desktop );
- }
-#endif // ENABLE_TASK_SUPPORT
-
return mainActions;
}
@@ -1015,7 +994,8 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType han
gtk_widget_set_sensitive(tb, FALSE);
GtkWidget *hb = 0;
- if ( UXManager::getInstance()->isFloatWindowProblem() ) {
+ gboolean forceFloatAllowed = Inkscape::Preferences::get()->getBool("/options/workarounds/floatallowed", false);
+ if ( UXManager::getInstance()->isFloatWindowProblem() && !forceFloatAllowed ) {
hb = gtk_event_box_new(); // A simple, neutral container.
} else {
hb = gtk_handle_box_new();
@@ -1293,7 +1273,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"),
sp_units_get_pixels(adj->value, *unit));
}
@@ -1491,7 +1471,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
InkToggleAction* act = ink_toggle_action_new( "NodesShowTransformHandlesAction",
_("Show Transform Handles"),
- _("Show node transformation handles"),
+ _("Show transformation handles for selected nodes"),
"node-transform",
secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -1502,7 +1482,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
InkToggleAction* act = ink_toggle_action_new( "NodesShowHandlesAction",
_("Show Handles"),
- _("Show the Bezier handles of selected nodes"),
+ _("Show Bezier handles of selected nodes"),
INKSCAPE_ICON_SHOW_NODE_HANDLES,
secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -1513,7 +1493,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath",
_("Show Outline"),
- _("Show the outline of the path"),
+ _("Show path outline (without path effects)"),
INKSCAPE_ICON_SHOW_PATH_OUTLINE,
secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -1522,9 +1502,10 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
}
{
- InkAction* inky = ink_action_new( "EditNextLPEParameterAction",
- _("Next path effect parameter"),
- _("Show next path effect parameter for editing"),
+ Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER);
+ InkAction* inky = ink_action_new( verb->get_id(),
+ verb->get_name(),
+ verb->get_tip(),
INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop );
@@ -1535,7 +1516,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
InkToggleAction* inky = ink_toggle_action_new( "ObjectEditClipPathAction",
_("Edit clipping paths"),
- _("Show editing controls for clipping paths of selected objects"),
+ _("Show clipping path(s) of selected object(s)"),
INKSCAPE_ICON_PATH_CLIP_EDIT,
secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1546,7 +1527,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
InkToggleAction* inky = ink_toggle_action_new( "ObjectEditMaskPathAction",
_("Edit masks"),
- _("Show editing controls for masks of selected objects"),
+ _("Show mask(s) of selected object(s)"),
INKSCAPE_ICON_PATH_MASK_EDIT,
secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
gchar const * descr =
"<ui>"
" <toolbar name='ToolToolbar'>"
+
+ " <!-- Basics -->"
" <toolitem action='ToolSelector' />"
" <toolitem action='ToolNode' />"
" <toolitem action='ToolTweak' />"
- " <toolitem action='ToolSpray' />"
" <toolitem action='ToolZoom' />"
+
+ " <!-- Shapes -->"
" <toolitem action='ToolRect' />"
" <toolitem action='Tool3DBox' />"
" <toolitem action='ToolArc' />"
" <toolitem action='ToolStar' />"
" <toolitem action='ToolSpiral' />"
+
+ " <!-- Paths -->"
" <toolitem action='ToolPencil' />"
" <toolitem action='ToolPen' />"
" <toolitem action='ToolCalligraphic' />"
+
+ " <!-- Text -->"
+ " <toolitem action='ToolText' />"
+
+ " <!-- Paint large areas -->"
+ " <toolitem action='ToolSpray' />"
" <toolitem action='ToolEraser' />"
-// " <toolitem action='ToolLPETool' />"
+
+ " <!-- Fill -->"
" <toolitem action='ToolPaintBucket' />"
- " <toolitem action='ToolText' />"
- " <toolitem action='ToolConnector' />"
" <toolitem action='ToolGradient' />"
" <toolitem action='ToolDropper' />"
+
+ " <toolitem action='ToolConnector' />"
+
+// " <toolitem action='ToolLPETool' />"
" </toolbar>"
"</ui>";
" <separator />"
" <toolitem action='DialogPreferences' />"
" <toolitem action='DialogDocumentProperties' />"
-#if ENABLE_TASK_SUPPORT
- " <separator />"
- " <toolitem action='TaskSetAction' />"
-#endif // ENABLE_TASK_SUPPORT
" </toolbar>"
"</ui>";
@@ -2064,8 +2055,8 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
return;
}
- bool saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
+ bool saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
bool v = false;
SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE"));
@@ -2150,7 +2141,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
// The snapping preferences are stored in the document, and therefore toggling makes the document dirty
doc->setModifiedSinceSave();
- sp_document_set_undo_sensitive(doc, saved);
+ DocumentUndo::setUndoSensitive(doc, saved);
}
void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
- InkToggleAction* act = ink_toggle_action_new("ToggleSnapGlobal",
- _("Snap"), _("Enable snapping"), INKSCAPE_ICON_SNAP, secondarySize,
+ // TODO: This is a cludge. On the one hand we have verbs+actions,
+ // on the other we have all these explicit callbacks specified here.
+ // We should really unify these (should save some lines of code as well).
+ // For example, this action could be based on the verb(+action) + PrefsPusher.
+ Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_TOGGLE_SNAPPING);
+ InkToggleAction* act = ink_toggle_action_new(verb->get_id(),
+ verb->get_name(), verb->get_tip(), INKSCAPE_ICON_SNAP, secondarySize,
SP_ATTR_INKSCAPE_SNAP_GLOBAL);
gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
@@ -2504,7 +2500,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
// do not remember prefs if this call is initiated by an undo change, because undoing object
// creation sets bogus values to its attributes before it is deleted
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -2535,8 +2531,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
}
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change number of corners"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change number of corners"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2546,7 +2542,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
if (!IS_NAN(adj->value)) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/star/proportion", adj->value);
@@ -2582,8 +2578,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change spoke ratio"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change spoke ratio"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2594,7 +2590,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
bool flat = ege_select_one_action_get_active( act ) == 0;
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/shapes/star/isflatsided", flat);
}
@@ -2626,8 +2622,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- flat ? _("Make polygon") : _("Make star"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ flat ? _("Make polygon") : _("Make star"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2637,7 +2633,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/star/rounded", (gdouble) adj->value);
}
@@ -2663,8 +2659,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
}
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change rounding"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change rounding"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2674,7 +2670,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/star/randomized", (gdouble) adj->value);
}
@@ -2700,8 +2696,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
}
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change randomization"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change randomization"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -3039,7 +3035,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name, sp_units_get_pixels(adj->value, *unit));
}
@@ -3068,8 +3064,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
sp_rtb_sensitivize( tbl );
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
- _("Change rectangle"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
+ _("Change rectangle"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
// set freeze so that it can be caught in box3d_angle_z_value_changed() (to avoid calling
- // sp_document_maybe_done() when the document is undo insensitive)
+ // SPDocumentUndo::maybeDone() when the document is undo insensitive)
g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
// TODO: Only update the appropriate part of the toolbar
@@ -3520,7 +3516,7 @@ static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, P
SP_OBJECT(persp)->updateRepr();
// TODO: use the correct axis here, too
- sp_document_maybe_done(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
+ DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -3715,7 +3711,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/spiral/" + value_name, adj->value);
}
@@ -3746,8 +3742,8 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
g_free(namespaced_name);
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
- _("Change spiral"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
+ _("Change spiral"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -4623,8 +4619,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
/* Standard_deviation */
gchar const* labels[] = {_("(minimum scatter)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum scatter)")};
gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
+
+ //TRANSLATORS: only translate "string" in "context|string".
+ // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction",
- _("Scatter"), _("Scatter:"), _("Increase to scatter sprayed objects."),
+ Q_("Toolbox|Scatter"), Q_("Toolbox|Scatter:"), _("Increase to scatter sprayed objects."),
"/tools/spray/standard_deviation", 70,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation",
1, 100, 1.0, 10.0,
@@ -4730,8 +4729,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
{ /* Scale */
gchar const* labels[] = {_("(low scale variation)"), 0, 0, _("(default)"), 0, 0, _("(high scale variation)")};
gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+
+ //TRANSLATORS: only translate "string" in "context|string".
+ // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
EgeAdjustmentAction *eact = create_adjustment_action( "SprayScaleAction",
- _("Scale"), _("Scale:"),
+ Q_("Toolbox|Scale"), Q_("Toolbox|Scale:"),
// xgettext:no-c-format
_("Variation in the scale of the sprayed objects. 0% for the same scale than the original object."),
"/tools/spray/scale_variation", 0,
@@ -5303,7 +5305,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, adj->value);
}
@@ -5351,8 +5353,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
sp_arctb_sensitivize( tbl, adj->value, other->value );
if (modmade) {
- sp_document_maybe_done(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC,
- _("Arc: Change start/end"));
+ DocumentUndo::maybeDone(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC,
+ _("Arc: Change start/end"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0);
}
@@ -5415,8 +5417,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
- _("Arc: Change open/closed"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
+ _("Arc: Change open/closed"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
SP_LPETOOL_CONTEXT(desktop->event_context)->mode = type;
}
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt( "/tools/lpetool/mode", mode );
}
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
bool eraserMode = ege_select_one_action_get_active( act ) != 0;
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/eraser/mode", eraserMode );
}
@@ -6161,245 +6163,160 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
//########################
//## Text Toolbox ##
//########################
-/*
-static void sp_text_letter_changed(GtkAdjustment *adj, GtkWidget *tbl)
-{
- //Call back for letter sizing spinbutton
-}
-
-static void sp_text_line_changed(GtkAdjustment *adj, GtkWidget *tbl)
-{
- //Call back for line height spinbutton
-}
-static void sp_text_horiz_kern_changed(GtkAdjustment *adj, GtkWidget *tbl)
-{
- //Call back for horizontal kerning spinbutton
-}
+// Functions for debugging:
+#ifdef DEBUG_TEXT
-static void sp_text_vert_kern_changed(GtkAdjustment *adj, GtkWidget *tbl)
-{
- //Call back for vertical kerning spinbutton
-}
+static void sp_print_font( SPStyle *query ) {
-static void sp_text_letter_rotation_changed(GtkAdjustment *adj, GtkWidget *tbl)
-{
- //Call back for letter rotation spinbutton
-}*/
+ bool family_set = query->text->font_family.set;
+ bool style_set = query->font_style.set;
+ bool fontspec_set = query->text->font_specification.set;
-namespace {
+ std::cout << " Family set? " << family_set
+ << " Style set? " << style_set
+ << " FontSpec set? " << fontspec_set
+ << std::endl;
+ std::cout << " Family: "
+ << (query->text->font_family.value ? query->text->font_family.value : "No value")
+ << " Style: " << query->font_style.computed
+ << " Weight: " << query->font_weight.computed
+ << " FontSpec: "
+ << (query->text->font_specification.value ? query->text->font_specification.value : "No value")
+ << std::endl;
+}
-static void sp_text_toolbox_selection_changed(Inkscape::Selection * /*selection*/, GObject *tbl)
-{
- // quit if run by the _changed callbacks
- if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
- return;
- }
+static void sp_print_fontweight( SPStyle *query ) {
+ const gchar* names[] = {"100", "200", "300", "400", "500", "600", "700", "800", "900",
+ "NORMAL", "BOLD", "LIGHTER", "BOLDER", "Out of range"};
+ // Missing book = 380
+ int index = query->font_weight.computed;
+ if( index < 0 || index > 13 ) index = 13;
+ std::cout << " Weight: " << names[ index ]
+ << " (" << query->font_weight.computed << ")" << std::endl;
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+}
- SPStyle *query =
- sp_style_new (SP_ACTIVE_DOCUMENT);
+static void sp_print_fontstyle( SPStyle *query ) {
- int result_family =
- sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+ const gchar* names[] = {"NORMAL", "ITALIC", "OBLIQUE", "Out of range"};
+ int index = query->font_style.computed;
+ if( index < 0 || index > 3 ) index = 3;
+ std::cout << " Style: " << names[ index ] << std::endl;
- int result_style =
- sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+}
+#endif
- int result_numbers =
- sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+// Format family drop-down menu.
+static void cell_data_func(GtkCellLayout * /*cell_layout*/,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer /*data*/)
+{
+ gchar *family;
+ gtk_tree_model_get(tree_model, iter, 0, &family, -1);
+ gchar *const family_escaped = g_markup_escape_text(family, -1);
- gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1);
+ if (show_sample) {
- // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
- if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
- // there are no texts in selection, read from prefs
+ Glib::ustring sample = prefs->getString("/tools/text/font_sample");
+ gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1);
- sp_style_read_from_prefs(query, "/tools/text");
+ std::stringstream markup;
+ markup << family_escaped << " <span foreground='gray' font_family='"
+ << family_escaped << "'>" << sample_escaped << "</span>";
+ g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL);
- if (g_object_get_data(tbl, "text_style_from_prefs")) {
- // do not reset the toolbar style from prefs if we already did it last time
- sp_style_unref(query);
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- return;
- }
- g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE));
+ g_free(sample_escaped);
} else {
- g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(FALSE));
- }
-
- if (query->text)
- {
- if (result_family == QUERY_STYLE_MULTIPLE_DIFFERENT) {
- GtkWidget *entry = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "family-entry"));
- gtk_entry_set_text (GTK_ENTRY (entry), "");
-
- } else if (query->text->font_specification.value || query->text->font_family.value) {
-
- Gtk::ComboBoxEntry *combo = (Gtk::ComboBoxEntry *) (g_object_get_data (G_OBJECT (tbl), "family-entry-combo"));
- GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry"));
-
- // Get the font that corresponds
- Glib::ustring familyName;
-
- font_instance * font = font_factory::Default()->FaceFromStyle(query);
- if (font) {
- familyName = font_factory::Default()->GetUIFamilyString(font->descr);
- font->Unref();
- font = NULL;
- }
-
- gtk_entry_set_text (GTK_ENTRY (entry), familyName.c_str());
-
- Gtk::TreeIter iter;
- try {
- Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (familyName);
- Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
- iter = model->get_iter(path);
- } catch (...) {
- g_warning("Family name %s does not have an entry in the font lister.", familyName.c_str());
- sp_style_unref(query);
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- return;
- }
-
- combo->set_active (iter);
- }
-
- //Size
- {
- GtkWidget *cbox = GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "combo-box-size"));
- gchar *const str = g_strdup_printf("%.5g", query->font_size.computed);
- gtk_entry_set_text(GTK_ENTRY(GTK_BIN(cbox)->child), str);
- g_free(str);
- }
-
- //Anchor
- if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY)
- {
- GtkWidget *button = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "text-fill"));
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- } else {
- if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START)
- {
- GtkWidget *button = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "text-start"));
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- } else if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) {
- GtkWidget *button = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "text-middle"));
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- } else if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_END) {
- GtkWidget *button = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "text-end"));
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- }
- }
-
- //Style
- {
- GtkToggleButton *button = GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (tbl), "style-bold"));
-
- gboolean active = gtk_toggle_button_get_active (button);
- gboolean check = ((query->font_weight.computed >= SP_CSS_FONT_WEIGHT_700) && (query->font_weight.computed != SP_CSS_FONT_WEIGHT_NORMAL) && (query->font_weight.computed != SP_CSS_FONT_WEIGHT_LIGHTER));
-
- if (active != check)
- {
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), check);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- }
- }
-
- {
- GtkToggleButton *button = GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (tbl), "style-italic"));
-
- gboolean active = gtk_toggle_button_get_active (button);
- gboolean check = (query->font_style.computed != SP_CSS_FONT_STYLE_NORMAL);
-
- if (active != check)
- {
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), check);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- }
- }
-
- //Orientation
- //locking both buttons, changing one affect all group (both)
- GtkWidget *button = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "orientation-horizontal"));
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
-
- GtkWidget *button1 = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "orientation-vertical"));
- g_object_set_data (G_OBJECT (button1), "block", gpointer(1));
-
- if (query->writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- } else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button1), TRUE);
- }
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- g_object_set_data (G_OBJECT (button1), "block", gpointer(0));
+ g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL);
}
+ // This doesn't work for two reasons... it set both selected and not selected backgrounds
+ // to white.. which means that white foreground text is invisible. It also only effects
+ // the text region, leaving the padding untouched.
+ // g_object_set (G_OBJECT (cell), "cell-background", "white", "cell-background-set", true, NULL);
- sp_style_unref(query);
-
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
-}
-
-static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, guint /*flags*/, GObject *tbl)
-{
- sp_text_toolbox_selection_changed (selection, tbl);
+ g_free(family);
+ g_free(family_escaped);
}
-static void sp_text_toolbox_subselection_changed(gpointer /*tc*/, GObject *tbl)
+// Font family
+static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GObject *tbl )
{
- sp_text_toolbox_selection_changed (NULL, tbl);
-}
+#ifdef DEBUG_TEXT
+ std::cout << std::endl;
+ std::cout << "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" << std::endl;
+ std::cout << "sp_text_fontfamily_value_changed: " << std::endl;
+#endif
-static void sp_text_toolbox_family_changed(GtkComboBoxEntry *,
- GObject *tbl)
-{
- // quit if run by the _changed callbacks
+ // 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) );
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- GtkWidget *entry = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
- const gchar* family = gtk_entry_get_text (GTK_ENTRY (entry));
+ gchar *family = ink_comboboxentry_action_get_active_text( act );
+#ifdef DEBUG_TEXT
+ std::cout << " New family: " << family << std::endl;
+#endif
- //g_print ("family changed to: %s\n", family);
+ // First try to get the old font spec from the stored value
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
- SPStyle *query =
- sp_style_new (SP_ACTIVE_DOCUMENT);
+ Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
- int result_fontspec =
- sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
+ // If that didn't work, try to get font spec from style
+ if (fontSpec.empty()) {
- SPCSSAttr *css = sp_repr_css_attr_new ();
+ // Must query all to fill font-family, font-style, font-weight, font-specification
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
- // First try to get the font spec from the stored value
- Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
+ // Construct a new font specification if it does not yet exist
+ font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+ if( fontFromStyle ) {
+ fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+ fontFromStyle->Unref();
+ }
+#ifdef DEBUG_TEXT
+ std::cout << " Fontspec not defined, reconstructed from style :" << fontSpec << ":" << std::endl;
+ sp_print_font( query );
+#endif
+ }
- if (fontSpec.empty()) {
+ // And if that didn't work use default
+ if( fontSpec.empty() ) {
+ sp_style_read_from_prefs(query, "/tools/text");
+#ifdef DEBUG_TEXT
+ std::cout << " read style from prefs:" << std::endl;
+ sp_print_font( query );
+#endif
// Construct a new font specification if it does not yet exist
font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
- fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
- fontFromStyle->Unref();
+ if( fontFromStyle ) {
+ fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+ fontFromStyle->Unref();
+ }
+#ifdef DEBUG_TEXT
+ std::cout << " Fontspec not defined, reconstructed from style :" << fontSpec << ":" << std::endl;
+ sp_print_font( query );
+#endif
}
+ SPCSSAttr *css = sp_repr_css_attr_new ();
if (!fontSpec.empty()) {
- Glib::ustring newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family);
+ // Now we have a font specification, replace family.
+ Glib::ustring newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family);
+
+#ifdef DEBUG_TEXT
+ std::cout << " New FontSpec from ReplaceFontSpecificationFamily :" << newFontSpec << ":" << std::endl;
+#endif
if (!newFontSpec.empty()) {
}
} else {
- // If the old font on selection (or default) was not existing on the system,
+
+ // newFontSpec empty
+ // If the old font on selection (or default) does not exist on the system,
+ // or the new font family does not exist,
// ReplaceFontSpecificationFamily does not work. In that case we fall back to blindly
// setting the family reported by the family chooser.
- //g_print ("fallback setting family: %s\n", family);
+ // g_print ("fallback setting family: %s\n", family);
sp_repr_css_set_property (css, "-inkscape-font-specification", family);
sp_repr_css_set_property (css, "font-family", family);
+ // Shoud we set other css font attributes?
}
- }
- // If querying returned nothing, set the default style of the tool (for new texts)
- if (result_fontspec == QUERY_STYLE_NOTHING) {
+ } // fontSpec not empty or not
+
+ // If querying returned nothing, update default style.
+ if (result_fontspec == QUERY_STYLE_NOTHING)
+ {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->mergeStyle("/tools/text/style", css);
- sp_text_edit_dialog_default_set_insensitive (); //FIXME: Replace trough a verb
- } else {
- sp_desktop_set_style (desktop, css, true, true);
+ sp_text_edit_dialog_default_set_insensitive (); //FIXME: Replace through a verb
+ }
+ else
+ {
+ sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true);
}
sp_style_unref(query);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change font family"));
- sp_repr_css_attr_unref (css);
+ g_free (family);
- gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));
+ // Save for undo
+ if (result_fontspec != QUERY_STYLE_NOTHING) {
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change font family"));
+ }
+ sp_repr_css_attr_unref (css);
// unfreeze
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
// focus to canvas
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
-}
+ gtk_widget_grab_focus (GTK_WIDGET((SP_ACTIVE_DESKTOP)->canvas));
+#ifdef DEBUG_TEXT
+ std::cout << "sp_text_toolbox_fontfamily_changes: exit" << std::endl;
+ std::cout << "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" << std::endl;
+ std::cout << std::endl;
+#endif
+}
-static void sp_text_toolbox_anchoring_toggled(GtkRadioButton *button,
- gpointer data)
+// Font size
+static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObject *tbl )
{
- if (g_object_get_data (G_OBJECT (button), "block")) {
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
return;
}
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
+ gchar *text = ink_comboboxentry_action_get_active_text( act );
+ gchar *endptr;
+ gdouble size = g_strtod( text, &endptr );
+ if (endptr == text) { // Conversion failed, non-numeric input.
+ g_warning( "Conversion of size text to double failed, input: %s\n", text );
+ g_free( text );
return;
}
- int prop = GPOINTER_TO_INT(data);
+ g_free( text );
+ // Set css font size.
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ Inkscape::CSSOStringStream osfs;
+ osfs << size << "px"; // For now always use px
+ sp_repr_css_set_property (css, "font-size", osfs.str().c_str());
+
+ // Apply font size to selected objects.
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css, true, true);
- // move the x of all texts to preserve the same bbox
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
- for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
- if (SP_IS_TEXT((SPItem *) items->data)) {
- SPItem *item = SP_ITEM(items->data);
+ // If no selected objects, set default.
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ if (result_numbers == QUERY_STYLE_NOTHING)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ } else {
+ // Save for undo
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE,
+ _("Text: Change font size"));
+ }
- unsigned writing_mode = SP_OBJECT_STYLE(item)->writing_mode.value;
- // below, variable names suggest horizontal move, but we check the writing direction
- // and move in the corresponding axis
- int axis;
- if (writing_mode == SP_CSS_WRITING_MODE_LR_TB || writing_mode == SP_CSS_WRITING_MODE_RL_TB) {
- axis = NR::X;
- } else {
- axis = NR::Y;
- }
+ sp_style_unref(query);
- Geom::OptRect bbox
- = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX);
- if (!bbox) {
- continue;
- }
- double width = bbox->dimensions()[axis];
- // If you want to align within some frame, other than the text's own bbox, calculate
- // the left and right (or top and bottom for tb text) slacks of the text inside that
- // frame (currently unused)
- double left_slack = 0;
- double right_slack = 0;
- unsigned old_align = SP_OBJECT_STYLE(item)->text_align.value;
- double move = 0;
- if (old_align == SP_CSS_TEXT_ALIGN_START || old_align == SP_CSS_TEXT_ALIGN_LEFT) {
- switch (prop) {
- case 0:
- move = -left_slack;
- break;
- case 1:
- move = width/2 + (right_slack - left_slack)/2;
- break;
- case 2:
- move = width + right_slack;
- break;
- }
- } else if (old_align == SP_CSS_TEXT_ALIGN_CENTER) {
- switch (prop) {
- case 0:
- move = -width/2 - left_slack;
- break;
- case 1:
+ sp_repr_css_attr_unref (css);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+// Handles both Bold and Italic/Oblique
+static void sp_text_style_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) );
+
+ // Called by Bold or Italics button?
+ const gchar* name = gtk_action_get_name( GTK_ACTION( act ) );
+ gint prop = (strcmp(name, "TextBoldAction") == 0) ? 0 : 1;
+
+ // First query font-specification, this is the most complete font face description.
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
+
+ // font_specification will not be set unless defined explicitely on a tspan.
+ // This should be fixed!
+ Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
+
+ if (fontSpec.empty()) {
+ // Construct a new font specification if it does not yet exist
+ // Must query font-family, font-style, font-weight, to find correct font face.
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+
+ font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+ if( fontFromStyle ) {
+ fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+ fontFromStyle->Unref();
+ }
+ }
+
+ // Now that we have the old face, find the new face.
+ Glib::ustring newFontSpec = "";
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ gboolean nochange = true;
+ gboolean active = gtk_toggle_action_get_active( GTK_TOGGLE_ACTION(act) );
+
+ switch (prop)
+ {
+ case 0:
+ {
+ // Bold
+ if (!fontSpec.empty()) {
+
+ newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active);
+
+ if (!newFontSpec.empty()) {
+
+ // Set weight if we found font.
+ font_instance * font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str());
+ if (font) {
+ gchar c[256];
+ font->Attribute( "weight", c, 256);
+ sp_repr_css_set_property (css, "font-weight", c);
+ font->Unref();
+ font = NULL;
+ }
+ nochange = false;
+ }
+ }
+ // Reset button if no change.
+ // The reset code didn't work in 0.47 and doesn't here... one must prevent an infinite loop
+ /*
+ if(nochange) {
+ gtk_action_block_activate( GTK_ACTION(act) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), !active );
+ gtk_action_unblock_activate( GTK_ACTION(act) );
+ }
+ */
+ break;
+ }
+
+ case 1:
+ {
+ // Italic/Oblique
+ if (!fontSpec.empty()) {
+
+ newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active);
+
+ if (!newFontSpec.empty()) {
+
+ // Don't even set the italic/oblique if the font didn't exist on the system
+ if( active ) {
+ if( newFontSpec.find( "Italic" ) != Glib::ustring::npos ) {
+ sp_repr_css_set_property (css, "font-style", "italic");
+ } else {
+ sp_repr_css_set_property (css, "font-style", "oblique");
+ }
+ } else {
+ sp_repr_css_set_property (css, "font-style", "normal");
+ }
+ nochange = false;
+ }
+ }
+ // Reset button if no change.
+ // The reset code didn't work in 0.47... one must prevent an infinite loop
+ /*
+ if(nochange) {
+ gtk_action_block_activate( GTK_ACTION(act) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), !active );
+ gtk_action_unblock_activate( GTK_ACTION(act) );
+ }
+ */
+ break;
+ }
+ }
+
+ if (!newFontSpec.empty()) {
+ sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str());
+ }
+
+ // If querying returned nothing, update default style.
+ if (result_fontspec == QUERY_STYLE_NOTHING)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ }
+
+ sp_style_unref(query);
+
+ // Do we need to update other CSS values?
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css, true, true);
+ if (result_fontspec != QUERY_STYLE_NOTHING) {
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change font style"));
+ }
+ sp_repr_css_attr_unref (css);
+
+ 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 )
+{
+ // 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) );
+
+ // Called by Superscript or Subscript button?
+ const gchar* name = gtk_action_get_name( GTK_ACTION( act ) );
+ gint prop = (strcmp(name, "TextSuperscriptAction") == 0) ? 0 : 1;
+
+#ifdef DEBUG_TEXT
+ std::cout << "sp_text_script_changed: " << prop << std::endl;
+#endif
+
+ // Query baseline
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_baseline = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_BASELINES);
+
+ bool setSuper = false;
+ bool setSub = false;
+
+ if(result_baseline == QUERY_STYLE_NOTHING || result_baseline == QUERY_STYLE_MULTIPLE_DIFFERENT ) {
+ // If not set or mixed, turn on superscript or subscript
+ if( prop == 0 ) {
+ setSuper = true;
+ } else {
+ setSub = true;
+ }
+ } else {
+ // Superscript
+ gboolean superscriptSet = (query->baseline_shift.set &&
+ query->baseline_shift.type == SP_BASELINE_SHIFT_LITERAL &&
+ query->baseline_shift.literal == SP_CSS_BASELINE_SHIFT_SUPER );
+
+ // Subscript
+ gboolean subscriptSet = (query->baseline_shift.set &&
+ query->baseline_shift.type == SP_BASELINE_SHIFT_LITERAL &&
+ query->baseline_shift.literal == SP_CSS_BASELINE_SHIFT_SUB );
+
+ setSuper = !superscriptSet && prop == 0;
+ setSub = !subscriptSet && prop == 1;
+ }
+
+ // Set css properties
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ if( setSuper || setSub ) {
+ // Openoffice 2.3 and Adobe use 58%, Microsoft Word 2002 uses 65%, LaTex about 70%.
+ // 58% looks too small to me, especially if a superscript is placed on a superscript.
+ // If you make a change here, consider making a change to baseline-shift amount
+ // in style.cpp.
+ sp_repr_css_set_property (css, "font-size", "65%");
+ } else {
+ sp_repr_css_set_property (css, "font-size", "");
+ }
+ if( setSuper ) {
+ sp_repr_css_set_property (css, "baseline-shift", "super");
+ } else if( setSub ) {
+ sp_repr_css_set_property (css, "baseline-shift", "sub");
+ } else {
+ sp_repr_css_set_property (css, "baseline-shift", "baseline");
+ }
+
+ // Apply css to selected objects.
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css, true, false);
+
+ // Save for undo
+ if(result_baseline != QUERY_STYLE_NOTHING) {
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE,
+ _("Text: Change superscript or subscript"));
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void sp_text_align_mode_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 );
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/tools/text/align_mode", mode);
+
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
+ // move the x of all texts to preserve the same bbox
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
+ if (SP_IS_TEXT((SPItem *) items->data)) {
+ SPItem *item = SP_ITEM(items->data);
+
+ unsigned writing_mode = SP_OBJECT_STYLE(item)->writing_mode.value;
+ // below, variable names suggest horizontal move, but we check the writing direction
+ // and move in the corresponding axis
+ int axis;
+ if (writing_mode == SP_CSS_WRITING_MODE_LR_TB || writing_mode == SP_CSS_WRITING_MODE_RL_TB) {
+ axis = NR::X;
+ } else {
+ axis = NR::Y;
+ }
+
+ Geom::OptRect bbox
+ = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX);
+ if (!bbox)
+ continue;
+ double width = bbox->dimensions()[axis];
+ // If you want to align within some frame, other than the text's own bbox, calculate
+ // the left and right (or top and bottom for tb text) slacks of the text inside that
+ // frame (currently unused)
+ double left_slack = 0;
+ double right_slack = 0;
+ unsigned old_align = SP_OBJECT_STYLE(item)->text_align.value;
+ double move = 0;
+ if (old_align == SP_CSS_TEXT_ALIGN_START || old_align == SP_CSS_TEXT_ALIGN_LEFT) {
+ switch (mode) {
+ case 0:
+ move = -left_slack;
+ break;
+ case 1:
+ move = width/2 + (right_slack - left_slack)/2;
+ break;
+ case 2:
+ move = width + right_slack;
+ break;
+ }
+ } else if (old_align == SP_CSS_TEXT_ALIGN_CENTER) {
+ switch (mode) {
+ case 0:
+ move = -width/2 - left_slack;
+ break;
+ case 1:
move = (right_slack - left_slack)/2;
break;
case 2:
break;
}
} else if (old_align == SP_CSS_TEXT_ALIGN_END || old_align == SP_CSS_TEXT_ALIGN_RIGHT) {
- switch (prop) {
+ switch (mode) {
case 0:
move = -width - left_slack;
break;
}
SPCSSAttr *css = sp_repr_css_attr_new ();
- switch (prop)
+ switch (mode)
{
case 0:
{
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
- // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
+ // If querying returned nothing, update default style.
if (result_numbers == QUERY_STYLE_NOTHING)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
sp_style_unref(query);
sp_desktop_set_style (desktop, css, true, true);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change alignment"));
+ if (result_numbers != QUERY_STYLE_NOTHING)
+ {
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change alignment"));
+ }
sp_repr_css_attr_unref (css);
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_text_toolbox_style_toggled(GtkToggleButton *button,
- gpointer data)
+static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
{
- if (g_object_get_data (G_OBJECT (button), "block")) {
+ // 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) );
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- SPCSSAttr *css = sp_repr_css_attr_new ();
- int prop = GPOINTER_TO_INT(data);
- bool active = gtk_toggle_button_get_active (button);
-
- SPStyle *query =
- sp_style_new (SP_ACTIVE_DOCUMENT);
+ // At the moment this handles only numerical values (i.e. no percent).
+ // Set css line height.
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ Inkscape::CSSOStringStream osfs;
+ osfs << adj->value*100 << "%";
+ sp_repr_css_set_property (css, "line-height", osfs.str().c_str());
- int result_fontspec =
- sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
+ // Apply line-height to selected objects.
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css, true, false);
- //int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
- //int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
- //int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
- Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
- Glib::ustring newFontSpec = "";
+ // Until deprecated sodipodi:linespacing purged:
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ GSList const *items = selection->itemList();
+ bool modmade = false;
+ for (; items != NULL; items = items->next) {
+ if (SP_IS_TEXT (items->data)) {
+ SP_OBJECT_REPR(items->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
+ modmade = true;
+ }
+ }
- if (fontSpec.empty()) {
- // Construct a new font specification if it does not yet exist
- font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
- fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
- fontFromStyle->Unref();
+ // Save for undo
+ if(modmade) {
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE,
+ _("Text: Change line-height"));
}
- bool nochange = true;
- switch (prop)
+ // If no selected objects, set default.
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ if (result_numbers == QUERY_STYLE_NOTHING)
{
- case 0:
- {
- if (!fontSpec.empty()) {
- newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active);
- if (!newFontSpec.empty()) {
- // Don't even set the bold if the font didn't exist on the system
- sp_repr_css_set_property (css, "font-weight", active ? "bold" : "normal" );
- nochange = false;
- }
- }
- // set or reset the button according
- if(nochange) {
- gboolean check = gtk_toggle_button_get_active (button);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ }
+ sp_style_unref(query);
- if (active != check)
- {
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- }
- }
+ sp_repr_css_attr_unref (css);
- break;
- }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
- case 1:
- {
- if (!fontSpec.empty()) {
- newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active);
- if (!newFontSpec.empty()) {
- // Don't even set the italic if the font didn't exist on the system
- sp_repr_css_set_property (css, "font-style", active ? "italic" : "normal");
- nochange = false;
- }
- }
- if(nochange) {
- gboolean check = gtk_toggle_button_get_active (button);
+static void sp_text_wordspacing_value_changed( GtkAdjustment *adj, 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) );
- if (active != check)
- {
- g_object_set_data (G_OBJECT (button), "block", gpointer(1));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
- }
- }
- break;
- }
+ // At the moment this handles only numerical values (i.e. no em unit).
+ // Set css word-spacing
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ Inkscape::CSSOStringStream osfs;
+ osfs << adj->value << "px"; // For now always use px
+ sp_repr_css_set_property (css, "word-spacing", osfs.str().c_str());
+
+ // Apply word-spacing to selected objects.
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css, true, false);
+
+ // If no selected objects, set default.
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ if (result_numbers == QUERY_STYLE_NOTHING)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ } else {
+ // Save for undo
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE,
+ _("Text: Change word-spacing"));
}
+ sp_style_unref(query);
- if (!newFontSpec.empty()) {
- sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str());
+ sp_repr_css_attr_unref (css);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, 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) );
- // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
- if (result_fontspec == QUERY_STYLE_NOTHING)
+ // At the moment this handles only numerical values (i.e. no em unit).
+ // Set css letter-spacing
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ Inkscape::CSSOStringStream osfs;
+ osfs << adj->value << "px"; // For now always use px
+ sp_repr_css_set_property (css, "letter-spacing", osfs.str().c_str());
+
+ // Apply letter-spacing to selected objects.
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css, true, false);
+
+
+ // If no selected objects, set default.
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ if (result_numbers == QUERY_STYLE_NOTHING)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->mergeStyle("/tools/text/style", css);
}
+ else
+ {
+ // Save for undo
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE,
+ _("Text: Change letter-spacing"));
+ }
sp_style_unref(query);
- sp_desktop_set_style (desktop, css, true, true);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change font style"));
+
sp_repr_css_attr_unref (css);
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_text_toolbox_orientation_toggled(GtkRadioButton *button,
- gpointer data)
+
+static void sp_text_dx_value_changed( GtkAdjustment *adj, GObject *tbl )
{
- if (g_object_get_data (G_OBJECT (button), "block")) {
+ // 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) );
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- SPCSSAttr *css = sp_repr_css_attr_new ();
- int prop = GPOINTER_TO_INT(data);
+ gdouble new_dx = adj->value;
+ bool modmade = false;
- switch (prop)
+ if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
+ SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ if( tc ) {
+ unsigned char_index = -1;
+ TextTagAttributes *attributes =
+ text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
+ if( attributes ) {
+ double old_dx = attributes->getDx( char_index );
+ double delta_dx = new_dx - old_dx;
+ sp_te_adjust_dx( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_dx );
+ modmade = true;
+ }
+ }
+ }
+
+ if(modmade) {
+ // Save for undo
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE,
+ _("Text: Change dx (kern)"));
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void sp_text_dy_value_changed( GtkAdjustment *adj, 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) );
+
+ gdouble new_dy = adj->value;
+ bool modmade = false;
+
+ if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
+ SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ if( tc ) {
+ unsigned char_index = -1;
+ TextTagAttributes *attributes =
+ text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
+ if( attributes ) {
+ double old_dy = attributes->getDy( char_index );
+ double delta_dy = new_dy - old_dy;
+ sp_te_adjust_dy( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_dy );
+ modmade = true;
+ }
+ }
+ }
+
+ if(modmade) {
+ // Save for undo
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE,
+ _("Text: Change dy"));
+ }
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void sp_text_rotation_value_changed( GtkAdjustment *adj, 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) );
+
+ gdouble new_degrees = adj->value;
+
+ bool modmade = false;
+ if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
+ SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ if( tc ) {
+ unsigned char_index = -1;
+ TextTagAttributes *attributes =
+ text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
+ if( attributes ) {
+ double old_degrees = attributes->getRotate( char_index );
+ double delta_deg = new_degrees - old_degrees;
+ sp_te_adjust_rotation( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_deg );
+ modmade = true;
+ }
+ }
+ }
+
+ // Save for undo
+ if(modmade) {
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE,
+ _("Text: Change rotate"));
+ }
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void sp_text_orientation_mode_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:
{
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
- // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
+ // 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 (desktop, css, true, true);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change orientation"));
+ sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true);
+ if(result_numbers != QUERY_STYLE_NOTHING)
+ {
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change orientation"));
+ }
sp_repr_css_attr_unref (css);
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static gboolean sp_text_toolbox_family_keypress(GtkWidget * /*w*/, GdkEventKey *event, GObject *tbl)
+/*
+ * This function sets up the text-tool tool-controls, setting the entry boxes
+ * etc. to the values from the current selection or the default if no selection.
+ * It is called whenever a text selection is changed, including stepping cursor
+ * through text.
+ */
+static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/, GObject *tbl)
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (!desktop) {
- return FALSE;
- }
+#ifdef DEBUG_TEXT
+ static int count = 0;
+ ++count;
+ std::cout << std::endl;
+ std::cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
+ std::cout << "sp_text_toolbox_selection_changed: start " << count << std::endl;
- switch (get_group0_keyval (event)) {
- case GDK_KP_Enter: // chosen
- case GDK_Return:
- // unfreeze and update, which will defocus
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- sp_text_toolbox_family_changed (NULL, tbl);
- return TRUE; // I consumed the event
- break;
- case GDK_Escape:
- // defocus
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- return TRUE; // I consumed the event
- break;
+ std::cout << " Selected items:" << std::endl;
+ for (GSList const *items = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList();
+ items != NULL;
+ items = items->next)
+ {
+ const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
+ std::cout << " " << id << std::endl;
}
- return FALSE;
-}
+ Glib::ustring selected_text = sp_text_get_selected_text((SP_ACTIVE_DESKTOP)->event_context);
+ std::cout << " Selected text:" << std::endl;
+ std::cout << selected_text << std::endl;
+#endif
-static gboolean sp_text_toolbox_family_list_keypress(GtkWidget * /*w*/, GdkEventKey *event, GObject * /*tbl*/)
-{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (!desktop) {
- return FALSE;
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+#ifdef DEBUG_TEXT
+ std::cout << " Frozen, returning" << std::endl;
+ std::cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
+ std::cout << std::endl;
+#endif
+ return;
}
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- switch (get_group0_keyval (event)) {
- case GDK_KP_Enter:
- case GDK_Return:
- case GDK_Escape: // defocus
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- return TRUE; // I consumed the event
- break;
- case GDK_w:
- case GDK_W:
- if (event->state & GDK_CONTROL_MASK) {
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- return TRUE; // I consumed the event
- }
+ // Only flowed text can be justified, only normal text can be kerned...
+ // Find out if we have flowed text now so we can use it several places
+ gboolean isFlow = false;
+ for (GSList const *items = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList();
+ items != NULL;
+ items = items->next) {
+ // const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
+ // std::cout << " " << id << std::endl;
+ if( SP_IS_FLOWTEXT(( SPItem *) items->data )) {
+ isFlow = true;
+ // std::cout << " Found flowed text" << std::endl;
break;
+ }
}
- return FALSE;
-}
+ /*
+ * Query from current selection:
+ * Font family (font-family)
+ * Style (font-weight, font-style, font-stretch, font-variant, font-align)
+ * Numbers (font-size, letter-spacing, word-spacing, line-height, text-anchor, writing-mode)
+ * Font specification (Inkscape private attribute)
+ */
+ SPStyle *query =
+ sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+ int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+ int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ int result_baseline = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_BASELINES);
+
+ // Used later:
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
+
+ /*
+ * If no text in selection (querying returned nothing), read the style from
+ * the /tools/text preferencess (default style for new texts). Return if
+ * tool bar already set to these preferences.
+ */
+ if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
+ // There are no texts in selection, read from preferences.
+ sp_style_read_from_prefs(query, "/tools/text");
+#ifdef DEBUG_TEXT
+ std::cout << " read style from prefs:" << std::endl;
+ sp_print_font( query );
+#endif
+ if (g_object_get_data(tbl, "text_style_from_prefs")) {
+ // Do not reset the toolbar style from prefs if we already did it last time
+ sp_style_unref(query);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+#ifdef DEBUG_TEXT
+ std::cout << " text_style_from_prefs: toolbar already set" << std:: endl;
+ std::cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
+ std::cout << std::endl;
+#endif
+ return;
+ }
-static void sp_text_toolbox_size_changed(GtkComboBox *cbox,
- GObject *tbl)
-{
- // quit if run by the _changed callbacks
- if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
- return;
+ g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE));
+ } else {
+ g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(FALSE));
}
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ // If we have valid query data for text (font-family, font-specification) set toolbar accordingly.
+ if (query->text)
+ {
+ // Font family
+ if( query->text->font_family.value ) {
+ gchar *fontFamily = query->text->font_family.value;
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ Ink_ComboBoxEntry_Action* fontFamilyAction =
+ INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) );
+ ink_comboboxentry_action_set_active_text( fontFamilyAction, fontFamily );
+ }
- // If this is not from selecting a size in the list (in which case get_active will give the
- // index of the selected item, otherwise -1) and not from user pressing Enter/Return, do not
- // process this event. This fixes GTK's stupid insistence on sending an activate change every
- // time any character gets typed or deleted, which made this control nearly unusable in 0.45.
- if (gtk_combo_box_get_active (cbox) < 0 && !g_object_get_data (tbl, "enter-pressed")) {
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- return;
- }
- gdouble value = -1;
- {
- gchar *endptr;
- gchar *const text = gtk_combo_box_get_active_text(cbox);
- if (text) {
- value = g_strtod(text, &endptr);
- if (endptr == text) { // Conversion failed, non-numeric input.
- value = -1;
+ // Size (average of text selected)
+ double size = query->font_size.computed;
+ gchar size_text[G_ASCII_DTOSTR_BUF_SIZE];
+ g_ascii_dtostr (size_text, sizeof (size_text), size);
+
+ Ink_ComboBoxEntry_Action* fontSizeAction =
+ INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontSizeAction" ) );
+ ink_comboboxentry_action_set_active_text( fontSizeAction, size_text );
+
+
+ // Weight (Bold)
+ // Note: in the enumeration, normal and lighter come at the end so we must explicitly test for them.
+ gboolean boldSet = ((query->font_weight.computed >= SP_CSS_FONT_WEIGHT_700) &&
+ (query->font_weight.computed != SP_CSS_FONT_WEIGHT_NORMAL) &&
+ (query->font_weight.computed != SP_CSS_FONT_WEIGHT_LIGHTER));
+
+ InkToggleAction* textBoldAction = INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextBoldAction" ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(textBoldAction), boldSet );
+
+
+ // Style (Italic/Oblique)
+ gboolean italicSet = (query->font_style.computed != SP_CSS_FONT_STYLE_NORMAL);
+
+ InkToggleAction* textItalicAction = INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextItalicAction" ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(textItalicAction), italicSet );
+
+
+ // Superscript
+ gboolean superscriptSet =
+ ((result_baseline == QUERY_STYLE_SINGLE || result_baseline == QUERY_STYLE_MULTIPLE_SAME ) &&
+ query->baseline_shift.set &&
+ query->baseline_shift.type == SP_BASELINE_SHIFT_LITERAL &&
+ query->baseline_shift.literal == SP_CSS_BASELINE_SHIFT_SUPER );
+
+ InkToggleAction* textSuperscriptAction = INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextSuperscriptAction" ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(textSuperscriptAction), superscriptSet );
+
+
+ // Subscript
+ gboolean subscriptSet =
+ ((result_baseline == QUERY_STYLE_SINGLE || result_baseline == QUERY_STYLE_MULTIPLE_SAME ) &&
+ query->baseline_shift.set &&
+ query->baseline_shift.type == SP_BASELINE_SHIFT_LITERAL &&
+ query->baseline_shift.literal == SP_CSS_BASELINE_SHIFT_SUB );
+
+ InkToggleAction* textSubscriptAction = INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextSubscriptAction" ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(textSubscriptAction), subscriptSet );
+
+
+ // Alignment
+ EgeSelectOneAction* textAlignAction = EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextAlignAction" ) );
+
+ // Note: SVG 1.1 doesn't include text-align, SVG 1.2 Tiny doesn't include text-align="justify"
+ // text-align="justify" was a draft SVG 1.2 item (along with flowed text).
+ // Only flowed text can be left and right justified at the same time.
+ // Disable button if we don't have flowed text.
+
+ // The GtkTreeModel class doesn't have a set function so we can't
+ // simply add an ege_select_one_action_set_sensitive method!
+ // We must set values directly with the GtkListStore and then
+ // ask that the GtkAction update the sensitive parameters.
+ GtkListStore * model = GTK_LIST_STORE( ege_select_one_action_get_model( textAlignAction ) );
+ GtkTreePath * path = gtk_tree_path_new_from_string("3"); // Justify entry
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
+ gtk_list_store_set( model, &iter, /* column */ 3, isFlow, -1 );
+ ege_select_one_action_update_sensitive( textAlignAction );
+ // ege_select_one_action_set_sensitive( textAlignAction, 3, isFlow );
+
+ int activeButton = 0;
+ if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY)
+ {
+ activeButton = 3;
+ } else {
+ if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) activeButton = 0;
+ if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) activeButton = 1;
+ if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_END) activeButton = 2;
+ }
+ ege_select_one_action_set_active( textAlignAction, activeButton );
+
+
+ // Line height (spacing)
+ double height;
+ if (query->line_height.normal) {
+ height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ } else {
+ if (query->line_height.unit == SP_CSS_UNIT_PERCENT) {
+ height = query->line_height.value;
+ } else {
+ height = query->line_height.computed;
}
- g_free(text);
}
- }
- if (value <= 0) {
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- return; // could not parse value
- }
- SPCSSAttr *css = sp_repr_css_attr_new ();
- Inkscape::CSSOStringStream osfs;
- osfs << value;
- sp_repr_css_set_property (css, "font-size", osfs.str().c_str());
+ GtkAction* lineHeightAction = GTK_ACTION( g_object_get_data( tbl, "TextLineHeightAction" ) );
+ GtkAdjustment *lineHeightAdjustment =
+ ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( lineHeightAction ));
+ gtk_adjustment_set_value( lineHeightAdjustment, height );
+
+
+ // Word spacing
+ double wordSpacing;
+ if (query->word_spacing.normal) wordSpacing = 0.0;
+ else wordSpacing = query->word_spacing.computed; // Assume no units (change in desktop-style.cpp)
+
+ GtkAction* wordSpacingAction = GTK_ACTION( g_object_get_data( tbl, "TextWordSpacingAction" ) );
+ GtkAdjustment *wordSpacingAdjustment =
+ ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( wordSpacingAction ));
+ gtk_adjustment_set_value( wordSpacingAdjustment, wordSpacing );
+
+
+ // Letter spacing
+ double letterSpacing;
+ if (query->letter_spacing.normal) letterSpacing = 0.0;
+ else letterSpacing = query->letter_spacing.computed; // Assume no units (change in desktop-style.cpp)
+
+ GtkAction* letterSpacingAction = GTK_ACTION( g_object_get_data( tbl, "TextLetterSpacingAction" ) );
+ GtkAdjustment *letterSpacingAdjustment =
+ ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( letterSpacingAction ));
+ gtk_adjustment_set_value( letterSpacingAdjustment, letterSpacing );
+
+
+ // Orientation
+ int activeButton2 = (query->writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB ? 0 : 1);
+
+ EgeSelectOneAction* textOrientationAction =
+ EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextOrientationAction" ) );
+ ege_select_one_action_set_active( textOrientationAction, activeButton2 );
+
+
+ } // if( query->text )
+
+#ifdef DEBUG_TEXT
+ std::cout << " GUI: fontfamily.value: "
+ << (query->text->font_family.value ? query->text->font_family.value : "No value")
+ << std::endl;
+ std::cout << " GUI: font_size.computed: " << query->font_size.computed << std::endl;
+ std::cout << " GUI: font_weight.computed: " << query->font_weight.computed << std::endl;
+ std::cout << " GUI: font_style.computed: " << query->font_style.computed << std::endl;
+ std::cout << " GUI: text_anchor.computed: " << query->text_anchor.computed << std::endl;
+ std::cout << " GUI: text_align.computed: " << query->text_align.computed << std::endl;
+ std::cout << " GUI: line_height.computed: " << query->line_height.computed
+ << " line_height.value: " << query->line_height.value
+ << " line_height.unit: " << query->line_height.unit << std::endl;
+ std::cout << " GUI: word_spacing.computed: " << query->word_spacing.computed
+ << " word_spacing.value: " << query->word_spacing.value
+ << " word_spacing.unit: " << query->word_spacing.unit << std::endl;
+ std::cout << " GUI: letter_spacing.computed: " << query->letter_spacing.computed
+ << " letter_spacing.value: " << query->letter_spacing.value
+ << " letter_spacing.unit: " << query->letter_spacing.unit << std::endl;
+ std::cout << " GUI: writing_mode.computed: " << query->writing_mode.computed << std::endl;
+#endif
- SPStyle *query =
- sp_style_new (SP_ACTIVE_DOCUMENT);
- int result_numbers =
- sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ sp_style_unref(query);
- // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
- if (result_numbers == QUERY_STYLE_NOTHING)
- {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->mergeStyle("/tools/text/style", css);
+ // Kerning (xshift), yshift, rotation. NB: These are not CSS attributes.
+ if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
+ SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ if( tc ) {
+ unsigned char_index = -1;
+ TextTagAttributes *attributes =
+ text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
+ if( attributes ) {
+
+ // Dx
+ double dx = attributes->getDx( char_index );
+ GtkAction* dxAction = GTK_ACTION( g_object_get_data( tbl, "TextDxAction" ));
+ GtkAdjustment *dxAdjustment =
+ ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( dxAction ));
+ gtk_adjustment_set_value( dxAdjustment, dx );
+
+ // Dy
+ double dy = attributes->getDy( char_index );
+ GtkAction* dyAction = GTK_ACTION( g_object_get_data( tbl, "TextDyAction" ));
+ GtkAdjustment *dyAdjustment =
+ ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( dyAction ));
+ gtk_adjustment_set_value( dyAdjustment, dy );
+
+ // Rotation
+ double rotation = attributes->getRotate( char_index );
+ /* SVG value is between 0 and 360 but we're using -180 to 180 in widget */
+ if( rotation > 180.0 ) rotation -= 360.0;
+ GtkAction* rotationAction = GTK_ACTION( g_object_get_data( tbl, "TextRotationAction" ));
+ GtkAdjustment *rotationAdjustment =
+ ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( rotationAction ));
+ gtk_adjustment_set_value( rotationAdjustment, rotation );
+
+#ifdef DEBUG_TEXT
+ std::cout << " GUI: Dx: " << dx << std::endl;
+ std::cout << " GUI: Dy: " << dy << std::endl;
+ std::cout << " GUI: Rotation: " << rotation << std::endl;
+#endif
+ }
+ }
}
- sp_style_unref(query);
+ {
+ // Set these here as we don't always have kerning/rotating attributes
+ GtkAction* dxAction = GTK_ACTION( g_object_get_data( tbl, "TextDxAction" ));
+ gtk_action_set_sensitive( GTK_ACTION(dxAction), !isFlow );
- sp_desktop_set_style (desktop, css, true, true);
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE,
- _("Text: Change font size"));
- sp_repr_css_attr_unref (css);
+ GtkAction* dyAction = GTK_ACTION( g_object_get_data( tbl, "TextDyAction" ));
+ gtk_action_set_sensitive( GTK_ACTION(dyAction), !isFlow );
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ GtkAction* rotationAction = GTK_ACTION( g_object_get_data( tbl, "TextRotationAction" ));
+ gtk_action_set_sensitive( GTK_ACTION(rotationAction), !isFlow );
+ }
+
+#ifdef DEBUG_TEXT
+ std::cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
+ std::cout << std::endl;
+#endif
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+
}
-static gboolean sp_text_toolbox_size_focusout(GtkWidget * /*w*/, GdkEventFocus * /*event*/, GObject *tbl)
+static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, guint /*flags*/, GObject *tbl)
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (!desktop) {
- return FALSE;
+ sp_text_toolbox_selection_changed (selection, tbl);
+}
+
+void
+sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl)
+{
+ sp_text_toolbox_selection_changed (NULL, tbl);
+}
+
+// Define all the "widgets" in the toolbar.
+static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+
+ // Is this used?
+ UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
+ tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
+ g_object_set_data( holder, "tracker", tracker );
+
+ /* Font family */
+ {
+ // Font list
+ Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list();
+ GtkListStore* model = store->gobj();
+
+ Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction",
+ _("Font Family"),
+ _("Select Font Family (Alt-X to access)"),
+ NULL,
+ GTK_TREE_MODEL(model),
+ -1, // Entry width
+ 50, // Extra list width
+ (gpointer)cell_data_func ); // Cell layout
+ ink_comboboxentry_action_popup_enable( act ); // Enable entry completion
+ gchar *const warning = _("Font not found on system");
+ ink_comboboxentry_action_set_warning( act, warning ); // Show icon with tooltip if missing font
+ ink_comboboxentry_action_set_altx_name( act, "altx-text" ); // Set Alt-X keyboard shortcut
+ g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontfamily_value_changed), holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "TextFontFamilyAction", act );
+
+ // Change style of drop-down from menu to list
+ gtk_rc_parse_string (
+ "style \"dropdown-as-list-style\"\n"
+ "{\n"
+ " GtkComboBox::appears-as-list = 1\n"
+ "}\n"
+ "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\"");
+ }
+
+ /* Font size */
+ {
+ // List of font sizes for drop-down menu
+ GtkListStore* model_size = gtk_list_store_new( 1, G_TYPE_STRING );
+ gchar const *const sizes[] = {
+ "4", "6", "8", "9", "10", "11", "12", "13", "14", "16",
+ "18", "20", "22", "24", "28", "32", "36", "40", "48", "56",
+ "64", "72", "144"
+ };
+ for( unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i ) {
+ GtkTreeIter iter;
+ gtk_list_store_append( model_size, &iter );
+ gtk_list_store_set( model_size, &iter, 0, sizes[i], -1 );
+ }
+
+ Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontSizeAction",
+ _("Font Size"),
+ _("Font size (px)"),
+ NULL,
+ GTK_TREE_MODEL(model_size),
+ 4 ); // Width in characters
+ g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontsize_value_changed), holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "TextFontSizeAction", act );
}
- if (!g_object_get_data (tbl, "esc-pressed")) {
- g_object_set_data (tbl, "enter-pressed", gpointer(1));
- GtkComboBox *cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT (tbl), "combo-box-size"));
- sp_text_toolbox_size_changed (cbox, tbl);
- g_object_set_data (tbl, "enter-pressed", gpointer(0));
+ /* Style - Bold */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "TextBoldAction", // Name
+ _("Toggle Bold"), // Label
+ _("Toggle bold or normal weight"), // Tooltip
+ GTK_STOCK_BOLD, // Icon (inkId)
+ secondarySize ); // Icon size
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_style_changed), holder );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/bold", false) );
+ g_object_set_data( holder, "TextBoldAction", act );
}
- return FALSE; // I consumed the event
-}
+ /* Style - Italic/Oblique */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "TextItalicAction", // Name
+ _("Toggle Italic/Oblique"), // Label
+ _("Toggle italic/oblique style"),// Tooltip
+ GTK_STOCK_ITALIC, // Icon (inkId)
+ secondarySize ); // Icon size
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_style_changed), holder );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/italic", false) );
+ g_object_set_data( holder, "TextItalicAction", act );
+ }
-static gboolean sp_text_toolbox_size_keypress(GtkWidget * /*w*/, GdkEventKey *event, GObject *tbl)
-{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (!desktop) {
- return FALSE;
+ /* Style - Superscript */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "TextSuperscriptAction", // Name
+ _("Toggle Superscript"), // Label
+ _("Toggle superscript"), // Tooltip
+ "text_superscript", // Icon (inkId)
+ secondarySize ); // Icon size
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_script_changed), holder );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/super", false) );
+ g_object_set_data( holder, "TextSuperscriptAction", act );
}
- switch (get_group0_keyval (event)) {
- case GDK_Escape: // defocus
- g_object_set_data (tbl, "esc-pressed", gpointer(1));
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- g_object_set_data (tbl, "esc-pressed", gpointer(0));
- return TRUE; // I consumed the event
- break;
- case GDK_Return: // defocus
- case GDK_KP_Enter:
- g_object_set_data (tbl, "enter-pressed", gpointer(1));
- GtkComboBox *cbox = GTK_COMBO_BOX(g_object_get_data (G_OBJECT (tbl), "combo-box-size"));
- sp_text_toolbox_size_changed (cbox, tbl);
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- g_object_set_data (tbl, "enter-pressed", gpointer(0));
- return TRUE; // I consumed the event
- break;
+ /* Style - Subscript */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "TextSubscriptAction", // Name
+ _("Toggle Subscript"), // Label
+ _("Toggle subscript"), // Tooltip
+ "text_subscript", // Icon (inkId)
+ secondarySize ); // Icon size
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_script_changed), holder );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/sub", false) );
+ g_object_set_data( holder, "TextSubscriptAction", act );
}
- return FALSE;
-}
-// While editing font name in the entry, disable family_changed by freezing, otherwise completion
-// does not work!
-static gboolean sp_text_toolbox_entry_focus_in(GtkWidget *entry,
- GdkEventFocus * /*event*/,
- GObject *tbl)
-{
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- gtk_entry_select_region (GTK_ENTRY (entry), 0, -1); // select all
- return FALSE;
-}
+ /* Alignment */
+ {
+ GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
-static gboolean sp_text_toolbox_entry_focus_out(GtkWidget *entry,
- GdkEventFocus * /*event*/,
- GObject *tbl)
-{
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- gtk_entry_select_region (GTK_ENTRY (entry), 0, 0); // deselect
- return FALSE;
-}
+ GtkTreeIter iter;
-static void cell_data_func(GtkCellLayout * /*cell_layout*/,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer /*data*/)
-{
- gchar *family;
- gtk_tree_model_get(tree_model, iter, 0, &family, -1);
- gchar *const family_escaped = g_markup_escape_text(family, -1);
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Align left"),
+ 1, _("Align left"),
+ 2, GTK_STOCK_JUSTIFY_LEFT,
+ 3, true,
+ -1 );
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1);
- if (show_sample) {
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Align center"),
+ 1, _("Align center"),
+ 2, GTK_STOCK_JUSTIFY_CENTER,
+ 3, true,
+ -1 );
- Glib::ustring sample = prefs->getString("/tools/text/font_sample");
- gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1);
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Align right"),
+ 1, _("Align right"),
+ 2, GTK_STOCK_JUSTIFY_RIGHT,
+ 3, true,
+ -1 );
- std::stringstream markup;
- markup << family_escaped << " <span foreground='darkgray' font_family='"
- << family_escaped << "'>" << sample_escaped << "</span>";
- g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL);
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Justify"),
+ 1, _("Justify (only flowed text)"),
+ 2, GTK_STOCK_JUSTIFY_FILL,
+ 3, false,
+ -1 );
- g_free(sample_escaped);
- } else {
- g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL);
+ EgeSelectOneAction* act = ege_select_one_action_new( "TextAlignAction", // Name
+ _("Alignment"), // Label
+ _("Text alignment"), // Tooltip
+ NULL, // StockID
+ 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, "TextAlignAction", 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/align_mode", 0);
+ ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_align_mode_changed), holder );
}
- g_free(family);
- g_free(family_escaped);
-}
+ /* Orientation (Left to Right, Top to Bottom */
+ {
+ GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
-static gboolean text_toolbox_completion_match_selected(GtkEntryCompletion * /*widget*/,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- GObject *tbl)
-{
- // We intercept this signal so as to fire family_changed at once (without it, you'd have to
- // press Enter again after choosing a completion)
- gchar *family = 0;
- gtk_tree_model_get(model, iter, 0, &family, -1);
+ GtkTreeIter iter;
- GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry"));
- gtk_entry_set_text (GTK_ENTRY (entry), family);
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Horizontal"),
+ 1, _("Horizontal text"),
+ 2, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL,
+ -1 );
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- sp_text_toolbox_family_changed (NULL, tbl);
- return TRUE;
-}
-
-
-static void cbe_add_completion(GtkComboBoxEntry *cbe, GObject *tbl)
-{
- GtkEntry *entry;
- GtkEntryCompletion *completion;
- GtkTreeModel *model;
-
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbe)));
- completion = gtk_entry_completion_new();
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
- gtk_entry_completion_set_model(completion, model);
- gtk_entry_completion_set_text_column(completion, 0);
- gtk_entry_completion_set_inline_completion(completion, FALSE);
- gtk_entry_completion_set_inline_selection(completion, FALSE);
- gtk_entry_completion_set_popup_completion(completion, TRUE);
- gtk_entry_set_completion(entry, completion);
-
- g_signal_connect (G_OBJECT (completion), "match-selected", G_CALLBACK (text_toolbox_completion_match_selected), tbl);
-
- g_object_unref(completion);
-}
-
-static void sp_text_toolbox_family_popnotify(GtkComboBox *widget,
- void * /*property*/,
- GObject *tbl)
-{
- // while the drop-down is open, we disable font family changing, reenabling it only when it closes
-
- gboolean shown;
- g_object_get (G_OBJECT(widget), "popup-shown", &shown, NULL);
- if (shown) {
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- //g_print("POP: notify: SHOWN\n");
- } else {
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
-
- // stupid GTK doesn't let us attach to events in the drop-down window, so we peek here to
- // find out if the drop down was closed by Enter and if so, manually update (only
- // necessary on Windows, on Linux it updates itself - what a mess, but we'll manage)
- GdkEvent *ev = gtk_get_current_event();
- if (ev) {
- //g_print ("ev type: %d\n", ev->type);
- if (ev->type == GDK_KEY_PRESS) {
- switch (get_group0_keyval ((GdkEventKey *) ev)) {
- case GDK_KP_Enter: // chosen
- case GDK_Return:
- {
- // make sure the chosen one is inserted into the entry
- GtkComboBox *combo = GTK_COMBO_BOX (((Gtk::ComboBox *) (g_object_get_data (tbl, "family-entry-combo")))->gobj());
- GtkTreeModel *model = gtk_combo_box_get_model(combo);
- GtkTreeIter iter;
- gboolean has_active = gtk_combo_box_get_active_iter (combo, &iter);
- if (has_active) {
- gchar *family;
- gtk_tree_model_get(model, &iter, 0, &family, -1);
- GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry"));
- gtk_entry_set_text (GTK_ENTRY (entry), family);
- }
-
- // update
- sp_text_toolbox_family_changed (NULL, tbl);
- break;
- }
- }
- }
- }
-
- // regardless of whether we updated, defocus the widget
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- }
- //g_print("POP: notify: HIDDEN\n");
- }
-}
-
-GtkWidget *sp_text_toolbox_new(SPDesktop *desktop)
-{
- GtkToolbar *tbl = GTK_TOOLBAR(gtk_toolbar_new());
- GtkIconSize secondarySize = static_cast<GtkIconSize>(ToolboxFactory::prefToSize("/toolbox/secondary", 1));
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Vertical"),
+ 1, _("Vertical text"),
+ 2, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL,
+ -1 );
- gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
- gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop);
+ EgeSelectOneAction* act = ege_select_one_action_new( "TextOrientationAction", // Name
+ _("Orientation"), // Label
+ _("Text orientation"), // Tooltip
+ NULL, // StockID
+ GTK_TREE_MODEL(model) ); // Model
- GtkTooltips *tt = gtk_tooltips_new();
-
- ////////////Family
- Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list();
- Gtk::ComboBoxEntry *font_sel = Gtk::manage(new Gtk::ComboBoxEntry(store));
-
- gtk_rc_parse_string (
- "style \"dropdown-as-list-style\"\n"
- "{\n"
- " GtkComboBox::appears-as-list = 1\n"
- "}\n"
- "widget \"*.toolbox-fontfamily-list\" style \"dropdown-as-list-style\"");
- gtk_widget_set_name(GTK_WIDGET (font_sel->gobj()), "toolbox-fontfamily-list");
- gtk_tooltips_set_tip (tt, GTK_WIDGET (font_sel->gobj()), _("Select font family (Alt+X to access)"), "");
-
- g_signal_connect (G_OBJECT (font_sel->gobj()), "key-press-event", G_CALLBACK(sp_text_toolbox_family_list_keypress), tbl);
-
- cbe_add_completion(font_sel->gobj(), G_OBJECT(tbl));
-
- gtk_toolbar_append_widget( tbl, (GtkWidget*) font_sel->gobj(), "", "");
- g_object_set_data (G_OBJECT (tbl), "family-entry-combo", font_sel);
-
- // expand the field a bit so as to view more of the previews in the drop-down
- GtkRequisition req;
- gtk_widget_size_request (GTK_WIDGET (font_sel->gobj()), &req);
- gtk_widget_set_size_request (GTK_WIDGET (font_sel->gobj()), MIN(req.width + 50, 500), -1);
-
- GtkWidget* entry = (GtkWidget*) font_sel->get_entry()->gobj();
- g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (sp_text_toolbox_family_changed), tbl);
-
- g_signal_connect (G_OBJECT (font_sel->gobj()), "changed", G_CALLBACK (sp_text_toolbox_family_changed), tbl);
- g_signal_connect (G_OBJECT (font_sel->gobj()), "notify::popup-shown",
- G_CALLBACK (sp_text_toolbox_family_popnotify), tbl);
- g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK(sp_text_toolbox_family_keypress), tbl);
- g_signal_connect (G_OBJECT (entry), "focus-in-event", G_CALLBACK (sp_text_toolbox_entry_focus_in), tbl);
- g_signal_connect (G_OBJECT (entry), "focus-out-event", G_CALLBACK (sp_text_toolbox_entry_focus_out), tbl);
-
- gtk_object_set_data(GTK_OBJECT(entry), "altx-text", entry);
- g_object_set_data (G_OBJECT (tbl), "family-entry", entry);
-
- GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_clear( GTK_CELL_LAYOUT(font_sel->gobj()) );
- gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(font_sel->gobj()) , cell , TRUE );
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(font_sel->gobj()), cell, GtkCellLayoutDataFunc (cell_data_func), NULL, NULL);
-
- GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, secondarySize);
- GtkWidget *box = gtk_event_box_new ();
- gtk_container_add (GTK_CONTAINER (box), image);
- gtk_toolbar_append_widget( tbl, box, "", "");
- g_object_set_data (G_OBJECT (tbl), "warning-image", box);
- gtk_tooltips_set_tip (tt, box, _("This font is currently not installed on your system. Inkscape will use the default font instead."), "");
- gtk_widget_hide (GTK_WIDGET (box));
- g_signal_connect_swapped (G_OBJECT (tbl), "show", G_CALLBACK (gtk_widget_hide), box);
-
- ////////////Size
- gchar const *const sizes[] = {
- "4", "6", "8", "9", "10", "11", "12", "13", "14",
- "16", "18", "20", "22", "24", "28",
- "32", "36", "40", "48", "56", "64", "72", "144"
- };
+ g_object_set( act, "short_label", "NotUsed", NULL );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "TextOrientationAction", 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 );
- GtkWidget *cbox = gtk_combo_box_entry_new_text ();
- for (unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i) {
- gtk_combo_box_append_text(GTK_COMBO_BOX(cbox), sizes[i]);
- }
- gtk_widget_set_size_request (cbox, 80, -1);
- gtk_toolbar_append_widget( tbl, cbox, "", "");
- g_object_set_data (G_OBJECT (tbl), "combo-box-size", cbox);
- g_signal_connect (G_OBJECT (cbox), "changed", G_CALLBACK (sp_text_toolbox_size_changed), tbl);
- gtk_signal_connect(GTK_OBJECT(gtk_bin_get_child(GTK_BIN(cbox))), "key-press-event", GTK_SIGNAL_FUNC(sp_text_toolbox_size_keypress), tbl);
- gtk_signal_connect(GTK_OBJECT(gtk_bin_get_child(GTK_BIN(cbox))), "focus-out-event", GTK_SIGNAL_FUNC(sp_text_toolbox_size_focusout), tbl);
-
- ////////////Text anchor
- GtkWidget *group = gtk_radio_button_new (NULL);
- GtkWidget *row = gtk_hbox_new (FALSE, 4);
- g_object_set_data (G_OBJECT (tbl), "anchor-group", group);
-
- // left
- GtkWidget *rbutton = group;
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_LEFT, secondarySize));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "text-start", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_anchoring_toggled), gpointer(0));
- gtk_tooltips_set_tip(tt, rbutton, _("Align left"), NULL);
-
- // center
- rbutton = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_CENTER, secondarySize));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "text-middle", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_anchoring_toggled), gpointer (1));
- gtk_tooltips_set_tip(tt, rbutton, _("Center"), NULL);
-
- // right
- rbutton = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT, secondarySize));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "text-end", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_anchoring_toggled), gpointer(2));
- gtk_tooltips_set_tip(tt, rbutton, _("Align right"), NULL);
-
- // fill
- rbutton = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton), gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_FILL, secondarySize));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "text-fill", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_anchoring_toggled), gpointer(3));
- gtk_tooltips_set_tip(tt, rbutton, _("Justify"), NULL);
-
- gtk_toolbar_append_widget( tbl, row, "", "");
-
- //spacer
- gtk_toolbar_append_widget( tbl, gtk_vseparator_new(), "", "" );
-
- ////////////Text style
- row = gtk_hbox_new (FALSE, 4);
-
- // bold
- rbutton = gtk_toggle_button_new ();
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton), gtk_image_new_from_stock (GTK_STOCK_BOLD, secondarySize));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
- gtk_tooltips_set_tip(tt, rbutton, _("Bold"), NULL);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "style-bold", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_style_toggled), gpointer(0));
-
- // italic
- rbutton = gtk_toggle_button_new ();
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton), gtk_image_new_from_stock (GTK_STOCK_ITALIC, secondarySize));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
- gtk_tooltips_set_tip(tt, rbutton, _("Italic"), NULL);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "style-italic", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_style_toggled), gpointer (1));
-
- gtk_toolbar_append_widget( tbl, row, "", "");
-
- //spacer
- gtk_toolbar_append_widget( tbl, gtk_vseparator_new(), "", "" );
-
- // Text orientation
- group = gtk_radio_button_new (NULL);
- row = gtk_hbox_new (FALSE, 4);
- g_object_set_data (G_OBJECT (tbl), "orientation-group", group);
-
- // horizontal
- rbutton = group;
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton),
- sp_icon_new (static_cast<Inkscape::IconSize>(secondarySize), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
- gtk_tooltips_set_tip(tt, rbutton, _("Horizontal text"), NULL);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "orientation-horizontal", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_orientation_toggled), gpointer(0));
-
- // vertical
- rbutton = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
- gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (rbutton),
- sp_icon_new (static_cast<Inkscape::IconSize>(secondarySize), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
- gtk_tooltips_set_tip(tt, rbutton, _("Vertical text"), NULL);
-
- gtk_box_pack_start (GTK_BOX (row), rbutton, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (tbl), "orientation-vertical", rbutton);
- g_signal_connect (G_OBJECT (rbutton), "toggled", G_CALLBACK (sp_text_toolbox_orientation_toggled), gpointer (1));
- gtk_toolbar_append_widget( tbl, row, "", "" );
+ gint mode = prefs->getInt("/tools/text/orientation", 0);
+ ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_mode_changed), holder );
+ }
+
+ /* Line height */
+ {
+ // Drop down menu
+ gchar const* labels[] = {_("Smaller spacing"), 0, 0, 0, 0, _("Normal"), 0, 0, 0, 0, 0, _("Larger spacing")};
+ gdouble values[] = { 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1,2, 1.3, 1.4, 1.5, 2.0};
+
+ EgeAdjustmentAction *eact = create_adjustment_action(
+ "TextLineHeightAction", /* name */
+ _("Line Height"), /* label */
+ _("Line:"), /* short label */
+ _("Spacing between lines (times font size)"), /* tooltip */
+ "/tools/text/lineheight", /* preferences path */
+ 0.0, /* default */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ NULL, /* unit selector */
+ holder, /* dataKludge */
+ FALSE, /* set alt-x keyboard shortcut? */
+ NULL, /* altx_mark */
+ 0.0, 10.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
+ labels, values, G_N_ELEMENTS(labels), /* drop down menu */
+ sp_text_lineheight_value_changed, /* callback */
+ 0.1, /* step (used?) */
+ 2, /* digits to show */
+ 1.0 /* factor (multiplies default) */
+ );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "TextLineHeightAction", eact );
+ g_object_set( G_OBJECT(eact), "iconId", "text_line_spacing", NULL );
+ }
+
+ /* Word spacing */
+ {
+ // Drop down menu
+ gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, _("Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")};
+ gdouble values[] = {-2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0};
+
+ EgeAdjustmentAction *eact = create_adjustment_action(
+ "TextWordSpacingAction", /* name */
+ _("Word spacing"), /* label */
+ _("Word:"), /* short label */
+ _("Spacing between words (px)"), /* tooltip */
+ "/tools/text/wordspacing", /* preferences path */
+ 0.0, /* default */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ NULL, /* unit selector */
+ holder, /* dataKludge */
+ FALSE, /* set alt-x keyboard shortcut? */
+ NULL, /* altx_mark */
+ -100.0, 100.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
+ labels, values, G_N_ELEMENTS(labels), /* drop down menu */
+ sp_text_wordspacing_value_changed, /* callback */
+ 0.1, /* step (used?) */
+ 2, /* digits to show */
+ 1.0 /* factor (multiplies default) */
+ );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "TextWordSpacingAction", eact );
+ g_object_set( G_OBJECT(eact), "iconId", "text_word_spacing", NULL );
+ }
+
+ /* Letter spacing */
+ {
+ // Drop down menu
+ gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, _("Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")};
+ gdouble values[] = {-2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0};
+
+ EgeAdjustmentAction *eact = create_adjustment_action(
+ "TextLetterSpacingAction", /* name */
+ _("Letter spacing"), /* label */
+ _("Letter:"), /* short label */
+ _("Spacing between letters (px)"), /* tooltip */
+ "/tools/text/letterspacing", /* preferences path */
+ 0.0, /* default */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ NULL, /* unit selector */
+ holder, /* dataKludge */
+ FALSE, /* set alt-x keyboard shortcut? */
+ NULL, /* altx_mark */
+ -100.0, 100.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
+ labels, values, G_N_ELEMENTS(labels), /* drop down menu */
+ sp_text_letterspacing_value_changed, /* callback */
+ 0.1, /* step (used?) */
+ 2, /* digits to show */
+ 1.0 /* factor (multiplies default) */
+ );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "TextLetterSpacingAction", eact );
+ g_object_set( G_OBJECT(eact), "iconId", "text_letter_spacing", NULL );
+ }
+
+ /* Character kerning (horizontal shift) */
+ {
+ // Drop down menu
+ gchar const* labels[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ gdouble values[] = { -2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5 };
+
+ EgeAdjustmentAction *eact = create_adjustment_action(
+ "TextDxAction", /* name */
+ _("Kerning"), /* label */
+ _("Kern:"), /* short label */
+ _("Horizontal kerning (px)"), /* tooltip */
+ "/tools/text/dx", /* preferences path */
+ 0.0, /* default */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ NULL, /* unit selector */
+ holder, /* dataKludge */
+ FALSE, /* set alt-x keyboard shortcut? */
+ NULL, /* altx_mark */
+ -100.0, 100.0, 0.01, 0.1, /* lower, upper, step (arrow up/down), page up/down */
+ labels, values, G_N_ELEMENTS(labels), /* drop down menu */
+ sp_text_dx_value_changed, /* callback */
+ 0.1, /* step (used?) */
+ 2, /* digits to show */
+ 1.0 /* factor (multiplies default) */
+ );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "TextDxAction", eact );
+ g_object_set( G_OBJECT(eact), "iconId", "text_horz_kern", NULL );
+ }
+
+ /* Character vertical shift */
+ {
+ // Drop down menu
+ gchar const* labels[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ gdouble values[] = { -2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5 };
+
+ EgeAdjustmentAction *eact = create_adjustment_action(
+ "TextDyAction", /* name */
+ _("Vertical Shift"), /* label */
+ _("Vert:"), /* short label */
+ _("Vertical shift (px)"), /* tooltip */
+ "/tools/text/dy", /* preferences path */
+ 0.0, /* default */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ NULL, /* unit selector */
+ holder, /* dataKludge */
+ FALSE, /* set alt-x keyboard shortcut? */
+ NULL, /* altx_mark */
+ -100.0, 100.0, 0.01, 0.1, /* lower, upper, step (arrow up/down), page up/down */
+ labels, values, G_N_ELEMENTS(labels), /* drop down menu */
+ sp_text_dy_value_changed, /* callback */
+ 0.1, /* step (used?) */
+ 2, /* digits to show */
+ 1.0 /* factor (multiplies default) */
+ );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "TextDyAction", eact );
+ g_object_set( G_OBJECT(eact), "iconId", "text_vert_kern", NULL );
+ }
+
+ /* Character rotation */
+ {
+ // Drop down menu
+ gchar const* labels[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ gdouble values[] = { -90, -45, -30, -15, 0, 15, 30, 45, 90, 180 };
+
+ EgeAdjustmentAction *eact = create_adjustment_action(
+ "TextRotationAction", /* name */
+ _("Letter rotation"), /* label */
+ _("Rot:"), /* short label */
+ _("Character rotation (degrees)"),/* tooltip */
+ "/tools/text/rotation", /* preferences path */
+ 0.0, /* default */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ NULL, /* unit selector */
+ holder, /* dataKludge */
+ FALSE, /* set alt-x keyboard shortcut? */
+ NULL, /* altx_mark */
+ -180.0, 180.0, 0.1, 1.0, /* lower, upper, step (arrow up/down), page up/down */
+ labels, values, G_N_ELEMENTS(labels), /* drop down menu */
+ sp_text_rotation_value_changed, /* callback */
+ 0.1, /* step (used?) */
+ 2, /* digits to show */
+ 1.0 /* factor (multiplies default) */
+ );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "TextRotationAction", eact );
+ g_object_set( G_OBJECT(eact), "iconId", "text_rotation", NULL );
+ }
+ // Is this necessary to call? Shouldn't hurt.
+ sp_text_toolbox_selection_changed(sp_desktop_selection(desktop), holder);
- //watch selection
- Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISTextToolbox");
+ // Watch selection
+ Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISTextToolboxGTK");
sigc::connection *c_selection_changed =
new sigc::connection (sp_desktop_selection (desktop)->connectChanged
- (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)tbl)));
+ (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)holder)));
pool->add_connection ("selection-changed", c_selection_changed);
sigc::connection *c_selection_modified =
new sigc::connection (sp_desktop_selection (desktop)->connectModified
- (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), (GObject*)tbl)));
+ (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), (GObject*)holder)));
pool->add_connection ("selection-modified", c_selection_modified);
sigc::connection *c_subselection_changed =
new sigc::connection (desktop->connectToolSubselectionChanged
- (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), (GObject*)tbl)));
+ (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), (GObject*)holder)));
pool->add_connection ("tool-subselection-changed", c_subselection_changed);
- Inkscape::ConnectionPool::connect_destroy (G_OBJECT (tbl), pool);
-
-
- gtk_widget_show_all( GTK_WIDGET(tbl) );
+ Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool);
- return GTK_WIDGET(tbl);
-} // end of sp_text_toolbox_new()
+ g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
-}//<unnamed> namespace
+}
//#########################
@@ -7324,7 +7910,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
- if (!sp_document_get_undo_sensitive(doc)) {
+ if (!DocumentUndo::getUndoSensitive(doc)) {
return;
}
@@ -7348,7 +7934,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
SPItem *item = (SPItem *) l->data;
if (cc_item_is_connector(item)) {
- sp_object_setAttribute(item, "inkscape:connector-type",
+ item->setAttribute( "inkscape:connector-type",
value, false);
item->avoidRef->handleSettingChange();
modmade = true;
@@ -7359,10 +7945,11 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
if (!modmade) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/connector/orthogonal", is_orthog);
- }
+ } else {
- sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
- is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline"));
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline"));
+ }
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
- if (!sp_document_get_undo_sensitive(doc)) {
+ if (!DocumentUndo::getUndoSensitive(doc)) {
return;
}
SPItem *item = (SPItem *) l->data;
if (cc_item_is_connector(item)) {
- sp_object_setAttribute(item, "inkscape:connector-curvature",
+ item->setAttribute( "inkscape:connector-curvature",
value, false);
item->avoidRef->handleSettingChange();
modmade = true;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/connector/curvature"), newValue);
}
-
- sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
- _("Change connector curvature"));
+ else {
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ _("Change connector curvature"));
+ }
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
SPDocument *doc = sp_desktop_document(desktop);
- if (!sp_document_get_undo_sensitive(doc)) {
+ if (!DocumentUndo::getUndoSensitive(doc)) {
return;
}
sp_repr_set_css_double(repr, "inkscape:connector-spacing", adj->value);
SP_OBJECT(desktop->namedview)->updateRepr();
+ bool modmade = false;
GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop);
for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) {
SPItem *item = reinterpret_cast<SPItem *>(iter->data);
Geom::Matrix m = Geom::identity();
avoid_item_move(&m, item);
+ modmade = true;
}
if (items) {
g_slist_free(items);
}
-
- sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
- _("Change connector spacing"));
-
+ if(modmade) {
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ _("Change connector spacing"));
+ }
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
}
static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GtkObject * /*tbl*/ )
{
GtkWidget *tbl = GTK_WIDGET(data);
- if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
- return;
- }
- if (strcmp(name, "inkscape:connector-spacing") == 0)
- {
- GtkAdjustment *adj = (GtkAdjustment*)
- gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
+ if ( !g_object_get_data(G_OBJECT(tbl), "freeze")
+ && (strcmp(name, "inkscape:connector-spacing") == 0) ) {
+ GtkAdjustment *adj = static_cast<GtkAdjustment*>(gtk_object_get_data(GTK_OBJECT(tbl), "spacing"));
gdouble spacing = defaultConnSpacing;
sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);
gtk_adjustment_set_value(adj, spacing);
gtk_adjustment_value_changed(adj);
- }
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(GTK_OBJECT(tbl));
+ }
}
static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl)
@@ -7915,4 +8501,4 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :