stack: return the stack page when adding a child, to ease setting props

This commit is contained in:
Andy Holmes 2019-11-03 18:05:03 -08:00
parent 6d16f7ad35
commit 44093f4966
No known key found for this signature in database
GPG Key ID: 27A243A363521CEC
2 changed files with 19 additions and 13 deletions

View File

@ -1319,7 +1319,7 @@ stack_child_visibility_notify_cb (GObject *obj,
}
}
static void
static GtkStackPage *
gtk_stack_add_internal (GtkStack *stack,
GtkWidget *child,
const char *name,
@ -1336,17 +1336,19 @@ gtk_stack_add_internal (GtkStack *stack,
* The child is identified by the @name. The @title
* will be used by #GtkStackSwitcher to represent
* @child in a tab bar, so it should be short.
*
* Returns: (transfer none): the #GtkStackPage for @child
*/
void
GtkStackPage *
gtk_stack_add_titled (GtkStack *stack,
GtkWidget *child,
const gchar *name,
const gchar *title)
{
g_return_if_fail (GTK_IS_STACK (stack));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_val_if_fail (GTK_IS_STACK (stack), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
gtk_stack_add_internal (stack, child, name, title);
return gtk_stack_add_internal (stack, child, name, title);
}
/**
@ -1357,16 +1359,18 @@ gtk_stack_add_titled (GtkStack *stack,
*
* Adds a child to @stack.
* The child is identified by the @name.
*
* Returns: (transfer none): the #GtkStackPage for @child
*/
void
GtkStackPage *
gtk_stack_add_named (GtkStack *stack,
GtkWidget *child,
const gchar *name)
{
g_return_if_fail (GTK_IS_STACK (stack));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_val_if_fail (GTK_IS_STACK (stack), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
gtk_stack_add_internal (stack, child, name, NULL);
return gtk_stack_add_internal (stack, child, name, NULL);
}
static void
@ -1378,7 +1382,7 @@ gtk_stack_add (GtkContainer *container,
gtk_stack_add_internal (stack, child, NULL, NULL);
}
static void
static GtkStackPage *
gtk_stack_add_internal (GtkStack *stack,
GtkWidget *child,
const char *name,
@ -1386,7 +1390,7 @@ gtk_stack_add_internal (GtkStack *stack,
{
GtkStackPage *child_info;
g_return_if_fail (child != NULL);
g_return_val_if_fail (child != NULL, NULL);
child_info = g_object_new (GTK_TYPE_STACK_PAGE, NULL);
child_info->widget = g_object_ref (child);
@ -1399,6 +1403,8 @@ gtk_stack_add_internal (GtkStack *stack,
gtk_stack_add_page (stack, child_info);
g_object_unref (child_info);
return child_info;
}
static void

View File

@ -79,11 +79,11 @@ GType gtk_stack_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_stack_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_stack_add_named (GtkStack *stack,
GtkStackPage * gtk_stack_add_named (GtkStack *stack,
GtkWidget *child,
const gchar *name);
GDK_AVAILABLE_IN_ALL
void gtk_stack_add_titled (GtkStack *stack,
GtkStackPage * gtk_stack_add_titled (GtkStack *stack,
GtkWidget *child,
const gchar *name,
const gchar *title);