[gnome-software: 58/110] gs-summary-tile: Replace GtkWidget.get_preferred_width by GtkWidget.measure




commit c1ccbe96d9ba0ef7b976a8f25773e702474ae2e2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 24 20:54:02 2021 -0300

    gs-summary-tile: Replace GtkWidget.get_preferred_width by GtkWidget.measure
    
    GtkWidget.measure is the new vfunc to be overriden when one wants to affect
    the minimum and natural sizes of widget subclasses.

 src/gs-summary-tile.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/src/gs-summary-tile.c b/src/gs-summary-tile.c
index 667d7a903..fd21d4f52 100644
--- a/src/gs-summary-tile.c
+++ b/src/gs-summary-tile.c
@@ -145,24 +145,38 @@ gs_summary_tile_set_property (GObject *object,
 }
 
 static void
-gs_app_get_preferred_width (GtkWidget *widget,
-                           gint *min, gint *nat)
+gs_summary_tile_measure (GtkWidget      *widget,
+                         GtkOrientation  orientation,
+                         gint            for_size,
+                         gint           *minimum,
+                         gint           *natural,
+                         gint           *minimum_baseline,
+                         gint           *natural_baseline)
 {
        gint m;
        GsSummaryTile *app_tile = GS_SUMMARY_TILE (widget);
 
-       if (app_tile->preferred_width < 0) {
+       if (app_tile->preferred_width < 0 || orientation == GTK_ORIENTATION_VERTICAL) {
                /* Just retrieve the default values */
-               GTK_WIDGET_CLASS (gs_summary_tile_parent_class)->get_preferred_width (widget, min, nat);
+               GTK_WIDGET_CLASS (gs_summary_tile_parent_class)->measure (widget,
+                                                                         orientation,
+                                                                         for_size,
+                                                                         minimum,
+                                                                         natural,
+                                                                         minimum_baseline,
+                                                                         natural_baseline);
                return;
        }
 
-       GTK_WIDGET_CLASS (gs_summary_tile_parent_class)->get_preferred_width (widget, &m, NULL);
-
-       if (min != NULL)
-               *min = m;
-       if (nat != NULL)
-               *nat = MAX (m, app_tile->preferred_width);
+       GTK_WIDGET_CLASS (gs_summary_tile_parent_class)->measure (widget,
+                                                                 orientation,
+                                                                 for_size,
+                                                                 &m, NULL,
+                                                                 NULL, NULL);
+       if (minimum != NULL)
+               *minimum = m;
+       if (natural != NULL)
+               *natural = MAX (m, app_tile->preferred_width);
 }
 
 static void
@@ -175,7 +189,7 @@ gs_summary_tile_class_init (GsSummaryTileClass *klass)
        object_class->get_property = gs_summary_tile_get_property;
        object_class->set_property = gs_summary_tile_set_property;
 
-       widget_class->get_preferred_width = gs_app_get_preferred_width;
+       widget_class->measure = gs_summary_tile_measure;
 
        tile_class->refresh = gs_summary_tile_refresh;
 


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