1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include "siod/siod.h"
#include "siod-wrapper.h"
#include "script-fu-console.h"
#include "script-fu-scripts.h"
#include "script-fu-server.h"
#include "script-fu-text-console.h"
#include "script-fu-intl.h"
/* Declare local functions. */
static void script_fu_quit (void);
static void script_fu_query (void);
static void script_fu_run (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals);
static void script_fu_auxillary_init (void);
static void script_fu_refresh_proc (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
script_fu_quit, /* quit_proc */
script_fu_query, /* query_proc */
script_fu_run /* run_proc */
};
MAIN ()
static void
script_fu_quit (void)
{
}
static void
script_fu_query (void)
{
static GimpParamDef console_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
};
static GimpParamDef textconsole_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
};
static GimpParamDef eval_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" },
{ GIMP_PDB_STRING, "code", "The code to evaluate" }
};
static GimpParamDef server_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" },
{ GIMP_PDB_INT32, "port", "The port on which to listen for requests" },
{ GIMP_PDB_STRING, "logfile", "The file to log server activity to" }
};
gimp_plugin_domain_register (GETTEXT_PACKAGE "-script-fu", NULL);
gimp_install_procedure ("extension_script_fu",
"A scheme interpreter for scripting GIMP operations",
"More help here later",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
NULL,
NULL,
GIMP_EXTENSION,
0, 0, NULL, NULL);
gimp_install_procedure ("plug_in_script_fu_console",
"Provides a console mode for script-fu development",
"Provides an interface which allows interactive "
"scheme development.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
N_("Script-Fu _Console"),
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (console_args), 0,
console_args, NULL);
gimp_plugin_menu_register ("plug_in_script_fu_console",
N_("<Toolbox>/Xtns/Script-Fu"));
gimp_install_procedure ("plug_in_script_fu_text_console",
"Provides a text console mode for script-fu "
"development",
"Provides an interface which allows interactive "
"scheme development.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (textconsole_args), 0,
textconsole_args, NULL);
gimp_install_procedure ("plug_in_script_fu_server",
"Provides a server for remote script-fu operation",
"Provides a server for remote script-fu operation",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
N_("_Start Server..."),
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (server_args), 0,
server_args, NULL);
gimp_plugin_menu_register ("plug_in_script_fu_server",
N_("<Toolbox>/Xtns/Script-Fu"));
gimp_install_procedure ("plug_in_script_fu_eval",
"Evaluate scheme code",
"Evaluate the code under the scheme interpreter "
"(primarily for batch mode)",
"Manish Singh",
"Manish Singh",
"1998",
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (eval_args), 0,
eval_args, NULL);
}
static void
script_fu_run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
INIT_I18N();
siod_set_console_mode (0);
siod_set_output_file (stdout);
/* Determine before we allow scripts to register themselves
* whether this is the base, automatically installed script-fu extension
*/
if (strcmp (name, "extension_script_fu") == 0)
{
/* Setup auxillary temporary procedures for the base extension */
script_fu_auxillary_init ();
/* Init the interpreter */
siod_init (TRUE);
}
else
{
/* Init the interpreter */
siod_init (FALSE);
}
/* Load all of the available scripts */
script_fu_find_scripts ();
if (strcmp (name, "extension_script_fu") == 0)
{
/*
* The main, automatically installed script fu extension. For
* things like logos and effects that are runnable from GIMP
* menus.
*/
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
/* Acknowledge that the extension is properly initialized */
gimp_extension_ack ();
while (TRUE)
gimp_extension_process (0);
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
else if (strcmp (name, "plug_in_script_fu_text_console") == 0)
{
/*
* The script-fu text console for interactive SIOD development
*/
script_fu_text_console_run (name, nparams, param,
nreturn_vals, return_vals);
}
else if (strcmp (name, "plug_in_script_fu_console") == 0)
{
/*
* The script-fu console for interactive SIOD development
*/
script_fu_console_run (name, nparams, param,
nreturn_vals, return_vals);
}
else if (strcmp (name, "plug_in_script_fu_server") == 0)
{
/*
* The script-fu server for remote operation
*/
script_fu_server_run (name, nparams, param,
nreturn_vals, return_vals);
}
else if (strcmp (name, "plug_in_script_fu_eval") == 0)
{
/*
* A non-interactive "console" (for batch mode)
*/
script_fu_eval_run (name, nparams, param,
nreturn_vals, return_vals);
}
}
static void
script_fu_auxillary_init (void)
{
static GimpParamDef args[] =
{
{ GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" }
};
gimp_install_temp_proc ("script_fu_refresh",
"Re-read all available scripts",
"Re-read all available scripts",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
N_("_Refresh Scripts"),
NULL,
GIMP_TEMPORARY,
G_N_ELEMENTS (args), 0,
args, NULL,
script_fu_refresh_proc);
gimp_plugin_menu_register ("script_fu_refresh",
N_("<Toolbox>/Xtns/Script-Fu"));
}
static void
script_fu_refresh_proc (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
/* Reload all of the available scripts */
script_fu_find_scripts ();
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
|