[gtk/wip/otte/titlebar: 1/4] window: Improve set_titlebar() function




commit c5478553cbbba509343ddffa9f08984b40a4b25c
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 21 03:39:19 2021 +0200

    window: Improve set_titlebar() function
    
    Get rid of a goto and check if the titlebar is already set.

 gtk/gtkwindow.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 44cf033d2a..7486e1178e 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3023,6 +3023,9 @@ gtk_window_set_titlebar (GtkWindow *window,
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
+  if (priv->title_box == titlebar)
+    return;
+
   if ((!priv->title_box && titlebar) || (priv->title_box && !titlebar))
     {
       was_mapped = _gtk_widget_get_mapped (widget);
@@ -3043,19 +3046,18 @@ gtk_window_set_titlebar (GtkWindow *window,
       priv->client_decorated = FALSE;
       gtk_widget_remove_css_class (widget, "csd");
       gtk_widget_remove_css_class (widget, "solid-csd");
-
-      goto out;
     }
+  else
+    {
+      priv->use_client_shadow = gtk_window_supports_client_shadow (window);
 
-  priv->use_client_shadow = gtk_window_supports_client_shadow (window);
-
-  gtk_window_enable_csd (window);
-  priv->title_box = titlebar;
-  gtk_widget_insert_before (priv->title_box, widget, NULL);
+      gtk_window_enable_csd (window);
+      priv->title_box = titlebar;
+      gtk_widget_insert_before (priv->title_box, widget, NULL);
 
-  gtk_widget_add_css_class (titlebar, "titlebar");
+      gtk_widget_add_css_class (titlebar, "titlebar");
+    }
 
-out:
   if (was_mapped)
     gtk_widget_map (widget);
 }


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