16 void ync_dialog(const char *title
, const char *text
, void *f_yes
, void *f_no
) {
21 dialog
= gtk_dialog_new();
22 gtk_window_set_title(GTK_WINDOW(dialog
), title
);
23 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
24 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
26 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
27 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
30 bouton
= gtk_button_new_with_label("Yes");
31 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
32 GTK_SIGNAL_FUNC(f_yes
),
34 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
35 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
37 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
38 bouton
, TRUE
, TRUE
, 0);
39 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
40 gtk_widget_grab_default(GTK_WIDGET(bouton
));
41 gtk_widget_show(bouton
);
43 bouton
= gtk_button_new_with_label("No");
44 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
45 GTK_SIGNAL_FUNC(f_no
),
47 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
48 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
50 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
51 bouton
, TRUE
, TRUE
, 0);
52 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
53 gtk_widget_show(bouton
);
55 bouton
= gtk_button_new_with_label("Cancel");
56 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
57 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
59 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
60 bouton
, TRUE
, TRUE
, 0);
61 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
62 gtk_widget_show(bouton
);
64 gtk_container_set_border_width(GTK_CONTAINER
65 (GTK_DIALOG(dialog
)->vbox
), 6);
66 label
= gtk_label_new(text
);
67 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->vbox
), label
, TRUE
,
69 gtk_widget_show(label
);
71 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
72 gtk_widget_show(dialog
);
76 void ok_dialog(const char *title
, const char *text
) {
81 dialog
= gtk_dialog_new();
82 gtk_window_set_title(GTK_WINDOW(dialog
), title
);
83 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
84 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
86 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
87 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
90 bouton
= gtk_button_new_with_label("OK");
91 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
92 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
94 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
95 bouton
, TRUE
, TRUE
, 0);
96 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
97 gtk_widget_grab_default(GTK_WIDGET(bouton
));
98 gtk_widget_show(bouton
);
100 gtk_container_set_border_width(GTK_CONTAINER
101 (GTK_DIALOG(dialog
)->vbox
), 6);
102 label
= gtk_label_new(text
);
103 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->vbox
), label
, TRUE
,
105 gtk_widget_show(label
);
107 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
108 gtk_widget_show(dialog
);
112 void file_dialog(const char *title
,
113 const char *dir
, const char *filter
,
114 void *ok_cb
, void *cancel_cb
) {
117 if (! title
) title
= "File...";
119 dialog
= gtk_file_selection_new(title
);
120 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
121 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
123 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
124 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
129 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->ok_button
),
131 GTK_SIGNAL_FUNC(ok_cb
), dialog
);
132 gtk_signal_connect_object(
133 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->ok_button
),
135 GTK_SIGNAL_FUNC(gtk_widget_destroy
), GTK_OBJECT(dialog
));
137 if (cancel_cb
!= NULL
)
139 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->cancel_button
),
141 GTK_SIGNAL_FUNC(cancel_cb
), dialog
);
142 gtk_signal_connect_object(
143 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->cancel_button
),
145 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
149 gtk_file_selection_set_filename(
150 GTK_FILE_SELECTION(dialog
),
155 gtk_file_selection_complete(GTK_FILE_SELECTION(dialog
), filter
);
158 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
159 gtk_widget_show(dialog
);