summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/dspconfig.c14
-rw-r--r--plugins/gtkui/pluginconf.c48
-rw-r--r--plugins/gtkui/pluginconf.h4
-rw-r--r--plugins/gtkui/prefwin.c2
4 files changed, 45 insertions, 23 deletions
diff --git a/plugins/gtkui/dspconfig.c b/plugins/gtkui/dspconfig.c
index fb1c1d41..440b03dd 100644
--- a/plugins/gtkui/dspconfig.c
+++ b/plugins/gtkui/dspconfig.c
@@ -240,6 +240,14 @@ dsp_ctx_get_param (const char *key, char *value, int len, const char *def) {
current_dsp_context->plugin->get_param (current_dsp_context, atoi (key), value, len);
}
+int
+button_cb (int btn, void *ctx) {
+ if (btn == ddb_button_apply) {
+ update_streamer ();
+ }
+ return 1;
+}
+
void
on_dsp_configure_clicked (GtkButton *button,
gpointer user_data)
@@ -273,9 +281,11 @@ on_dsp_configure_clicked (GtkButton *button,
.set_param = dsp_ctx_set_param,
.get_param = dsp_ctx_get_param,
};
- gtkui_run_dialog (prefwin, &conf, 0);
+ int response = gtkui_run_dialog (prefwin, &conf, 0, button_cb, NULL);
+ if (response == ddb_button_ok) {
+ update_streamer ();
+ }
current_dsp_context = NULL;
- update_streamer ();
}
static int
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);
}
diff --git a/plugins/gtkui/pluginconf.h b/plugins/gtkui/pluginconf.h
index 0af2f394..3f3e7b33 100644
--- a/plugins/gtkui/pluginconf.h
+++ b/plugins/gtkui/pluginconf.h
@@ -20,9 +20,9 @@
#define __PLUGINCONF_H
int
-gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *dlg, uint32_t buttons);
+gtkui_run_dialog (GtkWidget *parentwin, ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx);
int
-gtkui_run_dialog_root (ddb_dialog_t *dlg, uint32_t buttons);
+gtkui_run_dialog_root (ddb_dialog_t *conf, uint32_t buttons, int (*callback)(int button, void *ctx), void *ctx);
#endif
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index 81b7922a..bf84a8a9 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -825,7 +825,7 @@ on_configure_plugin_clicked (GtkButton *button,
.set_param = deadbeef->conf_set_str,
.get_param = gtkui_conf_get_str,
};
- gtkui_run_dialog (prefwin, &conf, 0);
+ gtkui_run_dialog (prefwin, &conf, 0, NULL, NULL);
}
}