summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-29 19:30:44 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-29 19:30:44 +0200
commit6942abb950eddea2ffc4337f73f9684c103f1f54 (patch)
tree952e1eceb34877c39d380eaee0772f42c593a919
parent75d630d07d325ca8ac895dc23186819c00003926 (diff)
delete selection puts cursor to expected row
-rw-r--r--callbacks.c2
-rw-r--r--playlist.c10
-rw-r--r--playlist.h3
3 files changed, 11 insertions, 4 deletions
diff --git a/callbacks.c b/callbacks.c
index 2150b0d1..f03c36c4 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -404,7 +404,7 @@ on_remove1_activate (GtkMenuItem *menuitem,
{
gtkplaylist_t *ps = &main_playlist;
GtkWidget *widget = ps->playlist;
- pl_delete_selected ();
+ ps->row = pl_delete_selected ();
gtkpl_setup_scrollbar (ps);
gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height);
gtkpl_expose (ps, 0, 0, widget->allocation.width, widget->allocation.height);
diff --git a/playlist.c b/playlist.c
index bc046b78..2f3b54eb 100644
--- a/playlist.c
+++ b/playlist.c
@@ -955,15 +955,21 @@ pl_find_meta (playItem_t *it, const char *key) {
return NULL;
}
-void
+int
pl_delete_selected (void) {
+ int i = 0;
+ int ret = -1;
playItem_t *next = NULL;
- for (playItem_t *it = playlist_head[PL_MAIN]; it; it = next) {
+ for (playItem_t *it = playlist_head[PL_MAIN]; it; it = next, i++) {
next = it->next[PL_MAIN];
if (it->selected) {
+ if (ret == -1) {
+ ret = i;
+ }
pl_remove (it);
}
}
+ return ret;
}
void
diff --git a/playlist.h b/playlist.h
index 1c2038b9..eb50a7f4 100644
--- a/playlist.h
+++ b/playlist.h
@@ -133,7 +133,8 @@ pl_format_item_display_name (playItem_t *it, char *str, int len);
const char *
pl_find_meta (playItem_t *it, const char *key);
-void
+// returns index of 1st deleted item
+int
pl_delete_selected (void);
void