[gnome-software: 5/9] upgrade-banner: Subclass AdwBin




commit 5f958b60ceb510c1b4c93ce4bb735cf5c595559b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Aug 18 15:14:39 2022 -0300

    upgrade-banner: Subclass AdwBin
    
    Now that GsUpdatesPage is properly disposed, it revealed that
    GsUpgradeBanner was not unparenting its only child, a GtkBox.
    This triggers a GTK warning.
    
    This could have been worked around by unparenting this single
    box, but libadwaita provides a widget tailored for single
    child widgets: AdwBin. It also takes care of disposing for us,
    and is generally a better option here.
    
    Make GsUpgradeBanner subclass AdwBin.

 src/gs-upgrade-banner.c  | 3 +--
 src/gs-upgrade-banner.h  | 6 +++---
 src/gs-upgrade-banner.ui | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-upgrade-banner.c b/src/gs-upgrade-banner.c
index f0b340726..8a5e6a29e 100644
--- a/src/gs-upgrade-banner.c
+++ b/src/gs-upgrade-banner.c
@@ -35,7 +35,7 @@ typedef struct
        GtkCssProvider  *banner_provider;  /* (owned) (nullable) */
 } GsUpgradeBannerPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsUpgradeBanner, gs_upgrade_banner, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE_WITH_PRIVATE (GsUpgradeBanner, gs_upgrade_banner, ADW_TYPE_BIN)
 
 enum {
        SIGNAL_DOWNLOAD_CLICKED,
@@ -348,7 +348,6 @@ 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 2ddf6021e..7aff12ba0 100644
--- a/src/gs-upgrade-banner.h
+++ b/src/gs-upgrade-banner.h
@@ -8,7 +8,7 @@
 
 #pragma once
 
-#include <gtk/gtk.h>
+#include <adwaita.h>
 
 #include "gnome-software-private.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, GtkWidget)
+G_DECLARE_DERIVABLE_TYPE (GsUpgradeBanner, gs_upgrade_banner, GS, UPGRADE_BANNER, AdwBin)
 
 struct _GsUpgradeBannerClass
 {
-       GtkWidgetClass   parent_class;
+       AdwBinClass      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 1f0f6abef..3ea236bd3 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="GtkWidget">
+  <template class="GsUpgradeBanner" parent="AdwBin">
     <child>
       <object class="GtkBox" id="vbox">
         <property name="orientation">vertical</property>


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