summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-24 00:01:52 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-24 00:01:52 +0100
commit7bcde9ee91093fc791a246e3dd06bb2d4f499911 (patch)
treed580b3de8ad4eb32ec5632edcb72ef5f1048f888 /plugins
parentd3d33c9ce00dbae99443deee4166b52dab1ec01a (diff)
added reload metadata hotkey
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/gtkui.c1
-rw-r--r--plugins/gtkui/plcommon.c13
-rw-r--r--plugins/hotkeys/actionhandlers.c38
-rw-r--r--plugins/hotkeys/actionhandlers.h8
-rw-r--r--plugins/hotkeys/hotkeys.c6
5 files changed, 57 insertions, 9 deletions
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 10f7e57f..0a9e2652 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -469,6 +469,7 @@ playlist_refresh (void) {
// DdbListview *ps = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
// ddb_listview_refresh (ps, DDB_REFRESH_LIST | DDB_REFRESH_VSCROLL);
search_refresh ();
+ trkproperties_fill_metadata ();
}
static gboolean
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 143a69f2..e28fc5d0 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -249,12 +249,12 @@ main_remove_from_playback_queue_activate
search_redraw ();
}
+#if 0
void
main_reload_metadata_activate
(GtkMenuItem *menuitem,
gpointer user_data)
{
- DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (menuitem), "ps"));
DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
while (it) {
deadbeef->pl_lock ();
@@ -290,6 +290,7 @@ main_reload_metadata_activate
search_redraw ();
trkproperties_fill_metadata ();
}
+#endif
void
main_properties_activate (GtkMenuItem *menuitem,
@@ -465,11 +466,12 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
gtk_container_add (GTK_CONTAINER (playlist_menu), remove_from_playback_queue1);
g_object_set_data (G_OBJECT (remove_from_playback_queue1), "ps", listview);
+#if 0
reload_metadata = gtk_menu_item_new_with_mnemonic (_("Reload metadata"));
gtk_widget_show (reload_metadata);
gtk_container_add (GTK_CONTAINER (playlist_menu), reload_metadata);
g_object_set_data (G_OBJECT (reload_metadata), "ps", listview);
-
+#endif
separator9 = gtk_separator_menu_item_new ();
gtk_widget_show (separator9);
@@ -600,10 +602,7 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
g_signal_connect ((gpointer) actionitem, "activate",
G_CALLBACK (actionitem_activate),
action);
- if (!(
- ((selected_count == 1) && (action->flags & DB_ACTION_SINGLE_TRACK)) ||
- ((selected_count > 1) && (action->flags & DB_ACTION_MULTIPLE_TRACKS))
- ) ||
+ if ((selected_count > 1 && !(action->flags & DB_ACTION_MULTIPLE_TRACKS)) ||
(action->flags & DB_ACTION_DISABLED))
{
gtk_widget_set_sensitive (GTK_WIDGET (actionitem), FALSE);
@@ -637,9 +636,11 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
g_signal_connect ((gpointer) remove_from_playback_queue1, "activate",
G_CALLBACK (main_remove_from_playback_queue_activate),
NULL);
+#if 0
g_signal_connect ((gpointer) reload_metadata, "activate",
G_CALLBACK (main_reload_metadata_activate),
NULL);
+#endif
g_signal_connect ((gpointer) remove2, "activate",
G_CALLBACK (on_remove2_activate),
NULL);
diff --git a/plugins/hotkeys/actionhandlers.c b/plugins/hotkeys/actionhandlers.c
index 820d925b..b2b93047 100644
--- a/plugins/hotkeys/actionhandlers.c
+++ b/plugins/hotkeys/actionhandlers.c
@@ -33,4 +33,42 @@ extern DB_functions_t *deadbeef;
int
action_jump_to_current_handler (DB_plugin_action_t *act, int ctx) {
deadbeef->sendmessage (DB_EV_TRACKFOCUSCURRENT, 0, 0, 0);
+ return 0;
+}
+
+int
+action_reload_metadata_handler (DB_plugin_action_t *act, int ctx) {
+ DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
+ while (it) {
+ deadbeef->pl_lock ();
+ char decoder_id[100];
+ const char *dec = deadbeef->pl_find_meta (it, ":DECODER");
+ if (dec) {
+ strncpy (decoder_id, dec, sizeof (decoder_id));
+ }
+ int match = deadbeef->pl_is_selected (it) && deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI")) && dec;
+ deadbeef->pl_unlock ();
+
+ if (match) {
+ uint32_t f = deadbeef->pl_get_item_flags (it);
+ if (!(f & DDB_IS_SUBTRACK)) {
+ f &= ~DDB_TAG_MASK;
+ deadbeef->pl_set_item_flags (it, f);
+ DB_decoder_t **decoders = deadbeef->plug_get_decoder_list ();
+ for (int i = 0; decoders[i]; i++) {
+ if (!strcmp (decoders[i]->plugin.id, decoder_id)) {
+ if (decoders[i]->read_metadata) {
+ decoders[i]->read_metadata (it);
+ }
+ break;
+ }
+ }
+ }
+ }
+ DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
+ deadbeef->pl_item_unref (it);
+ it = next;
+ }
+ deadbeef->sendmessage (DB_EV_PLAYLIST_REFRESH, 0, 0, 0);
+ return 0;
}
diff --git a/plugins/hotkeys/actionhandlers.h b/plugins/hotkeys/actionhandlers.h
index 7be46151..f6f5db20 100644
--- a/plugins/hotkeys/actionhandlers.h
+++ b/plugins/hotkeys/actionhandlers.h
@@ -21,5 +21,13 @@
3. This notice may not be removed or altered from any source distribution.
*/
+#ifndef __HOTKEYS_ACTIONHANDLERS_H
+#define __HOTKEYS_ACTIONHANDLERS_H
+
int
action_jump_to_current_handler (DB_plugin_action_t *act, int ctx);
+
+int
+action_reload_metadata_handler (DB_plugin_action_t *act, int ctx);
+
+#endif
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c
index 0f9024d4..5f8bb8c2 100644
--- a/plugins/hotkeys/hotkeys.c
+++ b/plugins/hotkeys/hotkeys.c
@@ -696,10 +696,10 @@ action_toggle_stop_after_current_cb (struct DB_plugin_action_s *action, int ctx)
}
static DB_plugin_action_t action_reload_metadata = {
- .title = "[stub] Reload metadata",
+ .title = "Reload metadata",
.name = "reload_metadata",
- .flags = DB_ACTION_MULTIPLE_TRACKS,
- .callback = NULL,
+ .flags = DB_ACTION_MULTIPLE_TRACKS | DB_ACTION_ADD_MENU,
+ .callback = action_reload_metadata_handler,
.next = NULL
};