summaryrefslogtreecommitdiff
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
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
-rw-r--r--playlist.c28
-rw-r--r--plugins/gtkui/actionhandlers.c38
-rw-r--r--plugins/gtkui/deadbeef.glade120
-rw-r--r--plugins/gtkui/interface.c29
4 files changed, 183 insertions, 32 deletions
diff --git a/playlist.c b/playlist.c
index 27330ca7..62b97d30 100644
--- a/playlist.c
+++ b/playlist.c
@@ -2913,9 +2913,22 @@ pl_format_title_int (const char *escape_chars, playItem_t *it, int idx, char *s,
}
else if (*fmt == 'a') {
meta = pl_find_meta_raw (it, "artist");
- if (!meta) {
+ const char *custom = pl_find_meta_raw (it, "DDB:CUSTOM_TITLE");
+ if (!meta && !custom) {
meta = "Unknown artist";
}
+
+ if (custom) {
+ if (!meta) {
+ meta = custom;
+ }
+ else {
+ int l = strlen (custom) + strlen (meta) + 4;
+ char *out = alloca (l);
+ snprintf (out, l, "[%s] %s", custom, meta);
+ meta = out;
+ }
+ }
}
else if (*fmt == 't') {
meta = pl_find_meta_raw (it, "title");
@@ -2963,6 +2976,19 @@ pl_format_title_int (const char *escape_chars, playItem_t *it, int idx, char *s,
}
}
}
+
+ const char *custom = pl_find_meta_raw (it, "DDB:CUSTOM_TITLE");
+ if (custom) {
+ if (!meta) {
+ meta = custom;
+ }
+ else {
+ int l = strlen (custom) + strlen (meta) + 4;
+ char *out = alloca (l);
+ snprintf (out, l, "[%s] %s", custom, meta);
+ meta = out;
+ }
+ }
}
else if (*fmt == 'C') {
meta = pl_find_meta_raw (it, "composer");
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 ();
}
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index b3782497..98f85ffc 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -6417,49 +6417,113 @@ if you don't press Apply.</property>
</child>
<child>
- <widget class="GtkHBox" id="hbox34">
+ <widget class="GtkVBox" id="vbox45">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">8</property>
<child>
- <widget class="GtkLabel" id="label41">
+ <widget class="GtkHBox" id="hbox34">
<property name="visible">True</property>
- <property name="label" translatable="yes">URL:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child>
+ <widget class="GtkLabel" id="label41">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">URL:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="addlocation_entry">
+ <property name="width_request">297</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">•</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
</packing>
</child>
<child>
- <widget class="GtkEntry" id="addlocation_entry">
- <property name="width_request">297</property>
+ <widget class="GtkHBox" id="hbox122">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">•</property>
- <property name="activates_default">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="set_custom_title">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Set custom title</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="custom_title">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">•</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index b08daf45..b712cba2 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -3272,9 +3272,13 @@ create_addlocationdlg (void)
{
GtkWidget *addlocationdlg;
GtkWidget *dialog_vbox4;
+ GtkWidget *vbox45;
GtkWidget *hbox34;
GtkWidget *label41;
GtkWidget *addlocation_entry;
+ GtkWidget *hbox122;
+ GtkWidget *set_custom_title;
+ GtkWidget *custom_title;
GtkWidget *addlocation_actionarea;
GtkWidget *cancelbutton3;
GtkWidget *alignment18;
@@ -3294,10 +3298,14 @@ create_addlocationdlg (void)
dialog_vbox4 = gtk_dialog_get_content_area (GTK_DIALOG (addlocationdlg));
gtk_widget_show (dialog_vbox4);
+ vbox45 = gtk_vbox_new (FALSE, 8);
+ gtk_widget_show (vbox45);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox4), vbox45, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox45), 12);
+
hbox34 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox34);
- gtk_box_pack_start (GTK_BOX (dialog_vbox4), hbox34, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (hbox34), 12);
+ gtk_box_pack_start (GTK_BOX (vbox45), hbox34, TRUE, TRUE, 0);
label41 = gtk_label_new (_("URL:"));
gtk_widget_show (label41);
@@ -3310,6 +3318,19 @@ create_addlocationdlg (void)
gtk_entry_set_invisible_char (GTK_ENTRY (addlocation_entry), 8226);
gtk_entry_set_activates_default (GTK_ENTRY (addlocation_entry), TRUE);
+ hbox122 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox122);
+ gtk_box_pack_start (GTK_BOX (vbox45), hbox122, TRUE, TRUE, 0);
+
+ set_custom_title = gtk_check_button_new_with_mnemonic (_("Set custom title"));
+ gtk_widget_show (set_custom_title);
+ gtk_box_pack_start (GTK_BOX (hbox122), set_custom_title, FALSE, FALSE, 0);
+
+ custom_title = gtk_entry_new ();
+ gtk_widget_show (custom_title);
+ gtk_box_pack_start (GTK_BOX (hbox122), custom_title, TRUE, TRUE, 0);
+ gtk_entry_set_invisible_char (GTK_ENTRY (custom_title), 8226);
+
addlocation_actionarea = gtk_dialog_get_action_area (GTK_DIALOG (addlocationdlg));
gtk_widget_show (addlocation_actionarea);
gtk_button_box_set_layout (GTK_BUTTON_BOX (addlocation_actionarea), GTK_BUTTONBOX_END);
@@ -3359,9 +3380,13 @@ create_addlocationdlg (void)
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (addlocationdlg, addlocationdlg, "addlocationdlg");
GLADE_HOOKUP_OBJECT_NO_REF (addlocationdlg, dialog_vbox4, "dialog_vbox4");
+ GLADE_HOOKUP_OBJECT (addlocationdlg, vbox45, "vbox45");
GLADE_HOOKUP_OBJECT (addlocationdlg, hbox34, "hbox34");
GLADE_HOOKUP_OBJECT (addlocationdlg, label41, "label41");
GLADE_HOOKUP_OBJECT (addlocationdlg, addlocation_entry, "addlocation_entry");
+ GLADE_HOOKUP_OBJECT (addlocationdlg, hbox122, "hbox122");
+ GLADE_HOOKUP_OBJECT (addlocationdlg, set_custom_title, "set_custom_title");
+ GLADE_HOOKUP_OBJECT (addlocationdlg, custom_title, "custom_title");
GLADE_HOOKUP_OBJECT_NO_REF (addlocationdlg, addlocation_actionarea, "addlocation_actionarea");
GLADE_HOOKUP_OBJECT (addlocationdlg, cancelbutton3, "cancelbutton3");
GLADE_HOOKUP_OBJECT (addlocationdlg, alignment18, "alignment18");