build/windows: generate a default XCF file to be copied by Windows

Attribute uap4:ShellNewFileName is meant as a template file to be copied when
someone initiate the Shell "New" command (via the Explorer context menu).
This commit is contained in:
Jehan 2024-02-26 23:09:26 +01:00 committed by Bruno Lopes
parent 4c968d9aa0
commit 085d8a02b5
4 changed files with 51 additions and 1 deletions

View file

@ -82,6 +82,7 @@ if (Test-Path -Path "$icons_path")
{
New-Item -ItemType Directory -Path "$arch\Assets\"
Copy-Item -Path "$icons_path\*.png" -Destination "$arch\Assets\" -Recurse
Copy-Item -Path "$icons_path\*.xcf" -Destination "$arch\Assets\" -Recurse
}
}
else

View file

@ -45,7 +45,7 @@
<uap:DisplayName>eXperimental Computing Facility file</uap:DisplayName>
<uap:Logo>Assets\fileicon.png</uap:Logo>
<uap:SupportedFileTypes>
<uap:FileType>.xcf</uap:FileType>
<uap:FileType uap4:ShellNewFileName="Assets\New_GIMP_Project.xcf" uap4:ShellNewDisplayName="GIMP project file">.xcf</uap:FileType>
</uap:SupportedFileTypes>
</uap3:FileTypeAssociation>
</uap3:Extension>

View file

@ -0,0 +1,25 @@
import os
import sys
output_path = '@BUILDDIR@/New_GIMP_Project.xcf'
default_width = 1920
default_height = 1080
image = Gimp.Image.new(default_width, default_height, Gimp.ImageBaseType.RGB)
layer = Gimp.Layer.new(image, None, default_width, default_height,
Gimp.ImageType.RGB_IMAGE, 100.0, Gimp.LayerMode.NORMAL)
layer.fill(Gimp.FillType.WHITE)
image.insert_layer(layer, None, 0)
procedure = Gimp.get_pdb().lookup_procedure("gimp-xcf-save")
config = procedure.create_config()
drawables = image.list_selected_drawables()
config.set_property("image", image)
config.set_property("num-drawables", len(drawables))
config.set_property("drawables", Gimp.ObjectArray.new(Gimp.Drawable, drawables, False))
config.set_property("file", Gio.file_new_for_path(output_path))
Gimp.Procedure.run(procedure, config)
v = Gimp.Procedure.run(procedure, config)
if v.index(0) != Gimp.PDBStatusType.SUCCESS:
sys.exit(os.EX_SOFTWARE)

View file

@ -248,3 +248,27 @@ foreach scale : scales
build_by_default: true,
env: gimp_run_env)
endforeach
# OTHER ASSETS
## Generate default XCF file (uap4:ShellNewFileName)
gen_new_xcf_conf = configuration_data()
gen_new_xcf_conf.set('BUILDDIR', meson.current_build_dir())
gen_new_xcf_py = configure_file(
input : 'gen-new-xcf.py.in',
output : 'gen-new-xcf.py',
configuration : gen_new_xcf_conf
)
xcf_file = custom_target('New_GIMP_Project.xcf',
input : [ gen_new_xcf_py ],
depend_files: [ wilber_path ],
output: [ 'New_GIMP_Project.xcf', ],
command: [ gimp_exe, '-nidfs',
'--batch-interpreter', 'python-fu-eval',
'-b', '-', '--quit'],
feed: true,
build_by_default: true,
env: gimp_run_env
)