summaryrefslogtreecommitdiff
path: root/plugins/gtkui/fileman.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-01-04 21:51:40 +0100
committerGravatar waker <wakeroid@gmail.com>2011-01-04 21:51:40 +0100
commit8d3c2eb27ed0d8766e83ee0eaf081076e684e360 (patch)
tree8112d9786bc4051fdfaf7a479b40c25933b543fe /plugins/gtkui/fileman.c
parent5091c47c79e83cff01b9c964ed91bcb26cc7d302 (diff)
added new GUI option to auto-name playlists from folder names
Diffstat (limited to 'plugins/gtkui/fileman.c')
-rw-r--r--plugins/gtkui/fileman.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
index a41f6000..874ffb2c 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -2,6 +2,7 @@
#include <gtk/gtk.h>
#include <stdlib.h>
#include <ctype.h>
+#include <string.h>
#include "gtkui.h"
#include "ddblistview.h"
#include "progress.h"
@@ -23,6 +24,25 @@ gtkpl_adddir_cb (gpointer data, gpointer userdata) {
void
gtkpl_add_dirs (GSList *lst) {
+ if (g_slist_length (lst) == 1
+ && deadbeef->conf_get_int ("gtkui.name_playlist_from_folder", 0)) {
+ deadbeef->plt_lock ();
+ int plt = deadbeef->plt_get_curr ();
+ if (plt != -1) {
+ char t[1000];
+ if (!deadbeef->plt_get_title (plt, t, sizeof (t))) {
+ char *def = _("New Playlist");
+ if (!strncmp (t, def, strlen (def))) {
+ const char *folder = strrchr ((char*)lst->data, '/');
+ if (!folder) {
+ folder = lst->data;
+ }
+ deadbeef->plt_set_title (plt, folder+1);
+ }
+ }
+ }
+ deadbeef->plt_unlock ();
+ }
g_idle_add (gtkui_progress_show_idle, NULL);
g_slist_foreach(lst, gtkpl_adddir_cb, NULL);
g_slist_free (lst);
@@ -82,6 +102,7 @@ void
gtkui_open_files (struct _GSList *lst) {
deadbeef->pl_clear ();
playlist_refresh ();
+
intptr_t tid = deadbeef->thread_start (open_files_worker, lst);
deadbeef->thread_detach (tid);
}