summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-12-17 22:39:47 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-12-17 22:39:47 +0100
commitfc493f5e80de2860c73b998c8ce187ea68bedcdf (patch)
tree6cc06a89530d8b2bc9d8ca1a3e361cf9fdc465af /plugins
parentf30ba666c5fa2a16c0b5b2ee1d253ab2ac71de09 (diff)
fix bug #1020: incorrect cursor/scroll after deleting playlists
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/ddbtabstrip.c22
-rw-r--r--plugins/gtkui/mainplaylist.c12
-rw-r--r--plugins/gtkui/widgets.c32
-rw-r--r--plugins/pltbrowser/pltbrowser.c25
4 files changed, 20 insertions, 71 deletions
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index e347fc9d..5bc1234b 100644
--- a/plugins/gtkui/ddbtabstrip.c
+++ b/plugins/gtkui/ddbtabstrip.c
@@ -1065,30 +1065,8 @@ on_tabstrip_motion_notify_event (GtkWidget *widget,
x += width - tab_overlap_size;
}
if (inspos >= 0 && inspos != ts->dragging) {
- char str1[100];
- char str2[100];
- char strcursor1[100];
- char strcursor2[100];
- int pos1;
- int pos2;
- int cursor1;
- int cursor2;
- snprintf (str1, sizeof (str1), "playlist.scroll.%d", ts->dragging);
- pos1 = deadbeef->conf_get_int (str1, 0);
- snprintf (str2, sizeof (str2), "playlist.scroll.%d", inspos);
- pos2 = deadbeef->conf_get_int (str2, 0);
-
- snprintf (strcursor1, sizeof (strcursor1), "playlist.cursor.%d", ts->dragging);
- cursor1 = deadbeef->conf_get_int (strcursor1, 0);
- snprintf (strcursor2, sizeof (strcursor2), "playlist.cursor.%d", inspos);
- cursor2 = deadbeef->conf_get_int (strcursor2, 0);
-
deadbeef->plt_move (ts->dragging, inspos);
tab_moved = 1;
- deadbeef->conf_set_int (str1, pos2);
- deadbeef->conf_set_int (str2, pos1);
- deadbeef->conf_set_int (strcursor1, cursor2);
- deadbeef->conf_set_int (strcursor2, cursor1);
ts->dragging = inspos;
deadbeef->conf_set_int ("playlist.current", ts->dragging);
}
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index d1920021..477d3550 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -64,9 +64,6 @@ main_get_cursor (void) {
static void
main_set_cursor (int cursor) {
- char conf[100];
- snprintf (conf, sizeof (conf), "playlist.cursor.%d", deadbeef->plt_get_curr_idx ());
- deadbeef->conf_set_int (conf, cursor);
return deadbeef->pl_set_cursor (PL_MAIN, cursor);
}
@@ -275,10 +272,11 @@ void main_col_free_user_data (void *data) {
void
main_vscroll_changed (int pos) {
coverart_reset_queue ();
- int curr = deadbeef->plt_get_curr_idx ();
- char conf[100];
- snprintf (conf, sizeof (conf), "playlist.scroll.%d", curr);
- deadbeef->conf_set_int (conf, pos);
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_set_scroll (plt, pos);
+ deadbeef->plt_unref (plt);
+ }
}
void
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c
index b8e94810..ae58ef22 100644
--- a/plugins/gtkui/widgets.c
+++ b/plugins/gtkui/widgets.c
@@ -1603,26 +1603,25 @@ refresh_cb (gpointer data) {
static gboolean
playlistswitch_cb (gpointer p) {
w_playlist_t *tp = (w_playlist_t *)p;
- int curr = deadbeef->plt_get_curr_idx ();
- char conf[100];
- snprintf (conf, sizeof (conf), "playlist.scroll.%d", curr);
- int scroll = deadbeef->conf_get_int (conf, 0);
- snprintf (conf, sizeof (conf), "playlist.cursor.%d", curr);
- int cursor = deadbeef->conf_get_int (conf, -1);
- deadbeef->pl_set_cursor (PL_MAIN, cursor);
if (!strcmp (tp->base.type, "tabbed_playlist")) {
ddb_tabstrip_refresh (((w_tabbed_playlist_t *)tp)->tabstrip);
}
- if (cursor != -1) {
- DB_playItem_t *it = deadbeef->pl_get_for_idx_and_iter (cursor, PL_MAIN);
- if (it) {
- deadbeef->pl_set_selected (it, 1);
- deadbeef->pl_item_unref (it);
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ int cursor = deadbeef->plt_get_cursor (plt, PL_MAIN);
+ int scroll = deadbeef->plt_get_scroll (plt);
+ if (cursor != -1) {
+ DB_playItem_t *it = deadbeef->pl_get_for_idx_and_iter (cursor, PL_MAIN);
+ if (it) {
+ deadbeef->pl_set_selected (it, 1);
+ deadbeef->pl_item_unref (it);
+ }
}
- }
+ deadbeef->plt_unref (plt);
- ddb_listview_refresh (tp->list, DDB_LIST_CHANGED | DDB_REFRESH_LIST | DDB_REFRESH_VSCROLL);
- ddb_listview_set_vscroll (tp->list, scroll);
+ ddb_listview_refresh (tp->list, DDB_LIST_CHANGED | DDB_REFRESH_LIST | DDB_REFRESH_VSCROLL);
+ ddb_listview_set_vscroll (tp->list, scroll);
+ }
return FALSE;
}
@@ -1649,9 +1648,6 @@ songchanged_cb (gpointer p) {
if (p) {
to_idx = deadbeef->plt_get_item_idx (p, to, PL_MAIN);
if (cursor_follows_playback) {
- char conf[100];
- snprintf (conf, sizeof (conf), "playlist.cursor.%d", plt);
- deadbeef->conf_set_int (conf, to_idx);
deadbeef->plt_deselect_all (p);
deadbeef->pl_set_selected (to, 1);
deadbeef->plt_set_cursor (p, PL_MAIN, to_idx);
diff --git a/plugins/pltbrowser/pltbrowser.c b/plugins/pltbrowser/pltbrowser.c
index 3ebf02f5..0d729715 100644
--- a/plugins/pltbrowser/pltbrowser.c
+++ b/plugins/pltbrowser/pltbrowser.c
@@ -53,31 +53,9 @@ on_pltbrowser_row_inserted (GtkTreeModel *tree_model, GtkTreePath *path, GtkTree
return;
}
- char str1[100];
- char str2[100];
- char strcursor1[100];
- char strcursor2[100];
- int pos1;
- int pos2;
- int cursor1;
- int cursor2;
- snprintf (str1, sizeof (str1), "playlist.scroll.%d", plt->last_selected);
- pos1 = deadbeef->conf_get_int (str1, 0);
- snprintf (str2, sizeof (str2), "playlist.scroll.%d", idx);
- pos2 = deadbeef->conf_get_int (str2, 0);
-
- snprintf (strcursor1, sizeof (strcursor1), "playlist.cursor.%d", plt->last_selected);
- cursor1 = deadbeef->conf_get_int (strcursor1, 0);
- snprintf (strcursor2, sizeof (strcursor2), "playlist.cursor.%d", idx);
- cursor2 = deadbeef->conf_get_int (strcursor2, 0);
-
deadbeef->plt_move (plt->last_selected, idx);
- deadbeef->conf_set_int (str1, pos2);
- deadbeef->conf_set_int (str2, pos1);
- deadbeef->conf_set_int (strcursor1, cursor2);
- deadbeef->conf_set_int (strcursor2, cursor1);
plt->last_selected = idx;
- deadbeef->conf_set_int ("playlist.current", idx);
+ deadbeef->plt_set_curr_idx (idx);
deadbeef->sendmessage (DB_EV_PLAYLISTSWITCHED, 0, 0, 0);
}
@@ -94,7 +72,6 @@ on_pltbrowser_cursor_changed (GtkTreeView *treeview, gpointer user_data) {
if (indices) {
if (indices[0] >= 0) {
deadbeef->plt_set_curr_idx (indices[0]);
- deadbeef->conf_set_int ("playlist.current", indices[0]);
w->last_selected = indices[0];
}
g_free (indices);