summaryrefslogtreecommitdiff
path: root/gtkplaylist.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-07-05 22:21:09 +0200
committerGravatar waker <wakeroid@gmail.com>2009-07-05 22:21:09 +0200
commit8ac0864bfedf683824963a859bbe80d21e4d2d01 (patch)
tree09e7e91197c0749b79deb297f8b8446df1042378 /gtkplaylist.c
parenta55523d7f3758d1fa46b8f8d063c57229db27bf3 (diff)
more multithreading fixes
Diffstat (limited to 'gtkplaylist.c')
-rw-r--r--gtkplaylist.c130
1 files changed, 101 insertions, 29 deletions
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 ();
+ }
+}