summaryrefslogtreecommitdiff
path: root/plugins/gtkui/actionhandlers.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-02-05 21:48:03 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-02-05 21:48:03 +0100
commit006ec267b2d6372ce547bbfd19df8e5a9bd24886 (patch)
tree10cd3ad6d4c1606315583e9929ac5e3ecba0b17c /plugins/gtkui/actionhandlers.c
parentb06812a7261467785f7fe3f537f010885cfa732f (diff)
experimental: added support for DDB:CUSTOM_TITLE metadata, for setting radio station titles
new text field in the Add Location dialog automatically use in title formatting for %B and %a
Diffstat (limited to 'plugins/gtkui/actionhandlers.c')
-rw-r--r--plugins/gtkui/actionhandlers.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c
index 6e3934e4..b032ddb8 100644
--- a/plugins/gtkui/actionhandlers.c
+++ b/plugins/gtkui/actionhandlers.c
@@ -390,9 +390,38 @@ action_hide_mainwin_handler (struct DB_plugin_action_s *action, int ctx) {
return 0;
}
+static void
+on_toggle_set_custom_title (GtkToggleButton *togglebutton, gpointer user_data) {
+ gboolean active = gtk_toggle_button_get_active (togglebutton);
+ deadbeef->conf_set_int ("gtkui.location_set_custom_title", active);
+
+ GtkWidget *ct = lookup_widget (GTK_WIDGET (user_data), "custom_title");
+ gtk_widget_set_sensitive (ct, active);
+
+ deadbeef->conf_save ();
+}
+
+
gboolean
action_add_location_handler_cb (void *user_data) {
GtkWidget *dlg = create_addlocationdlg ();
+
+ GtkWidget *sct = lookup_widget (dlg, "set_custom_title");
+ GtkWidget *ct = lookup_widget (dlg, "custom_title");
+
+ if (deadbeef->conf_get_int ("gtkui.location_set_custom_title", 0)) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sct), TRUE);
+ gtk_widget_set_sensitive (ct, TRUE);
+ }
+ else {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sct), FALSE);
+ gtk_widget_set_sensitive (ct, FALSE);
+ }
+
+ g_signal_connect ((gpointer) sct, "toggled",
+ G_CALLBACK (on_toggle_set_custom_title),
+ dlg);
+
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
int res = gtk_dialog_run (GTK_DIALOG (dlg));
if (res == GTK_RESPONSE_OK) {
@@ -402,7 +431,14 @@ action_add_location_handler_cb (void *user_data) {
if (text) {
ddb_playlist_t *plt = deadbeef->plt_get_curr ();
if (!deadbeef->plt_add_files_begin (plt, 0)) {
- deadbeef->plt_add_file2 (0, plt, text, NULL, NULL);
+ DB_playItem_t *tail = deadbeef->plt_get_last (plt, PL_MAIN);
+ DB_playItem_t *it = deadbeef->plt_insert_file2 (0, plt, tail, text, NULL, NULL, NULL);
+ if (deadbeef->conf_get_int ("gtkui.location_set_custom_title", 0)) {
+ deadbeef->pl_replace_meta (it, "DDB:CUSTOM_TITLE", gtk_entry_get_text (GTK_ENTRY (ct)));
+ }
+ if (tail) {
+ deadbeef->pl_item_unref (tail);
+ }
deadbeef->plt_add_files_end (plt, 0);
playlist_refresh ();
}