[gnome-builder] plugins/shellcmd: add switch to toggle sub-shell option



commit 7660463d7a13f1240c237ca08126188d9446c2dd
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 22 12:59:05 2022 -0700

    plugins/shellcmd: add switch to toggle sub-shell option

 src/plugins/shellcmd/gbp-shellcmd-command-dialog.c  |  7 +++++++
 src/plugins/shellcmd/gbp-shellcmd-command-dialog.ui | 12 ++++++++++++
 2 files changed, 19 insertions(+)
---
diff --git a/src/plugins/shellcmd/gbp-shellcmd-command-dialog.c 
b/src/plugins/shellcmd/gbp-shellcmd-command-dialog.c
index b4c1a1d23..5945d6b1e 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-command-dialog.c
+++ b/src/plugins/shellcmd/gbp-shellcmd-command-dialog.c
@@ -44,6 +44,7 @@ struct _GbpShellcmdCommandDialog
   GtkLabel              *shortcut_label;
   GtkButton             *save;
   GtkButton             *delete_button;
+  GtkSwitch             *use_shell;
 
   char                  *accel;
 
@@ -257,6 +258,7 @@ gbp_shellcmd_command_dialog_set_command (GbpShellcmdCommandDialog *self,
   const char *accel;
   const char *name;
   const char *cwd;
+  gboolean use_shell;
 
   IDE_ENTRY;
 
@@ -272,12 +274,14 @@ gbp_shellcmd_command_dialog_set_command (GbpShellcmdCommandDialog *self,
   cwd = ide_run_command_get_cwd (IDE_RUN_COMMAND (command));
   accel = gbp_shellcmd_run_command_get_accelerator (command);
   locality = gbp_shellcmd_run_command_get_locality (command);
+  use_shell = gbp_shellcmd_run_command_get_use_shell (command);
 
   argvstr = normalize_argv (argv);
 
   gtk_editable_set_text (GTK_EDITABLE (self->argv), argvstr);
   gtk_editable_set_text (GTK_EDITABLE (self->location), cwd);
   gtk_editable_set_text (GTK_EDITABLE (self->name), name);
+  gtk_switch_set_active (self->use_shell, use_shell);
   set_accel (self, accel);
 
   /* locality value equates to position in list model for simplicity */
@@ -416,6 +420,8 @@ command_save_action (GtkWidget  *widget,
   ide_run_command_set_cwd (IDE_RUN_COMMAND (self->command),
                            gtk_editable_get_text (GTK_EDITABLE (self->location)));
   gbp_shellcmd_run_command_set_accelerator (self->command, self->accel);
+  gbp_shellcmd_run_command_set_use_shell (self->command,
+                                          gtk_switch_get_active (self->use_shell));
 
   env = string_list_to_strv (self->envvars);
   ide_run_command_set_environ (IDE_RUN_COMMAND (self->command),
@@ -591,6 +597,7 @@ gbp_shellcmd_command_dialog_class_init (GbpShellcmdCommandDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GbpShellcmdCommandDialog, name);
   gtk_widget_class_bind_template_child (widget_class, GbpShellcmdCommandDialog, save);
   gtk_widget_class_bind_template_child (widget_class, GbpShellcmdCommandDialog, shortcut_label);
+  gtk_widget_class_bind_template_child (widget_class, GbpShellcmdCommandDialog, use_shell);
   gtk_widget_class_bind_template_callback (widget_class, on_env_entry_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_env_entry_activate_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_shortcut_activated_cb);
diff --git a/src/plugins/shellcmd/gbp-shellcmd-command-dialog.ui 
b/src/plugins/shellcmd/gbp-shellcmd-command-dialog.ui
index cdff46deb..ab2071864 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-command-dialog.ui
+++ b/src/plugins/shellcmd/gbp-shellcmd-command-dialog.ui
@@ -117,6 +117,18 @@
             </child>
             <child>
               <object class="AdwPreferencesGroup">
+                <child>
+                  <object class="AdwActionRow" id="shell_row">
+                    <property name="title" translatable="yes">Use Subshell</property>
+                    <property name="subtitle" translatable="yes">Run the program from a subshell such as 
&lt;tt&gt;sh -c ''&lt;/tt&gt;</property>
+                    <property name="activatable-widget">use_shell</property>
+                    <child type="suffix">
+                      <object class="GtkSwitch" id="use_shell">
+                        <property name="valign">center</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
                 <child>
                   <object class="AdwComboRow" id="locality">
                     <property name="title" translatable="yes">Locality</property>


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