Gimptalk - Premier Gimp Community: How can I transmit filename variable to script-fu-register? - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How can I transmit filename variable to script-fu-register?

#1 User is offline   gothica 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 21-January 10

Posted 01 March 2010 - 08:59 AM

I'd like to:
1. User opens image in gimp
2. Then he press hot key and executing script.

In the script i'd like to get filename (for example "picture.jpg) and pass it to parameters

(script-fu-register "script-fu-anketa"
        "/Script-Fu/anketa"
        "Обработка анкеты"
        "www.gimp.org"
        "made with gimp"
        "27 February 2010"
        ""
        SF-IMAGE "Image" 0
        SF-DRAWABLE "Drawable" 0
	SF-VALUE "Filename" "Original_image_filename"
)


So how can i pass it to script-fu-register function:
for example it would be:
(script-fu-register "script-fu-anketa"
        "/Script-Fu/anketa"
        "Обработка анкеты"
        "www.gimp.org"
        "made with gimp"
        "27 February 2010"
        ""
        SF-IMAGE "Image" 0
        SF-DRAWABLE "Drawable" 0
        SF-VALUE "Filename" "picture.jpg"
)

0

#2 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 01 March 2010 - 01:34 PM

i can't answer to your question but this

Quote

"/Script-Fu/anketa"


is wrong, there are no more menu in the toolbar.
Still somehow gimp usually remap the menu location but i am not sure will do in this case

Even if will do new location will be hard to guess most of the script that were registered in the toolbox are remapped in File/Create menu, were usually nobody think to look for scripts..but that if the path was something as /Xtras/ Logos in your case i am not sure

i hope somebody else may help for the question
0

#3 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 01 March 2010 - 02:21 PM

gothica said:

I'd like to:
1. User opens image in gimp
2. Then he press hot key and executing script.

In the script i'd like to get filename (for example "picture.jpg) and pass it to parameters

It can't be done. The initial values for the registration parameters are determined when Script-fu is initialized (i.e., when GIMP is first started, or when a Refresh Scripts is performed). These initial values are as declared in the 'script-fu-register' call. Once a particular script is run, subsequent calls of the script will employ the last setting of these values.

Consider this example:
(script-fu-register "script-fu-anketa"
...
...
	SF-FILENAME "Filename" "Original_image_filename")


When you open GIMP, the initial setting for the filename parameter will be "Original_image_filename" and when you run the 'script-fu-anketa' script for the first time, the dialog will fill in the associated text box with that filename. If the user changes that text to something such as "some_other_filename" then the next time the 'script-fu-anketa' script is run, the dialog will present "some_other_filename" in the associated text box.

If you want a dialog to be presented which has its settings initialized to values based on the active image, you will need to write a plug-in (not a script) which handles the creation and management of the dialog manually.


NOTE: SF-VALUE is used for numeric parameters. For filenames one should use either SF-FILENAME or SF-STRING.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#4 User is offline   gothica 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 21-January 10

Posted 01 March 2010 - 02:34 PM

saulgoode said:

If you want a dialog to be presented which has its settings initialized to values based on the active image, you will need to write a plug-in (not a script) which handles the creation and management of the dialog manually.


But how? I'd like to get filename of image (which was opened by user) in dialog window...
0

#5 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 03 March 2010 - 04:00 AM

Quote

I'd like to get filename of image (which was opened by user) in dialog window...


and what if the image has not a real filename but only a ID because was not opened but created (or even paste from clipboard) ?
Not sure if for what you wish "untitled" that is the default name for new or paste images ( till are not saved ) will be usable for your intent

If not or you will have to handle "untitled " that is a very commune case as a error and/or prompt the user to save (that is the only way to give to similar image a different filename ) before use the plugin
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic