summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playlist.c2
-rw-r--r--plugins/gtkui/ddblistview.c62
2 files changed, 35 insertions, 29 deletions
diff --git a/playlist.c b/playlist.c
index c760f2a7..bfabc972 100644
--- a/playlist.c
+++ b/playlist.c
@@ -3469,8 +3469,8 @@ pl_search_reset (void) {
void
pl_search_process (const char *text) {
- pl_search_reset ();
GLOBAL_LOCK;
+ pl_search_reset ();
for (playItem_t *it = playlist->head[PL_MAIN]; it; it = it->next[PL_MAIN]) {
it->selected = 0;
if (*text) {
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index 479c03c8..2b1e5562 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -1289,40 +1289,46 @@ ddb_listview_header_expose (DdbListview *ps, int x, int y, int w, int h) {
void
ddb_listview_select_single (DdbListview *ps, int sel) {
int nchanged = 0;
- int idx=0;
- DdbListviewIter it = ps->binding->head ();
- for (; it; idx++) {
- if (idx == sel) {
- if (!ps->binding->is_selected (it)) {
- ps->binding->select (it, 1);
- if (nchanged < NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW) {
- ddb_listview_draw_row (ps, idx, it);
- ps->binding->selection_changed (it, idx);
- }
- nchanged++;
- }
- else if (ps->binding->cursor () == idx) {
- if (nchanged < NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW) {
- ddb_listview_draw_row (ps, idx, it);
- }
- }
- }
- else if (ps->binding->is_selected (it)) {
- ps->binding->select (it, 0);
- if (nchanged < NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW) {
- ddb_listview_draw_row (ps, idx, it);
- ps->binding->selection_changed (it, idx);
- }
- nchanged++;
+ deadbeef->plt_lock ();
+
+ DB_playItem_t *sel_it = ps->binding->get_for_idx (sel);
+ if (!sel_it) {
+ deadbeef->plt_unlock ();
+ return;
+ }
+
+ DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
+ while (it) {
+ int selected = deadbeef->pl_is_selected (it);
+ if (it == sel_it) {
+ if (!selected) {
+ deadbeef->pl_set_selected (it, 1);
+// if (nchanged < NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW) {
+// ddb_listview_draw_row (ps, idx, it);
+// ps->binding->selection_changed (it, idx);
+// }
+// nchanged++;
+ }
+ }
+ else if (selected) {
+ deadbeef->pl_set_selected (it, 0);
+// if (nchanged < NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW) {
+// ddb_listview_draw_row (ps, idx, it);
+// ps->binding->selection_changed (it, idx);
+// }
+// nchanged++;
}
- DdbListviewIter next = PL_NEXT (it);
+ DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
UNREF (it);
it = next;
}
UNREF (it);
- if (nchanged >= NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW) {
+ UNREF (sel_it);
+ deadbeef->plt_unlock ();
+
+ if (nchanged >= NUM_CHANGED_ROWS_BEFORE_FULL_REDRAW, 1) {
ddb_listview_refresh (ps, DDB_REFRESH_LIST);
- ps->binding->selection_changed (it, -1); // that means "selection changed a lot, redraw everything"
+ ps->binding->selection_changed (NULL, -1); // that means "selection changed a lot, redraw everything"
}
ps->area_selection_start = sel;
ps->area_selection_end = sel;