Re: [gtk-list] Window destroying!



From: rhfreeman <rhfreeman@micron.com>
> Hi,
> 
> Sorry to be a bother folks! I appreciate the quick answers so far!
> 
> With this bit of code, after I destroy the window the test with
> gtk_widget_show() in it still passes. What I am doing wrong now?
> 
> void xmark_destroyed(GtkWidget *lwindow, GdkEvent *event, gpointer *data)
                        NOTA :
                        gpointer is typedef'd from (void *). You
                        do not need to declare data as a gpointer *.
> {
>   gtk_widget_destroy(lwindow);
>   lwindow=NULL;

    Wouch... This lwindow is <i>local</i> to xmark_destroy(),
    so setting it to NULL is useless.

    It is not the lwindow you defined in markx (and BTW, the
    markx() lwindow is local to markx() too - you cannot
    access it ouside of its scope). 

    I suppose you want to do:

GtkWidget *global_lwindow = NULL;

void xmark_destroyed(GtkWidget *w, GdkEvent *e, gpointer data)
{
    /* assuming the destroyed handler may be applied to another */
    /* widget, so let's test it */
    if (w == global_lwindow) 
    {
        gtk_widget_destroy(global_lwindow);
        global_lwindow = NULL;
    }
}

void xmark()
{
    ...
    if (global_lwindow != NULL)
    {
        gtk_widget_show(global_lwindow);
        return;
    }
    /* your init */
    global_window = ...
    ...
}

> Cheers
> 
> Rich

    Yours,

    Emmanuel



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