From: joncruz Date: Tue, 24 Oct 2006 01:51:47 +0000 (+0000) Subject: Added callback function to allow shrinking of widgets X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=18e9cd64eb2969c779a397432601025617bbf9aa;p=inkscape.git Added callback function to allow shrinking of widgets --- diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index a2ea9ff0d..95ea548ca 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -81,6 +81,7 @@ struct _EgeAdjustmentActionPrivate gdouble climbRate; guint digits; gchar* selfId; + EgeWidgetFixup toolPost; gdouble lastVal; gdouble step; gdouble page; @@ -94,7 +95,8 @@ enum { PROP_FOCUS_WIDGET, PROP_CLIMB_RATE, PROP_DIGITS, - PROP_SELFID + PROP_SELFID, + PROP_TOOL_POST }; GType ege_adjustment_action_get_type( void ) @@ -174,6 +176,13 @@ static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ) 0, (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + g_object_class_install_property( objClass, + PROP_TOOL_POST, + g_param_spec_pointer( "tool-post", + "Tool Widget post process", + "Function for final adjustments", + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + g_type_class_add_private( klass, sizeof(EgeAdjustmentActionClass) ); } } @@ -186,6 +195,7 @@ static void ege_adjustment_action_init( EgeAdjustmentAction* action ) action->private_data->climbRate = 0.0; action->private_data->digits = 2; action->private_data->selfId = 0; + action->private_data->toolPost = 0; action->private_data->lastVal = 0.0; action->private_data->step = 0.0; action->private_data->page = 0.0; @@ -239,6 +249,10 @@ static void ege_adjustment_action_get_property( GObject* obj, guint propId, GVal g_value_set_string( value, action->private_data->selfId ); break; + case PROP_TOOL_POST: + g_value_set_pointer( value, (void*)action->private_data->toolPost ); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); } @@ -288,6 +302,12 @@ void ege_adjustment_action_set_property( GObject* obj, guint propId, const GValu } break; + case PROP_TOOL_POST: + { + action->private_data->toolPost = (EgeWidgetFixup)g_value_get_pointer( value ); + } + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); } @@ -369,6 +389,11 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_widget_show_all( item ); + + /* Shrink or whatnot after shown */ + if ( act->private_data->toolPost ) { + act->private_data->toolPost( item ); + } } else { item = gParentClass->create_tool_item( action ); } diff --git a/src/ege-adjustment-action.h b/src/ege-adjustment-action.h index 109b5ff76..45049fbf5 100644 --- a/src/ege-adjustment-action.h +++ b/src/ege-adjustment-action.h @@ -85,6 +85,10 @@ GtkAdjustment* ege_adjustment_action_get_adjustment( EgeAdjustmentAction* action void ege_adjustment_action_set_focuswidget( EgeAdjustmentAction* action, GtkWidget* widget ); GtkWidget* ege_adjustment_action_get_focuswidget( EgeAdjustmentAction* action ); + +typedef void (*EgeWidgetFixup)(GtkWidget *widget); + + G_END_DECLS #endif /* SEEN_EGE_ADJUSTMENT_ACTION */ diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 68e9a0653..def088563 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -848,6 +848,9 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name, gtk_object_set_data( GTK_OBJECT(dataKludge), data, adj ); } + // Using a cast just to make sure we pass in the right kind of function pointer + g_object_set( G_OBJECT(act), "tool-post", static_cast(sp_set_font_size_smaller), NULL ); + return act; }