[libdazzle] multi-paned: add helper to get nth widget
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] multi-paned: add helper to get nth widget
- Date: Thu, 22 Jun 2017 06:02:53 +0000 (UTC)
commit 68f9d8d6f5b4069bb64c5d1438675ba62afc322d
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 21 23:02:44 2017 -0700
multi-paned: add helper to get nth widget
This is handy to get a widget knowing the index we care about.
src/widgets/dzl-multi-paned.c | 25 +++++++++++++++++++++++++
src/widgets/dzl-multi-paned.h | 2 ++
2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/widgets/dzl-multi-paned.c b/src/widgets/dzl-multi-paned.c
index 2fe9f96..cec85a3 100644
--- a/src/widgets/dzl-multi-paned.c
+++ b/src/widgets/dzl-multi-paned.c
@@ -2159,3 +2159,28 @@ dzl_multi_paned_get_n_children (DzlMultiPaned *self)
return priv->children ? priv->children->len : 0;
}
+
+/**
+ * dzl_multi_paned_get_nth_child:
+ * @self: a #DzlMultiPaned
+ *
+ * Gets the @nth child of the #DzlMultiPaned.
+ *
+ * It is an error to call this function with a value >= the result of
+ * dzl_multi_paned_get_nth_child().
+ *
+ * The index starts from 0.
+ *
+ * Returns: (transfer none): A #GtkWidget
+ */
+GtkWidget *
+dzl_multi_paned_get_nth_child (DzlMultiPaned *self,
+ guint nth)
+{
+ DzlMultiPanedPrivate *priv = dzl_multi_paned_get_instance_private (self);
+
+ g_return_val_if_fail (DZL_IS_MULTI_PANED (self), NULL);
+ g_return_val_if_fail (nth < priv->children->len, NULL);
+
+ return g_array_index (priv->children, DzlMultiPanedChild, nth).widget;
+}
diff --git a/src/widgets/dzl-multi-paned.h b/src/widgets/dzl-multi-paned.h
index a5bc3c8..fa2fc94 100644
--- a/src/widgets/dzl-multi-paned.h
+++ b/src/widgets/dzl-multi-paned.h
@@ -53,6 +53,8 @@ struct _DzlMultiPanedClass
GtkWidget *dzl_multi_paned_new (void);
guint dzl_multi_paned_get_n_children (DzlMultiPaned *self);
+GtkWidget *dzl_multi_paned_get_nth_child (DzlMultiPaned *self,
+ guint nth);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]