mirror of https://github.com/GNOME/gimp.git
plug-ins/script-fu/script-fu-scripts.[ch] appled patch from Kevin Cozens
2004-11-17 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/script-fu-scripts.[ch] * plug-ins/script-fu/siod-wrapper.c: appled patch from Kevin Cozens which adds (script-fu-menu-register) and allows scripts to register their menu_paths the same undeprecated way as plug-ins. Fixes bug #158117. * plug-ins/script-fu/scripts/test-sphere.scm: example how to use the new API. Doesn't change strings because test-shpere.scm is an untranslated example script.
This commit is contained in:
parent
3dea9410de
commit
6580cc4c4a
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2004-11-17 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/script-fu-scripts.[ch]
|
||||
* plug-ins/script-fu/siod-wrapper.c: appled patch from Kevin
|
||||
Cozens which adds (script-fu-menu-register) and allows scripts to
|
||||
register their menu_paths the same undeprecated way as plug-ins.
|
||||
Fixes bug #158117.
|
||||
|
||||
* plug-ins/script-fu/scripts/test-sphere.scm: example how to use
|
||||
the new API. Doesn't change strings because test-shpere.scm is an
|
||||
untranslated example script.
|
||||
|
||||
2004-11-17 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Made plug-in menu registration work the same way for ordinary and
|
||||
|
|
|
@ -180,6 +180,7 @@ static LISP lprin1s (LISP exp,
|
|||
gchar *dest);
|
||||
static LISP marshall_proc_db_call (LISP a);
|
||||
static LISP script_fu_register_call (LISP a);
|
||||
static LISP script_fu_menu_register_call (LISP a);
|
||||
static LISP script_fu_quit_call (LISP a);
|
||||
|
||||
|
||||
|
@ -211,6 +212,7 @@ init_procedures (void)
|
|||
/* register the database execution procedure */
|
||||
init_lsubr ("gimp-proc-db-call", marshall_proc_db_call);
|
||||
init_lsubr ("script-fu-register", script_fu_register_call);
|
||||
init_lsubr ("script-fu-menu-register", script_fu_menu_register_call);
|
||||
init_lsubr ("script-fu-quit", script_fu_quit_call);
|
||||
|
||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
||||
|
@ -1219,6 +1221,15 @@ script_fu_register_call (LISP a)
|
|||
return NIL;
|
||||
}
|
||||
|
||||
static LISP
|
||||
script_fu_menu_register_call (LISP a)
|
||||
{
|
||||
if (register_scripts)
|
||||
return script_fu_add_menu (a);
|
||||
else
|
||||
return NIL;
|
||||
}
|
||||
|
||||
static LISP
|
||||
script_fu_quit_call (LISP a)
|
||||
{
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h> /* Include early for obscure Win32
|
||||
build reasons */
|
||||
#include <glib.h> /* Include early for obscure Win32 build reasons */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -55,6 +54,13 @@
|
|||
#define SLIDER_WIDTH 80
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *pdb_name;
|
||||
gchar *menu_path;
|
||||
} SFMenu;
|
||||
|
||||
|
||||
/* External functions
|
||||
*/
|
||||
extern long nlength (LISP obj);
|
||||
|
@ -68,6 +74,8 @@ static void script_fu_load_script (const GimpDatafileData *file_data,
|
|||
static gboolean script_fu_install_script (gpointer foo,
|
||||
SFScript *script,
|
||||
gpointer bar);
|
||||
static void script_fu_install_menu (SFMenu *menu,
|
||||
gpointer foo);
|
||||
static gboolean script_fu_remove_script (gpointer foo,
|
||||
SFScript *script,
|
||||
gpointer bar);
|
||||
|
@ -86,6 +94,7 @@ static void script_fu_free_script (SFScript *script);
|
|||
*/
|
||||
|
||||
static GTree *script_list = NULL;
|
||||
static GSList *script_menu_list = NULL;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -123,6 +132,13 @@ script_fu_find_scripts (void)
|
|||
g_tree_foreach (script_list,
|
||||
(GTraverseFunc) script_fu_install_script,
|
||||
NULL);
|
||||
g_slist_foreach (script_menu_list,
|
||||
(GFunc) script_fu_install_menu,
|
||||
NULL);
|
||||
|
||||
/* Now we are done with the list of menu entries */
|
||||
g_slist_free (script_menu_list);
|
||||
script_menu_list = NULL;
|
||||
}
|
||||
|
||||
LISP
|
||||
|
@ -155,7 +171,6 @@ script_fu_add_script (LISP a)
|
|||
* 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 = '_';
|
||||
|
@ -544,6 +559,38 @@ script_fu_add_script (LISP a)
|
|||
return NIL;
|
||||
}
|
||||
|
||||
LISP
|
||||
script_fu_add_menu (LISP a)
|
||||
{
|
||||
SFMenu *menu;
|
||||
gchar *val;
|
||||
gchar *s;
|
||||
|
||||
/* Check the length of a */
|
||||
if (nlength (a) != 2)
|
||||
return my_err ("Incorrect number of arguments for script-fu-menu-register",
|
||||
NIL);
|
||||
|
||||
/* Create a new list of menus */
|
||||
menu = g_new0 (SFMenu, 1);
|
||||
|
||||
/* Find the script PDB entry name */
|
||||
val = get_c_string (car (a));
|
||||
menu->pdb_name = g_strdup (val);
|
||||
for (s = menu->pdb_name; *s; s++)
|
||||
if (*s == '-')
|
||||
*s = '_';
|
||||
a = cdr (a);
|
||||
|
||||
/* Find the script menu path */
|
||||
val = get_c_string (car (a));
|
||||
menu->menu_path = g_strdup (gettext (val));
|
||||
|
||||
script_menu_list = g_slist_append (script_menu_list, menu);
|
||||
|
||||
return NIL;
|
||||
}
|
||||
|
||||
void
|
||||
script_fu_error_msg (const gchar *command)
|
||||
{
|
||||
|
@ -573,7 +620,7 @@ script_fu_load_script (const GimpDatafileData *file_data,
|
|||
/* No, I don't know why, but this is
|
||||
* necessary on NT 4.0.
|
||||
*/
|
||||
Sleep(0);
|
||||
Sleep (0);
|
||||
#endif
|
||||
|
||||
g_free (command);
|
||||
|
@ -614,6 +661,20 @@ script_fu_install_script (gpointer foo,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following function is a GFunc.
|
||||
*/
|
||||
static void
|
||||
script_fu_install_menu (SFMenu *menu,
|
||||
gpointer foo)
|
||||
{
|
||||
gimp_plugin_menu_register (menu->pdb_name, menu->menu_path);
|
||||
|
||||
g_free (menu->pdb_name);
|
||||
g_free (menu->menu_path);
|
||||
g_free (menu);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following function is a GTraverseFunction.
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
void script_fu_find_scripts (void);
|
||||
LISP script_fu_add_script (LISP a);
|
||||
LISP script_fu_add_menu (LISP a);
|
||||
void script_fu_error_msg (const gchar *command);
|
||||
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@
|
|||
(gimp-context-pop)))
|
||||
|
||||
(script-fu-register "script-fu-test-sphere"
|
||||
"<Toolbox>/Xtns/Script-Fu/Test/_Sphere..."
|
||||
"_Sphere..."
|
||||
"Simple script to test and show the usage of the new Script-Fu API extensions."
|
||||
"Spencer Kimball, Sven Neumann"
|
||||
"Spencer Kimball"
|
||||
|
@ -253,3 +253,6 @@
|
|||
SF-LAYER "Layer" -1
|
||||
SF-CHANNEL "Channel" -1
|
||||
SF-DRAWABLE "Drawable" -1)
|
||||
|
||||
(script-fu-menu-register "script-fu-test-sphere"
|
||||
"<Toolbox>/Xtns/Script-Fu/Test")
|
||||
|
|
|
@ -180,6 +180,7 @@ static LISP lprin1s (LISP exp,
|
|||
gchar *dest);
|
||||
static LISP marshall_proc_db_call (LISP a);
|
||||
static LISP script_fu_register_call (LISP a);
|
||||
static LISP script_fu_menu_register_call (LISP a);
|
||||
static LISP script_fu_quit_call (LISP a);
|
||||
|
||||
|
||||
|
@ -211,6 +212,7 @@ init_procedures (void)
|
|||
/* register the database execution procedure */
|
||||
init_lsubr ("gimp-proc-db-call", marshall_proc_db_call);
|
||||
init_lsubr ("script-fu-register", script_fu_register_call);
|
||||
init_lsubr ("script-fu-menu-register", script_fu_menu_register_call);
|
||||
init_lsubr ("script-fu-quit", script_fu_quit_call);
|
||||
|
||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
||||
|
@ -1219,6 +1221,15 @@ script_fu_register_call (LISP a)
|
|||
return NIL;
|
||||
}
|
||||
|
||||
static LISP
|
||||
script_fu_menu_register_call (LISP a)
|
||||
{
|
||||
if (register_scripts)
|
||||
return script_fu_add_menu (a);
|
||||
else
|
||||
return NIL;
|
||||
}
|
||||
|
||||
static LISP
|
||||
script_fu_quit_call (LISP a)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue