summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamfile3
-rw-r--r--callbacks.c78
-rw-r--r--gtkplaylist.c130
-rw-r--r--gtkplaylist.h15
-rw-r--r--main.c30
5 files changed, 151 insertions, 105 deletions
diff --git a/Jamfile b/Jamfile
index 94b2f391..4be76e32 100644
--- a/Jamfile
+++ b/Jamfile
@@ -1,6 +1,7 @@
SubDir ROOT ;
CCFLAGS += -D_GNU_SOURCE ;
CCFLAGS += -std=c99 ;
+CCFLAGS += -D_REENTRANT ;
OPTIM += -O0 ;
OPTIM += -g ;
@@ -15,5 +16,5 @@ HDRS += /usr/include/cairo ;
Main deadbeef :
cmod.c codec.c cvorbis.c cwav.c cmp3.c playlist.c psdl.c main.c support.c interface.c callbacks.c threading.c messagepump.c gtkplaylist.c ;
-LINKLIBS on deadbeef = -lmikmod -lm -lvorbis -logg -lvorbisfile -lmad -lSDL -lsamplerate -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread -lpthread -lglib ;
+LINKLIBS on deadbeef = -lmikmod -lm -lvorbis -logg -lvorbisfile -lmad -lSDL -lsamplerate -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lgthread-2.0 ;
diff --git a/callbacks.c b/callbacks.c
index f4b52d18..719274ed 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -228,10 +228,10 @@ on_playlist_scroll_event (GtkWidget *widget,
GtkAdjustment* adj = gtk_range_get_adjustment (GTK_RANGE (range));
int newscroll = gtk_range_get_value (GTK_RANGE (range));
if (ev->direction == GDK_SCROLL_UP) {
- newscroll -= gtk_adjustment_get_page_increment (adj);
+ newscroll -= 10;//gtk_adjustment_get_page_increment (adj);
}
else if (ev->direction == GDK_SCROLL_DOWN) {
- newscroll += gtk_adjustment_get_page_increment (adj);
+ newscroll += 10;//gtk_adjustment_get_page_increment (adj);
}
gtk_range_set_value (GTK_RANGE (range), newscroll);
return FALSE;
@@ -242,7 +242,7 @@ void
on_stopbtn_clicked (GtkButton *button,
gpointer user_data)
{
- psdl_stop ();
+ messagepump_push (M_STOPSONG, 0, 0, 0);
}
@@ -258,12 +258,6 @@ void
on_pausebtn_clicked (GtkButton *button,
gpointer user_data)
{
- if (psdl_ispaused ()) {
- psdl_unpause ();
- }
- else {
- psdl_pause ();
- }
}
@@ -271,27 +265,7 @@ void
on_prevbtn_clicked (GtkButton *button,
gpointer user_data)
{
- GtkWidget *widget = lookup_widget (mainwin, "playlist");
- playItem_t *prev = playlist_current;
-
- if (playlist_current) {
- playlist_current = playlist_current->prev;
- }
- if (!playlist_current) {
- playlist_current = playlist_tail;
- }
- if (playlist_current) {
- psdl_stop ();
- psdl_play (playlist_current);
- }
- if (playlist_current != prev) {
- if (prev) {
- redraw_ps_row (widget, ps_get_idx_of (prev));
- }
- if (playlist_current) {
- redraw_ps_row (widget, ps_get_idx_of (playlist_current));
- }
- }
+ messagepump_push (M_PREVSONG, 0, 0, 0);
}
@@ -299,26 +273,7 @@ void
on_nextbtn_clicked (GtkButton *button,
gpointer user_data)
{
- GtkWidget *widget = lookup_widget (mainwin, "playlist");
- playItem_t *prev = playlist_current;
- if (playlist_current) {
- playlist_current = playlist_current->next;
- }
- if (!playlist_current) {
- playlist_current = playlist_head;
- }
- if (playlist_current) {
- psdl_stop ();
- psdl_play (playlist_current);
- }
- if (playlist_current != prev) {
- if (prev) {
- redraw_ps_row (widget, ps_get_idx_of (prev));
- }
- if (playlist_current) {
- redraw_ps_row (widget, ps_get_idx_of (playlist_current));
- }
- }
+ messagepump_push (M_NEXTSONG, 0, 0, 0);
}
@@ -326,27 +281,6 @@ void
on_playrand_clicked (GtkButton *button,
gpointer user_data)
{
- GtkWidget *widget = lookup_widget (mainwin, "playlist");
- playItem_t *prev = playlist_current;
- int r = rand () % ps_getcount ();
- playItem_t *it = ps_get_for_idx (r);
- if (it) {
- playlist_current = it;
- }
- else {
- playlist_current = NULL;
- }
- if (playlist_current) {
- psdl_stop ();
- psdl_play (playlist_current);
- }
- if (playlist_current != prev) {
- if (prev) {
- redraw_ps_row (widget, ps_get_idx_of (prev));
- }
- if (playlist_current) {
- redraw_ps_row (widget, ps_get_idx_of (playlist_current));
- }
- }
+ messagepump_push (M_PLAYRANDOM, 0, 0, 0);
}
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 85dc345d..c5d040d2 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -12,6 +12,8 @@
#include "playlist.h"
#include "psdl.h"
#include "common.h"
+#include "messagepump.h"
+#include "messages.h"
extern GtkWidget *mainwin;
static GdkPixmap *backbuf;
@@ -71,30 +73,6 @@ redraw_ps_row (GtkWidget *widget, int row) {
}
void
-gtkps_nextsong (void) {
- GtkWidget *widget = lookup_widget (mainwin, "playlist");
- playItem_t *prev = playlist_current;
- if (playlist_current) {
- playlist_current = playlist_current->next;
- }
- if (!playlist_current) {
- playlist_current = playlist_head;
- }
- if (playlist_current) {
- psdl_stop ();
- psdl_play (playlist_current);
- }
- if (playlist_current != prev) {
- if (prev) {
- redraw_ps_row (widget, ps_get_idx_of (prev));
- }
- if (playlist_current) {
- redraw_ps_row (widget, ps_get_idx_of (playlist_current));
- }
- }
-}
-
-void
draw_ps_row_back (GdkDrawable *drawable, cairo_t *cr, int row) {
// draw background
float w;
@@ -234,12 +212,13 @@ gtkps_mouse1_clicked (GtkWidget *widget, int ex, int ey, double time) {
if (prev) {
redraw_ps_row (widget, ps_get_idx_of (prev));
}
- if (playlist_current) {
- redraw_ps_row (widget, ps_get_idx_of (playlist_current));
- }
+// if (playlist_current) {
+// redraw_ps_row (widget, ps_get_idx_of (playlist_current));
+// }
}
- psdl_stop ();
- psdl_play (it);
+ messagepump_push (M_PLAYSONG, 0, 0, 0);
+// psdl_stop ();
+// psdl_play (it);
}
}
@@ -297,3 +276,96 @@ gtkps_playsong (void) {
}
}
}
+
+void
+gtkps_prevsong (void) {
+ GtkWidget *widget = lookup_widget (mainwin, "playlist");
+ playItem_t *prev = playlist_current;
+
+ if (playlist_current) {
+ playlist_current = playlist_current->prev;
+ }
+ if (!playlist_current) {
+ playlist_current = playlist_tail;
+ }
+ if (playlist_current) {
+ psdl_stop ();
+ psdl_play (playlist_current);
+ }
+ if (playlist_current != prev) {
+ if (prev) {
+ redraw_ps_row (widget, ps_get_idx_of (prev));
+ }
+ if (playlist_current) {
+ redraw_ps_row (widget, ps_get_idx_of (playlist_current));
+ }
+ }
+}
+
+void
+gtkps_nextsong (void) {
+ GtkWidget *widget = lookup_widget (mainwin, "playlist");
+ playItem_t *prev = playlist_current;
+ if (playlist_current) {
+ playlist_current = playlist_current->next;
+ }
+ if (!playlist_current) {
+ playlist_current = playlist_head;
+ }
+ if (playlist_current) {
+ psdl_stop ();
+ psdl_play (playlist_current);
+ }
+ if (playlist_current != prev) {
+ if (prev) {
+ redraw_ps_row (widget, ps_get_idx_of (prev));
+ }
+ if (playlist_current) {
+ redraw_ps_row (widget, ps_get_idx_of (playlist_current));
+ }
+ }
+}
+
+void
+gtkps_randomsong (void) {
+ if (!ps_getcount ()) {
+ return;
+ }
+ GtkWidget *widget = lookup_widget (mainwin, "playlist");
+ playItem_t *prev = playlist_current;
+ int r = rand () % ps_getcount ();
+ playItem_t *it = ps_get_for_idx (r);
+ if (it) {
+ playlist_current = it;
+ }
+ else {
+ playlist_current = NULL;
+ }
+ if (playlist_current) {
+ psdl_stop ();
+ psdl_play (playlist_current);
+ }
+ if (playlist_current != prev) {
+ if (prev) {
+ redraw_ps_row (widget, ps_get_idx_of (prev));
+ }
+ if (playlist_current) {
+ redraw_ps_row (widget, ps_get_idx_of (playlist_current));
+ }
+ }
+}
+
+void
+gtkps_stopsong (void) {
+ psdl_stop ();
+}
+
+void
+gtkps_pausesong (void) {
+ if (psdl_ispaused ()) {
+ psdl_unpause ();
+ }
+ else {
+ psdl_pause ();
+ }
+}
diff --git a/gtkplaylist.h b/gtkplaylist.h
index 153707cc..5bc952d1 100644
--- a/gtkplaylist.h
+++ b/gtkplaylist.h
@@ -35,6 +35,21 @@ void
gtkps_scroll (int newscroll);
void
+gtkps_stopsong (void);
+
+void
gtkps_playsong (void);
+void
+gtkps_prevsong (void);
+
+void
+gtkps_nextsong (void);
+
+void
+gtkps_randomsong (void);
+
+void
+gtkps_pausesong (void);
+
#endif
diff --git a/main.c b/main.c
index 4d13f071..e13524c0 100644
--- a/main.c
+++ b/main.c
@@ -32,11 +32,35 @@ psdl_thread (uintptr_t ctx) {
GDK_THREADS_LEAVE();
break;
case M_PLAYSONG:
- printf ("playsong!\n");
GDK_THREADS_ENTER();
gtkps_playsong ();
GDK_THREADS_LEAVE();
break;
+ case M_STOPSONG:
+ GDK_THREADS_ENTER();
+ gtkps_stopsong ();
+ GDK_THREADS_LEAVE();
+ break;
+ case M_NEXTSONG:
+ GDK_THREADS_ENTER();
+ gtkps_nextsong ();
+ GDK_THREADS_LEAVE();
+ break;
+ case M_PREVSONG:
+ GDK_THREADS_ENTER();
+ gtkps_prevsong ();
+ GDK_THREADS_LEAVE();
+ break;
+ case M_PAUSESONG:
+ GDK_THREADS_ENTER();
+ gtkps_pausesong ();
+ GDK_THREADS_LEAVE();
+ break;
+ case M_PLAYRANDOM:
+ GDK_THREADS_ENTER();
+ gtkps_randomsong ();
+ GDK_THREADS_LEAVE();
+ break;
}
}
usleep(10);
@@ -49,12 +73,12 @@ psdl_thread (uintptr_t ctx) {
int
main (int argc, char *argv[]) {
messagepump_init ();
-// thread_start (psdl_thread, 0);
+ thread_start (psdl_thread, 0);
g_thread_init (NULL);
gdk_threads_init ();
gdk_threads_enter ();
-// gtk_set_locale ();
+ gtk_set_locale ();
gtk_init (&argc, &argv);
/*