1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-07-03 10:27:32 +08:00
|
|
|
#include <glib.h> /* Include early for obscure Win32
|
|
|
|
build reasons */
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1999-04-26 03:30:31 +08:00
|
|
|
#include <sys/types.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
#include <gtk/gtk.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
|
2002-02-17 23:55:54 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2003-06-16 19:31:10 +08:00
|
|
|
#include <libgimpbase/gimpbase.h>
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
|
2003-11-27 01:14:58 +08:00
|
|
|
#include "siod/siod.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "script-fu-scripts.h"
|
2003-11-27 01:14:58 +08:00
|
|
|
#include "siod-wrapper.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-28 03:35:39 +08:00
|
|
|
#include "script-fu-intl.h"
|
2000-02-01 04:47:44 +08:00
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
#define RESPONSE_RESET 1
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
#define TEXT_WIDTH 100
|
|
|
|
#define COLOR_SAMPLE_WIDTH 100
|
|
|
|
#define COLOR_SAMPLE_HEIGHT 15
|
2003-06-09 22:17:57 +08:00
|
|
|
#define SLIDER_WIDTH 80
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
#define MAX_STRING_LENGTH 4096
|
1998-08-06 05:36:11 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-08-06 22:58:39 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2000-11-08 22:35:50 +08:00
|
|
|
GtkAdjustment *adj;
|
2003-06-19 19:36:12 +08:00
|
|
|
gdouble value;
|
|
|
|
gdouble lower;
|
|
|
|
gdouble upper;
|
|
|
|
gdouble step;
|
|
|
|
gdouble page;
|
2000-11-08 22:35:50 +08:00
|
|
|
gint digits;
|
|
|
|
SFAdjustmentType type;
|
1998-08-06 22:58:39 +08:00
|
|
|
} SFAdjustment;
|
|
|
|
|
1998-11-06 08:51:39 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
GtkWidget *file_entry;
|
1998-11-06 08:51:39 +08:00
|
|
|
gchar *filename;
|
|
|
|
} SFFilename;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
typedef struct
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2003-06-19 19:36:12 +08:00
|
|
|
gchar *name;
|
|
|
|
gdouble opacity;
|
|
|
|
gint spacing;
|
|
|
|
GimpLayerModeEffects paint_mode;
|
1998-10-21 06:36:52 +08:00
|
|
|
} SFBrush;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
typedef struct
|
2000-04-28 08:02:11 +08:00
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
guint history;
|
|
|
|
} SFOption;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
typedef union
|
|
|
|
{
|
2000-11-08 22:35:50 +08:00
|
|
|
gint32 sfa_image;
|
|
|
|
gint32 sfa_drawable;
|
|
|
|
gint32 sfa_layer;
|
|
|
|
gint32 sfa_channel;
|
2001-01-11 06:49:45 +08:00
|
|
|
GimpRGB sfa_color;
|
2000-11-08 22:35:50 +08:00
|
|
|
gint32 sfa_toggle;
|
|
|
|
gchar *sfa_value;
|
|
|
|
SFAdjustment sfa_adjustment;
|
|
|
|
SFFilename sfa_file;
|
2003-03-28 22:13:54 +08:00
|
|
|
gchar *sfa_font;
|
2000-11-08 22:35:50 +08:00
|
|
|
gchar *sfa_gradient;
|
2003-03-28 22:13:54 +08:00
|
|
|
gchar *sfa_pattern;
|
2000-11-08 22:35:50 +08:00
|
|
|
SFBrush sfa_brush;
|
|
|
|
SFOption sfa_option;
|
1997-11-25 06:05:25 +08:00
|
|
|
} SFArgValue;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2000-08-08 05:30:35 +08:00
|
|
|
gchar *script_name;
|
|
|
|
gchar *pdb_name;
|
|
|
|
gchar *description;
|
|
|
|
gchar *help;
|
|
|
|
gchar *author;
|
|
|
|
gchar *copyright;
|
|
|
|
gchar *date;
|
|
|
|
gchar *img_types;
|
|
|
|
gint num_args;
|
|
|
|
SFArgType *arg_types;
|
|
|
|
gchar **arg_labels;
|
|
|
|
SFArgValue *arg_defaults;
|
|
|
|
SFArgValue *arg_values;
|
2001-01-22 04:06:26 +08:00
|
|
|
gboolean image_based;
|
2000-08-08 05:30:35 +08:00
|
|
|
GimpParamDef *args; /* used only temporary until installed */
|
1997-11-25 06:05:25 +08:00
|
|
|
} SFScript;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2002-05-25 03:44:37 +08:00
|
|
|
GtkWidget *dialog;
|
2000-11-08 22:35:50 +08:00
|
|
|
GtkWidget **args_widgets;
|
|
|
|
GtkWidget *status;
|
|
|
|
GtkWidget *about_dialog;
|
2002-09-17 21:57:30 +08:00
|
|
|
gchar *title;
|
2000-11-08 22:35:50 +08:00
|
|
|
gchar *last_command;
|
|
|
|
gint command_count;
|
|
|
|
gint consec_command_count;
|
1997-11-25 06:05:25 +08:00
|
|
|
} SFInterface;
|
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* External functions
|
|
|
|
*/
|
2000-02-01 04:47:44 +08:00
|
|
|
extern long nlength (LISP obj);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local Functions
|
|
|
|
*/
|
|
|
|
|
2003-11-21 23:53:57 +08:00
|
|
|
static void script_fu_load_script (const GimpDatafileData *file_data,
|
|
|
|
gpointer user_data);
|
|
|
|
static gboolean script_fu_install_script (gpointer foo,
|
|
|
|
SFScript *script,
|
|
|
|
gpointer bar);
|
|
|
|
static gboolean script_fu_remove_script (gpointer foo,
|
|
|
|
SFScript *script,
|
|
|
|
gpointer bar);
|
|
|
|
static void script_fu_script_proc (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *params,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
|
|
|
|
static SFScript * script_fu_find_script (const gchar *script_name);
|
|
|
|
static void script_fu_free_script (SFScript *script);
|
|
|
|
static void script_fu_interface (SFScript *script);
|
|
|
|
static void script_fu_interface_quit (SFScript *script);
|
|
|
|
static void script_fu_error_msg (const gchar *command);
|
|
|
|
|
|
|
|
static void script_fu_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
SFScript *script);
|
|
|
|
static void script_fu_ok (SFScript *script);
|
|
|
|
static void script_fu_reset (SFScript *script);
|
|
|
|
static void script_fu_about_callback (GtkWidget *widget,
|
|
|
|
SFScript *script);
|
|
|
|
|
|
|
|
static void script_fu_file_entry_callback (GtkWidget *widget,
|
|
|
|
SFFilename *fil);
|
|
|
|
|
|
|
|
static void script_fu_pattern_callback (const gchar *name,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint bytes,
|
|
|
|
const guchar *mask_data,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data);
|
|
|
|
static void script_fu_gradient_callback (const gchar *name,
|
|
|
|
gint width,
|
|
|
|
const gdouble *mask_data,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data);
|
|
|
|
static void script_fu_font_callback (const gchar *name,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data);
|
|
|
|
static void script_fu_brush_callback (const gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
gint spacing,
|
|
|
|
GimpLayerModeEffects paint_mode,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
const guchar *mask_data,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data);
|
1998-10-02 06:09:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables
|
|
|
|
*/
|
|
|
|
|
2002-12-13 21:23:47 +08:00
|
|
|
static GTree *script_list = NULL;
|
2000-11-08 22:35:50 +08:00
|
|
|
static SFInterface *sf_interface = NULL; /* there can only be at most one
|
|
|
|
interactive interface */
|
2003-09-05 07:12:32 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2000-02-01 04:47:44 +08:00
|
|
|
script_fu_find_scripts (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-06-16 19:31:10 +08:00
|
|
|
gchar *path_str;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Make sure to clear any existing scripts */
|
|
|
|
if (script_list != NULL)
|
|
|
|
{
|
2003-09-05 07:12:32 +08:00
|
|
|
g_tree_foreach (script_list,
|
|
|
|
(GTraverseFunc) script_fu_remove_script,
|
2001-11-29 23:54:39 +08:00
|
|
|
NULL);
|
2000-05-08 06:04:51 +08:00
|
|
|
g_tree_destroy (script_list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-11-29 23:54:39 +08:00
|
|
|
script_list = g_tree_new ((GCompareFunc) strcoll);
|
2000-05-08 06:04:51 +08:00
|
|
|
|
2000-08-01 08:38:38 +08:00
|
|
|
path_str = gimp_gimprc_query ("script-fu-path");
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-01 08:38:38 +08:00
|
|
|
if (path_str == NULL)
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-06-16 19:31:10 +08:00
|
|
|
gimp_datafiles_read_directories (path_str, G_FILE_TEST_IS_REGULAR,
|
|
|
|
script_fu_load_script,
|
|
|
|
NULL);
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2000-08-01 08:38:38 +08:00
|
|
|
g_free (path_str);
|
2000-05-08 06:04:51 +08:00
|
|
|
|
|
|
|
/* now that all scripts are read in and sorted, tell gimp about them */
|
2003-09-05 07:12:32 +08:00
|
|
|
g_tree_foreach (script_list,
|
|
|
|
(GTraverseFunc) script_fu_install_script,
|
2001-11-29 23:54:39 +08:00
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LISP
|
|
|
|
script_fu_add_script (LISP a)
|
|
|
|
{
|
2000-08-08 05:30:35 +08:00
|
|
|
GimpParamDef *args;
|
2000-11-08 22:35:50 +08:00
|
|
|
SFScript *script;
|
|
|
|
gchar *val;
|
|
|
|
gint i;
|
2001-01-15 04:25:46 +08:00
|
|
|
guchar r, g, b;
|
2000-11-08 22:35:50 +08:00
|
|
|
LISP color_list;
|
|
|
|
LISP adj_list;
|
|
|
|
LISP brush_list;
|
|
|
|
LISP option_list;
|
|
|
|
gchar *s;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Check the length of a */
|
|
|
|
if (nlength (a) < 7)
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("Too few arguments to script-fu-register", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create a new script */
|
2000-11-08 22:35:50 +08:00
|
|
|
script = g_new0 (SFScript, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Find the script name */
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
script->script_name = g_strdup (val);
|
|
|
|
a = cdr (a);
|
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
/* transform the function name into a name containing "_" for each "-".
|
|
|
|
* this does not hurt anybody, yet improves the life of many... ;)
|
|
|
|
*/
|
|
|
|
script->pdb_name = g_strdup (val);
|
|
|
|
|
|
|
|
for (s = script->pdb_name; *s; s++)
|
|
|
|
if (*s == '-')
|
|
|
|
*s = '_';
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Find the script description */
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
script->description = g_strdup (val);
|
|
|
|
a = cdr (a);
|
|
|
|
|
|
|
|
/* Find the script help */
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
script->help = g_strdup (val);
|
|
|
|
a = cdr (a);
|
|
|
|
|
|
|
|
/* Find the script author */
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
script->author = g_strdup (val);
|
|
|
|
a = cdr (a);
|
|
|
|
|
|
|
|
/* Find the script copyright */
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
script->copyright = g_strdup (val);
|
|
|
|
a = cdr (a);
|
|
|
|
|
|
|
|
/* Find the script date */
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
script->date = g_strdup (val);
|
|
|
|
a = cdr (a);
|
|
|
|
|
|
|
|
/* Find the script image types */
|
|
|
|
if (TYPEP (a, tc_cons))
|
|
|
|
{
|
|
|
|
val = get_c_string (car (a));
|
|
|
|
a = cdr (a);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val = get_c_string (a);
|
|
|
|
a = NIL;
|
|
|
|
}
|
|
|
|
script->img_types = g_strdup (val);
|
|
|
|
|
|
|
|
/* Check the supplied number of arguments */
|
|
|
|
script->num_args = nlength (a) / 3;
|
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args = g_new (GimpParamDef, script->num_args + 1);
|
2001-01-22 04:06:26 +08:00
|
|
|
args[0].type = GIMP_PDB_INT32;
|
|
|
|
args[0].name = "run_mode";
|
1998-02-25 18:48:59 +08:00
|
|
|
args[0].description = "Interactive, non-interactive";
|
|
|
|
|
1999-10-21 20:37:18 +08:00
|
|
|
script->arg_types = g_new (SFArgType, script->num_args);
|
2000-05-08 06:04:51 +08:00
|
|
|
script->arg_labels = g_new (gchar *, script->num_args);
|
1999-10-21 20:37:18 +08:00
|
|
|
script->arg_defaults = g_new0 (SFArgValue, script->num_args);
|
|
|
|
script->arg_values = g_new0 (SFArgValue, script->num_args);
|
1998-02-25 18:48:59 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (script->num_args > 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
|
|
|
{
|
|
|
|
if (a != NIL)
|
|
|
|
{
|
|
|
|
if (!TYPEP (car (a), tc_flonum))
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: argument types must be integer values", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
script->arg_types[i] = get_c_long (car (a));
|
|
|
|
a = cdr (a);
|
|
|
|
}
|
|
|
|
else
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: missing type specifier", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (a != NIL)
|
|
|
|
{
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: argument labels must be strings", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
script->arg_labels[i] = g_strdup (get_c_string (car (a)));
|
|
|
|
a = cdr (a);
|
|
|
|
}
|
|
|
|
else
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: missing arguments label", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (a != NIL)
|
|
|
|
{
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
if (!TYPEP (car (a), tc_flonum))
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: drawable defaults must be integer values", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
script->arg_defaults[i].sfa_image = get_c_long (car (a));
|
|
|
|
script->arg_values[i].sfa_image = script->arg_defaults[i].sfa_image;
|
|
|
|
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_IMAGE;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "image";
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_DRAWABLE:
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_DRAWABLE;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "drawable";
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_LAYER:
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_LAYER;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "layer";
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_CHANNEL:
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_CHANNEL;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "channel";
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_COLOR:
|
|
|
|
if (!TYPEP (car (a), tc_cons))
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: color defaults must be a list of 3 integers", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
color_list = car (a);
|
2001-01-15 04:25:46 +08:00
|
|
|
r = CLAMP (get_c_long (car (color_list)), 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
color_list = cdr (color_list);
|
2001-01-15 04:25:46 +08:00
|
|
|
g = CLAMP (get_c_long (car (color_list)), 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
color_list = cdr (color_list);
|
2001-01-15 04:25:46 +08:00
|
|
|
b = CLAMP (get_c_long (car (color_list)), 0, 255);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
|
|
|
gimp_rgb_set_uchar (&script->arg_defaults[i].sfa_color,
|
2001-01-15 04:25:46 +08:00
|
|
|
r, g, b);
|
2001-01-11 06:49:45 +08:00
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_color =
|
2001-01-11 06:49:45 +08:00
|
|
|
script->arg_defaults[i].sfa_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_COLOR;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "color";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_TOGGLE:
|
|
|
|
if (!TYPEP (car (a), tc_flonum))
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: toggle default must be an integer value", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_toggle =
|
2000-11-08 22:35:50 +08:00
|
|
|
(get_c_long (car (a))) ? TRUE : FALSE;
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_toggle =
|
2000-11-08 22:35:50 +08:00
|
|
|
script->arg_defaults[i].sfa_toggle;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_INT32;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "toggle";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
case SF_VALUE:
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!TYPEP (car (a), tc_string))
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: value defaults must be string values", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_value =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (get_c_string (car (a)));
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_value =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (script->arg_defaults[i].sfa_value);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
1997-11-25 06:05:25 +08:00
|
|
|
args[i + 1].name = "value";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
1998-08-06 03:58:10 +08:00
|
|
|
|
|
|
|
case SF_STRING:
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
|
|
|
return my_err ("script-fu-register: string defaults must be string values", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_value =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (get_c_string (car (a)));
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_value =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (script->arg_defaults[i].sfa_value);
|
1998-08-06 03:58:10 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
1998-08-06 03:58:10 +08:00
|
|
|
args[i + 1].name = "string";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
1998-08-06 22:58:39 +08:00
|
|
|
case SF_ADJUSTMENT:
|
|
|
|
if (!TYPEP (car (a), tc_cons))
|
|
|
|
return my_err ("script-fu-register: adjustment defaults must be a list", NIL);
|
|
|
|
adj_list = car (a);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.value =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_double (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
adj_list = cdr (adj_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.lower =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_double (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
adj_list = cdr (adj_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.upper =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_double (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
adj_list = cdr (adj_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.step =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_double (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
adj_list = cdr (adj_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.page =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_double (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
adj_list = cdr (adj_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.digits =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_long (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
adj_list = cdr (adj_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.type =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_long (car (adj_list));
|
1998-08-06 22:58:39 +08:00
|
|
|
script->arg_values[i].sfa_adjustment.adj = NULL;
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_adjustment.value =
|
2000-11-08 22:35:50 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.value;
|
1998-08-06 22:58:39 +08:00
|
|
|
|
2002-02-22 23:21:08 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_FLOAT;
|
1998-08-06 22:58:39 +08:00
|
|
|
args[i + 1].name = "value";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
1998-11-06 08:51:39 +08:00
|
|
|
case SF_FILENAME:
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
|
|
|
return my_err ("script-fu-register: filename defaults must be string values", NIL);
|
2001-11-22 02:50:50 +08:00
|
|
|
/* fallthrough */
|
|
|
|
case SF_DIRNAME:
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
|
|
|
return my_err ("script-fu-register: dirname defaults must be string values", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_file.filename =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (get_c_string (car (a)));
|
1999-05-29 09:28:24 +08:00
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifdef G_OS_WIN32
|
1999-05-29 09:28:24 +08:00
|
|
|
/* Replace POSIX slashes with Win32 backslashes. This
|
|
|
|
* is just so script-fus can be written with only
|
|
|
|
* POSIX directory separators.
|
|
|
|
*/
|
|
|
|
val = script->arg_defaults[i].sfa_file.filename;
|
|
|
|
while (*val)
|
|
|
|
{
|
|
|
|
if (*val == '/')
|
|
|
|
*val = '\\';
|
|
|
|
val++;
|
|
|
|
}
|
|
|
|
#endif
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_file.filename =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (script->arg_defaults[i].sfa_file.filename);
|
2003-11-21 23:53:57 +08:00
|
|
|
script->arg_values[i].sfa_file.file_entry = NULL;
|
1998-11-06 08:51:39 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
2003-09-05 07:12:32 +08:00
|
|
|
args[i + 1].name = (script->arg_types[i] == SF_FILENAME ?
|
2001-11-22 02:50:50 +08:00
|
|
|
"filename" : "dirname");
|
1999-05-19 01:33:39 +08:00
|
|
|
args[i + 1].description = script->arg_labels[i];
|
1998-11-06 08:51:39 +08:00
|
|
|
break;
|
|
|
|
|
1998-08-10 23:06:58 +08:00
|
|
|
case SF_FONT:
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
|
|
|
return my_err ("script-fu-register: font defaults must be string values", NIL);
|
2003-03-28 22:13:54 +08:00
|
|
|
script->arg_defaults[i].sfa_font =
|
|
|
|
g_strdup (get_c_string (car (a)));
|
|
|
|
script->arg_values[i].sfa_font =
|
|
|
|
g_strdup (script->arg_defaults[i].sfa_font);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
1998-08-10 23:06:58 +08:00
|
|
|
args[i + 1].name = "font";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
1998-10-02 06:09:01 +08:00
|
|
|
|
|
|
|
case SF_PATTERN:
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
|
|
|
return my_err ("script-fu-register: pattern defaults must be string values", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_pattern =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (get_c_string (car (a)));
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_pattern =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (script->arg_defaults[i].sfa_pattern);
|
1998-10-02 06:09:01 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
1998-10-02 06:09:01 +08:00
|
|
|
args[i + 1].name = "pattern";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
case SF_BRUSH:
|
|
|
|
if (!TYPEP (car (a), tc_cons))
|
|
|
|
return my_err ("script-fu-register: brush defaults must be a list", NIL);
|
|
|
|
brush_list = car (a);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_brush.name =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (get_c_string (car (brush_list)));
|
1998-10-21 06:36:52 +08:00
|
|
|
brush_list = cdr (brush_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_brush.opacity =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_double (car (brush_list));
|
1998-10-21 06:36:52 +08:00
|
|
|
brush_list = cdr (brush_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_brush.spacing =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_long (car (brush_list));
|
1998-10-21 06:36:52 +08:00
|
|
|
brush_list = cdr (brush_list);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_brush.paint_mode =
|
2000-11-08 22:35:50 +08:00
|
|
|
get_c_long (car (brush_list));
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_brush =
|
2000-11-08 22:35:50 +08:00
|
|
|
script->arg_defaults[i].sfa_brush;
|
1998-10-21 06:36:52 +08:00
|
|
|
/* Need this since we need a copy of the string
|
|
|
|
* in the values area. We could free it later but the
|
|
|
|
* default one must hang around.
|
|
|
|
*/
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_brush.name =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup(script->arg_defaults[i].sfa_brush.name);
|
1998-10-21 06:36:52 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
1998-10-21 06:36:52 +08:00
|
|
|
args[i + 1].name = "brush";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
1998-08-10 23:06:58 +08:00
|
|
|
break;
|
1998-10-21 06:36:52 +08:00
|
|
|
|
1998-11-01 00:22:37 +08:00
|
|
|
case SF_GRADIENT:
|
|
|
|
if (!TYPEP (car (a), tc_string))
|
|
|
|
return my_err ("script-fu-register: gradient defaults must be string values", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_gradient =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (get_c_string (car (a)));
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_gradient =
|
2000-11-08 22:35:50 +08:00
|
|
|
g_strdup (script->arg_defaults[i].sfa_pattern);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_STRING;
|
1998-11-01 00:22:37 +08:00
|
|
|
args[i + 1].name = "gradient";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
case SF_OPTION:
|
|
|
|
if (!TYPEP (car (a), tc_cons))
|
|
|
|
return my_err ("script-fu-register: option defaults must be a list", NIL);
|
2003-09-05 07:12:32 +08:00
|
|
|
for (option_list = car (a);
|
|
|
|
option_list;
|
2000-11-08 22:35:50 +08:00
|
|
|
option_list = cdr (option_list))
|
2000-04-28 08:02:11 +08:00
|
|
|
{
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_option.list =
|
|
|
|
g_slist_append (script->arg_defaults[i].sfa_option.list,
|
2000-04-28 08:02:11 +08:00
|
|
|
g_strdup (get_c_string (car (option_list))));
|
|
|
|
}
|
|
|
|
script->arg_defaults[i].sfa_option.history = 0;
|
|
|
|
script->arg_values[i].sfa_option.history = 0;
|
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
args[i + 1].type = GIMP_PDB_INT32;
|
2000-04-28 08:02:11 +08:00
|
|
|
args[i + 1].name = "option";
|
|
|
|
args[i + 1].description = script->arg_labels[i];
|
|
|
|
break;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
a = cdr (a);
|
|
|
|
}
|
|
|
|
else
|
1998-04-09 17:00:27 +08:00
|
|
|
return my_err ("script-fu-register: missing default argument", NIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-08 06:04:51 +08:00
|
|
|
script->args = args;
|
|
|
|
g_tree_insert (script_list, gettext (script->description), script);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
script_fu_report_cc (gchar *command)
|
|
|
|
{
|
2000-11-08 22:35:50 +08:00
|
|
|
if (sf_interface == NULL)
|
|
|
|
return;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
if (sf_interface->last_command &&
|
2000-11-08 22:35:50 +08:00
|
|
|
strcmp (sf_interface->last_command, command) == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-04-28 08:02:11 +08:00
|
|
|
gchar *new_command;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
sf_interface->command_count++;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
new_command = g_strdup_printf ("%s <%d>",
|
2000-11-08 22:35:50 +08:00
|
|
|
command, sf_interface->command_count);
|
2002-05-25 03:44:37 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (sf_interface->status), new_command);
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (new_command);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-08 22:35:50 +08:00
|
|
|
sf_interface->command_count = 1;
|
2002-05-25 03:44:37 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (sf_interface->status), command);
|
2000-11-08 22:35:50 +08:00
|
|
|
g_free (sf_interface->last_command);
|
|
|
|
sf_interface->last_command = g_strdup (command);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-05-25 03:44:37 +08:00
|
|
|
|
|
|
|
while (gtk_main_iteration ());
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-08 06:04:51 +08:00
|
|
|
|
2003-06-16 19:31:10 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2003-07-03 01:11:00 +08:00
|
|
|
script_fu_load_script (const GimpDatafileData *file_data,
|
|
|
|
gpointer user_data)
|
2003-06-16 19:31:10 +08:00
|
|
|
{
|
|
|
|
if (gimp_datafiles_check_extension (file_data->filename, ".scm"))
|
|
|
|
{
|
|
|
|
gchar *command;
|
|
|
|
gchar *qf = g_strescape (file_data->filename, NULL);
|
|
|
|
|
|
|
|
command = g_strdup_printf ("(load \"%s\")", qf);
|
|
|
|
g_free (qf);
|
|
|
|
|
|
|
|
if (repl_c_string (command, 0, 0, 1) != 0)
|
|
|
|
script_fu_error_msg (command);
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
2003-09-05 07:12:32 +08:00
|
|
|
/* No, I don't know why, but this is
|
2003-06-16 19:31:10 +08:00
|
|
|
* necessary on NT 4.0.
|
|
|
|
*/
|
|
|
|
Sleep(0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_free (command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
/*
|
|
|
|
* The following function is a GTraverseFunction. Please
|
|
|
|
* note that it frees the script->args structure. --Sven
|
2000-05-08 06:04:51 +08:00
|
|
|
*/
|
2001-01-22 04:06:26 +08:00
|
|
|
static gboolean
|
2000-05-08 06:04:51 +08:00
|
|
|
script_fu_install_script (gpointer foo,
|
|
|
|
SFScript *script,
|
|
|
|
gpointer bar)
|
|
|
|
{
|
|
|
|
gchar *menu_path = NULL;
|
|
|
|
|
|
|
|
/* Allow scripts with no menus */
|
|
|
|
if (strncmp (script->description, "<None>", 6) != 0)
|
|
|
|
menu_path = script->description;
|
|
|
|
|
|
|
|
gimp_install_temp_proc (script->pdb_name,
|
|
|
|
script->description,
|
|
|
|
script->help,
|
|
|
|
script->author,
|
|
|
|
script->copyright,
|
|
|
|
script->date,
|
|
|
|
menu_path,
|
|
|
|
script->img_types,
|
2000-08-22 11:27:14 +08:00
|
|
|
GIMP_TEMPORARY,
|
2000-05-08 06:04:51 +08:00
|
|
|
script->num_args + 1, 0,
|
|
|
|
script->args, NULL,
|
|
|
|
script_fu_script_proc);
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2000-05-08 06:04:51 +08:00
|
|
|
g_free (script->args);
|
|
|
|
script->args = NULL;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
/*
|
2000-05-08 06:04:51 +08:00
|
|
|
* The following function is a GTraverseFunction.
|
|
|
|
*/
|
2001-01-22 04:06:26 +08:00
|
|
|
static gboolean
|
2000-05-08 06:04:51 +08:00
|
|
|
script_fu_remove_script (gpointer foo,
|
|
|
|
SFScript *script,
|
|
|
|
gpointer bar)
|
|
|
|
{
|
|
|
|
script_fu_free_script (script);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2003-07-02 08:15:09 +08:00
|
|
|
script_fu_script_proc (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *params,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-05-25 03:44:37 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
SFScript *script;
|
|
|
|
gint min_args;
|
|
|
|
gchar *escaped;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
run_mode = params[0].data.d_int32;
|
|
|
|
|
|
|
|
if (! (script = script_fu_find_script (name)))
|
2001-01-22 04:06:26 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
1998-02-25 18:48:59 +08:00
|
|
|
if (script->num_args == 0)
|
2000-08-22 11:27:14 +08:00
|
|
|
run_mode = GIMP_RUN_NONINTERACTIVE;
|
1998-02-25 18:48:59 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2000-11-08 22:35:50 +08:00
|
|
|
/* Determine whether the script is image based (runs on an image) */
|
1997-11-25 06:05:25 +08:00
|
|
|
if (strncmp (script->description, "<Image>", 7) == 0)
|
|
|
|
{
|
2000-04-28 08:02:11 +08:00
|
|
|
script->arg_values[0].sfa_image = params[1].data.d_image;
|
1997-11-25 06:05:25 +08:00
|
|
|
script->arg_values[1].sfa_drawable = params[2].data.d_drawable;
|
|
|
|
script->image_based = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
script->image_based = FALSE;
|
|
|
|
|
|
|
|
/* First acquire information with a dialog */
|
2003-09-05 07:12:32 +08:00
|
|
|
/* Skip this part if the script takes no parameters */
|
1998-01-25 17:29:29 +08:00
|
|
|
min_args = (script->image_based) ? 2 : 0;
|
2003-09-05 07:12:32 +08:00
|
|
|
if (script->num_args > min_args)
|
1999-10-21 20:37:18 +08:00
|
|
|
{
|
2003-09-05 07:12:32 +08:00
|
|
|
script_fu_interface (script);
|
1999-10-21 20:37:18 +08:00
|
|
|
break;
|
2003-09-05 07:12:32 +08:00
|
|
|
}
|
2000-11-08 22:35:50 +08:00
|
|
|
/* else fallthrough */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Make sure all the arguments are there! */
|
|
|
|
if (nparams != (script->num_args + 1))
|
2000-08-22 11:27:14 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-25 09:20:05 +08:00
|
|
|
guchar color[3];
|
2000-04-28 08:02:11 +08:00
|
|
|
gchar *text = NULL;
|
|
|
|
gchar *command;
|
|
|
|
gchar *c;
|
|
|
|
gchar buffer[MAX_STRING_LENGTH];
|
|
|
|
gint length;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
length = strlen (script->script_name) + 3;
|
|
|
|
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
length += 12; /* Maximum size of integer value will not exceed this many characters */
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_COLOR:
|
|
|
|
length += 16; /* Maximum size of color string: '(XXX XXX XXX) */
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_TOGGLE:
|
|
|
|
length += 6; /* Maximum size of (TRUE, FALSE) */
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_VALUE:
|
|
|
|
length += strlen (params[i + 1].data.d_string) + 1;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-08-06 03:58:10 +08:00
|
|
|
case SF_STRING:
|
1998-11-06 08:51:39 +08:00
|
|
|
case SF_FILENAME:
|
2001-11-22 02:50:50 +08:00
|
|
|
case SF_DIRNAME:
|
2001-11-23 07:46:13 +08:00
|
|
|
escaped = g_strescape (params[i + 1].data.d_string, NULL);
|
1999-05-29 09:28:24 +08:00
|
|
|
length += strlen (escaped) + 3;
|
|
|
|
g_free (escaped);
|
1998-11-06 08:51:39 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-08-06 22:58:39 +08:00
|
|
|
case SF_ADJUSTMENT:
|
2003-10-09 11:53:54 +08:00
|
|
|
length += G_ASCII_DTOSTR_BUF_SIZE;
|
1998-08-06 22:58:39 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-08-10 23:06:58 +08:00
|
|
|
case SF_FONT:
|
1998-10-02 06:09:01 +08:00
|
|
|
case SF_PATTERN:
|
1998-11-01 00:22:37 +08:00
|
|
|
case SF_GRADIENT:
|
1998-10-21 06:36:52 +08:00
|
|
|
case SF_BRUSH:
|
|
|
|
length += strlen (params[i + 1].data.d_string) + 3;
|
2003-09-05 07:12:32 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
case SF_OPTION:
|
|
|
|
length += strlen (params[i + 1].data.d_string) + 1;
|
1998-10-21 06:36:52 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
c = command = g_new (gchar, length);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-02-25 18:48:59 +08:00
|
|
|
if (script->num_args)
|
1999-12-06 04:48:06 +08:00
|
|
|
{
|
|
|
|
sprintf (command, "(%s ", script->script_name);
|
|
|
|
c += strlen (script->script_name) + 2;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
for (i = 0; i < script->num_args; i++)
|
|
|
|
{
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
2000-05-03 21:14:32 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%d",
|
|
|
|
params[i + 1].data.d_image);
|
1999-12-06 04:48:06 +08:00
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
case SF_COLOR:
|
2001-01-25 09:20:05 +08:00
|
|
|
gimp_rgb_get_uchar (¶ms[i + 1].data.d_color,
|
|
|
|
color, color + 1, color + 2);
|
2000-05-03 21:14:32 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)",
|
2001-01-25 09:20:05 +08:00
|
|
|
color[0], color[1], color[2]);
|
1999-12-06 04:48:06 +08:00
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
case SF_TOGGLE:
|
2000-02-01 04:47:44 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s",
|
2003-09-05 07:12:32 +08:00
|
|
|
(params[i + 1].data.d_int32) ? "TRUE"
|
2000-11-08 22:35:50 +08:00
|
|
|
: "FALSE");
|
1999-12-06 04:48:06 +08:00
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
case SF_VALUE:
|
|
|
|
text = params[i + 1].data.d_string;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
case SF_STRING:
|
|
|
|
case SF_FILENAME:
|
2001-11-22 02:50:50 +08:00
|
|
|
case SF_DIRNAME:
|
2003-09-05 07:12:32 +08:00
|
|
|
escaped = g_strescape (params[i + 1].data.d_string,
|
2001-11-23 07:46:13 +08:00
|
|
|
NULL);
|
2000-05-03 21:14:32 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
|
|
|
escaped);
|
1999-12-06 04:48:06 +08:00
|
|
|
g_free (escaped);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
case SF_ADJUSTMENT:
|
2003-10-09 11:53:54 +08:00
|
|
|
text = g_ascii_dtostr (buffer, sizeof (buffer),
|
|
|
|
params[i + 1].data.d_float);
|
1999-12-06 04:48:06 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
case SF_FONT:
|
|
|
|
case SF_PATTERN:
|
|
|
|
case SF_GRADIENT:
|
|
|
|
case SF_BRUSH:
|
2000-05-03 21:14:32 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
|
|
|
params[i + 1].data.d_string);
|
1999-12-06 04:48:06 +08:00
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
case SF_OPTION:
|
|
|
|
text = params[i + 1].data.d_string;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == script->num_args - 1)
|
|
|
|
sprintf (c, "%s)", text);
|
|
|
|
else
|
|
|
|
sprintf (c, "%s ", text);
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1999-12-06 04:48:06 +08:00
|
|
|
c += strlen (text) + 1;
|
|
|
|
}
|
|
|
|
}
|
1998-02-25 18:48:59 +08:00
|
|
|
else
|
|
|
|
sprintf (command, "(%s)", script->script_name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* run the command through the interpreter */
|
2000-11-08 22:35:50 +08:00
|
|
|
if (repl_c_string (command, 0, 0, 1) != 0)
|
|
|
|
script_fu_error_msg (command);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (command);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
|
|
|
|
2000-08-08 05:30:35 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
2000-05-08 06:04:51 +08:00
|
|
|
/* this is a GTraverseFunction */
|
2001-01-22 04:06:26 +08:00
|
|
|
static gboolean
|
2003-07-02 19:07:41 +08:00
|
|
|
script_fu_lookup_script (gpointer *foo,
|
|
|
|
SFScript *script,
|
|
|
|
gconstpointer *name)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-08 06:04:51 +08:00
|
|
|
if (strcmp (script->pdb_name, *name) == 0)
|
2003-09-05 07:12:32 +08:00
|
|
|
{
|
2000-05-08 06:04:51 +08:00
|
|
|
/* store the script in the name pointer and stop the traversal */
|
2003-07-02 19:07:41 +08:00
|
|
|
*name = script;
|
2000-05-08 06:04:51 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-05-08 06:04:51 +08:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-08 06:04:51 +08:00
|
|
|
static SFScript *
|
2003-07-02 19:07:41 +08:00
|
|
|
script_fu_find_script (const gchar *pdb_name)
|
2000-05-08 06:04:51 +08:00
|
|
|
{
|
2003-07-02 19:07:41 +08:00
|
|
|
gconstpointer script = pdb_name;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
g_tree_foreach (script_list,
|
|
|
|
(GTraverseFunc) script_fu_lookup_script,
|
2001-11-29 23:54:39 +08:00
|
|
|
&script);
|
2001-01-22 04:06:26 +08:00
|
|
|
|
2000-05-08 06:04:51 +08:00
|
|
|
if (script == pdb_name)
|
|
|
|
return NULL;
|
|
|
|
else
|
2003-07-02 19:07:41 +08:00
|
|
|
return (SFScript *) script;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
script_fu_free_script (SFScript *script)
|
|
|
|
{
|
2000-04-28 08:02:11 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Uninstall the temporary procedure for this script */
|
2004-02-03 19:37:03 +08:00
|
|
|
gimp_uninstall_temp_proc (script->pdb_name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (script)
|
|
|
|
{
|
|
|
|
g_free (script->script_name);
|
|
|
|
g_free (script->description);
|
|
|
|
g_free (script->help);
|
|
|
|
g_free (script->author);
|
|
|
|
g_free (script->copyright);
|
|
|
|
g_free (script->date);
|
|
|
|
g_free (script->img_types);
|
|
|
|
g_free (script->arg_types);
|
|
|
|
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
|
|
|
{
|
|
|
|
g_free (script->arg_labels[i]);
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
case SF_COLOR:
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_VALUE:
|
1998-08-10 23:06:58 +08:00
|
|
|
case SF_STRING:
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (script->arg_defaults[i].sfa_value);
|
1998-08-09 20:17:51 +08:00
|
|
|
g_free (script->arg_values[i].sfa_value);
|
1998-08-06 03:58:10 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-08-06 22:58:39 +08:00
|
|
|
case SF_ADJUSTMENT:
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-11-06 08:51:39 +08:00
|
|
|
case SF_FILENAME:
|
2001-11-22 02:50:50 +08:00
|
|
|
case SF_DIRNAME:
|
1998-11-06 08:51:39 +08:00
|
|
|
g_free (script->arg_defaults[i].sfa_file.filename);
|
|
|
|
g_free (script->arg_values[i].sfa_file.filename);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-08-10 23:06:58 +08:00
|
|
|
case SF_FONT:
|
2003-03-28 22:13:54 +08:00
|
|
|
g_free (script->arg_defaults[i].sfa_font);
|
|
|
|
g_free (script->arg_values[i].sfa_font);
|
1998-08-10 23:06:58 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-10-02 06:09:01 +08:00
|
|
|
case SF_PATTERN:
|
|
|
|
g_free (script->arg_defaults[i].sfa_pattern);
|
|
|
|
g_free (script->arg_values[i].sfa_pattern);
|
1998-10-21 06:36:52 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-11-01 00:22:37 +08:00
|
|
|
case SF_GRADIENT:
|
|
|
|
g_free (script->arg_defaults[i].sfa_gradient);
|
|
|
|
g_free (script->arg_values[i].sfa_gradient);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
case SF_BRUSH:
|
|
|
|
g_free (script->arg_defaults[i].sfa_brush.name);
|
|
|
|
g_free (script->arg_values[i].sfa_brush.name);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
case SF_OPTION:
|
2003-09-05 07:12:32 +08:00
|
|
|
g_slist_foreach (script->arg_defaults[i].sfa_option.list,
|
2000-04-28 08:02:11 +08:00
|
|
|
(GFunc)g_free, NULL);
|
|
|
|
if (script->arg_defaults[i].sfa_option.list)
|
|
|
|
g_slist_free (script->arg_defaults[i].sfa_option.list);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (script->arg_labels);
|
|
|
|
g_free (script->arg_defaults);
|
|
|
|
g_free (script->arg_values);
|
|
|
|
|
|
|
|
g_free (script);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
script_fu_interface (SFScript *script)
|
|
|
|
{
|
|
|
|
GtkWidget *dlg;
|
2000-02-01 04:47:44 +08:00
|
|
|
GtkWidget *frame;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *table;
|
1998-07-19 01:31:31 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
2000-11-08 22:35:50 +08:00
|
|
|
GSList *list;
|
2003-08-12 01:14:32 +08:00
|
|
|
gchar *title;
|
2000-11-08 22:35:50 +08:00
|
|
|
gchar *buf;
|
|
|
|
gint start_args;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
static gboolean gtk_initted = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
/* Simply return if there is already an interface. This is an
|
|
|
|
ugly workaround for the fact that we can not process two
|
|
|
|
scripts at a time. */
|
|
|
|
if (sf_interface != NULL)
|
|
|
|
return;
|
|
|
|
|
1999-10-21 20:37:18 +08:00
|
|
|
g_return_if_fail (script != NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!gtk_initted)
|
|
|
|
{
|
2001-10-29 20:51:21 +08:00
|
|
|
INIT_I18N();
|
1999-08-25 03:57:55 +08:00
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
gimp_ui_init ("script-fu", TRUE);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_initted = TRUE;
|
|
|
|
}
|
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
sf_interface = g_new0 (SFInterface, 1);
|
|
|
|
sf_interface->args_widgets = g_new0 (GtkWidget *, script->num_args);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
2000-02-28 03:35:39 +08:00
|
|
|
/* strip the first part of the menupath if it contains _("/Script-Fu/") */
|
|
|
|
buf = strstr (gettext (script->description), _("/Script-Fu/"));
|
1998-07-19 01:31:31 +08:00
|
|
|
if (buf)
|
2003-08-12 01:14:32 +08:00
|
|
|
title = g_strdup (buf + strlen (_("/Script-Fu/")));
|
2003-09-05 07:12:32 +08:00
|
|
|
else
|
2003-08-12 01:14:32 +08:00
|
|
|
title = g_strdup (gettext (script->description));
|
|
|
|
|
|
|
|
/* strip mnemonics from the menupath */
|
|
|
|
sf_interface->title = gimp_strip_uline (title);
|
|
|
|
g_free (title);
|
2000-02-28 03:35:39 +08:00
|
|
|
|
2002-09-17 21:57:30 +08:00
|
|
|
buf = strstr (sf_interface->title, "...");
|
2000-02-28 03:35:39 +08:00
|
|
|
if (buf)
|
|
|
|
*buf = '\0';
|
1998-07-19 01:31:31 +08:00
|
|
|
|
2002-09-17 21:57:30 +08:00
|
|
|
buf = g_strdup_printf (_("Script-Fu: %s"), sf_interface->title);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
sf_interface->dialog = dlg =
|
|
|
|
gimp_dialog_new (buf, "script-fu",
|
|
|
|
NULL, 0,
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_standard_help_func, script->pdb_name,
|
2002-05-25 03:44:37 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GIMP_STOCK_RESET, RESPONSE_RESET,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-05-25 03:44:37 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
2002-05-25 03:44:37 +08:00
|
|
|
|
2002-09-17 21:57:30 +08:00
|
|
|
g_free (buf);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (dlg, "response",
|
|
|
|
G_CALLBACK (script_fu_response),
|
|
|
|
script);
|
2002-05-25 03:44:37 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (dlg, "destroy",
|
2002-05-25 03:44:37 +08:00
|
|
|
G_CALLBACK (script_fu_interface_quit),
|
|
|
|
script);
|
|
|
|
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
|
|
|
|
|
2004-05-26 02:36:52 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
2002-05-25 03:44:37 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-11-08 22:46:14 +08:00
|
|
|
sf_interface->status = gtk_label_new (sf_interface->title);
|
2002-09-17 21:57:30 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (sf_interface->status), 0.0, 0.5);
|
2002-05-25 03:44:37 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), sf_interface->status, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (sf_interface->status);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label (_("About"));
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-05-25 03:44:37 +08:00
|
|
|
G_CALLBACK (script_fu_about_callback),
|
|
|
|
script);
|
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
/* the script arguments frame */
|
2004-05-26 02:36:52 +08:00
|
|
|
frame = gimp_frame_new (_("Script Arguments"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The argument table */
|
2003-06-09 22:17:57 +08:00
|
|
|
table = gtk_table_new (script->num_args + 1, 3, FALSE);
|
2004-05-26 02:36:52 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
gtk_widget_show (table);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
start_args = (script->image_based) ? 2 : 0;
|
|
|
|
|
|
|
|
for (i = start_args; i < script->num_args; i++)
|
|
|
|
{
|
2004-05-26 02:36:52 +08:00
|
|
|
GtkWidget *widget = NULL;
|
2003-11-12 03:22:35 +08:00
|
|
|
gchar *label_text;
|
2004-05-26 02:36:52 +08:00
|
|
|
gfloat label_yalign = 0.5;
|
|
|
|
gboolean leftalign = FALSE;
|
|
|
|
gint *ID_ptr = NULL;
|
2003-06-19 19:36:12 +08:00
|
|
|
|
|
|
|
/* we add a colon after the label;
|
|
|
|
some languages want an extra space here */
|
|
|
|
label_text = g_strdup_printf (_("%s:"),
|
|
|
|
gettext (script->arg_labels[i]));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
2004-04-21 06:14:49 +08:00
|
|
|
widget = gimp_image_combo_box_new (NULL, NULL);
|
|
|
|
ID_ptr = &script->arg_values[i].sfa_image;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_DRAWABLE:
|
2004-04-21 06:14:49 +08:00
|
|
|
widget = gimp_drawable_combo_box_new (NULL, NULL);
|
|
|
|
ID_ptr = &script->arg_values[i].sfa_drawable;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_LAYER:
|
2004-04-21 06:14:49 +08:00
|
|
|
widget = gimp_layer_combo_box_new (NULL, NULL);
|
|
|
|
ID_ptr = &script->arg_values[i].sfa_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case SF_CHANNEL:
|
2004-04-21 06:14:49 +08:00
|
|
|
widget = gimp_channel_combo_box_new (NULL, NULL);
|
|
|
|
ID_ptr = &script->arg_values[i].sfa_channel;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
menu = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2004-04-21 06:14:49 +08:00
|
|
|
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (widget), *ID_ptr);
|
|
|
|
g_signal_connect (widget, "changed",
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
ID_ptr);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_COLOR:
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gimp_color_button_new (_("Script-Fu Color Selection"),
|
|
|
|
COLOR_SAMPLE_WIDTH,
|
|
|
|
COLOR_SAMPLE_HEIGHT,
|
|
|
|
&script->arg_values[i].sfa_color,
|
|
|
|
GIMP_COLOR_AREA_FLAT);
|
|
|
|
|
|
|
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (widget), TRUE);
|
|
|
|
g_signal_connect (widget, "color_changed",
|
2001-07-30 08:46:09 +08:00
|
|
|
G_CALLBACK (gimp_color_button_get_color),
|
|
|
|
&script->arg_values[i].sfa_color);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_TOGGLE:
|
2000-04-28 08:02:11 +08:00
|
|
|
g_free (label_text);
|
|
|
|
label_text = NULL;
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gtk_check_button_new_with_mnemonic (gettext (script->arg_labels[i]));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
|
1997-11-25 06:05:25 +08:00
|
|
|
script->arg_values[i].sfa_toggle);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
g_signal_connect (widget, "toggled",
|
2001-07-30 08:46:09 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&script->arg_values[i].sfa_toggle);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_VALUE:
|
1998-08-06 03:58:10 +08:00
|
|
|
case SF_STRING:
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gtk_entry_new ();
|
|
|
|
gtk_widget_set_size_request (widget, TEXT_WIDTH, -1);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (widget),
|
|
|
|
script->arg_values[i].sfa_value);
|
1998-08-06 03:58:10 +08:00
|
|
|
break;
|
1998-08-06 22:58:39 +08:00
|
|
|
|
|
|
|
case SF_ADJUSTMENT:
|
|
|
|
switch (script->arg_defaults[i].sfa_adjustment.type)
|
|
|
|
{
|
|
|
|
case SF_SLIDER:
|
2003-06-09 22:17:57 +08:00
|
|
|
script->arg_values[i].sfa_adjustment.adj = (GtkAdjustment *)
|
|
|
|
gimp_scale_entry_new (GTK_TABLE (table), 0, i,
|
2003-09-05 07:12:32 +08:00
|
|
|
label_text, SLIDER_WIDTH, -1,
|
2003-06-09 22:17:57 +08:00
|
|
|
script->arg_values[i].sfa_adjustment.value,
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.lower,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.upper,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.step,
|
2003-06-09 22:17:57 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.page,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.digits,
|
|
|
|
TRUE, 0.0, 0.0,
|
|
|
|
NULL, NULL);
|
1998-08-06 22:58:39 +08:00
|
|
|
break;
|
1998-11-06 08:51:39 +08:00
|
|
|
|
1998-08-06 22:58:39 +08:00
|
|
|
case SF_SPINNER:
|
2004-05-26 02:36:52 +08:00
|
|
|
leftalign = TRUE;
|
2003-06-09 22:17:57 +08:00
|
|
|
script->arg_values[i].sfa_adjustment.adj = (GtkAdjustment *)
|
2003-09-05 07:12:32 +08:00
|
|
|
gtk_adjustment_new (script->arg_values[i].sfa_adjustment.value,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.lower,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.upper,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.step,
|
2003-06-09 22:17:57 +08:00
|
|
|
script->arg_defaults[i].sfa_adjustment.page, 0);
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gtk_spin_button_new (script->arg_values[i].sfa_adjustment.adj,
|
|
|
|
0,
|
|
|
|
script->arg_defaults[i].sfa_adjustment.digits);
|
1998-08-06 22:58:39 +08:00
|
|
|
break;
|
2001-01-22 04:06:26 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
default:
|
1998-08-06 22:58:39 +08:00
|
|
|
break;
|
1998-08-10 23:06:58 +08:00
|
|
|
}
|
1998-08-06 22:58:39 +08:00
|
|
|
break;
|
1998-11-06 08:51:39 +08:00
|
|
|
|
|
|
|
case SF_FILENAME:
|
2001-11-22 02:50:50 +08:00
|
|
|
case SF_DIRNAME:
|
|
|
|
if (script->arg_types[i] == SF_FILENAME)
|
2003-11-21 23:53:57 +08:00
|
|
|
widget = gimp_file_entry_new (_("Script-Fu File Selection"),
|
|
|
|
script->arg_values[i].sfa_file.filename,
|
|
|
|
FALSE, TRUE);
|
2001-11-22 02:50:50 +08:00
|
|
|
else
|
2003-11-21 23:53:57 +08:00
|
|
|
widget = gimp_file_entry_new (_("Script-Fu Folder Selection"),
|
|
|
|
script->arg_values[i].sfa_file.filename,
|
|
|
|
TRUE, TRUE);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
2003-11-21 23:53:57 +08:00
|
|
|
script->arg_values[i].sfa_file.file_entry = widget;
|
1999-05-19 01:33:39 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
g_signal_connect (widget, "filename_changed",
|
2003-11-21 23:53:57 +08:00
|
|
|
G_CALLBACK (script_fu_file_entry_callback),
|
2001-07-30 08:46:09 +08:00
|
|
|
&script->arg_values[i].sfa_file);
|
1998-11-06 08:51:39 +08:00
|
|
|
break;
|
|
|
|
|
1998-08-10 23:06:58 +08:00
|
|
|
case SF_FONT:
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gimp_font_select_widget_new (_("Script-Fu Font Selection"),
|
|
|
|
script->arg_values[i].sfa_font,
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_font_callback,
|
2003-11-12 03:22:35 +08:00
|
|
|
&script->arg_values[i].sfa_font);
|
1998-08-10 23:06:58 +08:00
|
|
|
break;
|
1998-11-06 08:51:39 +08:00
|
|
|
|
1998-10-02 06:09:01 +08:00
|
|
|
case SF_PATTERN:
|
2004-05-26 02:36:52 +08:00
|
|
|
leftalign = TRUE;
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gimp_pattern_select_widget_new (_("Script-fu Pattern Selection"),
|
|
|
|
script->arg_values[i].sfa_pattern,
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_pattern_callback,
|
2003-11-12 03:22:35 +08:00
|
|
|
&script->arg_values[i].sfa_pattern);
|
1998-10-02 06:09:01 +08:00
|
|
|
break;
|
1998-11-01 00:22:37 +08:00
|
|
|
case SF_GRADIENT:
|
2004-05-26 02:36:52 +08:00
|
|
|
leftalign = TRUE;
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gimp_gradient_select_widget_new (_("Script-Fu Gradient Selection"),
|
|
|
|
script->arg_values[i].sfa_gradient,
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_gradient_callback,
|
2003-11-12 03:22:35 +08:00
|
|
|
&script->arg_values[i].sfa_gradient);
|
1998-11-01 00:22:37 +08:00
|
|
|
break;
|
1998-11-06 08:51:39 +08:00
|
|
|
|
1998-10-21 06:36:52 +08:00
|
|
|
case SF_BRUSH:
|
2004-05-26 02:36:52 +08:00
|
|
|
leftalign = TRUE;
|
2003-11-12 03:22:35 +08:00
|
|
|
widget = gimp_brush_select_widget_new (_("Script-Fu Brush Selection"),
|
|
|
|
script->arg_values[i].sfa_brush.name,
|
|
|
|
script->arg_values[i].sfa_brush.opacity,
|
|
|
|
script->arg_values[i].sfa_brush.spacing,
|
|
|
|
script->arg_values[i].sfa_brush.paint_mode,
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_brush_callback,
|
2003-11-12 03:22:35 +08:00
|
|
|
&script->arg_values[i].sfa_brush);
|
1998-10-21 06:36:52 +08:00
|
|
|
break;
|
1998-10-02 06:09:01 +08:00
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
case SF_OPTION:
|
2004-04-18 06:47:56 +08:00
|
|
|
widget = gtk_combo_box_new_text ();
|
|
|
|
for (list = script->arg_defaults[i].sfa_option.list;
|
2003-09-05 07:12:32 +08:00
|
|
|
list;
|
2004-04-18 06:47:56 +08:00
|
|
|
list = g_slist_next (list))
|
2000-04-28 08:02:11 +08:00
|
|
|
{
|
2004-04-18 06:47:56 +08:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
|
|
|
|
gettext ((const gchar *) list->data));
|
2000-04-28 08:02:11 +08:00
|
|
|
}
|
2001-01-22 04:06:26 +08:00
|
|
|
|
2004-04-18 06:47:56 +08:00
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (widget),
|
|
|
|
script->arg_values[i].sfa_option.history);
|
2000-04-28 08:02:11 +08:00
|
|
|
break;
|
2003-09-05 07:12:32 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1998-11-06 08:51:39 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
if (widget)
|
2004-06-05 09:51:49 +08:00
|
|
|
{
|
|
|
|
if (label_text)
|
|
|
|
{
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, i,
|
|
|
|
label_text, 0.0, label_yalign,
|
|
|
|
widget, 2, leftalign);
|
|
|
|
g_free (label_text);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget, 0, 3, i, i+1,
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
}
|
|
|
|
}
|
2003-11-12 03:22:35 +08:00
|
|
|
|
|
|
|
sf_interface->args_widgets[i] = widget;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-08-09 20:17:51 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (dlg);
|
|
|
|
|
|
|
|
gtk_main ();
|
2000-11-08 22:35:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
script_fu_interface_quit (SFScript *script)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (script != NULL);
|
2003-09-05 07:12:32 +08:00
|
|
|
g_return_if_fail (sf_interface != NULL);
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2002-09-17 21:57:30 +08:00
|
|
|
g_free (sf_interface->title);
|
2000-11-08 22:35:50 +08:00
|
|
|
|
|
|
|
if (sf_interface->about_dialog)
|
|
|
|
gtk_widget_destroy (sf_interface->about_dialog);
|
|
|
|
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_FONT:
|
2003-07-01 23:06:06 +08:00
|
|
|
gimp_font_select_widget_close (sf_interface->args_widgets[i]);
|
2000-11-08 22:35:50 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_PATTERN:
|
2003-09-05 07:12:32 +08:00
|
|
|
gimp_pattern_select_widget_close (sf_interface->args_widgets[i]);
|
2000-11-08 22:35:50 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_GRADIENT:
|
2003-09-05 07:12:32 +08:00
|
|
|
gimp_gradient_select_widget_close (sf_interface->args_widgets[i]);
|
2000-11-08 22:35:50 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_BRUSH:
|
2003-09-05 07:12:32 +08:00
|
|
|
gimp_brush_select_widget_close (sf_interface->args_widgets[i]);
|
2000-11-08 22:35:50 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (sf_interface->args_widgets);
|
|
|
|
g_free (sf_interface->last_command);
|
|
|
|
|
|
|
|
g_free (sf_interface);
|
|
|
|
sf_interface = NULL;
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
/*
|
2000-11-08 22:35:50 +08:00
|
|
|
* We do not call gtk_main_quit() earlier to reduce the possibility
|
|
|
|
* that script_fu_script_proc() is called from gimp_extension_process()
|
|
|
|
* while we are not finished with the current script. This sucks!
|
|
|
|
*/
|
1999-10-21 20:37:18 +08:00
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
gtk_main_quit ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 06:09:01 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_pattern_callback (const gchar *name,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint bytes,
|
|
|
|
const guchar *mask_data,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data)
|
1998-10-02 06:09:01 +08:00
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
gchar **pname = data;
|
2000-05-03 21:14:32 +08:00
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
g_free (*pname);
|
|
|
|
*pname = g_strdup (name);
|
1998-10-02 06:09:01 +08:00
|
|
|
}
|
|
|
|
|
1998-11-01 00:22:37 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_gradient_callback (const gchar *name,
|
|
|
|
gint width,
|
|
|
|
const gdouble *mask_data,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data)
|
1998-11-01 00:22:37 +08:00
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
gchar **gname = data;
|
2000-05-03 21:14:32 +08:00
|
|
|
|
|
|
|
g_free (*gname);
|
|
|
|
*gname = g_strdup (name);
|
1998-11-01 00:22:37 +08:00
|
|
|
}
|
|
|
|
|
2003-03-28 22:13:54 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_font_callback (const gchar *name,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
gchar **fname = data;
|
2003-03-28 22:13:54 +08:00
|
|
|
|
|
|
|
g_free (*fname);
|
|
|
|
*fname = g_strdup (name);
|
|
|
|
}
|
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_brush_callback (const gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
gint spacing,
|
|
|
|
GimpLayerModeEffects paint_mode,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
const guchar *mask_data,
|
|
|
|
gboolean closing,
|
|
|
|
gpointer data)
|
1998-10-21 06:36:52 +08:00
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
SFBrush *brush = data;
|
2000-05-03 21:14:32 +08:00
|
|
|
|
1999-10-21 20:37:18 +08:00
|
|
|
g_free (brush->name);
|
2001-01-22 04:06:26 +08:00
|
|
|
|
2000-05-03 21:14:32 +08:00
|
|
|
brush->name = g_strdup (name);
|
|
|
|
brush->opacity = opacity;
|
|
|
|
brush->spacing = spacing;
|
1998-10-21 06:36:52 +08:00
|
|
|
brush->paint_mode = paint_mode;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
script_fu_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
SFScript *script)
|
|
|
|
{
|
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
case RESPONSE_RESET:
|
|
|
|
script_fu_reset (script);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_RESPONSE_OK:
|
|
|
|
script_fu_ok (script);
|
2003-11-21 23:53:57 +08:00
|
|
|
/* fallthru */
|
2003-11-06 23:27:05 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
gtk_widget_destroy (sf_interface->dialog);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
script_fu_ok (SFScript *script)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-04-18 06:47:56 +08:00
|
|
|
gchar *escaped;
|
|
|
|
gchar *text = NULL;
|
|
|
|
gchar *command;
|
|
|
|
gchar *c;
|
|
|
|
guchar r, g, b;
|
|
|
|
gchar buffer[MAX_STRING_LENGTH];
|
|
|
|
gint length;
|
|
|
|
gint i;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
length = strlen (script->script_name) + 3;
|
|
|
|
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
2003-11-12 03:22:35 +08:00
|
|
|
{
|
|
|
|
GtkWidget *widget = sf_interface->args_widgets[i];
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
length += 12; /* Maximum size of integer value */
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_COLOR:
|
|
|
|
length += 16; /* Maximum size of color string: '(XXX XXX XXX) */
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_TOGGLE:
|
|
|
|
length += 6; /* Maximum size of (TRUE, FALSE) */
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_VALUE:
|
|
|
|
length += strlen (gtk_entry_get_text (GTK_ENTRY (widget))) + 1;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_STRING:
|
|
|
|
escaped = g_strescape (gtk_entry_get_text (GTK_ENTRY (widget)),
|
|
|
|
NULL);
|
|
|
|
length += strlen (escaped) + 3;
|
|
|
|
g_free (escaped);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_ADJUSTMENT:
|
|
|
|
length += G_ASCII_DTOSTR_BUF_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_FILENAME:
|
|
|
|
case SF_DIRNAME:
|
|
|
|
escaped = g_strescape (script->arg_values[i].sfa_file.filename,
|
|
|
|
NULL);
|
|
|
|
length += strlen (escaped) + 3;
|
|
|
|
g_free (escaped);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_FONT:
|
|
|
|
length += strlen (script->arg_values[i].sfa_font) + 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_PATTERN:
|
|
|
|
length += strlen (script->arg_values[i].sfa_pattern) + 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_GRADIENT:
|
|
|
|
length += strlen (script->arg_values[i].sfa_gradient) + 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_BRUSH:
|
|
|
|
length += strlen (script->arg_values[i].sfa_brush.name) + 3;
|
|
|
|
length += 36; /* Maximum size of three ints */
|
|
|
|
/* for opacity, spacing, mode */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SF_OPTION:
|
|
|
|
length += 12; /* Maximum size of integer value */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-28 08:02:11 +08:00
|
|
|
c = command = g_new (gchar, length);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
sprintf (command, "(%s ", script->script_name);
|
|
|
|
c += strlen (script->script_name) + 2;
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
|
|
|
{
|
2003-11-12 03:22:35 +08:00
|
|
|
GtkWidget *widget = sf_interface->args_widgets[i];
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (script->arg_types[i])
|
2003-11-06 23:27:05 +08:00
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "%d",
|
|
|
|
script->arg_values[i].sfa_image);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_COLOR:
|
|
|
|
gimp_rgb_get_uchar (&script->arg_values[i].sfa_color, &r, &g, &b);
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)",
|
|
|
|
(gint) r, (gint) g, (gint) b);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_TOGGLE:
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s",
|
|
|
|
(script->arg_values[i].sfa_toggle) ? "TRUE" : "FALSE");
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_VALUE:
|
2003-11-12 03:22:35 +08:00
|
|
|
text = (gchar *) gtk_entry_get_text (GTK_ENTRY (widget));
|
2003-11-06 23:27:05 +08:00
|
|
|
g_free (script->arg_values[i].sfa_value);
|
|
|
|
script->arg_values[i].sfa_value = g_strdup (text);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_STRING:
|
2003-11-12 03:22:35 +08:00
|
|
|
text = (gchar *) gtk_entry_get_text (GTK_ENTRY (widget));
|
2003-11-06 23:27:05 +08:00
|
|
|
g_free (script->arg_values[i].sfa_value);
|
|
|
|
script->arg_values[i].sfa_value = g_strdup (text);
|
|
|
|
escaped = g_strescape (text, NULL);
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"", escaped);
|
|
|
|
g_free (escaped);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_ADJUSTMENT:
|
2002-11-08 22:46:14 +08:00
|
|
|
switch (script->arg_defaults[i].sfa_adjustment.type)
|
|
|
|
{
|
|
|
|
case SF_SLIDER:
|
|
|
|
script->arg_values[i].sfa_adjustment.value =
|
2003-09-05 07:12:32 +08:00
|
|
|
script->arg_values[i].sfa_adjustment.adj->value;
|
2003-11-06 23:27:05 +08:00
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_SPINNER:
|
|
|
|
script->arg_values[i].sfa_adjustment.value =
|
2003-11-12 03:22:35 +08:00
|
|
|
gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
|
2003-11-06 23:27:05 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
text = g_ascii_dtostr (buffer, sizeof (buffer),
|
|
|
|
script->arg_values[i].sfa_adjustment.value);
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_FILENAME:
|
|
|
|
case SF_DIRNAME:
|
|
|
|
escaped = g_strescape (script->arg_values[i].sfa_file.filename,
|
2001-11-23 07:46:13 +08:00
|
|
|
NULL);
|
2003-11-06 23:27:05 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"", escaped);
|
|
|
|
g_free (escaped);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_FONT:
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
|
|
|
script->arg_values[i].sfa_font);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_PATTERN:
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
|
|
|
script->arg_values[i].sfa_pattern);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_GRADIENT:
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
|
|
|
script->arg_values[i].sfa_gradient);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_BRUSH:
|
2002-11-08 22:46:14 +08:00
|
|
|
{
|
|
|
|
gchar opacity[G_ASCII_DTOSTR_BUF_SIZE];
|
|
|
|
|
|
|
|
g_ascii_dtostr (opacity, sizeof (opacity),
|
|
|
|
script->arg_values[i].sfa_brush.opacity);
|
|
|
|
|
|
|
|
g_snprintf (buffer, sizeof (buffer), "'(\"%s\" %s %d %d)",
|
|
|
|
script->arg_values[i].sfa_brush.name,
|
|
|
|
opacity,
|
|
|
|
script->arg_values[i].sfa_brush.spacing,
|
|
|
|
script->arg_values[i].sfa_brush.paint_mode);
|
|
|
|
text = buffer;
|
|
|
|
}
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
case SF_OPTION:
|
|
|
|
script->arg_values[i].sfa_option.history =
|
2004-04-18 06:47:56 +08:00
|
|
|
gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%d",
|
|
|
|
script->arg_values[i].sfa_option.history);
|
|
|
|
text = buffer;
|
|
|
|
break;
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (i == script->num_args - 1)
|
2003-11-06 23:27:05 +08:00
|
|
|
sprintf (c, "%s)", text);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2003-11-06 23:27:05 +08:00
|
|
|
sprintf (c, "%s ", text);
|
1997-11-25 06:05:25 +08:00
|
|
|
c += strlen (text) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* run the command through the interpreter */
|
2000-11-08 22:35:50 +08:00
|
|
|
if (repl_c_string (command, 0, 0, 1) != 0)
|
|
|
|
script_fu_error_msg (command);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (command);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
script_fu_reset (SFScript *script)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < script->num_args; i++)
|
2003-11-12 03:22:35 +08:00
|
|
|
{
|
|
|
|
GtkWidget *widget = sf_interface->args_widgets[i];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
switch (script->arg_types[i])
|
|
|
|
{
|
|
|
|
case SF_IMAGE:
|
|
|
|
case SF_DRAWABLE:
|
|
|
|
case SF_LAYER:
|
|
|
|
case SF_CHANNEL:
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_COLOR:
|
|
|
|
script->arg_values[i].sfa_color = script->arg_defaults[i].sfa_color;
|
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (widget),
|
|
|
|
&script->arg_values[i].sfa_color);
|
2003-11-06 23:27:05 +08:00
|
|
|
break;
|
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_TOGGLE:
|
|
|
|
script->arg_values[i].sfa_toggle = script->arg_defaults[i].sfa_toggle;
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
|
|
|
|
script->arg_values[i].sfa_toggle);
|
2003-11-06 23:27:05 +08:00
|
|
|
break;
|
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_VALUE:
|
|
|
|
case SF_STRING:
|
|
|
|
g_free (script->arg_values[i].sfa_value);
|
|
|
|
script->arg_values[i].sfa_value =
|
|
|
|
g_strdup (script->arg_defaults[i].sfa_value);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (widget),
|
|
|
|
script->arg_values[i].sfa_value);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_ADJUSTMENT:
|
|
|
|
script->arg_values[i].sfa_adjustment.value =
|
|
|
|
script->arg_defaults[i].sfa_adjustment.value;
|
|
|
|
gtk_adjustment_set_value (script->arg_values[i].sfa_adjustment.adj,
|
|
|
|
script->arg_values[i].sfa_adjustment.value);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_FILENAME:
|
|
|
|
case SF_DIRNAME:
|
|
|
|
g_free (script->arg_values[i].sfa_file.filename);
|
|
|
|
script->arg_values[i].sfa_file.filename =
|
|
|
|
g_strdup (script->arg_defaults[i].sfa_file.filename);
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_file_entry_set_filename
|
|
|
|
(GIMP_FILE_ENTRY (script->arg_values[i].sfa_file.file_entry),
|
2003-11-12 03:22:35 +08:00
|
|
|
script->arg_values[i].sfa_file.filename);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_FONT:
|
|
|
|
gimp_font_select_widget_set (widget,
|
|
|
|
script->arg_defaults[i].sfa_font);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_PATTERN:
|
|
|
|
gimp_pattern_select_widget_set (widget,
|
|
|
|
script->arg_defaults[i].sfa_pattern);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_GRADIENT:
|
|
|
|
gimp_gradient_select_widget_set (widget,
|
|
|
|
script->arg_defaults[i].sfa_gradient);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_BRUSH:
|
|
|
|
gimp_brush_select_widget_set (widget,
|
|
|
|
script->arg_defaults[i].sfa_brush.name,
|
|
|
|
script->arg_defaults[i].sfa_brush.opacity,
|
|
|
|
script->arg_defaults[i].sfa_brush.spacing,
|
|
|
|
script->arg_defaults[i].sfa_brush.paint_mode);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-11-12 03:22:35 +08:00
|
|
|
case SF_OPTION:
|
|
|
|
script->arg_values[i].sfa_option.history =
|
|
|
|
script->arg_defaults[i].sfa_option.history;
|
2004-04-18 06:47:56 +08:00
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (widget),
|
|
|
|
script->arg_values[i].sfa_option.history);
|
|
|
|
break;
|
2003-11-12 03:22:35 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
static void
|
|
|
|
script_fu_about_callback (GtkWidget *widget,
|
2003-11-21 23:53:57 +08:00
|
|
|
SFScript *script)
|
1998-08-12 03:17:23 +08:00
|
|
|
{
|
2004-05-26 02:50:08 +08:00
|
|
|
GtkWidget *dialog = sf_interface->about_dialog;
|
2001-07-30 08:46:09 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *text_view;
|
|
|
|
GtkTextBuffer *text_buffer;
|
2004-05-26 02:36:52 +08:00
|
|
|
gchar *text;
|
1998-08-12 03:17:23 +08:00
|
|
|
|
2004-05-26 02:50:08 +08:00
|
|
|
if (! dialog)
|
1998-08-12 03:17:23 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
sf_interface->about_dialog = dialog =
|
|
|
|
gimp_dialog_new (sf_interface->title, "script-fu-about",
|
|
|
|
sf_interface->dialog, 0,
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_standard_help_func, script->pdb_name,
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
NULL);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (dialog, "destroy",
|
2001-07-30 08:46:09 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&sf_interface->about_dialog);
|
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2004-05-26 02:36:52 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
|
2000-02-01 04:47:44 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame,
|
|
|
|
TRUE, TRUE, 0);
|
1998-08-12 03:17:23 +08:00
|
|
|
gtk_widget_show (frame);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
2002-05-25 03:44:37 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
1998-08-12 03:17:23 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
2000-02-01 04:47:44 +08:00
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
/* the name */
|
2002-05-25 03:44:37 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
label = gtk_label_new (script->script_name);
|
2002-05-25 03:44:37 +08:00
|
|
|
gtk_misc_set_padding (GTK_MISC (label), 2, 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), label);
|
1998-08-12 03:17:23 +08:00
|
|
|
gtk_widget_show (label);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
/* the help display */
|
2001-07-30 08:46:09 +08:00
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (scrolled_window);
|
|
|
|
|
|
|
|
text_buffer = gtk_text_buffer_new (NULL);
|
|
|
|
text_view = gtk_text_view_new_with_buffer (text_buffer);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_object_unref (text_buffer);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
|
|
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
|
2004-05-26 02:36:52 +08:00
|
|
|
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text_view), 12);
|
|
|
|
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (text_view), 12);
|
2002-05-25 03:44:37 +08:00
|
|
|
gtk_widget_set_size_request (text_view, 240, 120);
|
2001-07-30 08:46:09 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
|
|
|
gtk_widget_show (text_view);
|
|
|
|
|
2004-05-26 02:36:52 +08:00
|
|
|
text = g_strconcat ("\n", script->help, "\n", NULL);
|
|
|
|
gtk_text_buffer_set_text (text_buffer, text, -1);
|
|
|
|
g_free (text);
|
2003-09-05 07:12:32 +08:00
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
/* author, copyright, etc. */
|
|
|
|
table = gtk_table_new (2, 4, FALSE);
|
2004-05-26 02:36:52 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
|
1998-08-12 03:17:23 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
label = gtk_label_new (script->author);
|
2000-02-01 04:47:44 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2004-05-26 02:36:52 +08:00
|
|
|
_("Author:"), 0.0, 0.5,
|
2000-02-01 04:47:44 +08:00
|
|
|
label, 1, FALSE);
|
1998-08-12 03:17:23 +08:00
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
label = gtk_label_new (script->copyright);
|
2003-09-05 07:12:32 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2004-05-26 02:36:52 +08:00
|
|
|
_("Copyright:"), 0.0, 0.5,
|
2000-02-01 04:47:44 +08:00
|
|
|
label, 1, FALSE);
|
1998-08-12 03:17:23 +08:00
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
label = gtk_label_new (script->date);
|
2003-09-05 07:12:32 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
2004-05-26 02:36:52 +08:00
|
|
|
_("Date:"), 0.0, 0.5,
|
2000-02-01 04:47:44 +08:00
|
|
|
label, 1, FALSE);
|
|
|
|
|
2000-11-08 22:35:50 +08:00
|
|
|
if (strlen (script->img_types) > 0)
|
1998-08-12 03:17:23 +08:00
|
|
|
{
|
2000-11-08 22:35:50 +08:00
|
|
|
label = gtk_label_new (script->img_types);
|
2003-09-05 07:12:32 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
2004-05-26 02:36:52 +08:00
|
|
|
_("Image Types:"), 0.0, 0.5,
|
2000-02-01 04:47:44 +08:00
|
|
|
label, 1, FALSE);
|
1998-08-12 03:17:23 +08:00
|
|
|
}
|
|
|
|
}
|
2000-11-08 22:35:50 +08:00
|
|
|
|
2004-05-26 02:50:08 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-05-26 02:36:52 +08:00
|
|
|
|
|
|
|
/* move focus from the text view to the Close button */
|
|
|
|
gtk_widget_child_focus (dialog, GTK_DIR_TAB_FORWARD);
|
1998-08-12 03:17:23 +08:00
|
|
|
}
|
|
|
|
|
1998-11-06 08:51:39 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
script_fu_file_entry_callback (GtkWidget *widget,
|
|
|
|
SFFilename *file)
|
1998-11-06 08:51:39 +08:00
|
|
|
{
|
1999-05-19 01:33:39 +08:00
|
|
|
if (file->filename)
|
|
|
|
g_free (file->filename);
|
1998-11-06 08:51:39 +08:00
|
|
|
|
2003-09-05 07:12:32 +08:00
|
|
|
file->filename =
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_file_entry_get_filename (GIMP_FILE_ENTRY(file->file_entry));
|
1998-11-06 08:51:39 +08:00
|
|
|
}
|
|
|
|
|
1998-08-12 03:17:23 +08:00
|
|
|
static void
|
2003-07-02 19:07:41 +08:00
|
|
|
script_fu_error_msg (const gchar *command)
|
1998-08-12 03:17:23 +08:00
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
g_message (_("Error while executing\n%s\n%s"),
|
2003-11-27 01:14:58 +08:00
|
|
|
command, siod_get_error_msg ());
|
1998-08-12 03:17:23 +08:00
|
|
|
}
|