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_draw_default(GTK_WIDGET(bouton
));
42 gtk_widget_show(bouton
);
44 bouton
= gtk_button_new_with_label("No");
45 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
46 GTK_SIGNAL_FUNC(f_no
),
48 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
49 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
51 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
52 bouton
, TRUE
, TRUE
, 0);
53 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
54 gtk_widget_show(bouton
);
56 bouton
= gtk_button_new_with_label("Cancel");
57 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
58 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
60 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
61 bouton
, TRUE
, TRUE
, 0);
62 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
63 gtk_widget_show(bouton
);
65 gtk_container_set_border_width(GTK_CONTAINER
66 (GTK_DIALOG(dialog
)->vbox
), 6);
67 label
= gtk_label_new(text
);
68 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->vbox
), label
, TRUE
,
70 gtk_widget_show(label
);
72 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
73 gtk_widget_show(dialog
);
77 void ok_dialog(const char *title
, const char *text
) {
82 dialog
= gtk_dialog_new();
83 gtk_window_set_title(GTK_WINDOW(dialog
), title
);
84 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
85 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
87 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
88 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
91 bouton
= gtk_button_new_with_label("OK");
92 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
93 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
95 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
96 bouton
, TRUE
, TRUE
, 0);
97 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
98 gtk_widget_grab_default(GTK_WIDGET(bouton
));
99 gtk_widget_draw_default(GTK_WIDGET(bouton
));
100 gtk_widget_show(bouton
);
102 gtk_container_set_border_width(GTK_CONTAINER
103 (GTK_DIALOG(dialog
)->vbox
), 6);
104 label
= gtk_label_new(text
);
105 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->vbox
), label
, TRUE
,
107 gtk_widget_show(label
);
109 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
110 gtk_widget_show(dialog
);
114 void file_dialog(const char *title
,
115 const char *dir
, const char *filter
,
116 void *ok_cb
, void *cancel_cb
) {
119 if (! title
) title
= "File...";
121 dialog
= gtk_file_selection_new(title
);
122 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
123 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
125 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
126 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
131 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->ok_button
),
133 GTK_SIGNAL_FUNC(ok_cb
), dialog
);
134 gtk_signal_connect_object(
135 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->ok_button
),
137 GTK_SIGNAL_FUNC(gtk_widget_destroy
), GTK_OBJECT(dialog
));
139 if (cancel_cb
!= NULL
)
141 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->cancel_button
),
143 GTK_SIGNAL_FUNC(cancel_cb
), dialog
);
144 gtk_signal_connect_object(
145 GTK_OBJECT(GTK_FILE_SELECTION(dialog
)->cancel_button
),
147 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
151 gtk_file_selection_set_filename(
152 GTK_FILE_SELECTION(dialog
),
157 gtk_file_selection_complete(GTK_FILE_SELECTION(dialog
), filter
);
160 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
161 gtk_widget_show(dialog
);