[gnome-software: 28/110] Replace GtkBin by GtkBinLayout




commit 03f1d3f6f9c9d5f1f3c1e334f848e9bfa4de006c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Aug 22 21:01:57 2021 -0300

    Replace GtkBin by GtkBinLayout
    
    GtkBin is no more. Instead, subclass GtkWidget and set the default
    layout manager to GtkBinLayout, which should replicate the behavior
    of the old GtkBin.
    
    The `GsReviewBar` is so simple that it doesn’t need a layout manager.

 src/gs-page.c              | 5 ++++-
 src/gs-page.h              | 4 ++--
 src/gs-review-bar.c        | 4 ++--
 src/gs-review-bar.h        | 2 +-
 src/gs-review-histogram.c  | 3 ++-
 src/gs-review-histogram.h  | 4 ++--
 src/gs-review-histogram.ui | 2 +-
 src/gs-rounded-bin.c       | 5 +++--
 src/gs-rounded-bin.h       | 2 +-
 src/gs-screenshot-image.c  | 5 +++--
 src/gs-screenshot-image.h  | 2 +-
 src/gs-screenshot-image.ui | 2 +-
 src/gs-star-widget.c       | 3 ++-
 src/gs-star-widget.h       | 4 ++--
 src/gs-star-widget.ui      | 2 +-
 src/gs-upgrade-banner.c    | 3 ++-
 src/gs-upgrade-banner.h    | 4 ++--
 src/gs-upgrade-banner.ui   | 2 +-
 18 files changed, 33 insertions(+), 25 deletions(-)
---
diff --git a/src/gs-page.c b/src/gs-page.c
index 09ba0710a..ad0f8a339 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -26,7 +26,7 @@ typedef struct
        gboolean                 is_active;
 } GsPagePrivate;
 
-G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsPage, gs_page, GTK_TYPE_BIN)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsPage, gs_page, GTK_TYPE_WIDGET)
 
 typedef enum {
        PROP_TITLE = 1,
@@ -831,6 +831,7 @@ static void
 gs_page_class_init (GsPageClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
        object_class->get_property = gs_page_get_property;
        object_class->dispose = gs_page_dispose;
@@ -875,6 +876,8 @@ gs_page_class_init (GsPageClass *klass)
                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
        g_object_class_install_properties (object_class, G_N_ELEMENTS (obj_props), obj_props);
+
+       gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 }
 
 GsPage *
diff --git a/src/gs-page.h b/src/gs-page.h
index 186186b20..851c933a1 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -15,11 +15,11 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_PAGE (gs_page_get_type ())
 
-G_DECLARE_DERIVABLE_TYPE (GsPage, gs_page, GS, PAGE, GtkBin)
+G_DECLARE_DERIVABLE_TYPE (GsPage, gs_page, GS, PAGE, GtkWidget)
 
 struct _GsPageClass
 {
-       GtkBinClass      parent_class;
+       GtkWidgetClass   parent_class;
 
        void            (*app_installed)        (GsPage          *page,
                                                 GsApp           *app);
diff --git a/src/gs-review-bar.c b/src/gs-review-bar.c
index 8bff73dc0..8b4e50453 100644
--- a/src/gs-review-bar.c
+++ b/src/gs-review-bar.c
@@ -14,11 +14,11 @@
 
 struct _GsReviewBar
 {
-       GtkBin           parent_instance;
+       GtkWidget        parent_instance;
        gdouble          fraction;
 };
 
-G_DEFINE_TYPE (GsReviewBar, gs_review_bar, GTK_TYPE_BIN)
+G_DEFINE_TYPE (GsReviewBar, gs_review_bar, GTK_TYPE_WIDGET)
 
 void
 gs_review_bar_set_fraction (GsReviewBar *bar, gdouble fraction)
diff --git a/src/gs-review-bar.h b/src/gs-review-bar.h
index e09dca005..7fab0b334 100644
--- a/src/gs-review-bar.h
+++ b/src/gs-review-bar.h
@@ -14,7 +14,7 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_REVIEW_BAR (gs_review_bar_get_type ())
 
-G_DECLARE_FINAL_TYPE (GsReviewBar, gs_review_bar, GS, REVIEW_BAR, GtkBin)
+G_DECLARE_FINAL_TYPE (GsReviewBar, gs_review_bar, GS, REVIEW_BAR, GtkWidget)
 
 GtkWidget      *gs_review_bar_new              (void);
 
diff --git a/src/gs-review-histogram.c b/src/gs-review-histogram.c
index fd345a78c..173dd2990 100644
--- a/src/gs-review-histogram.c
+++ b/src/gs-review-histogram.c
@@ -30,7 +30,7 @@ typedef struct
        GtkWidget       *star_value_5;
 } GsReviewHistogramPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsReviewHistogram, gs_review_histogram, GTK_TYPE_BIN)
+G_DEFINE_TYPE_WITH_PRIVATE (GsReviewHistogram, gs_review_histogram, GTK_TYPE_WIDGET)
 
 void
 gs_review_histogram_set_ratings (GsReviewHistogram *histogram,
@@ -99,6 +99,7 @@ gs_review_histogram_class_init (GsReviewHistogramClass *klass)
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Software/gs-review-histogram.ui");
+       gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 
        gtk_widget_class_bind_template_child_private (widget_class, GsReviewHistogram, bar5);
        gtk_widget_class_bind_template_child_private (widget_class, GsReviewHistogram, bar4);
diff --git a/src/gs-review-histogram.h b/src/gs-review-histogram.h
index ada80736e..bd0fbf8bf 100644
--- a/src/gs-review-histogram.h
+++ b/src/gs-review-histogram.h
@@ -14,11 +14,11 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_REVIEW_HISTOGRAM (gs_review_histogram_get_type ())
 
-G_DECLARE_DERIVABLE_TYPE (GsReviewHistogram, gs_review_histogram, GS, REVIEW_HISTOGRAM, GtkBin)
+G_DECLARE_DERIVABLE_TYPE (GsReviewHistogram, gs_review_histogram, GS, REVIEW_HISTOGRAM, GtkWidget)
 
 struct _GsReviewHistogramClass
 {
-       GtkBinClass      parent_class;
+       GtkWidgetClass   parent_class;
 };
 
 GtkWidget      *gs_review_histogram_new                        (void);
diff --git a/src/gs-review-histogram.ui b/src/gs-review-histogram.ui
index 75928e698..2a9d7d0b8 100644
--- a/src/gs-review-histogram.ui
+++ b/src/gs-review-histogram.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
-  <template class="GsReviewHistogram" parent="GtkBin">
+  <template class="GsReviewHistogram" parent="GtkWidget">
     <property name="visible">True</property>
     <child>
       <object class="GtkGrid" id="grid1">
diff --git a/src/gs-rounded-bin.c b/src/gs-rounded-bin.c
index 79eb8faa9..07dccf2dd 100644
--- a/src/gs-rounded-bin.c
+++ b/src/gs-rounded-bin.c
@@ -55,13 +55,13 @@ typedef enum {
 
 struct _GsRoundedBin
 {
-       GtkBin           parent_instance;
+       GtkWidget        parent_instance;
 
        gint             last_border_radius;
        cairo_surface_t *masks[4];  /* (owned) (indexed-by GsCornerType) */
 };
 
-G_DEFINE_TYPE (GsRoundedBin, gs_rounded_bin, GTK_TYPE_BIN)
+G_DEFINE_TYPE (GsRoundedBin, gs_rounded_bin, GTK_TYPE_WIDGET)
 
 static void clear_masks (GsRoundedBin *self);
 
@@ -256,4 +256,5 @@ gs_rounded_bin_class_init (GsRoundedBinClass *klass)
        widget_class->draw = gs_rounded_bin_draw;
 
        gtk_widget_class_set_css_name (widget_class, "rounded-bin");
+       gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 }
diff --git a/src/gs-rounded-bin.h b/src/gs-rounded-bin.h
index c8799b438..987218223 100644
--- a/src/gs-rounded-bin.h
+++ b/src/gs-rounded-bin.h
@@ -18,6 +18,6 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_ROUNDED_BIN (gs_rounded_bin_get_type ())
 
-G_DECLARE_FINAL_TYPE (GsRoundedBin, gs_rounded_bin, GS, ROUNDED_BIN, GtkBin)
+G_DECLARE_FINAL_TYPE (GsRoundedBin, gs_rounded_bin, GS, ROUNDED_BIN, GtkWidget)
 
 G_END_DECLS
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index b9a8de9fe..8839651b2 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -20,7 +20,7 @@
 
 struct _GsScreenshotImage
 {
-       GtkBin           parent_instance;
+       GtkWidget        parent_instance;
 
        AsScreenshot    *screenshot;
        GtkWidget       *spinner;
@@ -41,7 +41,7 @@ struct _GsScreenshotImage
        gboolean         showing_image;
 };
 
-G_DEFINE_TYPE (GsScreenshotImage, gs_screenshot_image, GTK_TYPE_BIN)
+G_DEFINE_TYPE (GsScreenshotImage, gs_screenshot_image, GTK_TYPE_WIDGET)
 
 AsScreenshot *
 gs_screenshot_image_get_screenshot (GsScreenshotImage *ssimg)
@@ -723,6 +723,7 @@ gs_screenshot_image_class_init (GsScreenshotImageClass *klass)
 
        gtk_widget_class_set_template_from_resource (widget_class,
                                                     "/org/gnome/Software/gs-screenshot-image.ui");
+       gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 
        gtk_widget_class_bind_template_child (widget_class, GsScreenshotImage, spinner);
        gtk_widget_class_bind_template_child (widget_class, GsScreenshotImage, stack);
diff --git a/src/gs-screenshot-image.h b/src/gs-screenshot-image.h
index 9d1bfb493..418db4c88 100644
--- a/src/gs-screenshot-image.h
+++ b/src/gs-screenshot-image.h
@@ -19,7 +19,7 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_SCREENSHOT_IMAGE (gs_screenshot_image_get_type ())
 
-G_DECLARE_FINAL_TYPE (GsScreenshotImage, gs_screenshot_image, GS, SCREENSHOT_IMAGE, GtkBin)
+G_DECLARE_FINAL_TYPE (GsScreenshotImage, gs_screenshot_image, GS, SCREENSHOT_IMAGE, GtkWidget)
 
 GtkWidget      *gs_screenshot_image_new                (SoupSession            *session);
 
diff --git a/src/gs-screenshot-image.ui b/src/gs-screenshot-image.ui
index c01ea8386..07daca8c5 100644
--- a/src/gs-screenshot-image.ui
+++ b/src/gs-screenshot-image.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
-  <template class="GsScreenshotImage" parent="GtkBin">
+  <template class="GsScreenshotImage" parent="GtkWidget">
     <property name="visible">True</property>
     <style>
       <class name="screenshot-image"/>
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index 5c909c2b4..ef3193878 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -24,7 +24,7 @@ typedef struct
        GtkWidget       *images[5];
 } GsStarWidgetPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsStarWidget, gs_star_widget, GTK_TYPE_BIN)
+G_DEFINE_TYPE_WITH_PRIVATE (GsStarWidget, gs_star_widget, GTK_TYPE_WIDGET)
 
 typedef enum {
        PROP_ICON_SIZE = 1,
@@ -311,6 +311,7 @@ gs_star_widget_class_init (GsStarWidgetClass *klass)
        g_object_class_install_properties (object_class, G_N_ELEMENTS (properties), properties);
 
        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-star-widget.ui");
+       gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
        gtk_widget_class_bind_template_child_private (widget_class, GsStarWidget, box1);
 }
 
diff --git a/src/gs-star-widget.h b/src/gs-star-widget.h
index baa138284..cea155758 100644
--- a/src/gs-star-widget.h
+++ b/src/gs-star-widget.h
@@ -17,11 +17,11 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_STAR_WIDGET (gs_star_widget_get_type ())
 
-G_DECLARE_DERIVABLE_TYPE (GsStarWidget, gs_star_widget, GS, STAR_WIDGET, GtkBin)
+G_DECLARE_DERIVABLE_TYPE (GsStarWidget, gs_star_widget, GS, STAR_WIDGET, GtkWidget)
 
 struct _GsStarWidgetClass
 {
-       GtkBinClass      parent_class;
+       GtkWidgetClass   parent_class;
 
        void                    (*rating_changed)               (GsStarWidget   *star);
 };
diff --git a/src/gs-star-widget.ui b/src/gs-star-widget.ui
index 21621d1d3..7d2d8c110 100644
--- a/src/gs-star-widget.ui
+++ b/src/gs-star-widget.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
-  <template class="GsStarWidget" parent="GtkBin">
+  <template class="GsStarWidget" parent="GtkWidget">
     <property name="visible">True</property>
     <child>
       <object class="GtkBox" id="box1">
diff --git a/src/gs-upgrade-banner.c b/src/gs-upgrade-banner.c
index f8b800e4e..3af491155 100644
--- a/src/gs-upgrade-banner.c
+++ b/src/gs-upgrade-banner.c
@@ -36,7 +36,7 @@ typedef struct
        GtkCssProvider  *banner_provider;  /* (owned) (nullable) */
 } GsUpgradeBannerPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsUpgradeBanner, gs_upgrade_banner, GTK_TYPE_BIN)
+G_DEFINE_TYPE_WITH_PRIVATE (GsUpgradeBanner, gs_upgrade_banner, GTK_TYPE_WIDGET)
 
 enum {
        SIGNAL_DOWNLOAD_CLICKED,
@@ -374,6 +374,7 @@ gs_upgrade_banner_class_init (GsUpgradeBannerClass *klass)
                              G_TYPE_NONE, 0);
 
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Software/gs-upgrade-banner.ui");
+       gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 
        gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, box_upgrades_info);
        gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, box_upgrades_download);
diff --git a/src/gs-upgrade-banner.h b/src/gs-upgrade-banner.h
index 51380b9b7..2ddf6021e 100644
--- a/src/gs-upgrade-banner.h
+++ b/src/gs-upgrade-banner.h
@@ -16,11 +16,11 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_UPGRADE_BANNER (gs_upgrade_banner_get_type ())
 
-G_DECLARE_DERIVABLE_TYPE (GsUpgradeBanner, gs_upgrade_banner, GS, UPGRADE_BANNER, GtkBin)
+G_DECLARE_DERIVABLE_TYPE (GsUpgradeBanner, gs_upgrade_banner, GS, UPGRADE_BANNER, GtkWidget)
 
 struct _GsUpgradeBannerClass
 {
-       GtkBinClass      parent_class;
+       GtkWidgetClass   parent_class;
 
        void            (*download_clicked)     (GsUpgradeBanner        *self);
        void            (*install_clicked)      (GsUpgradeBanner        *self);
diff --git a/src/gs-upgrade-banner.ui b/src/gs-upgrade-banner.ui
index 92e1f1b4f..fc809a657 100644
--- a/src/gs-upgrade-banner.ui
+++ b/src/gs-upgrade-banner.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
-  <template class="GsUpgradeBanner" parent="GtkBin">
+  <template class="GsUpgradeBanner" parent="GtkWidget">
     <child>
       <object class="GtkBox" id="vbox">
         <property name="visible">True</property>


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