widget: add shortcut to gtk_widget_set_child_visible

So we don't do unnecessary work when just setting priv->child_visible to
the same value again.
This commit is contained in:
Timm Bäder 2018-04-21 20:14:05 +02:00
parent a54e5844b6
commit e0205eb27c
2 changed files with 9 additions and 4 deletions

View File

@ -7618,7 +7618,7 @@ gtk_widget_get_parent_surface (GtkWidget *widget)
/** /**
* gtk_widget_set_child_visible: * gtk_widget_set_child_visible:
* @widget: a #GtkWidget * @widget: a #GtkWidget
* @is_visible: if %TRUE, @widget should be mapped along with its parent. * @child_visible: if %TRUE, @widget should be mapped along with its parent.
* *
* Sets whether @widget should be mapped along with its when its parent * Sets whether @widget should be mapped along with its when its parent
* is mapped and @widget has been shown with gtk_widget_show(). * is mapped and @widget has been shown with gtk_widget_show().
@ -7640,17 +7640,22 @@ gtk_widget_get_parent_surface (GtkWidget *widget)
**/ **/
void void
gtk_widget_set_child_visible (GtkWidget *widget, gtk_widget_set_child_visible (GtkWidget *widget,
gboolean is_visible) gboolean child_visible)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!_gtk_widget_is_toplevel (widget)); g_return_if_fail (!_gtk_widget_is_toplevel (widget));
child_visible = !!child_visible;
if (priv->child_visible == child_visible)
return;
g_object_ref (widget); g_object_ref (widget);
gtk_widget_verify_invariants (widget); gtk_widget_verify_invariants (widget);
if (is_visible) if (child_visible)
priv->child_visible = TRUE; priv->child_visible = TRUE;
else else
{ {

View File

@ -589,7 +589,7 @@ GdkSurface * gtk_widget_get_parent_surface (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_widget_set_child_visible (GtkWidget *widget, void gtk_widget_set_child_visible (GtkWidget *widget,
gboolean is_visible); gboolean child_visible);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_get_child_visible (GtkWidget *widget); gboolean gtk_widget_get_child_visible (GtkWidget *widget);