summaryrefslogtreecommitdiff
path: root/gtkplaylist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-08-04 22:29:26 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-08-04 22:29:26 +0200
commit8e2e95f37a8509c7cbc7b85a61ab7b53f9d7b9d3 (patch)
treeb31ddc98a4af3041e9c94737510adf419e8c5dcc /gtkplaylist.c
parentfbbbd7436a347595e925c5ba8b69e8875b5c73bc (diff)
fixed drag and drop from filemanagers
Diffstat (limited to 'gtkplaylist.c')
-rw-r--r--gtkplaylist.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 497833e8..ead402ac 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -921,3 +921,62 @@ gtkps_handle_drag_drop (int drop_y, uint32_t *d, int length) {
playlist_tail = tail;
}
}
+
+void
+strcopy_special (char *dest, const char *src, int len) {
+ while (len > 0) {
+ if (len >= 3 && !strncmp (src, "\%20", 3)) {
+ *dest = ' ';
+ dest++;
+ src += 3;
+ len -= 3;
+ }
+ else {
+ *dest++ = *src++;
+ len--;
+ }
+ }
+ *dest = 0;
+}
+
+void
+gtkps_handle_fm_drag_drop (int drop_y, void *ptr, int length) {
+ int drop_row = drop_y / rowheight + scrollpos;
+ playItem_t *drop_before = ps_get_for_idx (drop_row);
+ playItem_t *after = NULL;
+ if (drop_before) {
+ after = drop_before->prev;
+ }
+ //printf ("data: %s\n", ptr);
+ // this happens when dropped from file manager
+ // 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)];
+ strcopy_special (fname, p, pe-p);
+ //strncpy (fname, p, pe - p);
+ //fname[pe - p] = 0;
+ playItem_t *inserted = ps_insert_dir (after, fname + 7);
+ if (!inserted) {
+ inserted = ps_insert_file (after, fname + 7);
+ }
+ if (inserted) {
+ after = inserted;
+ }
+ }
+ p = pe;
+ // skip whitespace
+ while (*p && *p <= ' ') {
+ p++;
+ }
+ }
+ gtkps_setup_scrollbar ();
+ GtkWidget *widget = lookup_widget (mainwin, "playlist");
+ draw_playlist (widget, 0, 0, widget->allocation.width, widget->allocation.height);
+ gtkps_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height);
+}