From: tavmjong-free Date: Tue, 18 May 2010 11:54:03 +0000 (+0200) Subject: Add icons for line-height, letter-spacing, etc. to text toolbar. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8b5e79c2485ad2369533a4c15a2b776d4c723552;p=inkscape.git Add icons for line-height, letter-spacing, etc. to text toolbar. Include units in tooltips. --- diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index e6ec392ad..17e11db2d 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -60,6 +60,8 @@ #include #include +#include "widgets/icon.h" +#include "icon-size.h" #include "ege-adjustment-action.h" @@ -132,6 +134,8 @@ struct _EgeAdjustmentActionPrivate gboolean transferFocus; GList* descriptions; gchar* appearance; + gchar* iconId; + Inkscape::IconSize iconSize; }; #define EGE_ADJUSTMENT_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), EGE_ADJUSTMENT_ACTION_TYPE, EgeAdjustmentActionPrivate ) ) @@ -143,7 +147,9 @@ enum { PROP_DIGITS, PROP_SELFID, PROP_TOOL_POST, - PROP_APPEARANCE + PROP_APPEARANCE, + PROP_ICON_ID, + PROP_ICON_SIZE }; enum { @@ -253,6 +259,24 @@ static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ) "", (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + g_object_class_install_property( objClass, + PROP_ICON_ID, + g_param_spec_string( "iconId", + "Icon ID", + "The id for the icon", + "", + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + + g_object_class_install_property( objClass, + PROP_ICON_SIZE, + g_param_spec_int( "iconSize", + "Icon Size", + "The size the icon", + (int)Inkscape::ICON_SIZE_MENU, + (int)Inkscape::ICON_SIZE_DECORATION, + (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR, + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + g_type_class_add_private( klass, sizeof(EgeAdjustmentActionClass) ); } } @@ -276,6 +300,8 @@ static void ege_adjustment_action_init( EgeAdjustmentAction* action ) action->private_data->transferFocus = FALSE; action->private_data->descriptions = 0; action->private_data->appearance = 0; + action->private_data->iconId = 0; + action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR; } static void ege_adjustment_action_finalize( GObject* object ) @@ -353,6 +379,14 @@ static void ege_adjustment_action_get_property( GObject* obj, guint propId, GVal g_value_set_string( value, action->private_data->appearance ); break; + case PROP_ICON_ID: + g_value_set_string( value, action->private_data->iconId ); + break; + + case PROP_ICON_SIZE: + g_value_set_int( value, action->private_data->iconSize ); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); } @@ -440,6 +474,20 @@ void ege_adjustment_action_set_property( GObject* obj, guint propId, const GValu } break; + case PROP_ICON_ID: + { + gchar* tmp = action->private_data->iconId; + action->private_data->iconId = g_value_dup_string( value ); + g_free( tmp ); + } + break; + + case PROP_ICON_SIZE: + { + action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value ); + } + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); } @@ -791,7 +839,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) const gchar* sss = g_value_get_string( &value ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { - spinbutton = gtk_hscale_new( act->private_data->adj); + // Slider + spinbutton = gtk_hscale_new( act->private_data->adj); gtk_widget_set_size_request(spinbutton, 100, -1); gtk_scale_set_digits (GTK_SCALE(spinbutton), 0); gtk_signal_connect(GTK_OBJECT(spinbutton), "format-value", GTK_SIGNAL_FUNC(slider_format_falue), (void *) sss); @@ -823,11 +872,18 @@ static GtkWidget* create_tool_item( GtkAction* action ) } if ( act->private_data->appearanceMode != APPEARANCE_FULL ) { - GtkWidget* lbl = gtk_label_new( sss ? sss : "wwww" ); - GtkWidget* filler1 = gtk_label_new(" "); - gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); - gtk_box_pack_start( GTK_BOX(hb), filler1, FALSE, FALSE, 0 ); - gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); + GtkWidget* filler1 = gtk_label_new(" "); + gtk_box_pack_start( GTK_BOX(hb), filler1, FALSE, FALSE, 0 ); + + // Use an icon if available or use short-label + if ( act->private_data->iconId && strcmp( act->private_data->iconId, "" ) != 0 ) { + GtkWidget* icon = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); + gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 ); + } else { + GtkWidget* lbl = gtk_label_new( sss ? sss : "wwww" ); + gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); + gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); + } } if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 2c129f02c..e505412d0 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -7381,7 +7381,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontSizeAction", _("Font Size"), - _("Select Font Size"), + _("Select Font Size (px)"), NULL, GTK_TREE_MODEL(model_size), 4 ); // Width in characters @@ -7527,7 +7527,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions "TextLineHeightAction", /* name */ _("Line Height"), /* label */ _("Line:"), /* short label */ - _("Spacing between lines."), /* tooltip */ + _("Spacing between lines (%)."), /* tooltip */ "/tools/text/lineheight", /* path? */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -7545,6 +7545,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions 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 */ @@ -7557,7 +7558,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions "TextWordSpacingAction", /* name */ _("Word spacing"), /* label */ _("Word:"), /* short label */ - _("Spacing between words."), /* tooltip */ + _("Spacing between words (px)."), /* tooltip */ "/tools/text/wordspacing", /* path? */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -7575,6 +7576,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions 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 */ @@ -7587,7 +7589,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions "TextLetterSpacingAction", /* name */ _("Letter spacing"), /* label */ _("Letter:"), /* short label */ - _("Spacing between letters."), /* tooltip */ + _("Spacing between letters (px)."), /* tooltip */ "/tools/text/letterspacing", /* path? */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -7605,6 +7607,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions 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) */ @@ -7617,7 +7620,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions "TextDxAction", /* name */ _("Kerning"), /* label */ _("Kern:"), /* short label */ - _("Kerning (horizontal shift of characters)."), /* tooltip */ + _("Kerning (horizontal shift of characters) (px)."), /* tooltip */ "/tools/text/dx", /* path? */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -7635,6 +7638,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions 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 */ @@ -7647,7 +7651,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions "TextDyAction", /* name */ _("Vertical Shift"), /* label */ _("Vert:"), /* short label */ - _("Vertical shift of characters."), /* tooltip */ + _("Vertical shift of characters (px)."), /* tooltip */ "/tools/text/dy", /* path? */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -7665,6 +7669,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions 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 */ @@ -7695,6 +7700,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions 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.