[gtk/wip/baedert/for-master: 32/56] widget: Use early-out style in gtk_widget_realize()



commit 61195df7a3039fdf4bc5423aa17d495e45a41977
Author: Timm Bäder <mail baedert org>
Date:   Sun Apr 19 19:45:07 2020 +0200

    widget: Use early-out style in gtk_widget_realize()
    
    This is much more common in the current code base and reduces the
    indentation level by one.

 gtk/gtkwidget.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8ee76a263d..a0ad576816 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3463,41 +3463,41 @@ gtk_widget_realize (GtkWidget *widget)
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (!_gtk_widget_get_realized (widget))
-    {
-      gtk_widget_push_verify_invariants (widget);
+  if (priv->realized)
+    return;
 
-      /*
-       if (GTK_IS_CONTAINER (widget) && _gtk_widget_get_has_surface (widget))
-         g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
-      */
+  gtk_widget_push_verify_invariants (widget);
 
-      if (priv->parent == NULL && !GTK_IS_ROOT (widget))
-        g_warning ("Calling gtk_widget_realize() on a widget that isn't "
-                   "inside a toplevel window is not going to work very well. "
-                   "Widgets must be inside a toplevel container before realizing them.");
+  /*
+    if (GTK_IS_CONTAINER (widget) && _gtk_widget_get_has_surface (widget))
+    g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
+  */
 
-      if (priv->parent && !_gtk_widget_get_realized (priv->parent))
-       gtk_widget_realize (priv->parent);
+  if (priv->parent == NULL && !GTK_IS_ROOT (widget))
+    g_warning ("Calling gtk_widget_realize() on a widget that isn't "
+               "inside a toplevel window is not going to work very well. "
+               "Widgets must be inside a toplevel container before realizing them.");
 
-      g_signal_emit (widget, widget_signals[REALIZE], 0);
+  if (priv->parent && !_gtk_widget_get_realized (priv->parent))
+    gtk_widget_realize (priv->parent);
 
-      if (priv->multidevice)
-        {
-          GdkSurface *surface = gtk_widget_get_surface (widget);
+  g_signal_emit (widget, widget_signals[REALIZE], 0);
 
-          gdk_surface_set_support_multidevice (surface, TRUE);
-        }
+  if (priv->multidevice)
+    {
+      GdkSurface *surface = gtk_widget_get_surface (widget);
 
-      gtk_widget_update_alpha (widget);
+      gdk_surface_set_support_multidevice (surface, TRUE);
+    }
 
-      if (priv->context)
-       gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
-      else
-        gtk_widget_get_style_context (widget);
+  gtk_widget_update_alpha (widget);
 
-      gtk_widget_pop_verify_invariants (widget);
-    }
+  if (priv->context)
+    gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
+  else
+    gtk_widget_get_style_context (widget);
+
+  gtk_widget_pop_verify_invariants (widget);
 }
 
 /**


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