Code

Adding use of GtkScaleButton when available
authorjoncruz <joncruz@users.sourceforge.net>
Tue, 1 Jul 2008 06:43:38 +0000 (06:43 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Tue, 1 Jul 2008 06:43:38 +0000 (06:43 +0000)
src/ege-adjustment-action.cpp
src/widgets/toolbox.cpp

index 2380e2e6bf669fbf15bdcc48444d995bba1bd51c..c70fcc27d1cbf61c19cbdaa5b382c5acaa26337a 100644 (file)
 #include <string.h>
 
 #include <gdk/gdkkeysyms.h>
+#include <gtk/gtkversion.h>
 #include <gtk/gtktoolitem.h>
 #include <gtk/gtkspinbutton.h>
 #include <gtk/gtkhscale.h>
+#if GTK_CHECK_VERSION(2,12,0)
+#include <gtk/gtkscalebutton.h>
+#include <gtk/gtkstock.h>
+#endif /* GTK_CHECK_VERSION(2,12,0) */
 #include <gtk/gtkhbox.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkmisc.h>
@@ -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) );
         }
index 0d46cca359e723124e17780be61c8360f1d3b05a..6669f5825926565a30c791b636abd906deb26506 100644 (file)
@@ -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 =
         "<ui>"
@@ -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) );
     }