summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-08 19:09:26 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-08 19:09:26 +0200
commit6f0dde827ac676ad8863ab9f24274b8ec6d176c8 (patch)
treef87603439b446e7a3f72b4d48cdc6a971de3fa14
parenta206a5054db858478b693c0a6fcfcc91f56dbd93 (diff)
added progress display dialog when drag-dropped from external app
-rw-r--r--callbacks.c6
-rw-r--r--gtkplaylist.c60
-rw-r--r--gtkplaylist.h3
-rw-r--r--main.c4
-rw-r--r--messages.h1
5 files changed, 52 insertions, 22 deletions
diff --git a/callbacks.c b/callbacks.c
index 6befe0e1..df14d0ed 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -161,6 +161,9 @@ on_add_files_activate (GtkMenuItem *menuitem,
messagepump_push (M_ADDFILES, (uintptr_t)lst, 0, 0);
}
}
+ else {
+ gtk_widget_destroy (dlg);
+ }
}
void
@@ -178,6 +181,9 @@ on_add_folder1_activate (GtkMenuItem *menuitem,
messagepump_push (M_ADDDIR, (uintptr_t)folder, 0, 0);
}
}
+ else {
+ gtk_widget_destroy (dlg);
+ }
}
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 6fdf3288..3c58ebdc 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -1102,17 +1102,34 @@ strcopy_special (char *dest, const char *src, int len) {
*dest = 0;
}
+int
+gtkps_add_file_info_cb (playItem_t *it, void *data) {
+ GtkEntry *e = (GtkEntry *)data;
+ GDK_THREADS_ENTER();
+ gtk_entry_set_text (GTK_ENTRY (e), it->fname);
+ GDK_THREADS_LEAVE();
+ usleep (0);
+ return 0;
+}
+
void
-gtkps_handle_fm_drag_drop (int drop_y, void *ptr, int length) {
+gtkps_add_fm_dropped_files (char *ptr, int length, int drop_y) {
+ GDK_THREADS_ENTER();
+ gtk_widget_set_sensitive (mainwin, FALSE);
+ GtkWidget *d = gtk_dialog_new ();
+ GtkWidget *e = gtk_entry_new ();
+ gtk_widget_set_size_request (e, 500, -1);
+ gtk_widget_set_sensitive (GTK_WIDGET (e), FALSE);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (d))), e);
+ gtk_widget_show_all (d);
+ GDK_THREADS_LEAVE();
+
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;
@@ -1124,9 +1141,9 @@ gtkps_handle_fm_drag_drop (int drop_y, void *ptr, int length) {
strcopy_special (fname, p, pe-p);
//strncpy (fname, p, pe - p);
//fname[pe - p] = 0;
- playItem_t *inserted = ps_insert_dir (after, fname + 7, NULL, NULL);
+ playItem_t *inserted = ps_insert_dir (after, fname + 7, gtkps_add_file_info_cb, e);
if (!inserted) {
- inserted = ps_insert_file (after, fname + 7, NULL, NULL);
+ inserted = ps_insert_file (after, fname + 7, gtkps_add_file_info_cb, e);
}
if (inserted) {
after = inserted;
@@ -1138,15 +1155,27 @@ gtkps_handle_fm_drag_drop (int drop_y, void *ptr, int length) {
p++;
}
}
+ free (ptr);
ps_shuffle ();
- gtkps_setup_scrollbar ();
- GtkWidget *widget = lookup_widget (mainwin, "playlist");
-
// invalidate entire cache - slow, but rare
memset (drawps_cache, 0, sizeof (int16_t) * 3 * ncolumns * nvisiblerows);
-
+ GDK_THREADS_ENTER();
+ gtk_widget_destroy (d);
+ gtk_widget_set_sensitive (mainwin, TRUE);
+ 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);
+ GDK_THREADS_LEAVE();
+
+}
+
+void
+gtkps_handle_fm_drag_drop (int drop_y, void *ptr, int length) {
+ // this happens when dropped from file manager
+ char *mem = malloc (length);
+ memcpy (mem, ptr, length);
+ messagepump_push (M_FMDRAGDROP, (uintptr_t)mem, length, drop_y);
}
void
@@ -1332,17 +1361,6 @@ on_header_button_release_event (GtkWidget *widget,
return FALSE;
}
-int
-gtkps_add_file_info_cb (playItem_t *it, void *data) {
- GtkEntry *e = (GtkEntry *)data;
-// printf ("%s\n", it->fname);
- GDK_THREADS_ENTER();
- gtk_entry_set_text (GTK_ENTRY (e), it->fname);
- GDK_THREADS_LEAVE();
- usleep (0);
- return 0;
-}
-
void
gtkps_add_dir (char *folder) {
// create window
diff --git a/gtkplaylist.h b/gtkplaylist.h
index df4a8218..6d7cfc86 100644
--- a/gtkplaylist.h
+++ b/gtkplaylist.h
@@ -94,4 +94,7 @@ gtkps_add_dir (char *dir);
void
gtkps_add_files (GSList *lst);
+void
+gtkps_add_fm_dropped_files (char *ptr, int length, int drop_y);
+
#endif
diff --git a/main.c b/main.c
index a0a465da..71125684 100644
--- a/main.c
+++ b/main.c
@@ -83,11 +83,13 @@ psdl_thread (uintptr_t ctx) {
case M_ADDFILES:
gtkps_add_files ((GSList *)ctx);
break;
+ case M_FMDRAGDROP:
+ gtkps_add_fm_dropped_files ((char *)ctx, p1, p2);
+ break;
}
}
usleep(10000);
gtkps_update_songinfo ();
- // handle message pump here
}
}
diff --git a/messages.h b/messages.h
index 19e87fca..6593b6cd 100644
--- a/messages.h
+++ b/messages.h
@@ -14,6 +14,7 @@ enum {
M_SONGCHANGED, // p1=from, p2=to
M_ADDDIR, // ctx = pointer to string, which must be freed by f_free
M_ADDFILES, // ctx = GSList pointer, must be freed with g_slist_free
+ M_FMDRAGDROP, // ctx = char* ptr, must be freed with standard free, p1 is length of data, p2 is drop_y
};
#endif // __MESSAGES_H