summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deadbeef.h4
-rw-r--r--main.c31
-rw-r--r--plugins/gtkui/Makefile.am5
-rw-r--r--plugins/gtkui/callbacks.c7
-rw-r--r--plugins/gtkui/fileman.c39
-rw-r--r--plugins/gtkui/gtkplaylist.h3
-rw-r--r--plugins/gtkui/gtkui.c29
-rw-r--r--plugins/gtkui/gtkui.h17
8 files changed, 66 insertions, 69 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 5dc29cfa..931b6652 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -169,10 +169,6 @@ enum {
M_PAUSESONG,
M_PLAYRANDOM,
M_SONGCHANGED, // p1=from, p2=to
- M_ADDDIR, // ctx = pointer to string, which must be freed by g_free
- M_ADDFILES, // ctx = GSList pointer, must be freed with g_slist_free
- M_ADDDIRS, // ctx = GSList pointer, must be freed with g_slist_free
- M_OPENFILES, // 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
M_TERMINATE, // must be sent to player thread to terminate
M_PLAYLISTREFRESH,
diff --git a/main.c b/main.c
index 9f35dc1a..244a3b25 100644
--- a/main.c
+++ b/main.c
@@ -248,14 +248,6 @@ player_thread (uintptr_t ctx) {
}
break;
case M_TERMINATE:
- // FIXME: should signal main thread about termination
- // or will that be new main thread?
-#if 0
- // <placeholder>
- // tell gui plugin to shut down
- // FIXME: cleanup properly on main thread
- guiplug_shutdown ();
-#endif
return;
case M_SONGCHANGED:
plug_trigger_event_trackchange (p1, p2);
@@ -295,29 +287,6 @@ player_thread (uintptr_t ctx) {
p_stop ();
pl_randomsong ();
break;
- case M_ADDDIR:
- // <placeholder>
- // * let guiplug know that addition is in progress
- // * call it back on every file
- // * let guiplug know that addition is done
- // guiplug_add_dir ((char *)ctx);
- break;
- case M_ADDDIRS:
- // <placeholder>
- // same as above, but for many folders
- // guiplug_add_dirs ((GSList *)ctx);
- break;
- case M_ADDFILES:
- // <placeholder>
- // same as above but for many files
- // guiplug_add_files ((GSList *)ctx);
- break;
- case M_OPENFILES:
- p_stop ();
- // <placeholder>
- // open many files and start 1st of them
- // guiplug_open_files ((GSList *)ctx);
- break;
case M_FMDRAGDROP:
// <placeholder>
// handle drag-n-drop from filemanager
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am
index 606c01cb..2055cada 100644
--- a/plugins/gtkui/Makefile.am
+++ b/plugins/gtkui/Makefile.am
@@ -1,13 +1,14 @@
if HAVE_GTK
gtkuidir = $(libdir)/$(PACKAGE)
pkglib_LTLIBRARIES = gtkui.la
-gtkui_la_SOURCES = gtkui.c\
+gtkui_la_SOURCES = gtkui.c gtkui.h\
callbacks.c interface.c support.c callbacks.h interface.h support.h\
gtkplaylist.c gtkplaylist.h\
drawing.h gdkdrawing.c\
progress.c progress.h\
search.c search.h\
- gtksession.c
+ gtksession.c\
+ fileman.c
gtkui_la_LDFLAGS = -module
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 2334cbfd..5f1cd755 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -36,6 +36,7 @@
#include "search.h"
#include "progress.h"
#include "session.h"
+#include "gtkui.h"
extern GtkWidget *mainwin;
extern gtkplaylist_t main_playlist;
@@ -295,7 +296,7 @@ on_open_activate (GtkMenuItem *menuitem,
GSList *lst = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dlg));
gtk_widget_destroy (dlg);
if (lst) {
- deadbeef->sendmessage (M_OPENFILES, (uintptr_t)lst, 0, 0);
+ gtkui_open_files (lst);
}
}
else {
@@ -328,7 +329,7 @@ on_add_files_activate (GtkMenuItem *menuitem,
GSList *lst = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dlg));
gtk_widget_destroy (dlg);
if (lst) {
- deadbeef->sendmessage (M_ADDFILES, (uintptr_t)lst, 0, 0);
+ gtkui_add_files (lst);
}
}
else {
@@ -360,7 +361,7 @@ on_add_folders_activate (GtkMenuItem *menuitem,
GSList *lst = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dlg));
gtk_widget_destroy (dlg);
if (lst) {
- deadbeef->sendmessage (M_ADDDIRS, (uintptr_t)lst, 0, 0);
+ gtkui_add_dirs (lst);
}
}
else {
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
new file mode 100644
index 00000000..14bfddca
--- /dev/null
+++ b/plugins/gtkui/fileman.c
@@ -0,0 +1,39 @@
+#include "../../deadbeef.h"
+#include <gtk/gtk.h>
+#include "gtkui.h"
+#include "gtkplaylist.h"
+
+static void
+add_dirs_worker (void *data) {
+ GSList *lst = (GSList *)data;
+ gtkpl_add_dirs (&main_playlist, lst);
+}
+
+void
+gtkui_add_dirs (GSList *lst) {
+ deadbeef->thread_start (add_dirs_worker, lst);
+}
+
+static void
+add_files_worker (void *data) {
+ GSList *lst = (GSList *)data;
+ gtkpl_add_files (&main_playlist, lst);
+}
+
+void
+gtkui_add_files (struct _GSList *lst) {
+ deadbeef->thread_start (add_files_worker, lst);
+}
+
+static void
+open_files_worker (void *data) {
+ GSList *lst = (GSList *)data;
+ gtkpl_add_files (&main_playlist, lst);
+ deadbeef->sendmessage (M_PLAYSONG, 0, 0, 0);
+}
+
+void
+gtkui_open_files (struct _GSList *lst) {
+ deadbeef->pl_free ();
+ deadbeef->thread_start (open_files_worker, lst);
+}
diff --git a/plugins/gtkui/gtkplaylist.h b/plugins/gtkui/gtkplaylist.h
index 3d7c956e..ddeb479f 100644
--- a/plugins/gtkui/gtkplaylist.h
+++ b/plugins/gtkui/gtkplaylist.h
@@ -86,6 +86,9 @@ typedef struct {
gtkpl_column_t *columns;
} gtkplaylist_t;
+extern gtkplaylist_t main_playlist;
+extern gtkplaylist_t search_playlist;
+
#define GTKPL_PROLOGUE \
gtkplaylist_t *ps = (gtkplaylist_t *)gtk_object_get_data (GTK_OBJECT (widget), "ps"); assert (ps);
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index acb35e40..88688863 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -271,41 +271,12 @@ guiplug_start_random (void) {
}
void
-guiplug_add_dir (char *dir) {
- // long time processing
- // float t1 = (float)clock () / CLOCKS_PER_SEC;
- gtkpl_add_dir (&main_playlist, dir);
- // float t2 = (float)clock () / CLOCKS_PER_SEC;
- // printf ("time: %f\n", t2-t1);
-}
-
-void
-guiplug_add_dirs (GSList *dirs) {
- // long time processing
- // float t1 = (float)clock () / CLOCKS_PER_SEC;
- gtkpl_add_dirs (&main_playlist, dirs);
- // float t2 = (float)clock () / CLOCKS_PER_SEC;
- // printf ("time: %f\n", t2-t1);
-}
-
-void
-guiplug_add_files (GSList *files) {
- gtkpl_add_files (&main_playlist, files);
-}
-
-void
guiplug_open_files (GSList *files) {
gtkpl_add_files (&main_playlist, files);
//gtkpl_playsong (&main_playlist);
}
void
-guiplug_refresh_playlist (void) {
- // <deprecated>
- assert (0);
-}
-
-void
guiplug_add_fm_dropped_files (char *files, int p1, int p2) {
gtkpl_add_fm_dropped_files (&main_playlist, files, p1, p2);
}
diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h
new file mode 100644
index 00000000..dcfa5cd1
--- /dev/null
+++ b/plugins/gtkui/gtkui.h
@@ -0,0 +1,17 @@
+#ifndef __GTKUI_H
+#define __GTKUI_H
+
+extern DB_functions_t *deadbeef;
+
+struct _GSList;
+
+void
+gtkui_add_dirs (struct _GSList *lst);
+
+void
+gtkui_add_files (struct _GSList *lst);
+
+void
+gtkui_open_files (struct _GSList *lst);
+
+#endif