[gnome-builder/wip/gtk4-port: 1667/1774] plugins/buildui: use fake action row for progress info




commit d21ceee793dd7bf791aae797fdc151b92f3cdf28
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 27 12:50:22 2022 -0700

    plugins/buildui: use fake action row for progress info
    
    The spinner doesn't even seem to always spin correctly, likely a bug in
    GTK. But either way, we can provide more information than a spinner,
    specifically to help the case when the build system needs to be advanced
    like for Meson.

 src/plugins/buildui/gbp-buildui-runnables-dialog.c |  79 +++++++-------
 .../buildui/gbp-buildui-runnables-dialog.ui        | 117 ++++++++++++---------
 2 files changed, 107 insertions(+), 89 deletions(-)
---
diff --git a/src/plugins/buildui/gbp-buildui-runnables-dialog.c 
b/src/plugins/buildui/gbp-buildui-runnables-dialog.c
index 87dab08e9..28ba6af1b 100644
--- a/src/plugins/buildui/gbp-buildui-runnables-dialog.c
+++ b/src/plugins/buildui/gbp-buildui-runnables-dialog.c
@@ -34,9 +34,9 @@
 struct _GbpBuilduiRunnablesDialog
 {
   AdwWindow           parent_instance;
+  IdeContext         *context;
   GtkListBox         *list_box;
   AdwPreferencesPage *page;
-  GtkSpinner         *spinner;
   GtkStack           *stack;
   guint               busy : 1;
 };
@@ -45,7 +45,6 @@ G_DEFINE_FINAL_TYPE (GbpBuilduiRunnablesDialog, gbp_buildui_runnables_dialog, AD
 
 enum {
   PROP_0,
-  PROP_BUSY,
   PROP_CONTEXT,
   N_PROPS
 };
@@ -148,12 +147,12 @@ gbp_buildui_runnables_dialog_list_commands_cb (GObject      *object,
 
   IDE_ENTRY;
 
+  g_assert (IDE_IS_MAIN_THREAD ());
   g_assert (IDE_IS_RUN_MANAGER (run_manager));
   g_assert (G_IS_ASYNC_RESULT (result));
   g_assert (GBP_IS_BUILDUI_RUNNABLES_DIALOG (self));
 
-  self->busy = FALSE;
-  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BUSY]);
+  gtk_stack_set_visible_child_name (self->stack, "list");
 
   if (!(model = ide_run_manager_list_commands_finish (run_manager, result, &error)))
     {
@@ -171,22 +170,42 @@ gbp_buildui_runnables_dialog_list_commands_cb (GObject      *object,
 }
 
 static void
-gbp_buildui_runnables_dialog_set_context (GbpBuilduiRunnablesDialog *self,
-                                          IdeContext                *context)
+new_run_command_action (GtkWidget  *widget,
+                        const char *action_name,
+                        GVariant   *param)
+{
+  GbpBuilduiRunnablesDialog *self = (GbpBuilduiRunnablesDialog *)widget;
+  IdeWorkspace *workspace;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_BUILDUI_RUNNABLES_DIALOG (self));
+
+  workspace = ide_widget_get_workspace (GTK_WIDGET (self));
+  gtk_widget_activate_action (GTK_WIDGET (workspace),
+                              "workbench.configure-page",
+                              "s", "commands");
+  gtk_window_destroy (GTK_WINDOW (self));
+
+  IDE_EXIT;
+}
+
+static void
+gbp_buildui_runnables_dialog_realize (GtkWidget *widget)
 {
+  GbpBuilduiRunnablesDialog *self = (GbpBuilduiRunnablesDialog *)widget;
   IdeRunManager *run_manager;
 
   IDE_ENTRY;
 
   g_assert (GBP_IS_BUILDUI_RUNNABLES_DIALOG (self));
-  g_assert (!context || IDE_IS_CONTEXT (context));
+  g_assert (IDE_IS_CONTEXT (self->context));
 
-  if (context == NULL)
-    IDE_EXIT;
+  GTK_WIDGET_CLASS (gbp_buildui_runnables_dialog_parent_class)->realize (widget);
 
-  self->busy = TRUE;
+  gtk_stack_set_visible_child_name (self->stack, "loading");
 
-  run_manager = ide_run_manager_from_context (context);
+  run_manager = ide_run_manager_from_context (self->context);
   gtk_widget_insert_action_group (GTK_WIDGET (self),
                                   "run-manager",
                                   G_ACTION_GROUP (run_manager));
@@ -195,30 +214,17 @@ gbp_buildui_runnables_dialog_set_context (GbpBuilduiRunnablesDialog *self,
                                        gbp_buildui_runnables_dialog_list_commands_cb,
                                        g_object_ref (self));
 
-  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BUSY]);
-
   IDE_EXIT;
 }
 
 static void
-new_run_command_action (GtkWidget  *widget,
-                        const char *action_name,
-                        GVariant   *param)
+gbp_buildui_runnables_dialog_dispose (GObject *object)
 {
-  GbpBuilduiRunnablesDialog *self = (GbpBuilduiRunnablesDialog *)widget;
-  IdeWorkspace *workspace;
-
-  IDE_ENTRY;
-
-  g_assert (GBP_IS_BUILDUI_RUNNABLES_DIALOG (self));
+  GbpBuilduiRunnablesDialog *self = (GbpBuilduiRunnablesDialog *)object;
 
-  workspace = ide_widget_get_workspace (GTK_WIDGET (self));
-  gtk_widget_activate_action (GTK_WIDGET (workspace),
-                              "workbench.configure-page",
-                              "s", "commands");
-  gtk_window_destroy (GTK_WINDOW (self));
+  g_clear_object (&self->context);
 
-  IDE_EXIT;
+  G_OBJECT_CLASS (gbp_buildui_runnables_dialog_parent_class)->dispose (object);
 }
 
 static void
@@ -231,8 +237,8 @@ gbp_buildui_runnables_dialog_get_property (GObject    *object,
 
   switch (prop_id)
     {
-    case PROP_BUSY:
-      g_value_set_boolean (value, self->busy);
+    case PROP_CONTEXT:
+      g_value_set_object (value, self->context);
       break;
 
     default:
@@ -251,7 +257,7 @@ gbp_buildui_runnables_dialog_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_CONTEXT:
-      gbp_buildui_runnables_dialog_set_context (self, g_value_get_object (value));
+      self->context = g_value_dup_object (value);
       break;
 
     default:
@@ -262,21 +268,19 @@ gbp_buildui_runnables_dialog_set_property (GObject      *object,
 static void
 gbp_buildui_runnables_dialog_class_init (GbpBuilduiRunnablesDialogClass *klass)
 {
-  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = gbp_buildui_runnables_dialog_dispose;
   object_class->get_property = gbp_buildui_runnables_dialog_get_property;
   object_class->set_property = gbp_buildui_runnables_dialog_set_property;
 
-  properties [PROP_BUSY] =
-    g_param_spec_boolean ("busy", NULL, NULL,
-                          FALSE,
-                          (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  widget_class->realize = gbp_buildui_runnables_dialog_realize;
 
   properties [PROP_CONTEXT] =
     g_param_spec_object ("context", NULL, NULL,
                          IDE_TYPE_CONTEXT,
-                         (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_properties (object_class, N_PROPS, properties);
 
@@ -287,7 +291,6 @@ gbp_buildui_runnables_dialog_class_init (GbpBuilduiRunnablesDialogClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, 
"/plugins/buildui/gbp-buildui-runnables-dialog.ui");
   gtk_widget_class_bind_template_child (widget_class, GbpBuilduiRunnablesDialog, list_box);
   gtk_widget_class_bind_template_child (widget_class, GbpBuilduiRunnablesDialog, page);
-  gtk_widget_class_bind_template_child (widget_class, GbpBuilduiRunnablesDialog, spinner);
   gtk_widget_class_bind_template_child (widget_class, GbpBuilduiRunnablesDialog, stack);
 
   g_type_ensure (IDE_TYPE_ENUM_OBJECT);
diff --git a/src/plugins/buildui/gbp-buildui-runnables-dialog.ui 
b/src/plugins/buildui/gbp-buildui-runnables-dialog.ui
index 23ed71766..818a790c9 100644
--- a/src/plugins/buildui/gbp-buildui-runnables-dialog.ui
+++ b/src/plugins/buildui/gbp-buildui-runnables-dialog.ui
@@ -4,66 +4,81 @@
     <property name="default-width">700</property>
     <property name="default-height">550</property>
     <child type="content">
-      <object class="GtkStack" id="stack">
-        <property name="transition-type">slide-left-right</property>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
         <child>
-          <object class="GtkStackPage">
-            <property name="name">list</property>
-            <property name="child">
-              <object class="GtkBox">
-                <property name="orientation">vertical</property>
+          <object class="AdwHeaderBar">
+            <style>
+              <class name="flat"/>
+            </style>
+            <child type="title">
+              <object class="AdwWindowTitle">
+                <property name="title" translatable="yes">Select Run Command</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="AdwPreferencesPage" id="page">
+            <child>
+              <object class="AdwPreferencesGroup">
+                <property name="title" translatable="yes">Available Run Commands</property>
+                <property name="description" translatable="yes">Some run commands may not be available until 
the project has been configured.</property>
                 <child>
-                  <object class="AdwHeaderBar">
-                    <style>
-                      <class name="flat"/>
-                    </style>
-                    <child type="title">
-                      <object class="AdwWindowTitle">
-                        <property name="title" translatable="yes">Select Run Command</property>
+                  <object class="AdwActionRow">
+                    <property name="title" translatable="yes">Project Default</property>
+                    <property name="subtitle" translatable="yes">This selection allows the build system to 
choose the best default candidate.</property>
+                    <property name="activatable-widget">default_runnable</property>
+                    <child type="suffix">
+                      <object class="GtkCheckButton" id="default_runnable">
+                        <property name="action-name">run-manager.default-run-command</property>
+                        <property name="action-target">''</property>
+                        <style>
+                          <class name="checkimage"/>
+                        </style>
                       </object>
                     </child>
                   </object>
                 </child>
                 <child>
-                  <object class="AdwPreferencesPage" id="page">
+                  <object class="GtkButton">
+                    <property name="margin-top">12</property>
+                    <property name="margin-bottom">12</property>
+                    <property name="use-underline">true</property>
+                    <property name="label" translatable="yes">_Custom Command…</property>
+                    <property name="action-name">run-command.new</property>
+                    <property name="halign">end</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkStack" id="stack">
+                    <property name="hhomogeneous">false</property>
+                    <property name="vhomogeneous">false</property>
                     <child>
-                      <object class="AdwPreferencesGroup">
-                        <property name="title" translatable="yes">Available Run Commands</property>
-                        <property name="description" translatable="yes">Some run commands may not be 
available until the project has been configured.</property>
-                        <property name="header-suffix">
-                          <object class="GtkSpinner" id="spinner">
-                            <property name="spinning" bind-source="GbpBuilduiRunnablesDialog" 
bind-property="busy" bind-flags="sync-create"/>
-                            <property name="halign">end</property>
-                            <property name="valign">start</property>
-                          </object>
-                        </property>
-                        <child>
-                          <object class="AdwActionRow">
-                            <property name="title" translatable="yes">Project Default</property>
-                            <property name="subtitle" translatable="yes">This selection allows the build 
system to choose the best default candidate.</property>
-                            <property name="activatable-widget">default_runnable</property>
-                            <child type="suffix">
-                              <object class="GtkCheckButton" id="default_runnable">
-                                <property name="action-name">run-manager.default-run-command</property>
-                                <property name="action-target">''</property>
-                                <style>
-                                  <class name="checkimage"/>
-                                </style>
+                      <object class="GtkStackPage">
+                        <property name="name">loading</property>
+                        <property name="child">
+                          <object class="GtkListBox">
+                            <property name="margin-top">12</property>
+                            <property name="selection-mode">none</property>
+                            <style>
+                              <class name="boxed-list"/>
+                            </style>
+                            <child>
+                              <object class="AdwActionRow">
+                                <property name="icon-name">content-loading-symbolic</property>
+                                <property name="title" translatable="yes">Loading Run Commands</property>
+                                <property name="subtitle" translatable="yes">Some building may be required 
to load all run commands</property>
                               </object>
                             </child>
                           </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="margin-top">12</property>
-                            <property name="margin-bottom">12</property>
-                            <property name="use-underline">true</property>
-                            <property name="label" translatable="yes">_Custom Command…</property>
-                            <property name="action-name">run-command.new</property>
-                            <property name="halign">end</property>
-                          </object>
-                        </child>
-                        <child>
+                        </property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkStackPage">
+                        <property name="name">list</property>
+                        <property name="child">
                           <object class="GtkListBox" id="list_box">
                             <property name="margin-top">12</property>
                             <property name="selection-mode">none</property>
@@ -71,13 +86,13 @@
                               <class name="boxed-list"/>
                             </style>
                           </object>
-                        </child>
+                        </property>
                       </object>
                     </child>
                   </object>
                 </child>
               </object>
-            </property>
+            </child>
           </object>
         </child>
       </object>


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