gui/treeview: Add a "select path at pos" function
This function isn't easy to test without knowledge of screen coordinates, so I didn't include a unit test this time. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
3ae5e0f535
commit
e660e3f0b2
|
@ -218,6 +218,20 @@ void gui_treeview_scroll()
|
|||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
void gui_treeview_select_path_at_pos(unsigned int x, unsigned int y)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
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_path_free(path);
|
||||
}
|
||||
}
|
||||
|
||||
GList *gui_treeview_list_selected_tracks(void)
|
||||
{
|
||||
GList *rows, *cur, *list = NULL;
|
||||
|
|
|
@ -171,22 +171,15 @@ static GtkWidget *__view_rc_build_submenu(void)
|
|||
bool __view_button_press(GtkTreeView *treeview, GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||
GtkMenu *menu = GTK_MENU(gui_builder_widget("o_menu"));
|
||||
GtkWidget *submenu = NULL;
|
||||
GtkMenuItem *other;
|
||||
GtkTreePath *path;
|
||||
|
||||
if (event->button != GDK_BUTTON_SECONDARY)
|
||||
return false;
|
||||
|
||||
/* Select path if it isn't already selected */
|
||||
if (gtk_tree_view_get_path_at_pos(treeview, event->x, event->y,
|
||||
&path, NULL, NULL, NULL))
|
||||
{
|
||||
gtk_tree_selection_select_path(selection, path);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
gui_treeview_select_path_at_pos(event->x, event->y);
|
||||
|
||||
/* Set the "Other Playlists" submenu. */
|
||||
other = GTK_MENU_ITEM(gui_builder_widget("o_add_to_other"));
|
||||
|
|
|
@ -17,6 +17,9 @@ void gui_treeview_set_playlist(struct playlist *);
|
|||
/* Called to scroll the treeview to the current track. */
|
||||
void gui_treeview_scroll();
|
||||
|
||||
/* Called to select a path from (x, y) screen coodinates. */
|
||||
void gui_treeview_select_path_at_pos(unsigned int x, unsigned int y);
|
||||
|
||||
/*
|
||||
* Called to get a list of selected tracks.
|
||||
* NOTE: The caller is responsible for freeing the list with g_list_free().
|
||||
|
|
Loading…
Reference in New Issue