Browse Source

gui/treeview: Add a function for accessing the tree selection

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
next
Anna 4 years ago
parent
commit
fc5e6eb043
3 changed files with 13 additions and 11 deletions
  1. +6
    -10
      gui/treeview.c
  2. +6
    -0
      include/gui/treeview.h
  3. +1
    -1
      tests/gui/treeview.c

+ 6
- 10
gui/treeview.c View File

@ -218,26 +218,22 @@ void gui_treeview_scroll()
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,
&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);
}
}
GList *gui_treeview_list_selected_tracks(void)
{
GList *rows, *cur, *list = NULL;
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection(gui_treeview());
rows = gtk_tree_selection_get_selected_rows(selection, NULL);
cur = g_list_first(rows);
GtkTreeSelection *selection = gui_treeview_selection();
GList *rows = gtk_tree_selection_get_selected_rows(selection, NULL);
GList *cur = g_list_first(rows);
GList *list = NULL;
while (cur) {
list = g_list_append(list, gui_filter_path_get_track(cur->data));


+ 6
- 0
include/gui/treeview.h View File

@ -32,6 +32,12 @@ static inline GtkTreeView *gui_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. */
static inline GtkLabel *gui_sorting()
{


+ 1
- 1
tests/gui/treeview.c View File

@ -65,7 +65,7 @@ void test_treeview_select()
GList *list;
unsigned int i;
selection = gtk_tree_view_get_selection(gui_treeview());
selection = gui_treeview_selection();
gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "Collection"));
g_assert(gui_model_get_playlist() ==


Loading…
Cancel
Save