summaryrefslogtreecommitdiff
path: root/plugins/hotkeys
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/hotkeys
parentd3d33c9ce00dbae99443deee4166b52dab1ec01a (diff)
added reload metadata hotkey
Diffstat (limited to 'plugins/hotkeys')
-rw-r--r--plugins/hotkeys/actionhandlers.c38
-rw-r--r--plugins/hotkeys/actionhandlers.h8
-rw-r--r--plugins/hotkeys/hotkeys.c6
3 files changed, 49 insertions, 3 deletions
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
};