[gnome-builder/wip/gtk4-port] plugins/buildui: Port GbpBuilduiStageRow to GTK4



commit 4c118c624338ccc018f697a016b4081bc88e4e0c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Apr 26 16:59:13 2022 -0300

    plugins/buildui: Port GbpBuilduiStageRow to GTK4

 src/plugins/buildui/gbp-buildui-stage-row.c  | 40 +++++++++++++++++++---------
 src/plugins/buildui/gbp-buildui-stage-row.ui |  4 +--
 src/plugins/buildui/meson.build              |  2 +-
 3 files changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/src/plugins/buildui/gbp-buildui-stage-row.c b/src/plugins/buildui/gbp-buildui-stage-row.c
index 3e1bcf11d..2c87c89a2 100644
--- a/src/plugins/buildui/gbp-buildui-stage-row.c
+++ b/src/plugins/buildui/gbp-buildui-stage-row.c
@@ -22,8 +22,6 @@
 
 #include "config.h"
 
-#include <dazzle.h>
-
 #include "gbp-buildui-stage-row.h"
 
 struct _GbpBuilduiStageRow
@@ -32,7 +30,7 @@ struct _GbpBuilduiStageRow
 
   IdePipelineStage   *stage;
 
-  DzlBoldingLabel *label;
+  GtkLabel           *label;
 };
 
 enum {
@@ -45,6 +43,20 @@ G_DEFINE_FINAL_TYPE (GbpBuilduiStageRow, gbp_buildui_stage_row, GTK_TYPE_LIST_BO
 
 static GParamSpec *properties [N_PROPS];
 
+static void
+gbp_buildui_stage_row_notify_active (GbpBuilduiStageRow *row,
+                                     GParamSpec         *pspec,
+                                     IdePipelineStage   *stage)
+{
+  g_assert (GBP_IS_BUILDUI_STAGE_ROW (row));
+  g_assert (IDE_IS_PIPELINE_STAGE (stage));
+
+  if (ide_pipeline_stage_get_active (stage))
+    gtk_widget_add_css_class (GTK_WIDGET (row->label), "heading");
+  else
+    gtk_widget_remove_css_class (GTK_WIDGET (row->label), "heading");
+}
+
 static void
 gbp_buildui_stage_row_notify_completed (GbpBuilduiStageRow *row,
                                       GParamSpec       *pspec,
@@ -54,9 +66,9 @@ gbp_buildui_stage_row_notify_completed (GbpBuilduiStageRow *row,
   g_assert (IDE_IS_PIPELINE_STAGE (stage));
 
   if (ide_pipeline_stage_get_completed (stage))
-    dzl_gtk_widget_add_style_class (GTK_WIDGET (row->label), "dim-label");
+    gtk_widget_add_css_class (GTK_WIDGET (row->label), "dim-label");
   else
-    dzl_gtk_widget_remove_style_class (GTK_WIDGET (row->label), "dim-label");
+    gtk_widget_remove_css_class (GTK_WIDGET (row->label), "dim-label");
 }
 
 static void
@@ -75,7 +87,7 @@ gbp_buildui_stage_row_set_stage (GbpBuilduiStageRow *self,
   if (name == NULL)
     name = G_OBJECT_TYPE_NAME (stage);
 
-  gtk_label_set_label (GTK_LABEL (self->label), name);
+  gtk_label_set_label (self->label, name);
 
   g_signal_connect_object (stage,
                            "notify::completed",
@@ -83,6 +95,12 @@ gbp_buildui_stage_row_set_stage (GbpBuilduiStageRow *self,
                            self,
                            G_CONNECT_SWAPPED);
 
+  g_signal_connect_object (stage,
+                           "notify::active",
+                           G_CALLBACK (gbp_buildui_stage_row_notify_active),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   g_object_bind_property (stage, "disabled", self, "sensitive", G_BINDING_DEFAULT);
   g_object_bind_property (stage, "active", self->label, "bold", G_BINDING_DEFAULT);
 
@@ -90,13 +108,13 @@ gbp_buildui_stage_row_set_stage (GbpBuilduiStageRow *self,
 }
 
 static void
-gbp_buildui_stage_row_destroy (GtkWidget *widget)
+gbp_buildui_stage_row_dispose (GObject *object)
 {
-  GbpBuilduiStageRow *self = (GbpBuilduiStageRow *)widget;
+  GbpBuilduiStageRow *self = (GbpBuilduiStageRow *)object;
 
   g_clear_object (&self->stage);
 
-  GTK_WIDGET_CLASS (gbp_buildui_stage_row_parent_class)->destroy (widget);
+  G_OBJECT_CLASS (gbp_buildui_stage_row_parent_class)->dispose (object);
 }
 
 static void
@@ -143,11 +161,10 @@ gbp_buildui_stage_row_class_init (GbpBuilduiStageRowClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = gbp_buildui_stage_row_dispose;
   object_class->get_property = gbp_buildui_stage_row_get_property;
   object_class->set_property = gbp_buildui_stage_row_set_property;
 
-  widget_class->destroy = gbp_buildui_stage_row_destroy;
-
   properties [PROP_STAGE] =
     g_param_spec_object ("stage",
                          "Stage",
@@ -175,7 +192,6 @@ gbp_buildui_stage_row_new (IdePipelineStage *stage)
 
   return g_object_new (GBP_TYPE_BUILDUI_STAGE_ROW,
                        "stage", stage,
-                       "visible", TRUE,
                        NULL);
 }
 
diff --git a/src/plugins/buildui/gbp-buildui-stage-row.ui b/src/plugins/buildui/gbp-buildui-stage-row.ui
index 9eb96f579..4931ddef3 100644
--- a/src/plugins/buildui/gbp-buildui-stage-row.ui
+++ b/src/plugins/buildui/gbp-buildui-stage-row.ui
@@ -3,11 +3,9 @@
   <template class="GbpBuilduiStageRow" parent="GtkListBoxRow">
     <child>
       <object class="GtkBox">
-        <property name="visible">true</property>
         <property name="orientation">horizontal</property>
         <child>
-          <object class="DzlBoldingLabel" id="label">
-            <property name="visible">true</property>
+          <object class="GtkLabel" id="label">
             <property name="xalign">0.0</property>
           </object>
         </child>
diff --git a/src/plugins/buildui/meson.build b/src/plugins/buildui/meson.build
index c3c3a6b83..1da9aba2b 100644
--- a/src/plugins/buildui/meson.build
+++ b/src/plugins/buildui/meson.build
@@ -8,7 +8,7 @@ plugins_sources += files([
   #'gbp-buildui-pane.c',
   #'gbp-buildui-runtime-categories.c',
   #'gbp-buildui-runtime-row.c',
-  #'gbp-buildui-stage-row.c',
+  'gbp-buildui-stage-row.c',
   #'gbp-buildui-tree-addin.c',
   #'gbp-buildui-workspace-addin.c',
 ])


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