summaryrefslogtreecommitdiff
path: root/plugins/gtkui
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-11-30 21:44:26 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-11-30 21:47:49 +0100
commit7e20827fce4ac2609a834329e16fad363c58a201 (patch)
treee9353fcf825403bbe757cffa23a7fc5cd1190406 /plugins/gtkui
parent312708ff37f4edd0f4d5777b63ffc0af7c7237da (diff)
ported open/add files into gtkui plugin
Diffstat (limited to 'plugins/gtkui')
-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
6 files changed, 66 insertions, 34 deletions
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