Bonjour,
je commence aujourd'hui le GTK +. C'est vraiement sympa, j'arrive déjà à jouer avec les widgets et les évenements. Mais j'ai un problème similaire à celui-ci:
http://www.developpez.net/forums/sho...rmer+fen%EAtre

Mon programme est une fenêtre principale qui contient un bouton.
Lorsqu'on clic sur le bouton, une seconde fenêtre s'ouvre.
Cette fenêtre peut se fermer en cliquant sur la croix en haut à droite de la fenêtre.
Par contre, elle est détruite! Je ne peux donc plus la réouvrir en cliquant de nouveau sur le bouton de la fenêtre principale.

Voici le code source simple et bien commenté je pense que vous comprendrez le problème:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
#include <gtk/gtk.h>
 
/*display_widget function*/
void display_widget(GtkWidget *widget, gpointer data){
 
	/*Display the widget*/
	gtk_widget_show(data);
}
 
/*destroy_widget function*/
gint destroy_widget(GtkWidget *widget, gpointer data){
 
	/*Display the widget*/
	return FALSE;
}
 
/*main function*/
int main(int argc, char *argv[]){
 
	/*Create the widgets*/
	GtkWidget *window_video, *box_video, *entry_width, *entry_height, *window_main, *box_main, *button_video, *entry;
 
	/*Initialize GTK*/
	gtk_init (&argc, &argv);
 
	/*Create the window_video*/
	window_video = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request(GTK_WIDGET(window_video), 320, 240);
	gtk_window_set_title(GTK_WINDOW(window_video), "Game Creator - Video");
	g_signal_connect(G_OBJECT(window_video), "delete_event", G_CALLBACK(destroy_widget), NULL);
 
	/*Create the box_video*/
	box_video = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window_video), box_video);
 
	/*Create the text entry_width*/
	entry_width = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(box_video), entry_width, TRUE, TRUE, 0);
 
	/*Create the text entry_height*/
	entry_height = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(box_video), entry_height, TRUE, TRUE, 0);
 
	/*Display the box_video*/
	gtk_widget_show(box_video);
 
	/*Create the window*/
	window_main = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request(GTK_WIDGET(window_main), 320, 240);
	gtk_window_set_title(GTK_WINDOW(window_main), "Game Creator - Main");
	g_signal_connect(G_OBJECT(window_main), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
 
	/*Create the box_main*/
	box_main = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window_main), box_main);
 
	/*Create the button_video*/
	button_video = gtk_button_new_with_label("Video");
	g_signal_connect(G_OBJECT(button_video), "clicked", G_CALLBACK(display_widget), G_OBJECT(window_video));
	gtk_box_pack_start(GTK_BOX(box_main), button_video, TRUE, TRUE, 0);
 
	/*Display the button_video*/
	gtk_widget_show(button_video);
 
	/*Create the entry*/
	entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(box_main), entry, TRUE, TRUE, 0);
 
	/*Display the entry*/
	gtk_widget_show(entry);
 
	/*Display the box_main*/
	gtk_widget_show(box_main);
 
	/*Display the window*/
	gtk_widget_show(window_main);
 
	/*Waiting for events*/
	gtk_main ();
 
	return 0;
}
Est-ce qu'il n'y aurait pas un moyen moins brutal pour fermer la fenêtre sans la détruire? Ainsi je pourrais la réouvrir à volonté.
Merci beaucoup.