Code

Added callback function to allow shrinking of widgets
authorjoncruz <joncruz@users.sourceforge.net>
Tue, 24 Oct 2006 01:51:47 +0000 (01:51 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Tue, 24 Oct 2006 01:51:47 +0000 (01:51 +0000)
src/ege-adjustment-action.cpp
src/ege-adjustment-action.h
src/widgets/toolbox.cpp

index a2ea9ff0db9842fc8d3b28c2134351c8feeea71f..95ea548caa577c38be024bbdef00edc617a3fbe4 100644 (file)
@@ -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 );
     }
index 109b5ff7625e2e773a17e37591d178020b3f1af3..45049fbf5b6a95f7160a554e688aba5619d8ff33 100644 (file)
@@ -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 */
index 68e9a065369ea268a6b7aa7f56cb951e206aec81..def0885635327e3b61f8f02d270d7101d3ff43c9 100644 (file)
@@ -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<EgeWidgetFixup>(sp_set_font_size_smaller), NULL );
+
     return act;
 }