Re: destroy_signal

Monserrat Seisdedos Nuñez wrote:
Hello everybody:

I have a window, it has the X button to destroy it.
but i want the X button to just hide it not to destroy it. In the destroy
callback i wrote down:


but it seems to destroy the window as well.

Maybe i can mask the destroy signal for this window, can anybody help me?

/* gcc -Wall -g test.c -o test `pkg-config --cflags --libs gtk+-2.0` */

#include <gtk/gtk.h>

static void close_app(GtkWidget *, gpointer);
static gint delete_event(GtkWidget *, GdkEvent *, gpointer);
static void destroy(GtkWidget *, gpointer);

int main(int argc, char *argv[]) {
    GtkWidget *window;
    GtkWidget *button;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

/* set a callback for the "delete_event" signal (generated by the window
   manager when the user clicks the close button on the window frame) */
    g_signal_connect(G_OBJECT(window), "delete_event",
        G_CALLBACK(delete_event), NULL);

/* called if we return FALSE in the "delete_event" callback */
    g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(destroy), NULL);

    gtk_container_set_border_width(GTK_CONTAINER(window), 10);

    button = gtk_button_new_with_label("Close");
    g_signal_connect(G_OBJECT(button), "clicked",
        G_CALLBACK(close_app), NULL);

    gtk_container_add(GTK_CONTAINER(window), button);




    return 0;

void close_app(GtkWidget *widget, gpointer data) {

gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
	g_print("delete_event : attempting to iconify\n");


/* change to FALSE and app will be destroyed with a "delete_event" */

    return TRUE;

void destroy(GtkWidget *widget, gpointer data) {

chris wareham iosystems co uk (work)
cwareham btinternet com (home)

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