[gtk+] GtkListBox: Add a function for getting the index of a row



commit b46d583f87835c303ecc86f29bd601eb0b678863
Author: Kalev Lember <kalevlember gmail com>
Date:   Thu Jul 4 13:40:21 2013 +0200

    GtkListBox: Add a function for getting the index of a row
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703618

 gtk/gtklistbox.c |   21 +++++++++++++++++++++
 gtk/gtklistbox.h |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index fe6307f..d191a45 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -2673,6 +2673,27 @@ gtk_list_box_row_set_header (GtkListBoxRow *row,
     g_object_ref (header);
 }
 
+/**
+ * gtk_list_box_row_get_index:
+ * @row: a #GtkListBoxRow
+ *
+ * Gets the current index of the @row in its #GtkListBox container.
+ *
+ * Returns: the index of the @row, or -1 if the @row is not in a listbox
+ *
+ * Since: 3.10
+ */
+gint
+gtk_list_box_row_get_index (GtkListBoxRow *row)
+{
+  GtkListBoxRowPrivate *priv = gtk_list_box_row_get_instance_private (row);
+
+  if (priv->iter != NULL)
+    return g_sequence_iter_get_position (priv->iter);
+
+  return -1;
+}
+
 static void
 gtk_list_box_row_finalize (GObject *obj)
 {
diff --git a/gtk/gtklistbox.h b/gtk/gtklistbox.h
index 5410072..161bdb1 100644
--- a/gtk/gtklistbox.h
+++ b/gtk/gtklistbox.h
@@ -153,6 +153,8 @@ GDK_AVAILABLE_IN_3_10
 void       gtk_list_box_row_set_header    (GtkListBoxRow *row,
                                            GtkWidget     *header);
 GDK_AVAILABLE_IN_3_10
+gint       gtk_list_box_row_get_index     (GtkListBoxRow *row);
+GDK_AVAILABLE_IN_3_10
 void       gtk_list_box_row_changed       (GtkListBoxRow *row);
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]