[Glade-users] Binding data to widgets?

Damon Chaplin damon@karuna.uklinux.net
Tue, 31 Aug 2004 11:43:49 +0100


On Mon, 2004-08-30 at 21:05, Dave Andruczyk wrote:
> Is it possible to bind data to a widget with glade in the same manner as using
> "g_object_set_data(object,key,value)" in direct C? (using libglade-2.4.4, glade
> 2.0.1)

No, I'm afraid you can't do that within Glade.


> I'm trying to make my application
> (MegaTunix,http://sourceforge.net/project/showfiles.php?group_id=71778)
> be able to use libglade to load parts of the gui on demand.  This is needed
> because the app talks to external hardware (a Fuel injection ECU) and needs to
> adapt based on what features are supported in the hardware it's talking to.
> 
> The current code uses LOTS of g_object_set_data() calls to bind various data to
> the gui elements that is used in the signal handlers, from digging around in
> glade I didn't see any easy way to do this. (for the most part I'm binding
> numeric values to textual keys. 
>  i.e. g_object_set_data(G_OBJECT(spinner),"offset",121);  I'm not trying to
> bind pointers or pointers to structures which would be invalid in a glade file,
> just simple data that the handler needs in order to handle changes to the
> widget's value.

You should be using GINT_TO_POINTER() there, e.g.

  g_object_set_data(G_OBJECT(spinner),"offset",GINT_TO_POINTER (121))

I think you may have problems on 64-bit systems if you don't do that.

Damon