From: Ben Soares Date: Wed, 5 Jun 2024 00:27:24 +0000 (+0100) Subject: JAL-4421 Add --appname --appxpos --appypos to position variable application name... X-Git-Tag: Release_2_11_4_0~21^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cbee9978721e4efff9e0741ba6933fb090d3aa23;p=jalview.git JAL-4421 Add --appname --appxpos --appypos to position variable application name icons, or read from config[app] --- diff --git a/build.gradle b/build.gradle index a8d55dd..3a5f351 100644 --- a/build.gradle +++ b/build.gradle @@ -2863,7 +2863,14 @@ python { task install4jCustomiseDS_StoreX64(type: PythonTask) { inputs.file(install4jDMGDSStore) outputs.file(install4jDMGFixedDSStoreX64) - def command_args = [ jalview_customise_ds_store, '--input', install4jDMGDSStore, '--output', install4jDMGFixedDSStoreX64, '--volumename', install4jmacOSArchiveX64Name, '--backgroundfile', install4j_dmg_background_filename, '--dmg', install4jmacOSArchiveX64DMGFilename + ".dmg" ] + def command_args = [ jalview_customise_ds_store, + '--input', install4jDMGDSStore, + '--output', install4jDMGFixedDSStoreX64, + '--volumename', install4jmacOSArchiveX64Name, + '--backgroundfile', install4j_dmg_background_filename, + '--dmg', install4jmacOSArchiveX64DMGFilename + ".dmg", + '--appname', "${applicationName}.app", + ] if (file(install4jDMGDSStoreJSON).exists()) { command_args += [ '--config', install4jDMGDSStoreJSON ] inputs.file(install4jDMGDSStoreJSON) @@ -2877,7 +2884,14 @@ task install4jCustomiseDS_StoreX64(type: PythonTask) { task install4jCustomiseDS_StoreAarch64(type: PythonTask) { inputs.file(install4jDMGDSStore) outputs.file(install4jDMGFixedDSStoreAarch64) - def command_args = [ jalview_customise_ds_store, '--input', install4jDMGDSStore, '--output', install4jDMGFixedDSStoreAarch64, '--volumename', install4jmacOSArchiveAarch64Name, '--backgroundfile', install4j_dmg_background_filename, '--dmg', install4jmacOSArchiveAarch64DMGFilename + ".dmg" ] + def command_args = [ jalview_customise_ds_store, + '--input', install4jDMGDSStore, + '--output', install4jDMGFixedDSStoreAarch64, + '--volumename', install4jmacOSArchiveAarch64Name, + '--backgroundfile', install4j_dmg_background_filename, + '--dmg', install4jmacOSArchiveAarch64DMGFilename + ".dmg", + '--appname', "${applicationName}.app", + ] if (file(install4jDMGDSStoreJSON).exists()) { command_args += [ '--config', install4jDMGDSStoreJSON ] inputs.file(install4jDMGDSStoreJSON) diff --git a/utils/macos_dmg/jalview_customise_dsstore.py b/utils/macos_dmg/jalview_customise_dsstore.py index 2343fd8..167c4c8 100755 --- a/utils/macos_dmg/jalview_customise_dsstore.py +++ b/utils/macos_dmg/jalview_customise_dsstore.py @@ -22,7 +22,9 @@ parser.add_argument("-c", "--config", help="YAML configuration for window and ic parser.add_argument("-m", "--dmg", help="The filename of the DMG file", dest="dmg", default="Jalview_macos.dmg") parser.add_argument("--dump", help="Display contents of the input DS_Store to stdout", action="store_true", dest="dump") parser.add_argument("-q", "--quiet", help="Don't print messages to stdout", action="store_true", dest="quiet") -parser.add_argument("-f", "--filenames", help="List of comma-separated filenames to show information for --dump", dest="filenames", default="") +parser.add_argument("--appname", help="Filename of the application on the DMG (including '.app')", dest="appname") +parser.add_argument("--appxpos", help="x position of the application icon", dest="appxpos", type=int) +parser.add_argument("--appypos", help="y position of the application icon", dest="appypos", type=int) args = parser.parse_args() @@ -39,13 +41,9 @@ if (args.dump and not args.input): if (args.dump): with ds_store.DSStore.open(args.input, 'r') as d: - print(f"d=") - print(pprint.pformat(d['.']['bwsp'], width=1)) - for key in ["bwsp", "icvp","Iloc"]: try: - print(f"d['.']['{key}']=") - pprint.pprint(str(d['.'][key]), width=1) + print(f"d['.']['{key}'] =\n" + pprint.pformat(d['.'][key], width=4)) except: print(f"No info for d['.']['{key}']") @@ -60,12 +58,6 @@ if (args.dump): pprint.pprint(f"d['{data}']="+d[data], width=1) except: print(f"No info for d['{data}']") -# for filename in args.filenames.split(","): -# if (filename): -# for f in d.find(filename): -# myprint(f"d['{f}']=", d[f]) -# else: -# myprint(f"# No filename '{filename}' found in DS_Store '{args.input}'") exit(0) if (args.output and not (args.input or args.config)): @@ -94,11 +86,15 @@ outputds = ds_store.DSStore.open(args.output, 'w+') bwsp = {} for key in "ShowStatusBar SidebarWidthTenElevenOrLater ShowToolbar ShowTabView ContainerShowSidebar WindowBounds ShowSidebar ShowPathbar".split(): - if key in inputds['.']['bwsp']: - bwsp[key] = inputds['.']['bwsp'][key] - myprint(f"Setting bwsp['{key}'] to '"+str(inputds['.']['bwsp'][key])+"'") + if config and 'bwsp' in config and key in config['bwsp']: + bwsp[key] = config['bwsp'][key] + myprint(f"Setting bwsp['{key}'] to '"+str(bwsp[key])+"' from config") else: - myprint(f"Did not find '{key}' in input bwsp") + if key in inputds['.']['bwsp']: + bwsp[key] = inputds['.']['bwsp'][key] + myprint(f"Setting bwsp['{key}'] to '"+str(bwsp[key])+"' from input DS_Store") + else: + myprint(f"Did not find '{key}' in input bwsp") outputds['.']['bwsp'] = bwsp @@ -115,20 +111,20 @@ alias.target.carbon_path = f'{args.volumename}:{args.backgrounddir}:{args.backgr alias.target.posix_path = f'/{args.backgrounddir}/{args.backgroundfile}' icvp['backgroundImageAlias'] = alias.to_bytes() +myprint(f"Setting icvp['backgroundImageAlias']") for key in "backgroundColorRed backgroundColorBlue backgroundColorGreen gridSpacing gridOffsetX gridOffsetY showItemInfo viewOptionsVersion arrangeBy textSize labelOnBottom backgroundType showIconPreview iconSize".split(): - if key in inputds['.']['icvp']: - icvp[key] = inputds['.']['icvp'][key] - myprint(f"Setting icvp['{key}'] to '"+str(inputds['.']['icvp'][key])+"'") + if config and 'icvp' in config and key in config['icvp']: + icvp[key] = config['icvp'][key] + myprint(f"Setting icvp['{key}'] to '"+str(icvp[key])+"' from config") else: - myprint(f"Did not find '{key}' in input icvp") + if key in inputds['.']['icvp']: + icvp[key] = inputds['.']['icvp'][key] + myprint(f"Setting icvp['{key}'] to '"+str(icvp[key])+"' from input DS_Store") + else: + myprint(f"Did not find '{key}' in input icvp") outputds['.']['icvp'] = icvp - -# copy filenames properties? not working, using JSON config file -#for filename in args.filenames.split(","): -# outputds[filename]['Iloc'] = inputds[filename]['Iloc'] - outputds['.']['vSrn'] = ('long', 1) if config: @@ -136,6 +132,20 @@ if config: outputds[fileinfo['name']]['Iloc'] = (fileinfo['xpos'], fileinfo['ypos']) myprint("Setting icon location for filename '" + fileinfo['name'] + "' to ( " + str(fileinfo['xpos']) + ", " + str(fileinfo['ypos']) + " )") +if args.appname: + + xpos = args.appxpos + if (not xpos) and 'app' in config and 'xpos' in config['app']: + xpos = config['app']['xpos'] + + ypos = args.appypos + if (not ypos) and 'app' in config and 'ypos' in config['app']: + ypos = config['app']['ypos'] + + if xpos != None and ypos != None: + outputds[args.appname]['Iloc'] = (xpos, ypos) + myprint("Setting icon location for filename '" + args.appname + "' to ( " + str(xpos) + ", " + str(ypos) + " )") + outputds.flush() outputds.close() inputds.close()