Hi Saul,

Many thanks for instant help.

> > I'm trying to figure ut if there's any way that choices made by
> > user in dialog widgets can be remembered and used as values 
> > of those widgets next time dialog runs. 

> That is precisely how script dialogs currently behave; the last
> used  values are presented. These last values will be reset to
> their  original default values if 1) Script-fu is refreshed 
> ("Filters->Script-fu->Refresh Scripts") or 2) GIMP is restarted. 

Sorry, I mis-stated my problem.  I'd like dialog to come up with same 
widget values next time GIMP is started up.

...(snip)...

> Tick quoting does not result in evaluation of the list elements.
> Use  'list' so that WRF_BIT_WIDTH gets evaluated and replaced by
> its  numeric value: 

Thanks, I think it I read that bit in the Scheme manual and forgot 
it.

...(snip)...

> If, however, the issue you are attempting to address is having the
>  last values retained across sessions (or survive a Script
> Refresh),  this would be possible by storing your script's last
> values in the  <gimpdir>/parasiterc file: 

(define (script-fu-woodrat image drawable bit-width)
   ; Substitute function owing to buggy parasite-attach behavior
   (define (fu-parasite-attach parasite)
     (gimp-parasite-attach parasite)
     (while (not (string=? (caddr parasite)
                           (caddar (gimp-parasite-find (car 
parasite)))))
       (gimp-parasite-attach parasite)))

   ; Save the user-specified bit-width to an application parasite
   (fu-parasite-attach (list "WRF_BIT_WIDTH" 1 (number->string bit-
width)))
   ...
   )

(script-fu-register "script-fu-woodrat"
   :
   :
   :
   SF-IMAGE ...
   SF-DRAWABLE ...
   SF-VALUE "Bit width"
               (catch
                 17 ; fallback value if first-time run
                 (string->number (caddar (gimp-parasite-find 
"WRF_BIT_WIDTH")))
   )

> Note that 'gimp-parasite-find' is only executed once: when GIMP is
>  initially loaded (or if scripts are refreshed). Even though the 
> parasite is saved every time the script is executed, it is
> actually  GIMP's internally stored last value (not the parasite)
> that is used in  determining the value for the 'bit-width'
> parameter. The only reason  you'd want to take these steps is to
> support last values across  different sessions. The behavior you
> desired (as expressed in the  first paragraph of your post) is
> already supported by GIMP. 

Sorry, mis-stated by requirement.  

parasites are just what I need.  Can't find much about them.

(list "WRF_BIT_WIDTH" 1 (number->string bit-width)))

First list member: parasite ID string. 

What's the second list member?  Flags, I understand from one search 
result I found.  Used?

Third list member: parasite value (must always be a string). So an 
RGB colour value would have to be stringified. unstrbreakup maybe?

Generally: do all the gimp-*-parasite-attach methods suffer from same 
bug, so should be reapplied til they work?



Yrs,

Alan 

Public speaking is very easy.

                    -- Vice President Dan Quayle
                       to reporters in 10/88


===================== +++++  =====================



_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to