diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-09-29 19:30:44 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-09-29 19:30:44 +0200 |
commit | 6942abb950eddea2ffc4337f73f9684c103f1f54 (patch) | |
tree | 952e1eceb34877c39d380eaee0772f42c593a919 | |
parent | 75d630d07d325ca8ac895dc23186819c00003926 (diff) |
delete selection puts cursor to expected row
-rw-r--r-- | callbacks.c | 2 | ||||
-rw-r--r-- | playlist.c | 10 | ||||
-rw-r--r-- | playlist.h | 3 |
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); @@ -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 @@ -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 |