summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkstack.c34
-rw-r--r--gtk/gtkstack.h3
2 files changed, 37 insertions, 0 deletions
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 1c61192df7..f158d134e5 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -1134,6 +1134,40 @@ gtk_stack_remove (GtkContainer *container,
}
/**
+ * gtk_stack_get_child_by_name:
+ * @stack: a #GtkStack
+ * @name: the name of the child to find
+ *
+ * Finds the child of the #GtkStack with the name given as
+ * the argument. Returns %NULL if there is no child with this
+ * name.
+ *
+ * Return value: (transfer none): the requested child of the #GtkStack
+ *
+ * Since: 3.12
+ */
+GtkWidget *
+gtk_stack_get_child_by_name (GtkStack *stack,
+ const gchar *name)
+{
+ GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
+ GtkStackChildInfo *info;
+ GList *l;
+
+ g_return_val_if_fail (GTK_IS_STACK (stack), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ for (l = priv->children; l != NULL; l = l->next)
+ {
+ info = l->data;
+ if (info->name && strcmp (info->name, name) == 0)
+ return info->widget;
+ }
+
+ return NULL;
+}
+
+/**
* gtk_stack_set_homogeneous:
* @stack: a #GtkStack
* @homogeneous: %TRUE to make @stack homogeneous
diff --git a/gtk/gtkstack.h b/gtk/gtkstack.h
index d0bb47188a..edecf7f5a3 100644
--- a/gtk/gtkstack.h
+++ b/gtk/gtkstack.h
@@ -79,6 +79,9 @@ void gtk_stack_add_titled (GtkStack
GtkWidget *child,
const gchar *name,
const gchar *title);
+GDK_AVAILABLE_IN_3_12
+GtkWidget * gtk_stack_get_child_by_name (GtkStack *stack,
+ const gchar *name);
GDK_AVAILABLE_IN_3_10
void gtk_stack_set_visible_child (GtkStack *stack,
GtkWidget *child);