gimp r26702 - trunk/plug-ins/script-fu
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26702 - trunk/plug-ins/script-fu
- Date: Thu, 21 Aug 2008 17:35:53 +0000 (UTC)
Author: neo
Date: Thu Aug 21 17:35:52 2008
New Revision: 26702
URL: http://svn.gnome.org/viewvc/gimp?rev=26702&view=rev
Log:
2008-08-21 Sven Neumann <sven gimp org>
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/script-fu-interface.[ch]: changed to
actually
return a meaningful return status when a script-fu procedure is
run.
Modified:
trunk/plug-ins/script-fu/script-fu-interface.c
trunk/plug-ins/script-fu/script-fu-interface.h
trunk/plug-ins/script-fu/script-fu-scripts.c
Modified: trunk/plug-ins/script-fu/script-fu-interface.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-interface.c (original)
+++ trunk/plug-ins/script-fu/script-fu-interface.c Thu Aug 21 17:35:52 2008
@@ -108,8 +108,11 @@
* Local variables
*/
-static SFInterface *sf_interface = NULL; /* there can only be at most one
- interactive interface */
+static SFInterface *sf_interface = NULL; /* there can only be at most
+ * oneinteractive interface
+ */
+
+static GimpPDBStatusType sf_status = GIMP_PDB_SUCCESS;
/*
@@ -165,9 +168,9 @@
gtk_main_iteration ();
}
-void
-script_fu_interface (SFScript *script,
- gint start_arg)
+GimpPDBStatusType
+script_fu_interface (SFScript *script,
+ gint start_arg)
{
GtkWidget *dialog;
GtkWidget *menu;
@@ -195,10 +198,10 @@
g_message (message, sf_interface->title);
g_free (message);
- return;
+ return GIMP_PDB_CANCEL;
}
- g_return_if_fail (script != NULL);
+ g_return_val_if_fail (script != NULL, FALSE);
if (!gtk_initted)
{
@@ -209,12 +212,14 @@
gtk_initted = TRUE;
}
+ sf_status = GIMP_PDB_SUCCESS;
+
sf_interface = g_slice_new0 (SFInterface);
sf_interface->widgets = g_new0 (GtkWidget *, script->num_args);
/* strip mnemonics from the menupath */
- sf_interface->title = gimp_strip_uline (gettext (script->menu_path));
+ sf_interface->title = gimp_strip_uline (gettext (script->menu_path));
/* if this looks like a full menu path, use only the last part */
if (sf_interface->title[0] == '<' &&
@@ -601,6 +606,8 @@
gtk_widget_show (dialog);
gtk_main ();
+
+ return sf_status;
}
static void
@@ -750,9 +757,11 @@
FALSE);
script_fu_ok (script);
- /* fallthru */
+ gtk_widget_destroy (sf_interface->dialog);
+ break;
default:
+ sf_status = GIMP_PDB_CANCEL;
gtk_widget_destroy (sf_interface->dialog);
break;
}
@@ -898,10 +907,12 @@
command = g_string_free (s, FALSE);
/* run the command through the interpreter */
- output = g_string_new ("");
+ output = g_string_new (NULL);
ts_register_output_func (ts_gstring_output_func, output);
+
if (ts_interpret_string (command))
script_fu_error_msg (command, output->str);
+
g_string_free (output, TRUE);
g_free (command);
Modified: trunk/plug-ins/script-fu/script-fu-interface.h
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-interface.h (original)
+++ trunk/plug-ins/script-fu/script-fu-interface.h Thu Aug 21 17:35:52 2008
@@ -20,10 +20,10 @@
#define __SCRIPT_FU_INTERFACE_H__
-void script_fu_interface (SFScript *script,
- gint start_arg);
-void script_fu_interface_report_cc (const gchar *command);
-gboolean script_fu_interface_is_active (void);
+GimpPDBStatusType script_fu_interface (SFScript *script,
+ gint start_arg);
+void script_fu_interface_report_cc (const gchar *command);
+gboolean script_fu_interface_is_active (void);
#endif /* __SCRIPT_FU_INTERFACE_H__ */
Modified: trunk/plug-ins/script-fu/script-fu-scripts.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-scripts.c (original)
+++ trunk/plug-ins/script-fu/script-fu-scripts.c Thu Aug 21 17:35:52 2008
@@ -53,6 +53,7 @@
* Local Functions
*/
+static gboolean script_fu_run_command (const gchar *command);
static void script_fu_load_script (const GimpDatafileData *file_data,
gpointer user_data);
static gboolean script_fu_install_script (gpointer foo,
@@ -670,24 +671,42 @@
/* private functions */
+static gboolean
+script_fu_run_command (const gchar *command)
+{
+ GString *output = g_string_new ("");
+ gboolean success = FALSE;
+
+ output = g_string_new ("");
+ ts_register_output_func (ts_gstring_output_func, output);
+
+ if (ts_interpret_string (command))
+ {
+ script_fu_error_msg (command, output->str);
+ }
+ else
+ {
+ success = TRUE;
+ }
+
+ g_string_free (output, TRUE);
+
+ return success;
+}
+
static void
script_fu_load_script (const GimpDatafileData *file_data,
gpointer user_data)
{
if (gimp_datafiles_check_extension (file_data->filename, ".scm"))
{
- gchar *command;
gchar *escaped = script_fu_strescape (file_data->filename);
- GString *output;
+ gchar *command;
command = g_strdup_printf ("(load \"%s\")", escaped);
g_free (escaped);
- output = g_string_new ("");
- ts_register_output_func (ts_gstring_output_func, output);
- if (ts_interpret_string (command))
- script_fu_error_msg (command, output->str);
- g_string_free (output, TRUE);
+ script_fu_run_command (command);
#ifdef G_OS_WIN32
/* No, I don't know why, but this is
@@ -888,6 +907,11 @@
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
SFScript *script;
+ *nreturn_vals = 1;
+ *return_vals = values;
+
+ values[0].type = GIMP_PDB_STATUS;
+
script = script_fu_find_script (name);
if (! script)
@@ -912,7 +936,7 @@
/* ...then acquire the rest of arguments (if any) with a dialog */
if (script->num_args > min_args)
{
- script_fu_interface (script, min_args);
+ status = script_fu_interface (script, min_args);
break;
}
/* otherwise (if the script takes no more arguments), skip
@@ -928,7 +952,6 @@
if (status == GIMP_PDB_SUCCESS)
{
GString *s;
- GString *output;
gchar *command;
gint i;
@@ -1015,11 +1038,7 @@
command = g_string_free (s, FALSE);
/* run the command through the interpreter */
- output = g_string_new ("");
- ts_register_output_func (ts_gstring_output_func, output);
- if (ts_interpret_string (command))
- script_fu_error_msg (command, output->str);
- g_string_free (output, TRUE);
+ script_fu_run_command (command);
g_free (command);
}
@@ -1028,7 +1047,6 @@
case GIMP_RUN_WITH_LAST_VALS:
{
GString *s;
- GString *output;
gchar *command;
gint i;
@@ -1150,11 +1168,7 @@
command = g_string_free (s, FALSE);
/* run the command through the interpreter */
- output = g_string_new ("");
- ts_register_output_func (ts_gstring_output_func, output);
- if (ts_interpret_string (command))
- script_fu_error_msg (command, output->str);
- g_string_free (output, TRUE);
+ script_fu_run_command (command);
g_free (command);
}
@@ -1165,10 +1179,6 @@
}
}
- *nreturn_vals = 1;
- *return_vals = values;
-
- values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]