Script-Fu GUI for choosing file to save can be better with 'SF-SAVE-FILENAME'
Currently, ScriptFu generated plugin dialogs have SF-FILENAME and SF-DIRNAME kinds of args and widgets.
A plugin arg declared as kind SF-FILENAME is shown in the plugin's dialog as a button that pops up a file chooser dialog. But the file chooser has action "Open." (Its a GtkFileChooserButton with GTK_FILE_CHOOSER_ACTION_OPEN). So a user can only choose an existing file, and can't enter the name of a new file.
An example of the deficiency is the plugin in scripts/palette-export.scm You can see the plugin GUI by click right mouse button in the Palettes dockable and choose "Export As>CSS...". It has a button for choosing a folder (SF-DIRNAME) and a button for entering a filename string (SF-STRING, not SF-FILENAME.) The plugin code has much duplicative code for constructing valid filenames from the entered filename string. The GUI is clunky, the dialog doesn't show a default directory always, and the user can forget to choose one. The two buttons should be replaced by a single button that popups up a file chooser widget for choosing the save location of a file.
The enhancement is to add SF-SAVE-FILENAME to ScriptFu. It would popup a widget for choosing a directory and entering a new filename i.e. for "Save" or "Save as".
The enhancement would use the cross-platform portability of gtk, instead of the hard-to-maintain code in palette-export.scm for managing filename strings.
This enhancement would be made in code that ScriptFu uses to generate dialogs (script-fu-interface.c). The enhancement is simple, just a variant of existing code, with variant GTK_FILE_CHOOSER_ACTION_SAVE.
Unfortunately, there is a tentative plan to make ScriptFu instead use GimpProcedureDialog. Any dialog generated by GimpProcedureDialog might have a similar issue, (but I have not looked at it closely.) Declaring an argument as type GFile doesn't give enough information to generate the appropriate widget: for either "Open" or "Save" action.
The palette export plugin seems to be the only ScriptFu script in the repo that could use this enhancement. But I suspect some third-party plugins would want to save arbitrary format files (that are not image files, since that is handled already.)
The steps would be:
- Make this enhancement to ScriptFu
- Revamp palette-export.scm to have one SF-SAVE-FILENAME arg instead of two
- Revamp test-sphere.scm, the demo plugin
- Edit documents