Re: Glade, Libglade, and using user_data in callbacks



On Fri, 14 Jan 2005 16:09:02 -0500, Matthew Yaconis <myaconis nycap rr com> 
[...]
In the Glade Object box for the toggled event callback I've placed:
"&GLOBAL_VAR.MY_GBOOLEAN"

What am I missing?  I'm using libglade to load the interface, so I'm not
sure if that can actually link up the global variable when the callback
routine is connected to the widget's toggled signal.

The object parameter in glade is the name of the widget in the glade-ui
(the string that you would pass to `glade_xml_get_widget ()' ) 

I've implemented something similar though in glade-3 (which is not really
available yet) which allows you to check "lookup" checkbox and a patched
libglade will g_module_lookup() the user_data string in that case 
(you would still need "&GLOBAL_VAR.MY_GBOOLEAN" to be a valid 
symbol to lookup).

I also do some very black magic in order to use the same generic callback
for every signal's signature (we use this to genericly feed events to a finite
state machine engine):
==========================================
void object_event (GObject *object, ...)
{
    GSignalInvocationHint *ihint;
    GSignalQuery           query;
    fsm_event              event;
    gint                   i;
    va_list                ap;

    if ((ihint = g_signal_get_invocation_hint (object)) != NULL) {
        g_signal_query (ihint->signal_id, &query);  

        va_start (ap, object);
        for (i = 0; i < query.n_params; i++) {
            /* pop stack */
            va_arg (ap, gpointer);
        }
        event = va_arg (ap, fsm_event);
        va_end (ap);

        /* XXX execute filtered event XXX */
        fsm_run (state_machine, object, event);
    }
}
==========================================

It works, but like I said; its not really readily available software :-)

Cheers,
                                                                    -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]