gui/treeview: Add a function for accessing the tree selection
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
a41652ab28
commit
fc5e6eb043
|
@ -218,26 +218,22 @@ void gui_treeview_scroll()
|
||||||
|
|
||||||
void gui_treeview_select_path_at_pos(unsigned int x, unsigned int y)
|
void gui_treeview_select_path_at_pos(unsigned int x, unsigned int y)
|
||||||
{
|
{
|
||||||
GtkTreeSelection *selection;
|
GtkTreePath *path;
|
||||||
GtkTreePath *path;
|
|
||||||
|
|
||||||
selection = gtk_tree_view_get_selection(gui_treeview());
|
|
||||||
if (gtk_tree_view_get_path_at_pos(gui_treeview(), x, y,
|
if (gtk_tree_view_get_path_at_pos(gui_treeview(), x, y,
|
||||||
&path, NULL, NULL, NULL))
|
&path, NULL, NULL, NULL))
|
||||||
{
|
{
|
||||||
gtk_tree_selection_select_path(selection, path);
|
gtk_tree_selection_select_path(gui_treeview_selection(), path);
|
||||||
gtk_tree_path_free(path);
|
gtk_tree_path_free(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GList *gui_treeview_list_selected_tracks(void)
|
GList *gui_treeview_list_selected_tracks(void)
|
||||||
{
|
{
|
||||||
GList *rows, *cur, *list = NULL;
|
GtkTreeSelection *selection = gui_treeview_selection();
|
||||||
GtkTreeSelection *selection;
|
GList *rows = gtk_tree_selection_get_selected_rows(selection, NULL);
|
||||||
|
GList *cur = g_list_first(rows);
|
||||||
selection = gtk_tree_view_get_selection(gui_treeview());
|
GList *list = NULL;
|
||||||
rows = gtk_tree_selection_get_selected_rows(selection, NULL);
|
|
||||||
cur = g_list_first(rows);
|
|
||||||
|
|
||||||
while (cur) {
|
while (cur) {
|
||||||
list = g_list_append(list, gui_filter_path_get_track(cur->data));
|
list = g_list_append(list, gui_filter_path_get_track(cur->data));
|
||||||
|
|
|
@ -32,6 +32,12 @@ static inline GtkTreeView *gui_treeview()
|
||||||
return GTK_TREE_VIEW(gui_builder_widget("treeview"));
|
return GTK_TREE_VIEW(gui_builder_widget("treeview"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called to access the treview selection. */
|
||||||
|
static inline GtkTreeSelection *gui_treeview_selection()
|
||||||
|
{
|
||||||
|
return gtk_tree_view_get_selection(gui_treeview());
|
||||||
|
}
|
||||||
|
|
||||||
/* Called to access the sorting display widget. */
|
/* Called to access the sorting display widget. */
|
||||||
static inline GtkLabel *gui_sorting()
|
static inline GtkLabel *gui_sorting()
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,7 @@ void test_treeview_select()
|
||||||
GList *list;
|
GList *list;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
selection = gtk_tree_view_get_selection(gui_treeview());
|
selection = gui_treeview_selection();
|
||||||
|
|
||||||
gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));
|
gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));
|
||||||
g_assert(gui_model_get_playlist() ==
|
g_assert(gui_model_get_playlist() ==
|
||||||
|
|
Loading…
Reference in New Issue
Block a user