[gnome-builder/wip/gtk4-port: 218/736] libide/greeter: port rows to GTK 4




commit 41a633b260e2daf3fd0b285980cc0d4e4e4c6264
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 30 13:49:59 2022 -0700

    libide/greeter: port rows to GTK 4

 src/libide/greeter/ide-greeter-row.c  | 32 +++++++++++---------------------
 src/libide/greeter/ide-greeter-row.ui |  6 ------
 2 files changed, 11 insertions(+), 27 deletions(-)
---
diff --git a/src/libide/greeter/ide-greeter-row.c b/src/libide/greeter/ide-greeter-row.c
index 069f5bbe2..64c477d65 100644
--- a/src/libide/greeter/ide-greeter-row.c
+++ b/src/libide/greeter/ide-greeter-row.c
@@ -74,23 +74,14 @@ ide_greeter_row_new (void)
 }
 
 static void
-ide_greeter_row_get_preferred_width (GtkWidget *widget,
-                                     gint      *min_width,
-                                     gint      *nat_width)
-{
-  *min_width = 600;
-  *nat_width = 600;
-}
-
-static void
-ide_greeter_row_finalize (GObject *object)
+ide_greeter_row_dispose (GObject *object)
 {
   IdeGreeterRow *self = (IdeGreeterRow *)object;
   IdeGreeterRowPrivate *priv = ide_greeter_row_get_instance_private (self);
 
   g_clear_object (&priv->project_info);
 
-  G_OBJECT_CLASS (ide_greeter_row_parent_class)->finalize (object);
+  G_OBJECT_CLASS (ide_greeter_row_parent_class)->dispose (object);
 }
 
 static void
@@ -149,12 +140,10 @@ ide_greeter_row_class_init (IdeGreeterRowClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->finalize = ide_greeter_row_finalize;
+  object_class->dispose = ide_greeter_row_dispose;
   object_class->get_property = ide_greeter_row_get_property;
   object_class->set_property = ide_greeter_row_set_property;
 
-  widget_class->get_preferred_width = ide_greeter_row_get_preferred_width;
-
   /**
    * IdeGreeterRow:project-info:
    *
@@ -211,15 +200,16 @@ static void
 ide_greeter_row_clear (IdeGreeterRow *self)
 {
   IdeGreeterRowPrivate *priv = ide_greeter_row_get_instance_private (self);
+  GtkWidget *child;
 
   g_assert (IDE_IS_GREETER_ROW (self));
 
   g_object_set (priv->image, "icon-name", NULL, NULL);
   gtk_label_set_label (priv->title, NULL);
   gtk_label_set_label (priv->subtitle, NULL);
-  gtk_container_foreach (GTK_CONTAINER (priv->tags),
-                         (GtkCallback)gtk_widget_destroy,
-                         NULL);
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (priv->tags))))
+    gtk_box_remove (priv->tags, child);
 }
 
 /**
@@ -311,13 +301,13 @@ ide_greeter_row_set_project_info (IdeGreeterRow  *self,
           for (guint i = 0; i < parts->len; i++)
             {
               const gchar *key = g_ptr_array_index (parts, i);
-              DzlPillBox *tag;
+              GtkLabel *tag;
 
-              tag = g_object_new (DZL_TYPE_PILL_BOX,
-                                  "visible", TRUE,
+              tag = g_object_new (GTK_TYPE_LABEL,
                                   "label", key,
                                   NULL);
-              gtk_container_add (GTK_CONTAINER (priv->tags), GTK_WIDGET (tag));
+              gtk_widget_add_css_class (GTK_WIDGET (tag), "pill");
+              gtk_box_append (priv->tags, GTK_WIDGET (tag));
             }
 
           if (icon != NULL)
diff --git a/src/libide/greeter/ide-greeter-row.ui b/src/libide/greeter/ide-greeter-row.ui
index 8f6d301d9..33ae081de 100644
--- a/src/libide/greeter/ide-greeter-row.ui
+++ b/src/libide/greeter/ide-greeter-row.ui
@@ -10,7 +10,6 @@
         <property name="margin-end">18</property>
         <property name="orientation">horizontal</property>
         <property name="spacing">12</property>
-        <property name="visible">true</property>
         <child>
           <object class="GtkCheckButton" id="check_button">
             <property name="margin-end">6</property>
@@ -29,11 +28,9 @@
             <property name="hexpand">true</property>
             <property name="orientation">vertical</property>
             <property name="spacing">6</property>
-            <property name="visible">true</property>
             <child>
               <object class="GtkLabel" id="title">
                 <property name="ellipsize">end</property>
-                <property name="visible">true</property>
                 <property name="xalign">0.0</property>
                 <attributes>
                   <attribute name="weight" value="bold"/>
@@ -43,7 +40,6 @@
             <child>
               <object class="GtkLabel" id="subtitle">
                 <property name="ellipsize">end</property>
-                <property name="visible">true</property>
                 <property name="xalign">0.0</property>
                 <style>
                   <class name="dim-label"/>
@@ -56,14 +52,12 @@
           <object class="GtkBox" id="tags">
             <property name="spacing">6</property>
             <property name="valign">center</property>
-            <property name="visible">true</property>
           </object>
         </child>
         <child>
           <object class="GtkImage">
             <property name="icon-name">go-next-symbolic</property>
             <property name="margin-start">6</property>
-            <property name="visible">true</property>
           </object>
         </child>
       </object>


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