summaryrefslogtreecommitdiff
path: root/plugins/gtkui/plcommon.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-05 19:46:55 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-05 19:46:55 +0100
commitd4132fccbcd079c56b8109ecc15b011e5d1bdee1 (patch)
tree5c53c9efc9745e42b7c48a525a39334ebed7aaf8 /plugins/gtkui/plcommon.c
parenta1d50122035b30e5735ca5db70593fe51028e628 (diff)
new action API code fixes
Diffstat (limited to 'plugins/gtkui/plcommon.c')
-rw-r--r--plugins/gtkui/plcommon.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 6f49cce7..1dd43308 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -376,7 +376,38 @@ void
actionitem_activate (GtkMenuItem *menuitem,
DB_plugin_action_t *action)
{
- action->callback (action, NULL, DDB_ACTION_CTX_SELECTION);
+ if (action->flags & DB_ACTION_USING_API_14) {
+ typedef int (*action_callback_14_t)(struct DB_plugin_action_s *action, void *userdata);
+ // Plugin can handle all tracks by itself
+ if (action->flags & DB_ACTION_CAN_MULTIPLE_TRACKS__DEPRECATED)
+ {
+ ((action_callback_14_t)action->callback) (action, NULL);
+ return;
+ }
+
+ // For single-track actions just invoke it with first selected track
+ if (!(action->flags & DB_ACTION_MULTIPLE_TRACKS))
+ {
+ DB_playItem_t *it = deadbeef->pl_get_for_idx_and_iter (clicked_idx, PL_MAIN);
+ ((action_callback_14_t)action->callback) (action, it);
+ deadbeef->pl_item_unref (it);
+ return;
+ }
+
+ //We end up here if plugin won't traverse tracks and we have to do it ourselves
+ DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
+ while (it) {
+ if (deadbeef->pl_is_selected (it)) {
+ ((action_callback_14_t)action->callback) (action, it);
+ }
+ DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
+ deadbeef->pl_item_unref (it);
+ it = next;
+ }
+ }
+ else {
+ action->callback (action, DDB_ACTION_CTX_SELECTION);
+ }
}
#define HOOKUP_OBJECT(component,widget,name) \