From 8555d598e860ad381f957d4423507a568ac3cd20 Mon Sep 17 00:00:00 2001 From: joncruz Date: Tue, 1 Jul 2008 06:43:38 +0000 Subject: [PATCH] Adding use of GtkScaleButton when available --- src/ege-adjustment-action.cpp | 30 ++++++++++++++++++++++++++++++ src/widgets/toolbox.cpp | 23 ++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 2380e2e6b..c70fcc27d 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -44,9 +44,14 @@ #include #include +#include #include #include #include +#if GTK_CHECK_VERSION(2,12,0) +#include +#include +#endif /* GTK_CHECK_VERSION(2,12,0) */ #include #include #include @@ -89,6 +94,17 @@ enum { APPEARANCE_MINIMAL, // no label, just choices in a drop-down menu }; +#if GTK_CHECK_VERSION(2,12,0) +/* TODO need to have appropriate icons setup for these: */ +static const gchar *floogles[] = { + GTK_STOCK_REMOVE, + GTK_STOCK_ADD, + GTK_STOCK_GO_DOWN, + GTK_STOCK_ABOUT, + GTK_STOCK_GO_UP, + 0}; +#endif /* GTK_CHECK_VERSION(2,12,0) */ + typedef struct _EgeAdjustmentDescr EgeAdjustmentDescr; struct _EgeAdjustmentDescr @@ -764,6 +780,12 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { spinbutton = gtk_hscale_new( act->private_data->adj); gtk_widget_set_size_request(spinbutton, 100, -1); +#if GTK_CHECK_VERSION(2,12,0) + } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { + spinbutton = gtk_scale_button_new( GTK_ICON_SIZE_MENU, 0, 100, 2, 0 ); + gtk_scale_button_set_adjustment( GTK_SCALE_BUTTON(spinbutton), act->private_data->adj ); + gtk_scale_button_set_icons( GTK_SCALE_BUTTON(spinbutton), floogles ); +#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { spinbutton = gtk_spin_button_new( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); } @@ -817,6 +839,10 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_signal_connect_swapped( G_OBJECT(spinbutton), "event", G_CALLBACK(event_cb), action ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { /* */ +#if GTK_CHECK_VERSION(2,12,0) + } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { + /* */ +#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { gtk_entry_set_width_chars( GTK_ENTRY(spinbutton), act->private_data->digits + 3 ); } @@ -860,6 +886,10 @@ gboolean focus_in_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) EgeAdjustmentAction* action = EGE_ADJUSTMENT_ACTION( data ); if ( GTK_IS_SPIN_BUTTON(widget) ) { action->private_data->lastVal = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); +#if GTK_CHECK_VERSION(2,12,0) + } else if ( GTK_IS_SCALE_BUTTON(widget) ) { + action->private_data->lastVal = gtk_scale_button_get_value( GTK_SCALE_BUTTON(widget) ); +#endif /* GTK_CHECK_VERSION(2,12,0) */ } else if (GTK_IS_RANGE(widget) ) { action->private_data->lastVal = gtk_range_get_value( GTK_RANGE(widget) ); } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 0d46cca35..6669f5825 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -220,6 +220,11 @@ static struct { { NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL } }; +#if GTK_CHECK_VERSION(2,12,0) +#define TOOLBAR_SLIDER_HINT "minimal" +#else // GTK_CHECK_VERSION(2,12,0) +#define TOOLBAR_SLIDER_HINT "full" +#endif // GTK_CHECK_VERSION(2,12,0) static gchar const * ui_descr = "" @@ -3420,7 +3425,7 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio NULL, NULL, 0, sp_pencil_tb_tolerance_value_changed, 1, 2); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, @@ -3529,7 +3534,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction 1, 100, 1.0, 0.0, labels, values, G_N_ELEMENTS(labels), sp_tweak_width_value_changed, 0.01, 0, 100 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -3546,7 +3551,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction 1, 100, 1.0, 0.0, labels, values, G_N_ELEMENTS(labels), sp_tweak_force_value_changed, 0.01, 0, 100 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -3936,7 +3941,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main 1, 100, 1.0, 0.0, labels, values, G_N_ELEMENTS(labels), sp_ddc_width_value_changed, 0.01, 0, 100 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -4021,7 +4026,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main labels, values, G_N_ELEMENTS(labels), sp_ddc_tremor_value_changed, 0.01, 2 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -4038,7 +4043,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main 0.0, 1.0, 0.01, 0.0, labels, values, G_N_ELEMENTS(labels), sp_ddc_wiggle_value_changed, 0.01, 2 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -4055,7 +4060,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main 0.0, 1.0, 0.01, 0.0, labels, values, G_N_ELEMENTS(labels), sp_ddc_mass_value_changed, 0.01, 2 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -4613,7 +4618,7 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio 1, 100, 1.0, 0.0, labels, values, G_N_ELEMENTS(labels), sp_ddc_width_value_changed, 0.01, 0, 100 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } @@ -6022,7 +6027,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main 0, 0, 0, paintbucket_threshold_changed, 1, 0 ); - ege_adjustment_action_set_appearance( eact, "full" ); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } -- 2.30.2