[gnome-builder/wip/gtk4-port] plugins/buildui: start on custom run commands



commit f541d7cd1d3b8295a1d78a50ab4dd57b1ce5dbc8
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 9 17:12:25 2022 -0700

    plugins/buildui: start on custom run commands
    
    This just gets some widgetry in place while we experiment with how it
    should look. There still needs to be work done on the form behind it and
    where we will end up storing/listing this stuff.

 src/plugins/buildui/gbp-buildui-runnables-dialog.c |  42 ++-
 .../buildui/gbp-buildui-runnables-dialog.ui        | 319 ++++++++++++++++++---
 2 files changed, 319 insertions(+), 42 deletions(-)
---
diff --git a/src/plugins/buildui/gbp-buildui-runnables-dialog.c 
b/src/plugins/buildui/gbp-buildui-runnables-dialog.c
index ccd1837b7..09854be33 100644
--- a/src/plugins/buildui/gbp-buildui-runnables-dialog.c
+++ b/src/plugins/buildui/gbp-buildui-runnables-dialog.c
@@ -26,6 +26,7 @@
 #include <glib/gi18n.h>
 #include <libpeas/peas.h>
 
+#include <libide-gtk.h>
 #include <libide-gui.h>
 
 #include "gbp-buildui-runnables-dialog.h"
@@ -35,6 +36,7 @@ struct _GbpBuilduiRunnablesDialog
   AdwWindow   parent_instance;
   GtkListBox *list_box;
   GtkSpinner *spinner;
+  GtkStack   *stack;
   guint       busy : 1;
 };
 
@@ -51,7 +53,7 @@ static GParamSpec *properties [N_PROPS];
 
 static GtkWidget *
 create_run_command_row (gpointer item,
-                   gpointer user_data)
+                        gpointer user_data)
 {
   IdeRunCommand *run_command = item;
   g_autoptr(GVariant) idv = NULL;
@@ -149,6 +151,32 @@ gbp_buildui_runnables_dialog_list_commands_cb (GObject      *object,
   IDE_EXIT;
 }
 
+static void
+gbp_buildui_runnables_dialog_set_page (GbpBuilduiRunnablesDialog *self,
+                                       const char                *page)
+{
+  g_assert (GBP_IS_BUILDUI_RUNNABLES_DIALOG (self));
+  g_assert (page != NULL);
+
+  gtk_stack_set_visible_child_name (self->stack, page);
+}
+
+static void
+new_run_command_action (GtkWidget  *widget,
+                        const char *action_name,
+                        GVariant   *param)
+{
+  gbp_buildui_runnables_dialog_set_page (GBP_BUILDUI_RUNNABLES_DIALOG (widget), "new");
+}
+
+static void
+list_run_command_action (GtkWidget  *widget,
+                         const char *action_name,
+                         GVariant   *param)
+{
+  gbp_buildui_runnables_dialog_set_page (GBP_BUILDUI_RUNNABLES_DIALOG (widget), "list");
+}
+
 static void
 gbp_buildui_runnables_dialog_set_context (GbpBuilduiRunnablesDialog *self,
                                           IdeContext                *context)
@@ -238,15 +266,27 @@ gbp_buildui_runnables_dialog_class_init (GbpBuilduiRunnablesDialogClass *klass)
 
   g_object_class_install_properties (object_class, N_PROPS, properties);
 
+  gtk_widget_class_install_action (widget_class, "run-command.new", NULL, new_run_command_action);
+  gtk_widget_class_install_action (widget_class, "run-command.list", NULL, list_run_command_action);
+
   gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "window.close", NULL);
 
   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, spinner);
+  gtk_widget_class_bind_template_child (widget_class, GbpBuilduiRunnablesDialog, stack);
+
+  g_type_ensure (IDE_TYPE_ENUM_OBJECT);
 }
 
 static void
 gbp_buildui_runnables_dialog_init (GbpBuilduiRunnablesDialog *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
+
+#ifdef DEVELOPMENT_BUILD
+  gtk_widget_add_css_class (GTK_WIDGET (self), "devel");
+#endif
+
+  gbp_buildui_runnables_dialog_set_page (self, "list");
 }
diff --git a/src/plugins/buildui/gbp-buildui-runnables-dialog.ui 
b/src/plugins/buildui/gbp-buildui-runnables-dialog.ui
index 34932dfdc..309df46d7 100644
--- a/src/plugins/buildui/gbp-buildui-runnables-dialog.ui
+++ b/src/plugins/buildui/gbp-buildui-runnables-dialog.ui
@@ -1,66 +1,303 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="GbpBuilduiRunnablesDialog" parent="AdwWindow">
-    <property name="title" translatable="yes">Select Run Command</property>
     <property name="default-width">700</property>
     <property name="default-height">550</property>
     <child type="content">
-      <object class="GtkBox">
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="AdwHeaderBar">
-          </object>
-        </child>
+      <object class="GtkStack" id="stack">
+        <property name="transition-type">slide-left-right</property>
         <child>
-          <object class="AdwPreferencesPage">
-            <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"/>
-                  </object>
-                </property>
+          <object class="GtkStackPage">
+            <property name="name">list</property>
+            <property name="child">
+              <object class="GtkBox">
+                <property name="orientation">vertical</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="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="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="halign">end</property>
+                  <object class="AdwPreferencesPage">
+                    <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"/>
+                          </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>
+                            </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>
+                          <object class="GtkListBox" id="list_box">
+                            <property name="margin-top">12</property>
+                            <property name="selection-mode">none</property>
+                            <style>
+                              <class name="boxed-list"/>
+                            </style>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                   </object>
                 </child>
+              </object>
+            </property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkStackPage">
+            <property name="name">new</property>
+            <property name="child">
+              <object class="GtkScrolledWindow">
+                <property name="hscrollbar-policy">never</property>
                 <child>
-                  <object class="GtkListBox" id="list_box">
-                    <property name="margin-top">12</property>
-                    <property name="selection-mode">none</property>
-                    <style>
-                      <class name="boxed-list"/>
-                    </style>
+                  <object class="GtkBox">
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <object class="AdwHeaderBar">
+                        <property name="show-start-title-buttons">false</property>
+                        <property name="show-end-title-buttons">false</property>
+                        <style>
+                          <class name="flat"/>
+                        </style>
+                        <child type="start">
+                          <object class="GtkButton">
+                            <property name="action-name">run-command.list</property>
+                            <property name="icon-name">go-previous-symbolic</property>
+                          </object>
+                        </child>
+                        <child type="title">
+                          <object class="AdwWindowTitle">
+                            <property name="title" translatable="yes">Create Run Command</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="AdwPreferencesPage">
+                        <child>
+                          <object class="AdwPreferencesGroup">
+                            <child>
+                              <object class="AdwEntryRow" id="name">
+                                <property name="title" translatable="yes">Name</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="margin-top">12</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">The name will be used when 
displaying your custom command.</property>
+                                <style>
+                                  <class name="dim-label"/>
+                                  <class name="caption"/>
+                                </style>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="AdwPreferencesGroup">
+                            <child>
+                              <object class="AdwComboRow" id="locality">
+                                <property name="title" translatable="yes">Locality</property>
+                                <property name="subtitle" translatable="yes">The locality determines where 
commands should be run.</property>
+                                <property name="model">localities</property>
+                                <property name="expression">
+                                  <lookup name="title" type="IdeEnumObject"/>
+                                </property>
+                                <!--signal name="notify::selected-item" handler="template_changed_cb" 
swapped="true" object="GbpCreateProjectWidget"/-->
+                                <property name="list-factory">
+                                  <object class="GtkBuilderListItemFactory">
+                                    <property name="bytes"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GtkListItem">
+    <property name="child">
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkLabel">
+            <property name="xalign">0</property>
+            <property name="hexpand">true</property>
+            <binding name="label">
+              <lookup name="title" type="IdeEnumObject">
+                <lookup name="item">GtkListItem</lookup>
+              </lookup>
+            </binding>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="xalign">0</property>
+            <property name="hexpand">true</property>
+            <property name="wrap">true</property>
+            <style>
+              <class name="caption"/>
+              <class name="dim-label"/>
+            </style>
+            <binding name="label">
+              <lookup name="description" type="IdeEnumObject">
+                <lookup name="item">GtkListItem</lookup>
+              </lookup>
+            </binding>
+          </object>
+        </child>
+      </object>
+    </property>
+  </template>
+</interface>
+]]>
+                                    </property>
+                                  </object>
+                                </property>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="AdwPreferencesGroup">
+                            <child>
+                              <object class="AdwEntryRow" id="location">
+                                <property name="title" translatable="yes">Location</property>
+                                <property name="text">$BUILDDIR/</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="margin-top">12</property>
+                                <property name="xalign">0</property>
+                                <property name="wrap">true</property>
+                                <property name="use-markup">true</property>
+                                <property name="label" translatable="yes">The location is the path where the 
command should be run and may contain &lt;tt&gt;$BUILDDIR&lt;/tt&gt; or &lt;tt&gt;$SRCDIR&lt;/tt&gt; 
variables.</property>
+                                <style>
+                                  <class name="dim-label"/>
+                                  <class name="caption"/>
+                                </style>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="AdwPreferencesGroup">
+                            <property name="title" translatable="yes">Environment Variables</property>
+                            <child type="header-suffix">
+                              <object class="GtkMenuButton">
+                                <style>
+                                  <class name="flat"/>
+                                </style>
+                                <property name="icon-name">list-add-symbolic</property>
+                                <property name="valign">center</property>
+                                <property name="direction">up</property>
+                                <property name="popover">
+                                  <object class="GtkPopover">
+                                    <child>
+                                      <object class="AdwPreferencesGroup">
+                                        <property name="margin-top">6</property>
+                                        <property name="margin-bottom">6</property>
+                                        <property name="margin-start">6</property>
+                                        <property name="margin-end">6</property>
+                                        <property name="title" translatable="yes">Add Variable</property>
+                                        <child>
+                                          <object class="AdwEntryRow" id="env_key">
+                                            <property name="title" translatable="yes">Name</property>
+                                          </object>
+                                        </child>
+                                        <child>
+                                          <object class="AdwEntryRow" id="env_value">
+                                            <property name="title" translatable="yes">Value</property>
+                                          </object>
+                                        </child>
+                                        <child>
+                                          <object class="GtkButton">
+                                            <style>
+                                              <class name="suggested-action"/>
+                                            </style>
+                                            <property name="margin-top">18</property>
+                                            <property name="label" translatable="yes">Add Variable</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </property>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>
-            </child>
+            </property>
           </object>
         </child>
       </object>
     </child>
   </template>
+  <object class="GListStore" id="localities">
+    <child>
+      <object class="IdeEnumObject">
+        <property name="title" translatable="yes">Default</property>
+        <property name="description" translatable="yes">The command will run as if you were running the 
application.</property>
+        <property name="nick">run</property>
+      </object>
+    </child>
+    <child>
+      <object class="IdeEnumObject">
+        <property name="title" translatable="yes">Build Container</property>
+        <property name="description" translatable="yes">The command will run from the projects build 
container which may not have display or network access.</property>
+        <property name="nick">build</property>
+      </object>
+    </child>
+    <child>
+      <object class="IdeEnumObject">
+        <property name="title" translatable="yes">Host System</property>
+        <property name="description" translatable="yes">The command will run on the host operating 
system.</property>
+        <property name="nick">host</property>
+      </object>
+    </child>
+    <child>
+      <object class="IdeEnumObject">
+        <!-- translators: this is referring to GNOME Builder the application -->
+        <property name="title" translatable="yes">GNOME Builder</property>
+        <property name="description" translatable="yes">The command will run as a subprocess of GNOME 
Builder.</property>
+        <property name="nick">app</property>
+      </object>
+    </child>
+  </object>
 </interface>


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