added an optional menu parameter to the register call to simplify menu
2006-08-17 Sven Neumann <sven@gimp.org> * plug-ins/pygimp/gimpfu.py: added an optional menu parameter to the register call to simplify menu registration. Also restored menupath specific mangling of the procedure arguments. * plug-ins/pygimp/plug-ins/*.py: use the menu parameter instead of defining a function to call on query. * plug-ins/pygimp/plug-ins/sphere.py: do it old-style here for testing.
This commit is contained in:
parent
0795120402
commit
f96049ae6e
13 changed files with 49 additions and 62 deletions
12
ChangeLog
12
ChangeLog
|
|
@ -1,3 +1,15 @@
|
|||
2006-08-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/pygimp/gimpfu.py: added an optional menu parameter to
|
||||
the register call to simplify menu registration. Also restored
|
||||
menupath specific mangling of the procedure arguments.
|
||||
|
||||
* plug-ins/pygimp/plug-ins/*.py: use the menu parameter instead
|
||||
of defining a function to call on query.
|
||||
|
||||
* plug-ins/pygimp/plug-ins/sphere.py: do it old-style here for
|
||||
testing.
|
||||
|
||||
2006-08-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/siod/sliba.c (aref1): when accessing members
|
||||
|
|
|
|||
|
|
@ -148,8 +148,8 @@ _type_mapping = {
|
|||
|
||||
_registered_plugins_ = {}
|
||||
|
||||
def register(proc_name, blurb, help, author, copyright, date, menupath,
|
||||
imagetypes, params, results, function,
|
||||
def register(proc_name, blurb, help, author, copyright, date, label,
|
||||
imagetypes, params, results, function, menu=None,
|
||||
on_query=None, on_run=None):
|
||||
'''This is called to register a new plugin.'''
|
||||
|
||||
|
|
@ -200,9 +200,9 @@ def register(proc_name, blurb, help, author, copyright, date, menupath,
|
|||
proc_name = 'python-fu-' + proc_name
|
||||
|
||||
_registered_plugins_[proc_name] = (blurb, help, author, copyright,
|
||||
date, menupath, imagetypes,
|
||||
date, label, imagetypes,
|
||||
plugin_type, params, results,
|
||||
function, on_query, on_run)
|
||||
function, menu, on_query, on_run)
|
||||
|
||||
file_params = [(PDB_STRING, "filename", "The name of the file"),
|
||||
(PDB_STRING, "raw-filename", "The name of the file")]
|
||||
|
|
@ -210,8 +210,8 @@ file_params = [(PDB_STRING, "filename", "The name of the file"),
|
|||
def _query():
|
||||
for plugin in _registered_plugins_.keys():
|
||||
(blurb, help, author, copyright, date,
|
||||
menupath, imagetypes, plugin_type,
|
||||
params, results, function,
|
||||
label, imagetypes, plugin_type,
|
||||
params, results, function, menu,
|
||||
on_query, on_run) = _registered_plugins_[plugin]
|
||||
|
||||
def make_params(params):
|
||||
|
|
@ -221,31 +221,39 @@ def _query():
|
|||
# add the run mode argument ...
|
||||
params.insert(0, (PDB_INT32, "run_mode",
|
||||
"Interactive, Non-Interactive"))
|
||||
|
||||
if menu is None and not label is None:
|
||||
fields = _string.split(label, '/')
|
||||
label = fields.pop()
|
||||
menu = _string.join(fields, '/')
|
||||
|
||||
if plugin_type == PLUGIN:
|
||||
if menupath is None:
|
||||
if menu is None:
|
||||
pass
|
||||
elif menupath[:7] == '<Load>/':
|
||||
elif menu[:7] == '<Load>/':
|
||||
params[1:1] = file_params
|
||||
elif menupath[:10] != '<Toolbox>/':
|
||||
elif menu[:10] != '<Toolbox>/':
|
||||
params.insert(1, (PDB_IMAGE, "image",
|
||||
"The image to work on"))
|
||||
params.insert(2, (PDB_DRAWABLE, "drawable",
|
||||
"The drawable to work on"))
|
||||
if menupath[:7] == '<Save>/':
|
||||
if menu[:7] == '<Save>/':
|
||||
params[3:3] = file_params
|
||||
|
||||
results = make_params(results)
|
||||
gimp.install_procedure(plugin, blurb, help, author, copyright,
|
||||
date, menupath, imagetypes, plugin_type,
|
||||
date, label, imagetypes, plugin_type,
|
||||
params, results)
|
||||
if menu:
|
||||
gimp.menu_register(plugin, menu)
|
||||
if on_query:
|
||||
on_query()
|
||||
|
||||
def _get_defaults(proc_name):
|
||||
import gimpshelf
|
||||
(blurb, help, author, copyright, date,
|
||||
menupath, imagetypes, plugin_type,
|
||||
params, results, function,
|
||||
menu, imagetypes, plugin_type,
|
||||
params, results, function, menu,
|
||||
on_query, on_run) = _registered_plugins_[proc_name]
|
||||
|
||||
key = "python-fu-save--" + proc_name
|
||||
|
|
@ -264,8 +272,8 @@ def _set_defaults(proc_name, defaults):
|
|||
|
||||
def _interact(proc_name, start_params):
|
||||
(blurb, help, author, copyright, date,
|
||||
menupath, imagetypes, plugin_type,
|
||||
params, results, function,
|
||||
menu, imagetypes, plugin_type,
|
||||
params, results, function, menu,
|
||||
on_query, on_run) = _registered_plugins_[proc_name]
|
||||
|
||||
def run_script(run_params):
|
||||
|
|
@ -600,8 +608,8 @@ def _interact(proc_name, start_params):
|
|||
def _run(proc_name, params):
|
||||
run_mode = params[0]
|
||||
plugin_type = _registered_plugins_[proc_name][7]
|
||||
menupath = _registered_plugins_[proc_name][5]
|
||||
func = _registered_plugins_[proc_name][10]
|
||||
menupath = _registered_plugins_[proc_name][11]
|
||||
|
||||
if plugin_type == PLUGIN and menupath and menupath[:10] != '<Toolbox>/':
|
||||
if menupath[:7] == '<Save>/':
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ def clothify(timg, tdrawable, bx=9, by=9, azimuth=135, elevation=45, depth=3):
|
|||
|
||||
gimp.delete(img)
|
||||
|
||||
def query_clothify():
|
||||
gimp.menu_register("python-fu-clothify", "<Image>/Filters/Artistic")
|
||||
|
||||
register(
|
||||
"python-fu-clothify",
|
||||
"Make the specified layer look like it is printed on cloth",
|
||||
|
|
@ -73,6 +70,6 @@ register(
|
|||
(PF_INT, "depth", "Depth", 3)
|
||||
],
|
||||
[],
|
||||
clothify, on_query=query_clothify)
|
||||
clothify, menu="<Image>/Filters/Artistic")
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ register(
|
|||
"Manish Singh and Carol Spears",
|
||||
"Manish Singh and Carol Spears",
|
||||
"2003",
|
||||
"<Save>/Colored XHTML",
|
||||
"Colored XHTML",
|
||||
"RGB",
|
||||
[
|
||||
(PF_RADIO, "source", "Where to take the characters from", 0,
|
||||
|
|
@ -196,6 +196,6 @@ register(
|
|||
(PF_BOOL, "separate", "Separate CSS file", True)
|
||||
],
|
||||
[],
|
||||
colorxhtml, on_query=register_save)
|
||||
colorxhtml, menu="<Save>", on_query=register_save)
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -93,10 +93,6 @@ def console():
|
|||
gobject.timeout_add(500, timeout)
|
||||
gtk.main()
|
||||
|
||||
def query_console():
|
||||
gimp.menu_register("python-fu-console",
|
||||
"<Toolbox>/Xtns/Languages/Python-Fu")
|
||||
|
||||
register(
|
||||
"python-fu-console",
|
||||
"Python interactive interpreter with gimp extensions",
|
||||
|
|
@ -108,6 +104,6 @@ register(
|
|||
"",
|
||||
[],
|
||||
[],
|
||||
console, on_query=query_console)
|
||||
console, menu="<Toolbox>/Xtns/Languages/Python-Fu")
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@ def palette_offset(palette, amount, forward):
|
|||
return palette
|
||||
|
||||
|
||||
def query_palette_offset():
|
||||
gimp.menu_register("python-fu-palette-offset", "<Palettes>")
|
||||
|
||||
register(
|
||||
"python-fu-palette-offset",
|
||||
"Offsets a given palette",
|
||||
|
|
@ -60,8 +57,7 @@ register(
|
|||
(PF_BOOL, "forward", "Offset the palette forward?", True)
|
||||
],
|
||||
[(PF_PALETTE, "new-palette", "Name of offset palette.")],
|
||||
palette_offset,
|
||||
on_query=query_palette_offset)
|
||||
palette_offset, menu="<Palettes>")
|
||||
|
||||
|
||||
main ()
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ def palette_sort (palette, model, channel, ascending):
|
|||
return palette
|
||||
|
||||
|
||||
def query_sort():
|
||||
gimp.menu_register("python-fu-palette-sort", "<Palettes>")
|
||||
|
||||
register(
|
||||
"python-fu-palette-sort",
|
||||
"Sort the selected palette.",
|
||||
|
|
@ -69,8 +66,7 @@ register(
|
|||
(PF_BOOL, "ascending", "Sort in ascending order", True)
|
||||
],
|
||||
[],
|
||||
palette_sort,
|
||||
on_query=query_sort)
|
||||
palette_sort, menu="<Palettes>")
|
||||
|
||||
|
||||
main ()
|
||||
|
|
|
|||
|
|
@ -63,8 +63,6 @@ def palette_to_gradient(palette):
|
|||
num_segments = num_colors - 1
|
||||
make_gradient(palette, num_segments, num_colors)
|
||||
|
||||
def query_palette_to_gradient():
|
||||
gimp.menu_register("python-fu-palette-to-gradient", "<Palettes>")
|
||||
|
||||
register(
|
||||
"python-fu-palette-to-gradient",
|
||||
|
|
@ -77,8 +75,7 @@ register(
|
|||
"",
|
||||
[(PF_PALETTE, "palette", "Name of palette to convert", "")],
|
||||
[(PF_GRADIENT, "new-gradient", "Name of the New Gradient:")],
|
||||
palette_to_gradient,
|
||||
on_query=query_palette_to_gradient)
|
||||
palette_to_gradient, menu="<Palettes>")
|
||||
|
||||
|
||||
main ()
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ def pdb_browse():
|
|||
|
||||
gtk.main()
|
||||
|
||||
def query_pdb_browse():
|
||||
gimp.menu_register("python-fu-pdb-browse",
|
||||
"<Toolbox>/Xtns/Languages/Python-Fu")
|
||||
|
||||
register(
|
||||
"python-fu-pdb-browse",
|
||||
|
|
@ -46,6 +43,6 @@ register(
|
|||
"",
|
||||
[],
|
||||
[],
|
||||
pdb_browse, on_query=query_pdb_browse)
|
||||
pdb_browse, menu="<Toolbox>/Xtns/Languages/Python-Fu")
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -408,8 +408,6 @@ End of the part generated by the GIMP
|
|||
|
||||
return url_list
|
||||
|
||||
def query_pyslice():
|
||||
gimp.menu_register("python-fu-slice", "<Image>/Filters/Web")
|
||||
|
||||
register(
|
||||
"python-fu-slice",
|
||||
|
|
@ -444,6 +442,6 @@ register(
|
|||
|
||||
],
|
||||
[],
|
||||
pyslice, on_query=query_pyslice)
|
||||
pyslice, menu="<Image>/Filters/Web")
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ def shadow_bevel(img, drawable, blur, bevel, do_shadow, drop_x, drop_y):
|
|||
# enable undo again
|
||||
img.undo_group_end()
|
||||
|
||||
def query_shadow_bevel():
|
||||
gimp.menu_register("python-fu-shadow-bevel",
|
||||
"<Image>/Filters/Light and Shadow/Shadow")
|
||||
|
||||
register(
|
||||
"python-fu-shadow-bevel",
|
||||
|
|
@ -74,6 +71,6 @@ register(
|
|||
(PF_INT, "drop-y", "Drop shadow Y displacement", 6)
|
||||
],
|
||||
[],
|
||||
shadow_bevel, on_query=query_shadow_bevel)
|
||||
shadow_bevel, menu="<Image>/Filters/Light and Shadow/Shadow")
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -89,10 +89,6 @@ def sphere(radius, light, shadow, bg_colour, sphere_colour):
|
|||
|
||||
disp = gimp.Display(img)
|
||||
|
||||
def query_sphere():
|
||||
gimp.menu_register("python-fu-sphere",
|
||||
"<Toolbox>/Xtns/Languages/Python-Fu/Test")
|
||||
|
||||
register(
|
||||
"python-fu-sphere",
|
||||
"Simple spheres with drop shadows",
|
||||
|
|
@ -100,7 +96,7 @@ register(
|
|||
"James Henstridge",
|
||||
"James Henstridge",
|
||||
"1997-1999",
|
||||
"_Sphere",
|
||||
"<Toolbox>/Xtns/Languages/Python-Fu/Test/_Sphere",
|
||||
"",
|
||||
[
|
||||
(PF_INT, "radius", "Radius for sphere", 100),
|
||||
|
|
@ -110,6 +106,6 @@ register(
|
|||
(PF_COLOR, "sphere-color", "Sphere", (255,0,0))
|
||||
],
|
||||
[],
|
||||
sphere, on_query=query_sphere)
|
||||
sphere)
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -196,9 +196,6 @@ def bilinear(x, y, values):
|
|||
return chr(int(m0 + y * (m1 - m0)))
|
||||
|
||||
|
||||
def query_whirl_pinch():
|
||||
gimp.menu_register("python-fu-whirl-pinch", "<Image>/Filters/Distorts")
|
||||
|
||||
register(
|
||||
"python-fu-whirl-pinch",
|
||||
"Distorts an image by whirling and pinching",
|
||||
|
|
@ -214,6 +211,6 @@ register(
|
|||
(PF_FLOAT, "radius", "radius", 1)
|
||||
],
|
||||
[],
|
||||
whirl_pinch, on_query=query_whirl_pinch)
|
||||
whirl_pinch, menu="<Image>/Filters/Distorts")
|
||||
|
||||
main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue