Philipp Hörist pushed to branch gajim_1.1 at gajim / gajim

Commits:

5 changed files:

Changes:

  • mac/Gajim.icns
    No preview for this file type
  • mac/Info.plist.template
    1
    +<?xml version="1.0" encoding="UTF-8"?>
    
    2
    +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    
    3
    +<plist version="1.0">
    
    4
    +<dict>
    
    5
    +    <key>CFBundleExecutable</key>
    
    6
    +    <string>launch.sh</string>
    
    7
    +    <key>CFBundleIdentifier</key>
    
    8
    +    <string>org.gajim.mac</string>
    
    9
    +    <key>CFBundleInfoDictionaryVersion</key>
    
    10
    +    <string>6.0</string>
    
    11
    +    <key>CFBundleName</key>
    
    12
    +    <string>Gajim</string>
    
    13
    +    <key>CFBundlePackageType</key>
    
    14
    +    <string>APPL</string>
    
    15
    +    <key>CFBundleShortVersionString</key>
    
    16
    +    <string>${short_version_string}</string>
    
    17
    +    <key>CFBundleSignature</key>
    
    18
    +    <string>DASH</string>
    
    19
    +    <key>CFBundleVersion</key>
    
    20
    +    <string>${version}</string>
    
    21
    +    <key>CFBundleIconFile</key>
    
    22
    +    <string>Gajim</string>
    
    23
    +    <key>CFBundleURLTypes</key>
    
    24
    +    <array>
    
    25
    +        <dict>
    
    26
    +            <key>CFBundleTypeRole</key>
    
    27
    +            <string>Viewer</string>
    
    28
    +            <key>CFBundleURLName</key>
    
    29
    +            <string>XMPP</string>
    
    30
    +            <key>CFBundleURLSchemes</key>
    
    31
    +            <array>
    
    32
    +                <string>xmpp</string>
    
    33
    +            </array>
    
    34
    +        </dict>
    
    35
    +    </array>
    
    36
    +</dict>
    
    37
    +</plist>

  • mac/launch.sh.template
    1
    +#!/bin/sh
    
    2
    +
    
    3
    +${bin_path}

  • mac/makebundle.py
    1
    +#!/usr/bin/env python3
    
    2
    +import os
    
    3
    +import shutil
    
    4
    +import sys
    
    5
    +from string import Template
    
    6
    +from os.path import join
    
    7
    +import argparse
    
    8
    +
    
    9
    +EXEC_TEMPLATE = 'mac/launch.sh.template'
    
    10
    +PLIST_TEMPLATE = 'mac/Info.plist.template'
    
    11
    +ICNS_FILE = 'mac/Gajim.icns'
    
    12
    +
    
    13
    +
    
    14
    +def fill_template(in_path, out_path, vars):
    
    15
    +    with open(in_path, 'r') as f:
    
    16
    +        templ = Template(f.read())
    
    17
    +    filled_templ = templ.substitute(vars)
    
    18
    +    with open(out_path, 'w') as f:
    
    19
    +        f.write(filled_templ)
    
    20
    +
    
    21
    +
    
    22
    +def create_executable(exec_path, bin_path):
    
    23
    +    fill_template(EXEC_TEMPLATE, exec_path, {
    
    24
    +        'bin_path': bin_path
    
    25
    +    })
    
    26
    +    os.chmod(exec_path, 0o755)
    
    27
    +
    
    28
    +
    
    29
    +def create_plist(plist_path, version):
    
    30
    +    fill_template(PLIST_TEMPLATE, plist_path, {
    
    31
    +        'version': version,
    
    32
    +        'short_version_string': version
    
    33
    +    })
    
    34
    +
    
    35
    +
    
    36
    +if __name__ == '__main__':
    
    37
    +    if not os.path.isdir('mac'):
    
    38
    +        sys.exit("can't find the 'mac' directory. make sure you run "
    
    39
    +                 "this script from the project root")
    
    40
    +
    
    41
    +    parser = argparse.ArgumentParser(description='Create a macOS .app bundle.')
    
    42
    +    parser.add_argument('bundle', help='bundle output location')
    
    43
    +    parser.add_argument('--version', default='0.0.1',
    
    44
    +                        help='version number of the .app bundle')
    
    45
    +    parser.add_argument('--bin-path', default='/usr/local/bin/gajim',
    
    46
    +                        help='location of the actual executable')
    
    47
    +    args = parser.parse_args()
    
    48
    +
    
    49
    +    bundle = args.bundle
    
    50
    +
    
    51
    +    os.mkdir(bundle)
    
    52
    +    os.mkdir(join(bundle, 'Contents'))
    
    53
    +    os.mkdir(join(bundle, 'Contents/MacOS'))
    
    54
    +    os.mkdir(join(bundle, 'Contents/Resources'))
    
    55
    +
    
    56
    +    create_executable(join(bundle, 'Contents/MacOS/launch.sh'), bin_path=args.bin_path)
    
    57
    +    create_plist(join(bundle, 'Contents/Info.plist'), version=args.version)
    
    58
    +    shutil.copy(ICNS_FILE, join(bundle, 'Contents/Resources/Gajim.icns'))

  • mac/makeicns.py
    1
    +#!/usr/bin/env python3
    
    2
    +import os
    
    3
    +import shutil
    
    4
    +from argparse import ArgumentParser
    
    5
    +from subprocess import run
    
    6
    +
    
    7
    +ICON_SVG = 'gajim/data/icons/hicolor/scalable/apps/org.gajim.Gajim.svg'
    
    8
    +
    
    9
    +
    
    10
    +def create_icns(icon_path):
    
    11
    +    tmpdir = 'Gajim.iconset'
    
    12
    +    if os.path.isdir(tmpdir):
    
    13
    +        shutil.rmtree(tmpdir)
    
    14
    +    os.mkdir(tmpdir)
    
    15
    +
    
    16
    +    for size_pt in [16, 32, 128, 256, 512]:
    
    17
    +        for scale in [1, 2]:
    
    18
    +            size_px = scale * size_pt
    
    19
    +            scale_txt = '@{}'.format(scale) if scale != 1 else ''
    
    20
    +            png_fn = 'icon_{}x{}{}.png'.format(size_pt, size_pt, scale_txt)
    
    21
    +            png_path = os.path.join(tmpdir, png_fn)
    
    22
    +            run(['inkscape', '-z', '-e', png_path,
    
    23
    +                 '-w', str(size_px), '-h', str(size_px), '-y', '0',
    
    24
    +                 ICON_SVG])
    
    25
    +    run(['iconutil', '-c', 'icns', '-o', icon_path, tmpdir])
    
    26
    +
    
    27
    +    shutil.rmtree(tmpdir)
    
    28
    +
    
    29
    +
    
    30
    +if __name__ == '__main__':
    
    31
    +    parser = ArgumentParser(description='Create a macOS .icns icon. '
    
    32
    +                            'Requires Inkscape and iconutil (macOS).')
    
    33
    +    parser.add_argument('output', help='bundle output location')
    
    34
    +    args = parser.parse_args()
    
    35
    +
    
    36
    +    create_icns(args.output)