[gnome-software: 35/110] Adapt to GtkWidget.size_allocate API changes




commit 98b58c39f22cee8fbf35878bf46c8acd668855e8
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Aug 22 23:13:46 2021 -0300

    Adapt to GtkWidget.size_allocate API changes
    
    It now receives the width, height, and baseline as separate arguments.

 src/gs-description-box.c |  9 +++++++--
 src/gs-feature-tile.c    | 13 +++++++++----
 src/gs-picture.c         | 31 -------------------------------
 src/gs-shell.c           | 10 ++++++++--
 4 files changed, 24 insertions(+), 39 deletions(-)
---
diff --git a/src/gs-description-box.c b/src/gs-description-box.c
index 5497693f5..b4dd41d39 100644
--- a/src/gs-description-box.c
+++ b/src/gs-description-box.c
@@ -117,11 +117,16 @@ gs_description_box_read_button_clicked_cb (GtkButton *button,
 
 static void
 gs_description_box_size_allocate (GtkWidget *widget,
-                                 GtkAllocation *allocation)
+                                  int        width,
+                                  int        height,
+                                  int        baseline)
 {
        GsDescriptionBox *box = GS_DESCRIPTION_BOX (widget);
 
-       GTK_WIDGET_CLASS (gs_description_box_parent_class)->size_allocate (widget, allocation);
+       GTK_WIDGET_CLASS (gs_description_box_parent_class)->size_allocate (widget,
+                                                                          width,
+                                                                          height,
+                                                                          baseline);
 
        gs_description_box_update_content (box);
 }
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index 3c529f23c..f3c536b21 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -415,18 +415,23 @@ gs_feature_tile_style_updated (GtkWidget *widget)
 }
 
 static void
-gs_feature_tile_size_allocate (GtkWidget     *widget,
-                               GtkAllocation *allocation)
+gs_feature_tile_size_allocate (GtkWidget *widget,
+                               gint       width,
+                               gint       height,
+                               gint       baseline)
 {
        GsFeatureTile *tile = GS_FEATURE_TILE (widget);
        gboolean narrow_mode;
 
        /* Chain up. */
-       GTK_WIDGET_CLASS (gs_feature_tile_parent_class)->size_allocate (widget, allocation);
+       GTK_WIDGET_CLASS (gs_feature_tile_parent_class)->size_allocate (widget,
+                                                                       width,
+                                                                       height,
+                                                                       baseline);
 
        /* Engage ‘narrow mode’ if the allocation becomes too narrow. The exact
         * choice of width is arbitrary here. */
-       narrow_mode = (allocation->width < 600);
+       narrow_mode = (width < 600);
        if (tile->narrow_mode != narrow_mode) {
                tile->narrow_mode = narrow_mode;
                gs_feature_tile_refresh (GS_APP_TILE (tile));
diff --git a/src/gs-picture.c b/src/gs-picture.c
index ed227f861..d07f6c0f2 100644
--- a/src/gs-picture.c
+++ b/src/gs-picture.c
@@ -229,36 +229,6 @@ gs_picture_get_preferred_height (GtkWidget *widget,
                            minimum, natural, NULL, NULL);
 }
 
-/* This is derived from the private adw_css_size_allocate_self() from Libhandy. */
-static void
-css_size_allocate_self (GtkWidget *widget, GtkAllocation *allocation)
-{
-       GtkStyleContext *style_context;
-       GtkStateFlags state_flags;
-       GtkBorder margin;
-
-       /* Manually apply the border, the padding and the margin as we can't use the
-        * private GtkGadget.
-        */
-       style_context = gtk_widget_get_style_context (widget);
-       state_flags = gtk_widget_get_state_flags (widget);
-
-       gtk_style_context_get_margin (style_context, state_flags, &margin);
-
-       allocation->width -= margin.left + margin.right;
-       allocation->height -= margin.top + margin.bottom;
-       allocation->x += margin.left;
-       allocation->y += margin.top;
-}
-
-static void
-gs_picture_size_allocate (GtkWidget    *widget,
-                         GtkAllocation *allocation)
-{
-       css_size_allocate_self (widget, allocation);
-       gtk_widget_set_allocation (widget, allocation);
-}
-
 /* This is derived from the private get_video_box() from RetroGTK.
  * I (Adrien Plazas) wrote that original code and the initial GsPicture, I
  * accept to license it as GPL-2.0+ so it can be used here. */
@@ -406,7 +376,6 @@ gs_picture_class_init (GsPictureClass *klass)
        widget_class->get_preferred_height = gs_picture_get_preferred_height;
        widget_class->get_preferred_height_for_width = gs_picture_get_preferred_height_for_width;
        widget_class->get_preferred_height_and_baseline_for_width = 
gs_picture_get_preferred_height_and_baseline_for_width;
-       widget_class->size_allocate = gs_picture_size_allocate;
        widget_class->draw = gs_picture_draw;
 
        /**
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 75830debe..6036c2263 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -2505,11 +2505,17 @@ allocation_changed_cb (gpointer user_data)
 }
 
 static void
-gs_shell_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+gs_shell_size_allocate (GtkWidget *widget,
+                        gint       width,
+                        gint       height,
+                        gint       baseline)
 {
        GsShell *shell = GS_SHELL (widget);
 
-       GTK_WIDGET_CLASS (gs_shell_parent_class)->size_allocate (widget, allocation);
+       GTK_WIDGET_CLASS (gs_shell_parent_class)->size_allocate (widget,
+                                                                width,
+                                                                height,
+                                                                baseline);
 
        /* Delay updating is-narrow so children can adapt to it, which isn't
         * possible during the widget's allocation phase as it would break their


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