summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d911569)
raw | patch | inline | side by side (parent: d911569)
author | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 20:05:09 +0000 (22:05 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 20:05:09 +0000 (22:05 +0200) |
src/hscroll.c | patch | blob | history | |
src/hscroll.h | patch | blob | history | |
src/screen_play.c | patch | blob | history | |
src/status_bar.c | patch | blob | history | |
src/status_bar.h | patch | blob | history |
diff --git a/src/hscroll.c b/src/hscroll.c
index 784c17d31c55794dc6d4499b20f850d2e2d33bf0..0ec5ad973f6adc03796a29709ae0bd10829f1325 100644 (file)
--- a/src/hscroll.c
+++ b/src/hscroll.c
assert(str != NULL);
assert(separator != NULL);
- if (hscroll->offset == 0) {
- ++hscroll->offset;
+ if (hscroll->offset == 0)
return g_strdup(str);
- }
/* create a buffer containing the string and the separator */
size = strlen(str)+strlen(separator)+1;
g_strlcat(buf, tmp, size);
}
- if (time(NULL) - hscroll->t >= 1) {
- hscroll->t = time(NULL);
- hscroll->offset++;
- }
-
g_free(tmp);
return buf;
}
diff --git a/src/hscroll.h b/src/hscroll.h
index cad3f17ddae93404c79774a9a4e4a76feafd607a..fadbae9af4ab978fe7b306a4a124499d98ebc164 100644 (file)
--- a/src/hscroll.h
+++ b/src/hscroll.h
struct hscroll {
gsize offset;
- GTime t; /* GTime is equivalent to time_t */
};
static inline void
hscroll->offset = 0;
}
+static inline void
+hscroll_step(struct hscroll *hscroll)
+{
+ ++hscroll->offset;
+}
+
char *
strscroll(struct hscroll *hscroll, char *str, char *separator, unsigned width);
diff --git a/src/screen_play.c b/src/screen_play.c
index 0abee2ee46f96b0be9c352bb43c9b2091e724f56..9560b2b9df4f48b68339d1cced3c22a63670bf4b 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
struct mpdclient *c;
} completion_callback_data_t;
-#ifndef NCMPC_MINI
static struct hscroll hscroll;
-#endif
-static bool must_scroll;
+static guint scroll_source_id;
#endif
static struct mpdclient_playlist *playlist;
playlist_save_selection();
}
+#ifndef NCMPC_MINI
+static gboolean
+scroll_timer_callback(G_GNUC_UNUSED gpointer data)
+{
+ scroll_source_id = 0;
+
+ hscroll_step(&hscroll);
+ playlist_repaint();
+ return false;
+}
+#endif
+
static const char *
list_callback(unsigned idx, bool *highlight, char **second_column, G_GNUC_UNUSED void *data)
{
@@ -152,8 +162,6 @@ list_callback(unsigned idx, bool *highlight, char **second_column, G_GNUC_UNUSED
static unsigned current_song;
char *tmp;
- must_scroll = true;
-
if (current_song != lw->selected) {
hscroll_reset(&hscroll);
current_song = lw->selected;
@@ -163,9 +171,20 @@ list_callback(unsigned idx, bool *highlight, char **second_column, G_GNUC_UNUSED
MAX_SONG_LENGTH);
g_strlcpy(songname, tmp, MAX_SONG_LENGTH);
g_free(tmp);
- }
- else
+
+ if (scroll_source_id == 0)
+ scroll_source_id =
+ g_timeout_add(1000,
+ scroll_timer_callback,
+ NULL);
+ } else {
hscroll_reset(&hscroll);
+
+ if (scroll_source_id != 0) {
+ g_source_remove(scroll_source_id);
+ scroll_source_id = 0;
+ }
+ }
}
#else
(void)second_column;
static void
screen_playlist_paint(void)
{
-#ifndef NCMPC_MINI
- must_scroll = false;
-#endif
-
list_window_paint(lw, list_callback, NULL);
}
center_playing_item(c, false);
playlist_repaint();
-#ifndef NCMPC_MINI
- } else if (options.scroll && must_scroll) {
- /* always repaint if horizontal scrolling is
- enabled */
- playlist_repaint();
-#endif
} else if (c->events & MPD_IDLE_PLAYLIST) {
/* the playlist has changed, we must paint the new
version */
diff --git a/src/status_bar.c b/src/status_bar.c
index 19eec1d0c584b1eb52bacda87fc05990bfd9b443..ddffb8ee060f7c5ee577541ab89da0deebcc2953 100644 (file)
--- a/src/status_bar.c
+++ b/src/status_bar.c
#include <assert.h>
#include <string.h>
+#ifndef NCMPC_MINI
+static gboolean
+scroll_timer_callback(gpointer data)
+{
+ struct status_bar *p = data;
+
+ p->scroll_source_id = 0;
+
+ hscroll_step(&p->hscroll);
+ status_bar_paint(p, p->prev_status, p->prev_song);
+ doupdate();
+ return false;
+}
+#endif
+
static gboolean
status_bar_clear_message(gpointer data)
{
int x = 0;
char buffer[p->window.cols * 4 + 1];
+#ifndef NCMPC_MINI
+ p->prev_status = status;
+ p->prev_song = song;
+#endif
+
if (p->message_source_id != 0)
return;
g_strlcpy(songname, tmp, sizeof(songname));
g_free(tmp);
+
+ if (p->scroll_source_id == 0)
+ p->scroll_source_id =
+ g_timeout_add(1000,
+ scroll_timer_callback,
+ p);
+ } else if (p->scroll_source_id != 0) {
+ g_source_remove(p->scroll_source_id);
+ p->scroll_source_id = 0;
}
#endif
//mvwaddnstr(w, 0, x, songname, width);
mvwaddstr(w, 0, x, songname);
+#ifndef NCMPC_MINI
+ } else if (p->scroll_source_id != 0) {
+ g_source_remove(p->scroll_source_id);
+ p->scroll_source_id = 0;
+#endif
}
/* display time string */
diff --git a/src/status_bar.h b/src/status_bar.h
index c97c7a1a6398a72b87d3bf9ef253f93d059f2699..1410aed989a8cd81b7fe8b5682c3108727066428 100644 (file)
--- a/src/status_bar.h
+++ b/src/status_bar.h
#ifndef NCMPC_MINI
struct hscroll hscroll;
+ guint scroll_source_id;
+
+ const struct mpd_status *prev_status;
+ const struct mpd_song *prev_song;
#endif
};
#ifndef NCMPC_MINI
hscroll_reset(&p->hscroll);
- p->hscroll.t = 0;
+ p->scroll_source_id = 0;
+ p->prev_status = NULL;
+ p->prev_song = NULL;
#endif
}