[gnome-builder/wip/gtk4-port: 1000/1774] libide/gtk: add selected row helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1000/1774] libide/gtk: add selected row helper
- Date: Mon, 11 Jul 2022 22:31:31 +0000 (UTC)
commit 65901d3d1c0126c15596f7a1c186ee5d5d264088
Author: Christian Hergert <chergert redhat com>
Date: Fri May 13 08:23:03 2022 -0700
libide/gtk: add selected row helper
src/libide/gtk/ide-gtk.c | 20 ++++++++++++++++++++
src/libide/gtk/ide-gtk.h | 3 +++
2 files changed, 23 insertions(+)
---
diff --git a/src/libide/gtk/ide-gtk.c b/src/libide/gtk/ide-gtk.c
index 5f8447ff6..8649ef1d5 100644
--- a/src/libide/gtk/ide-gtk.c
+++ b/src/libide/gtk/ide-gtk.c
@@ -512,3 +512,23 @@ ide_gtk_list_view_move_previous (GtkListView *view)
gtk_widget_activate_action (GTK_WIDGET (view), "list.scroll-to-item", "u", pos-1);
}
}
+
+gboolean
+ide_gtk_list_view_get_selected_row (GtkListView *view,
+ guint *position)
+{
+ GtkSelectionModel *model;
+ GtkBitset *bitset;
+
+ g_return_val_if_fail (GTK_IS_LIST_VIEW (view), FALSE);
+
+ if (!(model = gtk_list_view_get_model (view)))
+ return FALSE;
+
+ bitset = gtk_selection_model_get_selection (model);
+ if (gtk_bitset_is_empty (bitset))
+ return FALSE;
+
+ *position = gtk_bitset_get_minimum (bitset);
+ return TRUE;
+}
diff --git a/src/libide/gtk/ide-gtk.h b/src/libide/gtk/ide-gtk.h
index bdc6a44c7..f06a5b0f2 100644
--- a/src/libide/gtk/ide-gtk.h
+++ b/src/libide/gtk/ide-gtk.h
@@ -63,5 +63,8 @@ IDE_AVAILABLE_IN_ALL
void ide_gtk_list_view_move_next (GtkListView *view);
IDE_AVAILABLE_IN_ALL
void ide_gtk_list_view_move_previous (GtkListView *view);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_gtk_list_view_get_selected_row (GtkListView *view,
+ guint *position);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]