[nautilus/wip/antoniof/gtk4-preparation-popovers: 13/14] floating-bar: Stop overriding widget measurement vfunc




commit 256743939c982a0cd036da53eb0916a3a2b5e0ff
Author: António Fernandes <antoniof gnome org>
Date:   Sun Dec 19 19:39:46 2021 +0000

    floating-bar: Stop overriding widget measurement vfunc
    
    We are doing it in order to account for the border and padding.
    
    That's unnecessary, as GTK already accounts for border and padding
    from CSS. Actually, duplicating this work has been just adding more
    padding, resulting in a despropotionate padding at the start side.
    
    Remove the unnecessary overrides and just add 2 pixels more padding
    to preserve the visual height.

 src/nautilus-floating-bar.c   | 95 -------------------------------------------
 src/resources/css/Adwaita.css |  2 +-
 2 files changed, 1 insertion(+), 96 deletions(-)
---
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
index 4d166d4d8..0147ad656 100644
--- a/src/nautilus-floating-bar.c
+++ b/src/nautilus-floating-bar.c
@@ -306,97 +306,6 @@ nautilus_floating_bar_parent_set (GtkWidget *widget,
     }
 }
 
-static void
-get_padding_and_border (GtkWidget *widget,
-                        GtkBorder *border)
-{
-    GtkStyleContext *context;
-    GtkStateFlags state;
-    GtkBorder tmp;
-
-    context = gtk_widget_get_style_context (widget);
-    state = gtk_style_context_get_state (context);
-
-    gtk_style_context_get_padding (context, state, border);
-    gtk_style_context_get_border (context, state, &tmp);
-    border->top += tmp.top;
-    border->right += tmp.right;
-    border->bottom += tmp.bottom;
-    border->left += tmp.left;
-}
-
-static void
-nautilus_floating_bar_get_preferred_width (GtkWidget *widget,
-                                           gint      *minimum_size,
-                                           gint      *natural_size)
-{
-    GtkBorder border;
-
-    get_padding_and_border (widget, &border);
-
-    GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_width (widget,
-                                                                                minimum_size,
-                                                                                natural_size);
-
-    *minimum_size += border.left + border.right;
-    *natural_size += border.left + border.right;
-}
-
-static void
-nautilus_floating_bar_get_preferred_width_for_height (GtkWidget *widget,
-                                                      gint       height,
-                                                      gint      *minimum_size,
-                                                      gint      *natural_size)
-{
-    GtkBorder border;
-
-    get_padding_and_border (widget, &border);
-
-    GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_width_for_height (widget,
-                                                                                           height,
-                                                                                           minimum_size,
-                                                                                           natural_size);
-
-    *minimum_size += border.left + border.right;
-    *natural_size += border.left + border.right;
-}
-
-static void
-nautilus_floating_bar_get_preferred_height (GtkWidget *widget,
-                                            gint      *minimum_size,
-                                            gint      *natural_size)
-{
-    GtkBorder border;
-
-    get_padding_and_border (widget, &border);
-
-    GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_height (widget,
-                                                                                 minimum_size,
-                                                                                 natural_size);
-
-    *minimum_size += border.top + border.bottom;
-    *natural_size += border.top + border.bottom;
-}
-
-static void
-nautilus_floating_bar_get_preferred_height_for_width (GtkWidget *widget,
-                                                      gint       width,
-                                                      gint      *minimum_size,
-                                                      gint      *natural_size)
-{
-    GtkBorder border;
-
-    get_padding_and_border (widget, &border);
-
-    GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_height_for_width (widget,
-                                                                                           width,
-                                                                                           minimum_size,
-                                                                                           natural_size);
-
-    *minimum_size += border.top + border.bottom;
-    *natural_size += border.top + border.bottom;
-}
-
 static void
 nautilus_floating_bar_constructed (GObject *obj)
 {
@@ -480,10 +389,6 @@ nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
     oclass->get_property = nautilus_floating_bar_get_property;
     oclass->finalize = nautilus_floating_bar_finalize;
 
-    wclass->get_preferred_width = nautilus_floating_bar_get_preferred_width;
-    wclass->get_preferred_width_for_height = nautilus_floating_bar_get_preferred_width_for_height;
-    wclass->get_preferred_height = nautilus_floating_bar_get_preferred_height;
-    wclass->get_preferred_height_for_width = nautilus_floating_bar_get_preferred_height_for_width;
     wclass->parent_set = nautilus_floating_bar_parent_set;
 
     properties[PROP_PRIMARY_LABEL] =
diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css
index 03acabd4a..9a16c4c36 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -107,7 +107,7 @@ entry.search > * {
 
 /* Floating status bar */
 .floating-bar {
-  padding: 1px;
+  padding: 3px;
   background-color: @theme_base_color;
   border-width: 1px;
   border-style: solid solid none;


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