diff options
-rw-r--r-- | plugins/gtkui/ddblistview.c | 49 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.h | 2 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 2 |
3 files changed, 35 insertions, 18 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 1109e902..4a120cd4 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -2485,6 +2485,7 @@ struct set_cursor_t { int cursor; int prev; DdbListview *pl; + int noscroll; }; static gboolean @@ -2509,26 +2510,28 @@ ddb_listview_set_cursor_cb (gpointer data) { sc->pl->binding->unref (prev_it); } - DdbListviewIter it; - DdbListview *ps = sc->pl; + if (!sc->noscroll) { + DdbListviewIter it; + DdbListview *ps = sc->pl; - int cursor_scroll = ddb_listview_get_row_pos (sc->pl, sc->cursor); - int newscroll = sc->pl->scrollpos; - if (cursor_scroll < sc->pl->scrollpos) { - newscroll = cursor_scroll; - } - else if (cursor_scroll + sc->pl->rowheight >= sc->pl->scrollpos + sc->pl->list->allocation.height) { - newscroll = cursor_scroll + sc->pl->rowheight - sc->pl->list->allocation.height + 1; - if (newscroll < 0) { - newscroll = 0; + int cursor_scroll = ddb_listview_get_row_pos (sc->pl, sc->cursor); + int newscroll = sc->pl->scrollpos; + if (cursor_scroll < sc->pl->scrollpos) { + newscroll = cursor_scroll; + } + else if (cursor_scroll + sc->pl->rowheight >= sc->pl->scrollpos + sc->pl->list->allocation.height) { + newscroll = cursor_scroll + sc->pl->rowheight - sc->pl->list->allocation.height + 1; + if (newscroll < 0) { + newscroll = 0; + } + } + if (sc->pl->scrollpos != newscroll) { + GtkWidget *range = sc->pl->scrollbar; + gtk_range_set_value (GTK_RANGE (range), newscroll); } - } - if (sc->pl->scrollpos != newscroll) { - GtkWidget *range = sc->pl->scrollbar; - gtk_range_set_value (GTK_RANGE (range), newscroll); - } - free (data); + free (data); + } return FALSE; } @@ -2539,6 +2542,18 @@ ddb_listview_set_cursor (DdbListview *pl, int cursor) { data->prev = prev; data->cursor = cursor; data->pl = pl; + data->noscroll = 0; + g_idle_add (ddb_listview_set_cursor_cb, data); +} + +void +ddb_listview_set_cursor_noscroll (DdbListview *pl, int cursor) { + int prev = pl->binding->cursor (); + struct set_cursor_t *data = malloc (sizeof (struct set_cursor_t)); + data->prev = prev; + data->cursor = cursor; + data->pl = pl; + data->noscroll = 1; g_idle_add (ddb_listview_set_cursor_cb, data); } diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index 20b5f72c..55333384 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -176,6 +176,8 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state); void ddb_listview_set_cursor (DdbListview *pl, int cursor); void +ddb_listview_set_cursor_noscroll (DdbListview *pl, int cursor); +void ddb_listview_scroll_to (DdbListview *listview, int rowpos); void ddb_listview_set_vscroll (DdbListview *listview, gboolean scroll); diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 235bba0a..4e35e050 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -793,7 +793,7 @@ songchanged (DdbListview *ps, DB_playItem_t *from, DB_playItem_t *to) { ddb_listview_scroll_to (ps, to_idx); } if (deadbeef->conf_get_int ("playlist.scroll.cursorfollowplayback", 0)) { - ddb_listview_set_cursor (ps, to_idx); + ddb_listview_set_cursor_noscroll (ps, to_idx); } } } |