Code

Added tootips for toolbar spinbuttons
authorjoncruz <joncruz@users.sourceforge.net>
Wed, 21 Mar 2007 23:51:04 +0000 (23:51 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Wed, 21 Mar 2007 23:51:04 +0000 (23:51 +0000)
src/ege-adjustment-action.cpp

index fe26cd87e4b0e8f89994c3c57e3804faeea9b1d2..abe021cf739b485381928442c22b55ed96e8fafd 100644 (file)
@@ -50,6 +50,7 @@
 #include <gtk/gtklabel.h>
 #include <gtk/gtkmisc.h>
 #include <gtk/gtktoolbar.h>
+#include <gtk/gtktooltips.h>
 #include <gtk/gtkradiomenuitem.h>
 
 #include "ege-adjustment-action.h"
@@ -90,6 +91,7 @@ struct _EgeAdjustmentDescr
 struct _EgeAdjustmentActionPrivate
 {
     GtkAdjustment* adj;
+    GtkTooltips* toolTips;
     GtkWidget* focusWidget;
     gdouble climbRate;
     guint digits;
@@ -222,6 +224,7 @@ static void ege_adjustment_action_init( EgeAdjustmentAction* action )
 {
     action->private_data = EGE_ADJUSTMENT_ACTION_GET_PRIVATE( action );
     action->private_data->adj = 0;
+    action->private_data->toolTips = 0;
     action->private_data->focusWidget = 0;
     action->private_data->climbRate = 0.0;
     action->private_data->digits = 2;
@@ -714,6 +717,20 @@ static GtkWidget* create_tool_item( GtkAction* action )
         const gchar* sss = g_value_get_string( &value );
         GtkWidget* lbl = gtk_label_new( sss ? sss : "wwww" );
 
+        {
+            GValue tooltip;
+            memset( &tooltip, 0, sizeof(tooltip) );
+            g_value_init( &tooltip, G_TYPE_STRING );
+            g_object_get_property( G_OBJECT(action), "tooltip", &tooltip );
+            const gchar* tipstr = g_value_get_string( &tooltip );
+            if ( tipstr && *tipstr ) {
+                if ( !action->private_data->toolTips ) {
+                    action->private_data->toolTips = gtk_tooltips_new();
+                }
+                gtk_tooltips_set_tip( action->private_data->toolTips, spinbutton, tipstr, 0 );
+            }
+        }
+
         gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 );
 
         gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 );