Re: [gtk-list] Re: gtk-- delete/destroy confusion



Angel Jimenez Jimenez <ajimenez@vnet.es> writes:
>  We could also use a function callback, with a pointer to the object as
> data, instead of a method callback. This is a problem when we want this
> callback to do some operation in the object before deleting. For
> example, I have a dialog with an 'OK' and a 'Cancel' button. There's no
> problem with the cancel callback, but I want the ok callback to do
> something with the dialog's internal data, so I would like it to be a
> method (that's what GTK-- is for).
> 
>  Can you give an example of using idle_add() for this?

class dialog : public Gtk_Dialog {
public:
    ...
    /* this idle handler will be called when gtk is in its eventloop
       next time, with nothing to do */
    static gint my_delete_obj(dialog *a) { delete a; return 1; }

    void my_ok_callback() { /* connect this to the button press */
       ...
       /* do something with dialog's internal data */
       Gtk_Main::idle_add((GtkFunction)&my_delete_obj,this);
    }
};

This example shows few of the worst problems with gtk--:
1) need to use idle_add().
2) idle_add()'s interface is broken and not typesafe. (its just wrapper
   to gtk's idle_add..)

-- 
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --



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