[gthumb/ext: 44/79] Added a "terminal command" property to the script.
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 44/79] Added a "terminal command" property to the script.
- Date: Sun, 2 Aug 2009 20:28:48 +0000 (UTC)
commit 5f7f8d72aeed7b94b97a2c4ec741d1e134526ef6
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jul 14 11:48:58 2009 +0200
Added a "terminal command" property to the script.
Renamed scripts as commands.
.../list_tools/data/ui/personalize-scripts.ui | 4 +-
extensions/list_tools/data/ui/script-editor.ui | 25 +++++++--
extensions/list_tools/dlg-personalize-scripts.c | 4 +-
extensions/list_tools/gth-script-editor-dialog.c | 4 ++
extensions/list_tools/gth-script-task.c | 57 +++++++++++---------
extensions/list_tools/gth-script.c | 29 +++++++++-
extensions/list_tools/gth-script.h | 1 +
7 files changed, 88 insertions(+), 36 deletions(-)
---
diff --git a/extensions/list_tools/data/ui/personalize-scripts.ui b/extensions/list_tools/data/ui/personalize-scripts.ui
index 3b16fc2..76addff 100644
--- a/extensions/list_tools/data/ui/personalize-scripts.ui
+++ b/extensions/list_tools/data/ui/personalize-scripts.ui
@@ -4,7 +4,7 @@
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="personalize_scripts_dialog">
<property name="border_width">5</property>
- <property name="title" translatable="yes">Scripts</property>
+ <property name="title" translatable="yes">Commands</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@@ -27,7 +27,7 @@
<object class="GtkLabel" id="scripts_label">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">_Scripts:</property>
+ <property name="label" translatable="yes">Co_mmands:</property>
</object>
<packing>
<property name="expand">False</property>
diff --git a/extensions/list_tools/data/ui/script-editor.ui b/extensions/list_tools/data/ui/script-editor.ui
index 692c206..1e813c2 100644
--- a/extensions/list_tools/data/ui/script-editor.ui
+++ b/extensions/list_tools/data/ui/script-editor.ui
@@ -10,7 +10,7 @@
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -80,8 +80,8 @@
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
</packing>
</child>
<child>
@@ -95,8 +95,8 @@
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
<child>
@@ -419,6 +419,21 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="shell_script_checkbutton">
+ <property name="label" translatable="yes">_Terminal command (shell script)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
</object>
diff --git a/extensions/list_tools/dlg-personalize-scripts.c b/extensions/list_tools/dlg-personalize-scripts.c
index 192b5ea..510520a 100644
--- a/extensions/list_tools/dlg-personalize-scripts.c
+++ b/extensions/list_tools/dlg-personalize-scripts.c
@@ -358,7 +358,7 @@ new_script_cb (GtkButton *button,
{
GtkWidget *dialog;
- dialog = gth_script_editor_dialog_new (_("New Script"), GTK_WINDOW (data->dialog));
+ dialog = gth_script_editor_dialog_new (_("New Command"), GTK_WINDOW (data->dialog));
g_signal_connect (dialog, "response",
G_CALLBACK (script_editor_dialog__response_cb),
data);
@@ -385,7 +385,7 @@ edit_script_cb (GtkButton *button,
if (script == NULL)
return;
- dialog = gth_script_editor_dialog_new (_("Edit Script"), GTK_WINDOW (data->dialog));
+ dialog = gth_script_editor_dialog_new (_("Edit Command"), GTK_WINDOW (data->dialog));
gth_script_editor_dialog_set_script (GTH_SCRIPT_EDITOR_DIALOG (dialog), script);
g_signal_connect (dialog,
"response",
diff --git a/extensions/list_tools/gth-script-editor-dialog.c b/extensions/list_tools/gth-script-editor-dialog.c
index ca80738..0374ca4 100644
--- a/extensions/list_tools/gth-script-editor-dialog.c
+++ b/extensions/list_tools/gth-script-editor-dialog.c
@@ -37,6 +37,7 @@ struct _GthScriptEditorDialogPrivate {
char *script_id;
gboolean script_visible;
gboolean wait_command;
+ gboolean shell_script;
gboolean for_each_file;
gboolean help_visible;
};
@@ -187,6 +188,7 @@ _gth_script_editor_dialog_set_new_script (GthScriptEditorDialog *self)
{
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), "");
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("command_entry")), "");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("shell_script_checkbutton")), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("for_each_file_checkbutton")), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("wait_command_checkbutton")), FALSE);
}
@@ -208,6 +210,7 @@ gth_script_editor_dialog_set_script (GthScriptEditorDialog *self,
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), gth_script_get_display_name (script));
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("command_entry")), gth_script_get_command (script));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("shell_script_checkbutton")), gth_script_is_shell_script (script));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("for_each_file_checkbutton")), gth_script_for_each_file (script));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("wait_command_checkbutton")), gth_script_wait_command (script));
}
@@ -229,6 +232,7 @@ gth_script_editor_dialog_get_script (GthScriptEditorDialog *self,
"display-name", gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("name_entry"))),
"command", gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("command_entry"))),
"visible", self->priv->script_visible,
+ "shell-script", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("shell_script_checkbutton"))),
"for-each-file", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("for_each_file_checkbutton"))),
"wait-command", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("wait_command_checkbutton"))),
NULL);
diff --git a/extensions/list_tools/gth-script-task.c b/extensions/list_tools/gth-script-task.c
index 7c51e6f..1535446 100644
--- a/extensions/list_tools/gth-script-task.c
+++ b/extensions/list_tools/gth-script-task.c
@@ -136,32 +136,39 @@ _gth_script_task_exec (GthScriptTask *self)
if (error == NULL) {
char **argv;
-
- argv = g_new (char *, 4);
- argv[0] = "sh";
- argv[1] = "-c";
- argv[2] = command_line;
- argv[3] = NULL;
-
- if (gth_script_wait_command (self->priv->script)) {
- if (g_spawn_async (NULL,
- argv,
- NULL,
- G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- &self->priv->pid,
- &error))
- {
- self->priv->script_watch = g_child_watch_add (self->priv->pid,
- watch_script_cb,
- self);
- retval = TRUE;
- }
+ int argc;
+
+ if (gth_script_is_shell_script (self->priv->script)) {
+ argv = g_new (char *, 4);
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = command_line;
+ argv[3] = NULL;
}
- else {
- if (g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error))
- retval = TRUE;
+ else
+ g_shell_parse_argv (command_line, &argc, &argv, &error);
+
+ if (error == NULL) {
+ if (gth_script_wait_command (self->priv->script)) {
+ if (g_spawn_async (NULL,
+ argv,
+ NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ &self->priv->pid,
+ &error))
+ {
+ self->priv->script_watch = g_child_watch_add (self->priv->pid,
+ watch_script_cb,
+ self);
+ retval = TRUE;
+ }
+ }
+ else {
+ if (g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error))
+ retval = TRUE;
+ }
}
g_free (argv);
diff --git a/extensions/list_tools/gth-script.c b/extensions/list_tools/gth-script.c
index 9304308..d9258e9 100644
--- a/extensions/list_tools/gth-script.c
+++ b/extensions/list_tools/gth-script.c
@@ -31,6 +31,7 @@ enum {
PROP_DISPLAY_NAME,
PROP_COMMAND,
PROP_VISIBLE,
+ PROP_SHELL_SCRIPT,
PROP_FOR_EACH_FILE,
PROP_WAIT_COMMAND
};
@@ -41,6 +42,7 @@ struct _GthScriptPrivate {
char *display_name;
char *command;
gboolean visible;
+ gboolean shell_script;
gboolean for_each_file;
gboolean wait_command;
};
@@ -63,8 +65,9 @@ gth_script_real_create_element (DomDomizable *base,
"id", self->priv->id,
"display-name", self->priv->display_name,
"command", self->priv->command,
- "for-each-file", self->priv->for_each_file ? "true" : "false",
- "wait-command", self->priv->wait_command ? "true" : "false",
+ "shell-script", (self->priv->shell_script ? "true" : "false"),
+ "for-each-file", (self->priv->for_each_file ? "true" : "false"),
+ "wait-command", (self->priv->wait_command ? "true" : "false"),
NULL);
if (! self->priv->visible)
dom_element_set_attribute (element, "display", "none");
@@ -87,6 +90,7 @@ gth_script_real_load_from_element (DomDomizable *base,
"display-name", dom_element_get_attribute (element, "display-name"),
"command", dom_element_get_attribute (element, "command"),
"visible", (g_strcmp0 (dom_element_get_attribute (element, "display"), "none") != 0),
+ "shell-script", (g_strcmp0 (dom_element_get_attribute (element, "shell-script"), "true") == 0),
"for-each-file", (g_strcmp0 (dom_element_get_attribute (element, "for-each-file"), "true") == 0),
"wait-command", (g_strcmp0 (dom_element_get_attribute (element, "wait-command"), "true") == 0),
NULL);
@@ -105,6 +109,7 @@ gth_script_real_duplicate (GthDuplicable *duplicable)
"display-name", script->priv->display_name,
"command", script->priv->command,
"visible", script->priv->visible,
+ "shell-script", script->priv->shell_script,
"for-each-file", script->priv->for_each_file,
"wait-command", script->priv->wait_command,
NULL);
@@ -160,6 +165,9 @@ gth_script_set_property (GObject *object,
case PROP_VISIBLE:
self->priv->visible = g_value_get_boolean (value);
break;
+ case PROP_SHELL_SCRIPT:
+ self->priv->shell_script = g_value_get_boolean (value);
+ break;
case PROP_FOR_EACH_FILE:
self->priv->for_each_file = g_value_get_boolean (value);
break;
@@ -195,6 +203,9 @@ gth_script_get_property (GObject *object,
case PROP_VISIBLE:
g_value_set_boolean (value, self->priv->visible);
break;
+ case PROP_SHELL_SCRIPT:
+ g_value_set_boolean (value, self->priv->shell_script);
+ break;
case PROP_FOR_EACH_FILE:
g_value_set_boolean (value, self->priv->for_each_file);
break;
@@ -252,6 +263,13 @@ gth_script_class_init (GthScriptClass *klass)
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_SHELL_SCRIPT,
+ g_param_spec_boolean ("shell-script",
+ "Shell Script",
+ "Whether to execute the command inside a terminal (with sh)",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
PROP_FOR_EACH_FILE,
g_param_spec_boolean ("for-each-file",
"Each File",
@@ -376,6 +394,13 @@ gth_script_is_visible (GthScript *script)
gboolean
+gth_script_is_shell_script (GthScript *script)
+{
+ return script->priv->shell_script;
+}
+
+
+gboolean
gth_script_for_each_file (GthScript *script)
{
return script->priv->for_each_file;
diff --git a/extensions/list_tools/gth-script.h b/extensions/list_tools/gth-script.h
index 765effd..8152b8c 100644
--- a/extensions/list_tools/gth-script.h
+++ b/extensions/list_tools/gth-script.h
@@ -57,6 +57,7 @@ const char * gth_script_get_id (GthScript *script);
const char * gth_script_get_display_name (GthScript *script);
const char * gth_script_get_command (GthScript *script);
gboolean gth_script_is_visible (GthScript *script);
+gboolean gth_script_is_shell_script (GthScript *script);
gboolean gth_script_for_each_file (GthScript *script);
gboolean gth_script_wait_command (GthScript *script);
char * gth_script_get_requested_attributes (GthScript *script);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]