summaryrefslogtreecommitdiff
path: root/plugins/gtkui
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-15 21:56:59 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-15 21:56:59 +0100
commit4c2f9863d0c6016d80c1c188c8ac229e21c58c60 (patch)
treed67b3202bc80aeddc4109ab0e748863a996674ae /plugins/gtkui
parentc87b942009c7a824c67aca4949bdd61644ead4be (diff)
fixed drag-n-drop from filemanager
Diffstat (limited to 'plugins/gtkui')
-rw-r--r--plugins/gtkui/ddblistview.c6
-rw-r--r--plugins/gtkui/ddblistview.h2
-rw-r--r--plugins/gtkui/fileman.c37
-rw-r--r--plugins/gtkui/gtkui.c5
-rw-r--r--plugins/gtkui/gtkui.h8
5 files changed, 32 insertions, 26 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index dd125565..f55eed88 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -723,7 +723,11 @@ ddb_listview_list_drag_data_received (GtkWidget *widget,
memcpy (mem, ptr, data->length);
mem[data->length] = 0;
// we don't pass control structure, but there's only one drag-drop view currently
- ps->binding->external_drag_n_drop (mem, data->length, y);
+ DdbListviewIter it = ps->binding->get_for_idx (y / ps->rowheight + ps->scrollpos);
+ ps->binding->external_drag_n_drop (it, mem, data->length);
+ if (it) {
+ ps->binding->unref (it);
+ }
}
else if (target_type == 1) {
uint32_t *d= (uint32_t *)ptr;
diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h
index db1d9b0d..667f59ad 100644
--- a/plugins/gtkui/ddblistview.h
+++ b/plugins/gtkui/ddblistview.h
@@ -66,7 +66,7 @@ typedef struct {
// drag-n-drop
void (*drag_n_drop) (DdbListviewIter before, uint32_t *indices, int length);
- void (*external_drag_n_drop) (char *mem, int length, int row);
+ void (*external_drag_n_drop) (DdbListviewIter before, char *mem, int length);
// columns
int (*col_count) (void);
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
index ba5c6070..d6374ba6 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -32,7 +32,7 @@ gtkpl_add_file_info_cb (DB_playItem_t *it, void *data) {
static gboolean
progress_hide_idle (gpointer data) {
progress_hide ();
- //playlist_refresh ();
+ playlist_refresh ();
return FALSE;
}
@@ -153,25 +153,16 @@ strcopy_special (char *dest, const char *src, int len) {
}
void
-gtkpl_add_fm_dropped_files (char *ptr, int length, int drop_y) {
- // FIXME: port
-#if 0
+gtkpl_add_fm_dropped_files (DB_playItem_t *drop_before, char *ptr, int length) {
DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
g_idle_add (progress_show_idle, NULL);
-// int drop_row = drop_y / rowheight + ddb_get_vscroll_pos (pl);
- DdbListviewIter iter = ddb_listview_get_iter_from_coord (0, drop_y);
- drop_before = ((DdbListviewIter )iter);
- int drop_row = deadbeef->pl_get_idx_of (drop_before);
-// DdbListviewIter drop_before = deadbeef->pl_get_for_idx_and_iter (drop_row, PL_MAIN);
DdbListviewIter after = NULL;
if (drop_before) {
- after = PL_PREV (drop_before, PL_MAIN);
- UNREF (drop_before);
- drop_before = NULL;
+ after = deadbeef->pl_get_prev (drop_before, PL_MAIN);
}
else {
- after = PL_TAIL (ps->iterator);
+ after = deadbeef->pl_get_last (PL_MAIN);
}
const uint8_t *p = (const uint8_t*)ptr;
while (*p) {
@@ -191,7 +182,7 @@ gtkpl_add_fm_dropped_files (char *ptr, int length, int drop_y) {
}
if (inserted) {
if (after) {
- UNREF (after);
+ deadbeef->pl_item_unref (after);
}
after = inserted;
}
@@ -205,27 +196,29 @@ gtkpl_add_fm_dropped_files (char *ptr, int length, int drop_y) {
free (ptr);
if (after) {
- UNREF (after);
+ deadbeef->pl_item_unref (after);
}
g_idle_add (progress_hide_idle, NULL);
-#endif
}
struct fmdrop_data {
char *mem;
int length;
- int drop_y;
+ DB_playItem_t *drop_before;
};
static void
fmdrop_worker (void *ctx) {
struct fmdrop_data *data = (struct fmdrop_data *)ctx;
- gtkpl_add_fm_dropped_files (data->mem, data->length, data->drop_y);
+ gtkpl_add_fm_dropped_files (data->drop_before, data->mem, data->length);
+ if (data->drop_before) {
+ deadbeef->pl_item_unref (data->drop_before);
+ }
free (data);
}
void
-gtkui_receive_fm_drop (char *mem, int length, int drop_y) {
+gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length) {
struct fmdrop_data *data = malloc (sizeof (struct fmdrop_data));
if (!data) {
fprintf (stderr, "gtkui_receive_fm_drop: malloc failed\n");
@@ -233,6 +226,10 @@ gtkui_receive_fm_drop (char *mem, int length, int drop_y) {
}
data->mem = mem;
data->length = length;
- data->drop_y = drop_y;
+ if (before) {
+ deadbeef->pl_item_ref (before);
+ }
+ data->drop_before = before;
+ // since it happens in separate thread, we need to addref
deadbeef->thread_start (fmdrop_worker, data);
}
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 822f75fc..e5beccb0 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -480,7 +480,6 @@ playlist_refresh (void) {
static gboolean
playlistchanged_cb (gpointer none) {
playlist_refresh ();
- search_refresh ();
return FALSE;
}
@@ -792,8 +791,8 @@ void main_drag_n_drop (DdbListviewIter before, uint32_t *indices, int length) {
deadbeef->pl_move_items (PL_MAIN, (DB_playItem_t *)before, indices, length);
}
-void main_external_drag_n_drop (char *mem, int length, int row) {
- gtkui_receive_fm_drop (mem, length, row);
+void main_external_drag_n_drop (DdbListviewIter before, char *mem, int length) {
+ gtkui_receive_fm_drop ((DB_playItem_t *)before, mem, length);
}
static int main_col_count (void) {
diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h
index b5bfbd7a..13a31e82 100644
--- a/plugins/gtkui/gtkui.h
+++ b/plugins/gtkui/gtkui.h
@@ -43,7 +43,7 @@ void
gtkui_open_files (struct _GSList *lst);
void
-gtkui_receive_fm_drop (char *mem, int length, int drop_y);
+gtkui_receive_fm_drop (DB_playItem_t *before, char *mem, int length);
// plugin configuration dialogs
@@ -79,4 +79,10 @@ theme_set_fg_color (int col);
void
theme_set_bg_color (int col);
+void
+playlist_refresh (void);
+
+void
+search_refresh (void);
+
#endif