summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callbacks.c28
-rw-r--r--gtkplaylist.c3
-rw-r--r--playlist.c8
3 files changed, 36 insertions, 3 deletions
diff --git a/callbacks.c b/callbacks.c
index b38213de..2a148fe4 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -415,9 +415,33 @@ on_playlist_drag_data_received (GtkWidget *widget,
gchar *ptr=(char*)data->data;
// printf ("target type: %d\n", target_type);
if (target_type == 0) { // uris
- if (!strncmp(ptr,"file:///",8) && (strlen(ptr)<=4096)) {
+ if (!strncmp(ptr,"file:///",8)) {
+ //printf ("data: %s\n", ptr);
// this happens when dropped from file manager
-// printf ("%s\n", ptr);
+ // parse, and try to add to playlist
+ const gchar *p = ptr;
+ while (*p) {
+ const gchar *pe = p+1;
+ while (*pe && *pe > ' ') {
+ pe++;
+ }
+ if (pe - p < 4096 && pe - p > 7) {
+ char fname[(int)(pe - p)];
+ strncpy (fname, p, pe - p);
+ fname[pe - p] = 0;
+ if (ps_add_dir (fname+7)) {
+ ps_add_file (fname+7);
+ }
+ }
+ p = pe;
+ // skip whitespace
+ while (*p && *p <= ' ') {
+ p++;
+ }
+ }
+ gtkps_setup_scrollbar ();
+ draw_playlist (widget, 0, 0, widget->allocation.width, widget->allocation.height);
+ gtkps_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
}
}
else if (target_type == 1) {
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 24cc6db0..497833e8 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -713,8 +713,9 @@ gtkps_keypress (int keyval, int state) {
if (playlist_row >= ps_getcount ()) {
playlist_row = ps_getcount () - 1;
}
+ gtkps_setup_scrollbar ();
draw_playlist (widget, 0, 0, widget->allocation.width, widget->allocation.height);
- gdk_draw_drawable (widget->window, widget->style->black_gc, backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height);
+ gtkps_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
return;
}
else if (keyval == GDK_Down && playlist_row < ps_getcount () - 1) {
diff --git a/playlist.c b/playlist.c
index 6a7e261a..07a175d8 100644
--- a/playlist.c
+++ b/playlist.c
@@ -4,6 +4,9 @@
#include <fnmatch.h>
#include <stdio.h>
#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "playlist.h"
#include "codec.h"
#include "cwav.h"
@@ -288,6 +291,11 @@ ps_add_file (const char *fname) {
int
ps_add_dir (const char *dirname) {
+ struct stat buf;
+ lstat (dirname, &buf);
+ if (S_ISLNK(buf.st_mode)) {
+ return -1;
+ }
struct dirent **namelist = NULL;
int n;