summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/shellexec/shellexec.c44
-rw-r--r--plugins/shellexec/shellexec.h4
-rw-r--r--plugins/shellexecui/interface.c31
-rw-r--r--plugins/shellexecui/shellexec.glade68
-rw-r--r--plugins/shellexecui/shellexecui.c45
5 files changed, 91 insertions, 101 deletions
diff --git a/plugins/shellexec/shellexec.c b/plugins/shellexec/shellexec.c
index d442672a..fcc61aa8 100644
--- a/plugins/shellexec/shellexec.c
+++ b/plugins/shellexec/shellexec.c
@@ -39,7 +39,6 @@
local - command allowed for local files
remote - command allowed for non-local files
playlist - command allowed for playlist tabs
- disabled - ignore command
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -160,9 +159,6 @@ shx_save_actions(Shx_action_t *action_list)
if(action->parent.flags & DB_ACTION_ALLOW_MULTIPLE_TRACKS) {
strcat(conf_line, "multiple,");
}
- if(action->parent.flags & DB_ACTION_DISABLED) {
- strcat(conf_line, "disabled,");
- }
deadbeef->conf_set_str(conf_key, conf_line);
action = (Shx_action_t*)action->parent.next;
i++;
@@ -171,7 +167,7 @@ shx_save_actions(Shx_action_t *action_list)
}
Shx_action_t*
-shx_get_actions (DB_plugin_action_callback_t callback, int omit_disabled)
+shx_get_actions (DB_plugin_action_callback_t callback)
{
Shx_action_t *action_list = NULL;
Shx_action_t *prev = NULL;
@@ -214,11 +210,6 @@ shx_get_actions (DB_plugin_action_callback_t callback, int omit_disabled)
flags = "local,single";
}
- if (strstr (flags, "disabled") && omit_disabled) {
- item = deadbeef->conf_find ("shellexec.", item);
- continue;
- }
-
Shx_action_t *action = calloc (sizeof (Shx_action_t), 1);
action->parent.title = strdup (title);
@@ -244,10 +235,6 @@ shx_get_actions (DB_plugin_action_callback_t callback, int omit_disabled)
if (strstr (flags, "playlist"))
action->parent.flags |= DB_ACTION_PLAYLIST;
- if (strstr (flags, "disabled")) {
- action->parent.flags |= DB_ACTION_DISABLED;
- }
-
if (prev)
prev->parent.next = (DB_plugin_action_t *)action;
prev = action;
@@ -263,7 +250,29 @@ shx_get_actions (DB_plugin_action_callback_t callback, int omit_disabled)
static int
shx_start ()
{
- actions = shx_get_actions((DB_plugin_action_callback_t)shx_callback, 1);
+ actions = shx_get_actions((DB_plugin_action_callback_t)shx_callback);
+ return 0;
+}
+
+static int
+shx_stop ()
+{
+ Shx_action_t *a = actions;
+ while (a) {
+ Shx_action_t *next = (Shx_action_t *)a->parent.next;
+ if (a->shcommand) {
+ free ((char *)a->shcommand);
+ }
+ if (a->parent.title) {
+ free ((char *)a->parent.title);
+ }
+ if (a->parent.name) {
+ free ((char *)a->parent.name);
+ }
+ free (a);
+ a = next;
+ }
+ actions = NULL;
return 0;
}
@@ -288,7 +297,6 @@ static Shx_plugin_t plugin = {
" single - command allowed only for single track\n"
" local - command allowed only for local files\n"
" remote - command allowed only for non-local files\n"
- " disabled - ignore command\n\n"
"EXAMPLE: shellexec.00 notify-send \"%a - %t\":Show selected track:notify:single\n"
"this would show the name of selected track in notification popup"
,
@@ -314,8 +322,8 @@ static Shx_plugin_t plugin = {
,
.misc.plugin.website = "http://deadbeef.sf.net",
.misc.plugin.start = shx_start,
+ .misc.plugin.stop = shx_stop,
.misc.plugin.get_actions = shx_get_plugin_actions,
- .shx_get_actions = shx_get_actions,
- .shx_save_actions = shx_save_actions
+ .save_actions = shx_save_actions
};
diff --git a/plugins/shellexec/shellexec.h b/plugins/shellexec/shellexec.h
index 748340bd..b76dfd85 100644
--- a/plugins/shellexec/shellexec.h
+++ b/plugins/shellexec/shellexec.h
@@ -40,10 +40,8 @@ typedef struct Shx_action_s
typedef struct Shx_plugin_s
{
DB_misc_t misc;
- Shx_action_t *
- (*shx_get_actions)(DB_plugin_action_callback_t callback, int omit_disabled);
void
- (*shx_save_actions)(Shx_action_t *action_list);
+ (*save_actions)(Shx_action_t *action_list);
} Shx_plugin_t;
#endif
diff --git a/plugins/shellexecui/interface.c b/plugins/shellexecui/interface.c
index c5795b0e..cb986101 100644
--- a/plugins/shellexecui/interface.c
+++ b/plugins/shellexecui/interface.c
@@ -120,16 +120,15 @@ create_shellexec_conf_edit_dialog (void)
GtkWidget *table1;
GtkWidget *title_label;
GtkWidget *cmd_label;
- GtkWidget *name_entry;
GtkWidget *cmd_entry;
GtkWidget *name_label;
GtkWidget *title_entry;
+ GtkWidget *name_entry;
GtkWidget *single_check;
GtkWidget *multiple_check;
GtkWidget *local_check;
GtkWidget *remote_check;
GtkWidget *playlist_check;
- GtkWidget *disabled_check;
GtkWidget *dialog_action_area1;
GtkWidget *edit_cancel_button;
GtkWidget *edit_ok_button;
@@ -157,28 +156,22 @@ create_shellexec_conf_edit_dialog (void)
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (title_label), 0, 0.5);
- cmd_label = gtk_label_new (_("Shell Command:"));
+ cmd_label = gtk_label_new (_("Command:"));
gtk_widget_show (cmd_label);
gtk_table_attach (GTK_TABLE (table1), cmd_label, 0, 1, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (cmd_label), 0, 0.5);
- name_entry = gtk_entry_new ();
- gtk_widget_show (name_entry);
- gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_entry_set_invisible_char (GTK_ENTRY (name_entry), 8226);
-
cmd_entry = gtk_entry_new ();
gtk_widget_show (cmd_entry);
gtk_table_attach (GTK_TABLE (table1), cmd_entry, 1, 2, 2, 3,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
+ gtk_widget_set_tooltip_text (cmd_entry, _("Arbitrary shell command. Will be executed in the shell context which the main application was started from. Title formatting can be used. Example: xdg-open %D"));
gtk_entry_set_invisible_char (GTK_ENTRY (cmd_entry), 8226);
- name_label = gtk_label_new (_("Name:"));
+ name_label = gtk_label_new (_("ID:"));
gtk_widget_show (name_label);
gtk_table_attach (GTK_TABLE (table1), name_label, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
@@ -190,8 +183,17 @@ create_shellexec_conf_edit_dialog (void)
gtk_table_attach (GTK_TABLE (table1), title_entry, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
+ gtk_widget_set_tooltip_text (title_entry, _("Free-form name, for example \"My Shell Command\""));
gtk_entry_set_invisible_char (GTK_ENTRY (title_entry), 8226);
+ name_entry = gtk_entry_new ();
+ gtk_widget_show (name_entry);
+ gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_widget_set_tooltip_text (name_entry, _("Command ID, normally it should be something short, for example \"youtube_open\". It must be unique."));
+ gtk_entry_set_invisible_char (GTK_ENTRY (name_entry), 8226);
+
single_check = gtk_check_button_new_with_mnemonic (_("Single Tracks"));
gtk_widget_show (single_check);
gtk_box_pack_start (GTK_BOX (dialog_vbox1), single_check, FALSE, FALSE, 0);
@@ -212,10 +214,6 @@ create_shellexec_conf_edit_dialog (void)
gtk_widget_show (playlist_check);
gtk_box_pack_start (GTK_BOX (dialog_vbox1), playlist_check, FALSE, FALSE, 0);
- disabled_check = gtk_check_button_new_with_mnemonic (_("Disabled"));
- gtk_widget_show (disabled_check);
- gtk_box_pack_start (GTK_BOX (dialog_vbox1), disabled_check, FALSE, FALSE, 0);
-
dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG (shellexec_conf_edit_dialog));
gtk_widget_show (dialog_action_area1);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
@@ -243,16 +241,15 @@ create_shellexec_conf_edit_dialog (void)
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, table1, "table1");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, title_label, "title_label");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, cmd_label, "cmd_label");
- GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, name_entry, "name_entry");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, cmd_entry, "cmd_entry");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, name_label, "name_label");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, title_entry, "title_entry");
+ GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, name_entry, "name_entry");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, single_check, "single_check");
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, disabled_check, "disabled_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");
GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, edit_ok_button, "edit_ok_button");
diff --git a/plugins/shellexecui/shellexec.glade b/plugins/shellexecui/shellexec.glade
index 69425367..2b291d9f 100644
--- a/plugins/shellexecui/shellexec.glade
+++ b/plugins/shellexecui/shellexec.glade
@@ -257,7 +257,7 @@
<child>
<widget class="GtkLabel" id="cmd_label">
<property name="visible">True</property>
- <property name="label" translatable="yes">Shell Command:</property>
+ <property name="label" translatable="yes">Command:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -283,29 +283,9 @@
</child>
<child>
- <widget class="GtkEntry" id="name_entry">
- <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="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
<widget class="GtkEntry" id="cmd_entry">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Arbitrary shell command. Will be executed in the shell context which the main application was started from. Title formatting can be used. Example: xdg-open %D</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
@@ -327,7 +307,7 @@
<child>
<widget class="GtkLabel" id="name_label">
<property name="visible">True</property>
- <property name="label" translatable="yes">Name:</property>
+ <property name="label" translatable="yes">ID:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -355,6 +335,7 @@
<child>
<widget class="GtkEntry" id="title_entry">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Free-form name, for example &quot;My Shell Command&quot;</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
@@ -372,6 +353,28 @@
<property name="y_options"></property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Command ID, normally it should be something short, for example &quot;youtube_open&quot;. It must be unique.</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="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
@@ -474,25 +477,6 @@
<property name="fill">False</property>
</packing>
</child>
-
- <child>
- <widget class="GtkCheckButton" id="disabled_check">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Disabled</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>
</widget>
</child>
</widget>
diff --git a/plugins/shellexecui/shellexecui.c b/plugins/shellexecui/shellexecui.c
index a767e4f7..6662798e 100644
--- a/plugins/shellexecui/shellexecui.c
+++ b/plugins/shellexecui/shellexecui.c
@@ -37,8 +37,6 @@ static GtkWidget *conf_dlg;
static GtkWidget *edit_dlg;
static Shx_action_t *current_action; // selection action when edit window is active
-static int dirty = 0;
-
enum {
COL_TITLE = 0,
COL_META,
@@ -47,12 +45,18 @@ enum {
static int
name_exists(const char *name, Shx_action_t *skip) {
- Shx_action_t *action = actions;
- while(action) {
- if(action != skip && strcmp(action->parent.name, name) == 0) {
- return 1;
+ DB_plugin_t **p = deadbeef->plug_get_list ();
+ for (int i = 0; p[i]; i++) {
+ if (!p[i]->get_actions) {
+ continue;
+ }
+ DB_plugin_action_t *action = p[i]->get_actions (NULL);
+ while(action) {
+ if(action != (DB_plugin_action_t*)skip && action->name && !strcmp(action->name, name)) {
+ return 1;
+ }
+ action = action->next;
}
- action = (Shx_action_t*)action->parent.next;
}
return 0;
}
@@ -72,9 +76,6 @@ is_empty(const char *name) {
void
on_save_button_clicked (GtkButton *button,
gpointer user_data) {
- if(dirty) {
- shellexec_plugin->shx_save_actions(actions);
- }
gtk_widget_destroy(conf_dlg);
}
@@ -95,10 +96,13 @@ on_add_button_clicked (GtkButton *button,
// generate unique command name
char name[15] = "new_cmd";
int suffix = 0;
- while(name_exists(name, NULL)) { // create a unique name
- snprintf(name, 15, "new_cmd%d", suffix);
+ while(name_exists(name, NULL) && suffix < 1000) { // create a unique name
+ snprintf(name, sizeof (name), "new_cmd%d", suffix);
suffix++;
}
+ if (name_exists (name, NULL)) {
+ return;
+ }
// Set default values in text fields
gtk_entry_set_text(
GTK_ENTRY(lookup_widget(edit_dlg, "name_entry")),
@@ -173,7 +177,8 @@ on_remove_button_clicked (GtkButton *button,
}
gtk_list_store_remove(GTK_LIST_STORE(treemodel), &iter);
- dirty = 1;
+ shellexec_plugin->save_actions(actions);
+ deadbeef->sendmessage (DB_EV_ACTIONSCHANGED, 0, 0, 0);
}
}
@@ -235,19 +240,19 @@ validate_command_edit () {
text = gtk_entry_get_text(GTK_ENTRY(lookup_widget(edit_dlg, "name_entry")));
if(is_empty(text) || name_exists(text, current_action)) {
- strcat(message, _("Name should be non-empty and unique\n"));
+ strcat(message, _("ID must be non-empty and unique.\n"));
valid = 0;
}
text = gtk_entry_get_text(GTK_ENTRY(lookup_widget(edit_dlg, "title_entry")));
if(is_empty(text)) {
- strcat(message, _("Title should be non-empty\n"));
+ strcat(message, _("Title must be non-empty.\n"));
valid = 0;
}
text = gtk_entry_get_text(GTK_ENTRY(lookup_widget(edit_dlg, "cmd_entry")));
if(is_empty(text)) {
- strcat(message, _("Shell Command should be non-empty\n"));
+ strcat(message, _("Shell Command must be non-empty.\n"));
valid = 0;
}
@@ -331,8 +336,8 @@ on_edit_ok_button_clicked (GtkButton *button, gpointer user_data) {
edit_dlg = NULL;
current_action = NULL;
- dirty = 1;
- //enable_button(conf_dlg, "save_button");
+ shellexec_plugin->save_actions(actions);
+ deadbeef->sendmessage (DB_EV_ACTIONSCHANGED, 0, 0, 0);
}
static void
@@ -350,7 +355,7 @@ init_treeview() {
G_TYPE_STRING,
//G_TYPE_BOOLEAN,
G_TYPE_POINTER);
- actions = shellexec_plugin->shx_get_actions(NULL, FALSE);
+ actions = (Shx_action_t *)shellexec_plugin->misc.plugin.get_actions(NULL);
Shx_action_t *action = actions;
GtkTreeIter iter;
while(action) {
@@ -370,11 +375,9 @@ shellexecui_action_callback(DB_plugin_action_t *action,
void *user_data) {
conf_dlg = create_shellexec_conf_dialog();
gtk_widget_set_size_request (conf_dlg, 400, 400);
- dirty = 0;
gtk_window_set_transient_for(GTK_WINDOW(conf_dlg),
GTK_WINDOW(gtkui_plugin->get_mainwin()));
init_treeview();
- //disable_button(conf_dlg, "save_button");
gtk_widget_show(conf_dlg);
return 0;
}