[Glade-users] Reusing windows/dialogs after user closes them with 'X'



Keith...

Yes!!!!!

Thanks ever so much...I have been concentrating on destroy, destroy,
destroy, and never noticed that there was a delete event.

That worked perfectly, and that is a major problem solved.

Thanks again,
Dale



On Thu, 25 Nov 2004 12:00:22 +0000, Keith Sharp <kms passback co uk> wrote:
On Wed, 2004-11-24 at 21:34 -0500, Dale wrote:


I can't figure this one out.

If a user closes a dialog or popup window with the 'X' in the
top-right of the window, it destroys the window.

I have the destroy event signal, but I can't stop it from actually
destroying it (or can I?).  I've tried putting a ->hide_all in the
event loop to hide instead of destroy, but it's already destroyed.

What I would like to know is, how can I reuse the window/dialog?

In the case of a window you would catch the "delete-event" signal on the
window and in the callback you would hide the window and return TRUE.
This will prevent the destroy event being emitted.  For example:

gint
main (gint argc, gchar *argv[])
{
        GtkWidget *window;

        ...

        g_signal_connect (G_OBJECT (window), "delete-event",
                G_CALLBACK (delete_event_cb), NULL);

        ...
}

gboolean
delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{
        gtk_widget_hide (widget);
        return TRUE;
}

For a dialog you would normally use gtk_dialog_run and have
responsibility for hiding or destroying the dialog yourself.  For
example:

GtkWidget *dialog
gint result;

...

gtk_widget_show_all (dialog);

result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result) {
        case GTK_RESPONSE_ACCEPT:
                /* Do something here */
                break;
        default:
                break;
}
gtk_widget_hide (dialog);

Hope this helps,

Keith.

_______________________________________________
Glade-users maillist  -  Glade-users lists ximian com
http://lists.ximian.com/mailman/listinfo/glade-users





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