summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-07-05 18:55:57 +0200
committerGravatar waker <wakeroid@gmail.com>2009-07-05 18:55:57 +0200
commit19208d2ef24773b6f50fc431628a575eae740a54 (patch)
tree0d06902e3ae5cb97654b27d73a0fb526cfac4f25
parent7196d2ae439a991c9d38e353f57b22f3d6e4537d (diff)
some playlist improvements
-rw-r--r--callbacks.c57
-rwxr-xr-xmktarball.sh2
-rw-r--r--playlist.c13
-rw-r--r--playlist.h3
4 files changed, 73 insertions, 2 deletions
diff --git a/callbacks.c b/callbacks.c
index e73aeb9d..9226cae5 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -95,13 +95,18 @@ void
draw_ps_row (GdkDrawable *drawable, cairo_t *cr, int row, playItem_t *it) {
int width, height;
gdk_drawable_get_size (drawable, &width, &height);
+ if (it == playlist_current) {
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, 3, row * rowheight - trackerscroll * rowheight + 3, rowheight-6, rowheight-6);
+ cairo_fill (cr);
+ }
if (row == playlist_row) {
cairo_set_source_rgb (cr, 0, 0, 0);
}
else {
cairo_set_source_rgb (cr, 0xf4/255.f, 0x7e/255.f, 0x46/255.f);
}
- text_draw (cr, 0, row * rowheight - trackerscroll * rowheight, it->displayname);
+ text_draw (cr, rowheight, row * rowheight - trackerscroll * rowheight, it->displayname);
}
void
@@ -250,9 +255,18 @@ on_playlist_button_press_event (GtkWidget *widget,
if (playlist_row != -1) {
playItem_t *it = ps_get_for_idx (playlist_row);
if (it) {
+ playItem_t *prev = playlist_current;
+ playlist_current = it;
+ 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));
+ }
+ }
psdl_stop ();
psdl_play (it);
- playlist_current = it;
}
}
@@ -438,6 +452,12 @@ on_playbtn_clicked (GtkButton *button,
{
if (psdl_ispaused ())
psdl_unpause ();
+ else if (playlist_current) {
+ psdl_stop ();
+ psdl_play (playlist_current);
+ GtkWidget *widget = lookup_widget (mainwin, "playlist");
+ redraw_ps_row (widget, ps_get_idx_of (playlist_current));
+ }
else if (playlist_row != -1) {
playItem_t *it = ps_get_for_idx (playlist_row);
if (it) {
@@ -445,6 +465,8 @@ on_playbtn_clicked (GtkButton *button,
psdl_play (it);
playlist_current = it;
}
+ GtkWidget *widget = lookup_widget (mainwin, "playlist");
+ redraw_ps_row (widget, playlist_row);
}
}
@@ -466,6 +488,9 @@ 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;
}
@@ -476,6 +501,14 @@ on_prevbtn_clicked (GtkButton *button,
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));
+ }
+ }
}
@@ -483,6 +516,8 @@ 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;
}
@@ -493,6 +528,14 @@ on_nextbtn_clicked (GtkButton *button,
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));
+ }
+ }
}
@@ -500,6 +543,8 @@ 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) {
@@ -512,5 +557,13 @@ on_playrand_clicked (GtkButton *button,
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));
+ }
+ }
}
diff --git a/mktarball.sh b/mktarball.sh
new file mode 100755
index 00000000..d4db5b0d
--- /dev/null
+++ b/mktarball.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+tar jcvf deadbeef-prealpha.tar.bz2 *.c *.h Jamfile
diff --git a/playlist.c b/playlist.c
index 80e0e03f..bf06f226 100644
--- a/playlist.c
+++ b/playlist.c
@@ -154,3 +154,16 @@ ps_get_for_idx (int idx) {
return it;
}
+int
+ps_get_idx_of (playItem_t *it) {
+ playItem_t *c = playlist_head;
+ int idx = 0;
+ while (c && c != it) {
+ c = c->next;
+ idx++;
+ }
+ if (!c) {
+ return -1;
+ }
+ return idx;
+}
diff --git a/playlist.h b/playlist.h
index 92349943..8a8d426e 100644
--- a/playlist.h
+++ b/playlist.h
@@ -34,4 +34,7 @@ ps_getcount (void);
playItem_t *
ps_get_for_idx (int idx);
+int
+ps_get_idx_of (playItem_t *it);
+
#endif // __PLAYLIST_H