ocarina: Find selected indicies
Used for removing tracks from temporary playlists. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
99757c47f9
commit
3287cde11e
|
@ -35,6 +35,7 @@ namespace ocarina
|
|||
void right_click(guint, guint64);
|
||||
void select_none();
|
||||
void list_selected_tracks(list<libsaria::Track *> &);
|
||||
void list_selected_indices(list<unsigned int> &);
|
||||
|
||||
void set_playlist(libsaria::Playlist *);
|
||||
void renumbered(int);
|
||||
|
|
|
@ -68,6 +68,7 @@ void show_rc_menu(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
list<libsaria::Track *> tracks;
|
||||
list<unsigned int> indices;
|
||||
string key = gdk_keyval_name(event->key.keyval);
|
||||
libsaria::Playlist *list;
|
||||
ocarina::Playlist *plist = (ocarina::Playlist *)data;
|
||||
|
@ -95,10 +96,10 @@ gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
if (list)
|
||||
list->add_tracks(tracks);
|
||||
} else if (key == "Delete") {
|
||||
plist->list_selected_tracks(tracks);
|
||||
if (tracks.size() == 0)
|
||||
plist->list_selected_indices(indices);
|
||||
if (indices.size() == 0)
|
||||
return FALSE;
|
||||
plist->get_playlist()->remove_tracks(tracks);
|
||||
plist->get_playlist()->remove_indices(indices);
|
||||
} else if (key == "Escape") {
|
||||
plist->select_none();
|
||||
return FALSE;
|
||||
|
|
|
@ -18,6 +18,14 @@ static void selected_foreach_list(GtkTreeModel *model, GtkTreePath *path,
|
|||
tracks->push_back(track);
|
||||
}
|
||||
|
||||
static void selected_foreach_index(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
list<unsigned int> *indices = (list<unsigned int> *)data;
|
||||
unsigned int *index = (unsigned int *)gtk_tree_path_get_indices(path);
|
||||
indices->push_back(*index);
|
||||
}
|
||||
|
||||
static void do_filter(GtkWidget *entry, gpointer d)
|
||||
{
|
||||
string text = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
|
@ -72,6 +80,11 @@ namespace ocarina
|
|||
gtk_tree_selection_selected_foreach(treesel, selected_foreach_list, &tracks);
|
||||
}
|
||||
|
||||
void Playlist::list_selected_indices(list<unsigned int> &indices)
|
||||
{
|
||||
gtk_tree_selection_selected_foreach(treesel, selected_foreach_index, &indices);
|
||||
}
|
||||
|
||||
void Playlist::select_none()
|
||||
{
|
||||
gtk_tree_selection_unselect_all(treesel);
|
||||
|
|
Loading…
Reference in New Issue