diff --git a/gui/sidebar.c b/gui/sidebar.c index 3256c0e0..8aa8add8 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -486,3 +486,19 @@ gboolean gui_sidebar_iter_from_string(const gchar *path, GtkTreeIter *child) __gui_sidebar_filter_iter_convert(&iter, child); return TRUE; } + +gboolean gui_sidebar_iter_from_xy(gint x, gint y, GtkTreeIter *child) +{ + GtkTreeModel *model = GTK_TREE_MODEL(gui_sidebar_filter()); + GtkTreePath *path; + GtkTreeIter iter; + + if (!gtk_tree_view_get_path_at_pos(gui_sidebar_treeview(), x, y, + &path, NULL, NULL, NULL)) + return false; + + gtk_tree_model_get_iter(model, &iter, path); + __gui_sidebar_filter_iter_convert(&iter, child); + gtk_tree_path_free(path); + return true; +} diff --git a/include/gui/sidebar.h b/include/gui/sidebar.h index a5732161..2dcfa3e5 100644 --- a/include/gui/sidebar.h +++ b/include/gui/sidebar.h @@ -76,6 +76,9 @@ gboolean gui_sidebar_iter_find(GtkTreeIter *, const gchar *, /* Called to set the a GtkTreeIter to the row at path string */ gboolean gui_sidebar_iter_from_string(const gchar *, GtkTreeIter *); +/* Called to set the GtkTreeIter to the row at (x, y) */ +gboolean gui_sidebar_iter_from_xy(gint, gint, GtkTreeIter *); + /* Called to get the sidebar widget. */ static inline GtkPaned *gui_sidebar() {