summaryrefslogtreecommitdiff
path: root/plugins/gtkui/pluginconf.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-12-30 22:19:00 +0100
committerGravatar waker <wakeroid@gmail.com>2010-12-30 22:19:32 +0100
commita2d0bde748064072c36d1773bfe8d83482213d65 (patch)
treeff457df7649a4a3a96d489b71a37b1e46e3624b9 /plugins/gtkui/pluginconf.c
parent9c4051a94ed3827c5d5137636692a8b70b7593d4 (diff)
added API to handle button presses in gui dialogs;
dsp plugin parameters apply button now works correctly
Diffstat (limited to 'plugins/gtkui/pluginconf.c')
-rw-r--r--plugins/gtkui/pluginconf.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/plugins/gtkui/pluginconf.c b/plugins/gtkui/pluginconf.c
index 4d2bf488..73d50fed 100644
--- a/plugins/gtkui/pluginconf.c
+++ b/plugins/gtkui/pluginconf.c
@@ -190,7 +190,26 @@ prop_changed (GtkWidget *editable, gpointer user_data) {
}
int
-gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons) {
+ddb_button_from_gtk_response (int response) {
+ switch (response) {
+ case GTK_RESPONSE_OK:
+ return ddb_button_ok;
+ case GTK_RESPONSE_CANCEL:
+ return ddb_button_cancel;
+ case GTK_RESPONSE_CLOSE:
+ return ddb_button_close;
+ case GTK_RESPONSE_APPLY:
+ return ddb_button_apply;
+ case GTK_RESPONSE_YES:
+ return ddb_button_yes;
+ case GTK_RESPONSE_NO:
+ return ddb_button_no;
+ }
+ return -1;
+}
+
+int
+gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx) {
// create window
char title[200];
snprintf (title, sizeof (title), _("Configure %s"), conf->title);
@@ -496,26 +515,19 @@ gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons) {
if (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK) {
apply_conf (win, conf);
}
+ if (callback) {
+ int btn = ddb_button_from_gtk_response (response);
+ if (!callback (btn, ctx)) {
+ break;
+ }
+ }
} while (response == GTK_RESPONSE_APPLY);
gtk_widget_destroy (win);
- switch (response) {
- case GTK_RESPONSE_OK:
- return ddb_button_ok;
- case GTK_RESPONSE_CANCEL:
- return ddb_button_cancel;
- case GTK_RESPONSE_CLOSE:
- return ddb_button_close;
- case GTK_RESPONSE_APPLY:
- return ddb_button_apply;
- case GTK_RESPONSE_YES:
- return ddb_button_yes;
- case GTK_RESPONSE_NO:
- return ddb_button_no;
- }
- return -1;
+ int btn = ddb_button_from_gtk_response (response);
+ return btn;
}
int
-gtkui_run_dialog_root (ddb_dialog_t *conf, uint32_t buttons) {
- return gtkui_run_dialog (mainwin, conf, buttons);
+gtkui_run_dialog_root (ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx) {
+ return gtkui_run_dialog (mainwin, conf, buttons, callback, ctx);
}