summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deadbeef.h46
-rw-r--r--plugins/converter/convgui.c2
-rw-r--r--plugins/gtkui/actions.c2
-rw-r--r--plugins/gtkui/ddbtabstrip.c4
-rw-r--r--plugins/gtkui/hotkeys.c2
-rw-r--r--plugins/gtkui/plcommon.c32
-rw-r--r--plugins/hotkeys/hotkeys.c76
-rw-r--r--plugins/shellexec/shellexec.c12
-rw-r--r--plugins/shellexecui/interface.c7
-rw-r--r--plugins/shellexecui/shellexec.glade20
-rw-r--r--plugins/shellexecui/shellexecui.c11
11 files changed, 40 insertions, 174 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 218db84d..42ebc527 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -811,31 +811,39 @@ enum {
/* Action in main menu (or whereever ui prefers) */
DB_ACTION_COMMON = 1 << 0,
- /* Action allowed for single track */
+ /* Can handle single track */
DB_ACTION_SINGLE_TRACK = 1 << 1,
- /* Action allowed for multiple tracks at once */
- DB_ACTION_ALLOW_MULTIPLE_TRACKS = 1 << 2,
+ /* Can handle multiple tracks */
+ DB_ACTION_MULTIPLE_TRACKS = 1 << 2,
- /* Action can (and prefer) traverse multiple tracks by itself */
- DB_ACTION_CAN_MULTIPLE_TRACKS = 1 << 3,
+ /* deprecated in API 1.5 */
+ DB_ACTION_CAN_MULTIPLE_TRACKS__DEPRECATED = 1 << 3,
/* Action is inactive */
DB_ACTION_DISABLED = 1 << 4,
- /* Action for the playlist (tab) */
- /* this is new in 0.5.2 (API v1.2) */
- DB_ACTION_PLAYLIST = 1 << 5,
+ /* deprecated in API 1.5 */
+ DB_ACTION_PLAYLIST__DEPRECATED = 1 << 5,
+};
+
+// action contexts
+// since 1.5
+enum {
+ DDB_ACTION_CTX_MAIN,
+ DDB_ACTION_CTX_SELECTION,
+ DDB_ACTION_CTX_PLAYLIST,
+ DDB_ACTION_CTX_NOWPLAYING,
+ DDB_ACTION_CTX_COUNT
};
struct DB_plugin_action_s;
-// userdata type depends on type of action
-// it must be NULL for DB_ACTION_COMMON
-// or ddb_playlist_t * for DB_ACTION_PLAYLIST
-// or ddb_playItem_t * for none of the above (track context menu)
-typedef int (*DB_plugin_action_callback_t) (struct DB_plugin_action_s *action, void *userdata);
-#define DDB_ACTION_CALLBACK(x)((int (*)(struct DB_plugin_action_s *action, void *userdata))x)
+// userdata is kept for compatibility with API 1.4 and below
+// should not be used in newly written actions;
+// ctx is one of the above DDB_ACTION_CTX constants
+typedef int (*DB_plugin_action_callback_t) (struct DB_plugin_action_s *action, void *userdata, int ctx);
+#define DDB_ACTION_CALLBACK(x)((int (*)(struct DB_plugin_action_s *action, void *userdata, int ctx))x)
typedef struct DB_plugin_action_s {
const char *title;
@@ -855,16 +863,6 @@ typedef struct DB_plugin_action_s {
struct DB_plugin_action_s *next;
} DB_plugin_action_t;
-// action contexts
-// since 1.5
-enum {
- DDB_ACTION_CTX_MAIN,
- DDB_ACTION_CTX_SELECTION,
- DDB_ACTION_CTX_PLAYLIST,
- DDB_ACTION_CTX_NOWPLAYING,
- DDB_ACTION_CTX_COUNT
-};
-
// base plugin interface
typedef struct DB_plugin_s {
// type must be one of DB_PLUGIN_ types
diff --git a/plugins/converter/convgui.c b/plugins/converter/convgui.c
index 89a341f1..1c77c4ae 100644
--- a/plugins/converter/convgui.c
+++ b/plugins/converter/convgui.c
@@ -1388,7 +1388,7 @@ encoder_cmdline_help_link_create (gchar *widget_name, gchar *string1, gchar *str
static DB_plugin_action_t convert_action = {
.title = "Convert",
.name = "convert",
- .flags = DB_ACTION_CAN_MULTIPLE_TRACKS | DB_ACTION_ALLOW_MULTIPLE_TRACKS | DB_ACTION_SINGLE_TRACK,
+ .flags = DB_ACTION_MULTIPLE_TRACKS | DB_ACTION_SINGLE_TRACK,
.callback = DDB_ACTION_CALLBACK(converter_show),
.next = NULL
};
diff --git a/plugins/gtkui/actions.c b/plugins/gtkui/actions.c
index 751bdf23..ac74111f 100644
--- a/plugins/gtkui/actions.c
+++ b/plugins/gtkui/actions.c
@@ -36,7 +36,7 @@ static void
on_actionitem_activate (GtkMenuItem *menuitem,
DB_plugin_action_t *action)
{
- action->callback (action, NULL);
+ action->callback (action, NULL, DDB_ACTION_CTX_MAIN);
}
void
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index f367b0f8..ed91107e 100644
--- a/plugins/gtkui/ddbtabstrip.c
+++ b/plugins/gtkui/ddbtabstrip.c
@@ -890,7 +890,7 @@ on_actionitem_activate (GtkMenuItem *menuitem,
if (tab_clicked != -1) {
plt = deadbeef->plt_get_for_idx (tab_clicked);
}
- action->callback (action, plt);
+ action->callback (action, NULL, DDB_ACTION_CTX_PLAYLIST);
deadbeef->plt_unref (plt);
}
@@ -936,7 +936,7 @@ add_tab_actions (GtkWidget *menu) {
for (action = actions; action; action = action->next)
{
char *tmp = NULL;
- if (!(action->flags & DB_ACTION_PLAYLIST))
+ if (!(action->flags & DB_ACTION_MULTIPLE_TRACKS))
continue;
// create submenus (separated with '/')
diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c
index 0a24e04a..80fac7ea 100644
--- a/plugins/gtkui/hotkeys.c
+++ b/plugins/gtkui/hotkeys.c
@@ -253,7 +253,7 @@ prefwin_init_hotkeys (GtkWidget *_prefwin) {
gtk_tree_store_append (actions_store, &iter, &action_main_iter);
gtk_tree_store_set (actions_store, &iter, 0, title, 1, actions->name, 2, DDB_ACTION_CTX_MAIN, -1);
}
- if (actions->flags & (DB_ACTION_SINGLE_TRACK | DB_ACTION_ALLOW_MULTIPLE_TRACKS | DB_ACTION_CAN_MULTIPLE_TRACKS)) {
+ if (actions->flags & (DB_ACTION_SINGLE_TRACK | DB_ACTION_MULTIPLE_TRACKS)) {
gtk_tree_store_append (actions_store, &iter, &action_selection_iter);
gtk_tree_store_set (actions_store, &iter, 0, title, 1, actions->name, 2, DDB_ACTION_CTX_SELECTION, -1);
gtk_tree_store_append (actions_store, &iter, &action_playlist_iter);
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index a0117545..6f49cce7 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -376,31 +376,7 @@ void
actionitem_activate (GtkMenuItem *menuitem,
DB_plugin_action_t *action)
{
- // Plugin can handle all tracks by itself
- if (action->flags & DB_ACTION_CAN_MULTIPLE_TRACKS)
- {
- action->callback (action, NULL);
- return;
- }
-
- // For single-track actions just invoke it with first selected track
- if (!(action->flags & DB_ACTION_ALLOW_MULTIPLE_TRACKS))
- {
- DB_playItem_t *it = deadbeef->pl_get_for_idx_and_iter (clicked_idx, PL_MAIN);
- 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 (action, it);
- DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
- deadbeef->pl_item_unref (it);
- it = next;
- }
+ action->callback (action, NULL, DDB_ACTION_CTX_SELECTION);
}
#define HOOKUP_OBJECT(component,widget,name) \
@@ -551,7 +527,7 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
int count = 0;
for (action = actions; action; action = action->next)
{
- if (action->flags & (DB_ACTION_COMMON | DB_ACTION_PLAYLIST))
+ if (action->flags & DB_ACTION_COMMON)
continue;
// create submenus (separated with '/')
@@ -629,9 +605,9 @@ list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
action);
if (!(
((selected_count == 1) && (action->flags & DB_ACTION_SINGLE_TRACK)) ||
- ((selected_count > 1) && (action->flags & DB_ACTION_ALLOW_MULTIPLE_TRACKS))
+ ((selected_count > 1) && (action->flags & DB_ACTION_MULTIPLE_TRACKS))
) ||
- action->flags & DB_ACTION_DISABLED)
+ (action->flags & DB_ACTION_DISABLED))
{
gtk_widget_set_sensitive (GTK_WIDGET (actionitem), FALSE);
}
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c
index f01c62ab..dd9cffc1 100644
--- a/plugins/hotkeys/hotkeys.c
+++ b/plugins/hotkeys/hotkeys.c
@@ -94,79 +94,9 @@ trim (char* s)
and it does full traverse of playlist twice
*/
static void
-cmd_invoke_plugin_command (DB_plugin_action_t *action)
+cmd_invoke_plugin_command (DB_plugin_action_t *action, int ctx)
{
- trace ("We're here to invoke action %s / %s\n", action->title, action->name);
-
- // common action
- if (action->flags & DB_ACTION_COMMON)
- {
- action->callback (action, NULL);
- return;
- }
-
- // playlist action
- if (action->flags & DB_ACTION_PLAYLIST)
- {
- ddb_playlist_t *plt = deadbeef->plt_get_curr ();
- if (plt) {
- action->callback (action, plt);
- deadbeef->plt_unref (plt);
- }
- return;
- }
-
- int selected_count = 0;
- DB_playItem_t *pit = deadbeef->pl_get_first (PL_MAIN);
- DB_playItem_t *selected = NULL;
- while (pit) {
- if (deadbeef->pl_is_selected (pit))
- {
- if (!selected)
- selected = pit;
- selected_count++;
- }
- DB_playItem_t *next = deadbeef->pl_get_next (pit, PL_MAIN);
- deadbeef->pl_item_unref (pit);
- pit = next;
- }
-
- //Now we're checking if action is applicable:
-
- if (selected_count == 0)
- {
- trace ("No tracks selected\n");
- return;
- }
- if ((selected_count == 1) && (!(action->flags & DB_ACTION_SINGLE_TRACK)))
- {
- trace ("Hotkeys: action %s not allowed for single track\n", action->name);
- return;
- }
- if ((selected_count > 1) && (!(action->flags & DB_ACTION_ALLOW_MULTIPLE_TRACKS)))
- {
- trace ("Hotkeys: action %s not allowed for multiple tracks\n", action->name);
- return;
- }
-
- //So, action is allowed, do it.
-
- if (action->flags & DB_ACTION_CAN_MULTIPLE_TRACKS)
- {
- action->callback (action, NULL);
- return;
- }
-
- pit = deadbeef->pl_get_first (PL_MAIN);
- while (pit) {
- if (deadbeef->pl_is_selected (pit))
- {
- action->callback (action, pit);
- }
- DB_playItem_t *next = deadbeef->pl_get_next (pit, PL_MAIN);
- deadbeef->pl_item_unref (pit);
- pit = next;
- }
+ action->callback (action, NULL, ctx);
}
static DB_plugin_action_t *
@@ -423,7 +353,7 @@ hotkeys_event_loop (void *unused) {
(state == commands[ i ].modifier))
{
trace ("matches to commands[%d]!\n", i);
- cmd_invoke_plugin_command (commands[i].action);
+ cmd_invoke_plugin_command (commands[i].action, commands[i].ctx);
break;
}
}
diff --git a/plugins/shellexec/shellexec.c b/plugins/shellexec/shellexec.c
index 7d49c2d6..b011067f 100644
--- a/plugins/shellexec/shellexec.c
+++ b/plugins/shellexec/shellexec.c
@@ -83,7 +83,7 @@ trim (char* s)
static int
shx_callback (Shx_action_t *action, DB_playItem_t *it)
{
- if (action->parent.flags&(DB_ACTION_PLAYLIST|DB_ACTION_COMMON)) {
+ if (action->parent.flags&(DB_ACTION_COMMON)) {
trace ("%s\n", action->shcommand);
system (action->shcommand);
return 0;
@@ -158,13 +158,10 @@ shx_save_actions (void)
if(action->shx_flags & SHX_ACTION_LOCAL_ONLY) {
strcat(conf_line, "local,");
}
- if(action->parent.flags & DB_ACTION_PLAYLIST) {
- strcat(conf_line, "playlist,");
- }
if(action->parent.flags & DB_ACTION_SINGLE_TRACK) {
strcat(conf_line, "single,");
}
- if(action->parent.flags & DB_ACTION_ALLOW_MULTIPLE_TRACKS) {
+ if(action->parent.flags & DB_ACTION_MULTIPLE_TRACKS) {
strcat(conf_line, "multiple,");
}
if(action->parent.flags & DB_ACTION_COMMON) {
@@ -241,10 +238,7 @@ shx_get_actions (DB_plugin_action_callback_t callback)
action->parent.flags |= DB_ACTION_SINGLE_TRACK;
if (strstr (flags, "multiple"))
- action->parent.flags |= DB_ACTION_ALLOW_MULTIPLE_TRACKS;
-
- if (strstr (flags, "playlist"))
- action->parent.flags |= DB_ACTION_PLAYLIST;
+ action->parent.flags |= DB_ACTION_MULTIPLE_TRACKS;
if (strstr (flags, "common"))
action->parent.flags |= DB_ACTION_COMMON;
diff --git a/plugins/shellexecui/interface.c b/plugins/shellexecui/interface.c
index ee41ed1d..f6286eac 100644
--- a/plugins/shellexecui/interface.c
+++ b/plugins/shellexecui/interface.c
@@ -134,7 +134,6 @@ create_shellexec_conf_edit_dialog (void)
GtkWidget *multiple_check;
GtkWidget *local_check;
GtkWidget *remote_check;
- GtkWidget *playlist_check;
GtkWidget *common_check;
GtkWidget *dialog_action_area1;
GtkWidget *edit_cancel_button;
@@ -221,11 +220,6 @@ create_shellexec_conf_edit_dialog (void)
gtk_box_pack_start (GTK_BOX (dialog_vbox1), remote_check, FALSE, FALSE, 0);
gtk_widget_set_tooltip_text (remote_check, _("Works on remote files (e.g. http:// streams)"));
- playlist_check = gtk_check_button_new_with_mnemonic (_("Playlist"));
- gtk_widget_show (playlist_check);
- gtk_box_pack_start (GTK_BOX (dialog_vbox1), playlist_check, FALSE, FALSE, 0);
- gtk_widget_set_tooltip_text (playlist_check, _("Item should appear on the playlist tab context menu"));
-
common_check = gtk_check_button_new_with_mnemonic (_("Common"));
gtk_widget_show (common_check);
gtk_box_pack_start (GTK_BOX (dialog_vbox1), common_check, FALSE, FALSE, 0);
@@ -266,7 +260,6 @@ create_shellexec_conf_edit_dialog (void)
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, multiple_check, "multiple_check");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, local_check, "local_check");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, remote_check, "remote_check");
- GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, playlist_check, "playlist_check");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, common_check, "common_check");
GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_edit_dialog, dialog_action_area1, "dialog_action_area1");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, edit_cancel_button, "edit_cancel_button");
diff --git a/plugins/shellexecui/shellexec.glade b/plugins/shellexecui/shellexec.glade
index d2f21b35..3e64ca2b 100644
--- a/plugins/shellexecui/shellexec.glade
+++ b/plugins/shellexecui/shellexec.glade
@@ -476,26 +476,6 @@
</child>
<child>
- <widget class="GtkCheckButton" id="playlist_check">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Item should appear on the playlist tab context menu</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Playlist</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="GtkCheckButton" id="common_check">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Item should appear in the main menu</property>
diff --git a/plugins/shellexecui/shellexecui.c b/plugins/shellexecui/shellexecui.c
index b2a60230..9bd82bc6 100644
--- a/plugins/shellexecui/shellexecui.c
+++ b/plugins/shellexecui/shellexecui.c
@@ -196,10 +196,7 @@ on_edit_button_clicked(GtkButton *button, gpointer user_data) {
current_action->parent.flags & DB_ACTION_SINGLE_TRACK);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "multiple_check")),
- current_action->parent.flags & DB_ACTION_ALLOW_MULTIPLE_TRACKS);
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "playlist_check")),
- current_action->parent.flags & DB_ACTION_PLAYLIST);
+ current_action->parent.flags & DB_ACTION_MULTIPLE_TRACKS);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "local_check")),
current_action->shx_flags & SHX_ACTION_LOCAL_ONLY);
@@ -294,9 +291,7 @@ on_edit_ok_button_clicked (GtkButton *button, gpointer user_data) {
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "single_check")));
flags = (flags & ~DB_ACTION_SINGLE_TRACK) | (active?DB_ACTION_SINGLE_TRACK:0);
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "multiple_check")));
- flags = (flags & ~DB_ACTION_ALLOW_MULTIPLE_TRACKS) | (active?DB_ACTION_ALLOW_MULTIPLE_TRACKS:0);
- active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "playlist_check")));
- flags = (flags & ~DB_ACTION_PLAYLIST) | (active?DB_ACTION_PLAYLIST:0);
+ flags = (flags & ~DB_ACTION_MULTIPLE_TRACKS) | (active?DB_ACTION_MULTIPLE_TRACKS:0);
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "local_check")));
shx_flags = (shx_flags & ~SHX_ACTION_LOCAL_ONLY) | (active?SHX_ACTION_LOCAL_ONLY:0);
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(edit_dlg, "remote_check")));
@@ -362,7 +357,7 @@ shellexecui_action_gtk (void *data)
static int
shellexecui_action_callback(DB_plugin_action_t *action,
- void *user_data) {
+ void *user_data, int ctx) {
g_idle_add (shellexecui_action_gtk, NULL);
return 0;
}