diff --git a/gui/treeview.c b/gui/treeview.c index 9df4e4cf..f24a2852 100644 --- a/gui/treeview.c +++ b/gui/treeview.c @@ -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)); diff --git a/include/gui/treeview.h b/include/gui/treeview.h index f65b99cf..032929ea 100644 --- a/include/gui/treeview.h +++ b/include/gui/treeview.h @@ -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() { diff --git a/tests/gui/treeview.c b/tests/gui/treeview.c index c4ee90cb..be721558 100644 --- a/tests/gui/treeview.c +++ b/tests/gui/treeview.c @@ -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() ==