Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
0f3a42fd
by lovetox at 2022-05-30T07:52:33+02:00
-
be8659e7
by lovetox at 2022-05-30T07:52:33+02:00
-
38b0f471
by lovetox at 2022-05-30T07:52:33+02:00
-
313e50d3
by lovetox at 2022-05-30T07:53:23+02:00
-
72e5a16d
by lovetox at 2022-05-30T07:53:23+02:00
6 changed files:
- pyrightconfig.json
- − scripts/dev/multisplit.scm
- − scripts/dev/pngcrush
- scripts/dev/generate_ui_types.py → scripts/generate_ui_types.py
- scripts/dev/pre-push-tests.sh → scripts/pre-push-tests.sh
- setup.py
Changes:
| ... | ... | @@ -10,8 +10,11 @@ |
| 10 | 10 | ".git"
|
| 11 | 11 | ],
|
| 12 | 12 | "include": [
|
| 13 | - "win/*",
|
|
| 13 | + "launch.py",
|
|
| 14 | + "setup.py",
|
|
| 14 | 15 | ".ci/*",
|
| 16 | + "scripts/*",
|
|
| 17 | + "win/*",
|
|
| 15 | 18 | "gajim/gajim.py",
|
| 16 | 19 | "gajim/plugins/gajimplugin.py",
|
| 17 | 20 | "gajim/plugins/helpers.py",
|
| 1 | -; multisplit: splits up a mavica multi (sprites in one layer) into layers
|
|
| 2 | -; so you make make from png/jpg sprite a gif animation
|
|
| 3 | -; put me in ~/.gimp-ver/scripts and find me script-fu>animators>MultiSplit
|
|
| 4 | - |
|
| 5 | -(define (script-fu-multisplit multimg
|
|
| 6 | - drawable
|
|
| 7 | - horizontal
|
|
| 8 | - vertical
|
|
| 9 | - delay)
|
|
| 10 | - (let* (
|
|
| 11 | - (width 0)
|
|
| 12 | - (height 0)
|
|
| 13 | - (img 0)
|
|
| 14 | - (layerNum 0)
|
|
| 15 | - (hpos 0)
|
|
| 16 | - (vpos 0)
|
|
| 17 | - (layer 0)
|
|
| 18 | - (floatingLayer 0)
|
|
| 19 | - )
|
|
| 20 | - |
|
| 21 | - (set! width (/ (car (gimp-image-width multimg)) horizontal))
|
|
| 22 | - (set! height (/ (car (gimp-image-height multimg)) vertical))
|
|
| 23 | - (set! img (car (gimp-image-new width height RGB)))
|
|
| 24 | - |
|
| 25 | - (set! vpos 0)
|
|
| 26 | - (while (< vpos vertical)
|
|
| 27 | - (set! hpos 0)
|
|
| 28 | - (while (< hpos horizontal)
|
|
| 29 | - (set! layerNum (+ layerNum 1))
|
|
| 30 | - (set! layer (car (gimp-layer-new img width height RGB
|
|
| 31 | - (string-append "Frame" delay "(replace)")
|
|
| 32 | - 100 NORMAL)))
|
|
| 33 | - |
|
| 34 | - (gimp-layer-add-alpha layer)
|
|
| 35 | - (gimp-drawable-fill layer TRANSPARENT-FILL)
|
|
| 36 | - (gimp-image-add-layer img layer -1)
|
|
| 37 | - |
|
| 38 | - (gimp-rect-select multimg
|
|
| 39 | - (* hpos width) (* vpos height)
|
|
| 40 | - width height
|
|
| 41 | - REPLACE FALSE 0)
|
|
| 42 | - |
|
| 43 | - (gimp-edit-copy drawable)
|
|
| 44 | - |
|
| 45 | - (gimp-selection-all img)
|
|
| 46 | - |
|
| 47 | - (set! floatingLayer (car (gimp-edit-paste layer 0)))
|
|
| 48 | - (gimp-floating-sel-anchor floatingLayer)
|
|
| 49 | - |
|
| 50 | - (gimp-selection-none img)
|
|
| 51 | - (gimp-selection-none multimg)
|
|
| 52 | -
|
|
| 53 | - (set! hpos (+ hpos 1))
|
|
| 54 | - )
|
|
| 55 | - (set! vpos (+ vpos 1))
|
|
| 56 | - )
|
|
| 57 | - |
|
| 58 | - (gimp-display-new img)
|
|
| 59 | - )
|
|
| 60 | -)
|
|
| 61 | - |
|
| 62 | -(script-fu-register "script-fu-multisplit"
|
|
| 63 | - "<Image>/Script-Fu/Animators/MultiSplit"
|
|
| 64 | - "Split an image into layers"
|
|
| 65 | - "Rick Miller (Rick.Miller@Linux.org)"
|
|
| 66 | - "Rick Miller"
|
|
| 67 | - "05/19/2000"
|
|
| 68 | - "RGB RGBA GRAY GRAYA"
|
|
| 69 | - SF-IMAGE "Image" 0
|
|
| 70 | - SF-DRAWABLE "Drawable" 0
|
|
| 71 | - SF-VALUE "Horizontal Slices" "3"
|
|
| 72 | - SF-VALUE "Vertical Slices" "3"
|
|
| 73 | - SF-VALUE "Default Delay" "\"250ms\"")
|
|
| 74 | - |
| 1 | -#!/bin/sh
|
|
| 2 | - |
|
| 3 | -# there can be as many input arguments as you want
|
|
| 4 | -# they are all assumed to be PNG file names
|
|
| 5 | - |
|
| 6 | -# run as sh pngcrush $(ls *png)
|
|
| 7 | - |
|
| 8 | -# loop through all arguments
|
|
| 9 | -while (( $# >= 1 )); do
|
|
| 10 | - # create temp output file
|
|
| 11 | - # output file has all colorspace chunks removed and optimized compression
|
|
| 12 | - pngcrush -l 9 "$1" "$1".tmp
|
|
| 13 | - # remove the original file
|
|
| 14 | - rm "$1"
|
|
| 15 | - # replace the original with the new optimized output file
|
|
| 16 | - mv "$1".tmp "$1"
|
|
| 17 | - shift
|
|
| 18 | -done
|
|
| 19 | - |
|
| 20 | -exit 0
|
|
| 21 | - |
|
| 22 | -# from http://cvs.sourceforge.net/viewcvs.py/tom7misc/vstplugins/scripts/fixpng?rev=1.2&view=auto |
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | # Reads all .ui files and creates builder.pyi
|
| 4 | 4 | # Excecute this script from the repo root dir
|
| 5 | 5 | |
| 6 | +from io import TextIOWrapper
|
|
| 6 | 7 | from pathlib import Path
|
| 7 | 8 | from xml.etree import ElementTree as ET
|
| 8 | 9 | |
| ... | ... | @@ -41,22 +42,22 @@ def get_builder(file_name: Literal['%s'], widgets: list[str] = ...) -> %s: ...'' |
| 41 | 42 | def get_builder(file_name: str, widgets: list[str] = ...) -> Builder: ...'''
|
| 42 | 43 | |
| 43 | 44 | |
| 44 | -def make_class_name(path):
|
|
| 45 | +def make_class_name(path: Path) -> str:
|
|
| 45 | 46 | name = path.name.removesuffix('.ui')
|
| 46 | 47 | names = name.split('_')
|
| 47 | 48 | names = map(lambda x: x.capitalize(), names)
|
| 48 | 49 | return ''.join(names) + 'Builder'
|
| 49 | 50 | |
| 50 | 51 | |
| 51 | -def parse(path, file):
|
|
| 52 | +def parse(path: Path, file: TextIOWrapper) -> str:
|
|
| 52 | 53 | print('read', path)
|
| 53 | - lines = []
|
|
| 54 | + lines: list[str] = []
|
|
| 54 | 55 | tree = ET.parse(path)
|
| 55 | 56 | for node in tree.iter(tag='object'):
|
| 56 | 57 | id_ = node.attrib.get('id')
|
| 57 | 58 | if id_ is None:
|
| 58 | 59 | continue
|
| 59 | - klass = node.attrib.get('class')
|
|
| 60 | + klass = node.attrib['class']
|
|
| 60 | 61 | if klass.startswith('GtkSource'):
|
| 61 | 62 | klass = f'GtkSource.{klass.removeprefix("GtkSource")}'
|
| 62 | 63 | elif klass.startswith('Atk'):
|
| ... | ... | @@ -78,7 +79,7 @@ def parse(path, file): |
| 78 | 79 | return klass_name
|
| 79 | 80 | |
| 80 | 81 | |
| 81 | -builder_names = []
|
|
| 82 | +builder_names: list[tuple[str, str]] = []
|
|
| 82 | 83 | |
| 83 | 84 | with out_path.open(mode='w', encoding='utf8') as file:
|
| 84 | 85 | file.write(IMPORTS)
|
| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | from __future__ import annotations
|
| 4 | 4 | |
| 5 | +from typing import cast
|
|
| 6 | + |
|
| 5 | 7 | import os
|
| 6 | 8 | import sys
|
| 7 | 9 | |
| ... | ... | @@ -16,6 +18,9 @@ |
| 16 | 18 | from setuptools.command.install import install as _install
|
| 17 | 19 | |
| 18 | 20 | |
| 21 | +DataFilesT = list[tuple[str, list[str]]]
|
|
| 22 | + |
|
| 23 | + |
|
| 19 | 24 | MAN_FILES = [
|
| 20 | 25 | 'gajim.1',
|
| 21 | 26 | 'gajim-remote.1'
|
| ... | ... | @@ -65,7 +70,7 @@ def build_translation() -> None: |
| 65 | 70 | print('Compiling %s >> %s' % (po_file, mo_file))
|
| 66 | 71 | |
| 67 | 72 | |
| 68 | -def install_trans(data_files) -> None:
|
|
| 73 | +def install_trans(data_files: DataFilesT) -> None:
|
|
| 69 | 74 | for lang in ALL_LINGUAS:
|
| 70 | 75 | mo_file = str(BUILD_DIR / 'mo' / lang / 'LC_MESSAGES' / 'gajim.mo')
|
| 71 | 76 | target = f'share/locale/{lang}/LC_MESSAGES'
|
| ... | ... | @@ -97,7 +102,7 @@ def build_man() -> None: |
| 97 | 102 | print('Compiling %s >> %s' % (filename, man_file_gz))
|
| 98 | 103 | |
| 99 | 104 | |
| 100 | -def install_man(data_files) -> None:
|
|
| 105 | +def install_man(data_files: DataFilesT) -> None:
|
|
| 101 | 106 | man_dir = BUILD_DIR / 'man'
|
| 102 | 107 | target = 'share/man/man1'
|
| 103 | 108 | |
| ... | ... | @@ -120,12 +125,15 @@ def build_intl() -> None: |
| 120 | 125 | merge(Path(filename + '.in'), newfile, option)
|
| 121 | 126 | |
| 122 | 127 | |
| 123 | -def install_intl(data_files) -> None:
|
|
| 128 | +def install_intl(data_files: DataFilesT) -> None:
|
|
| 124 | 129 | for filename, target, _ in META_FILES:
|
| 125 | 130 | data_files.append((target, [str(BUILD_DIR / filename)]))
|
| 126 | 131 | |
| 127 | 132 | |
| 128 | -def merge(in_file, out_file, option, po_dir: str = 'po') -> None:
|
|
| 133 | +def merge(in_file: Path,
|
|
| 134 | + out_file: Path,
|
|
| 135 | + option: str,
|
|
| 136 | + po_dir: str = 'po') -> None:
|
|
| 129 | 137 | '''
|
| 130 | 138 | Run the msgfmt command.
|
| 131 | 139 | '''
|
| ... | ... | @@ -154,12 +162,12 @@ def run(self): |
| 154 | 162 | |
| 155 | 163 | class install(_install):
|
| 156 | 164 | def run(self):
|
| 157 | - data_files = self.distribution.data_files
|
|
| 165 | + data_files = cast(DataFilesT, self.distribution.data_files) # pyright: ignore
|
|
| 158 | 166 | install_trans(data_files)
|
| 159 | 167 | if sys.platform != 'win32':
|
| 160 | 168 | install_man(data_files)
|
| 161 | 169 | install_intl(data_files)
|
| 162 | - _install.run(self)
|
|
| 170 | + _install.run(self) # pyright: ignore
|
|
| 163 | 171 | |
| 164 | 172 | |
| 165 | 173 | # only install subdirectories of data
|
| ... | ... | @@ -170,7 +178,7 @@ def run(self): |
| 170 | 178 | ["gajim/data/icons/hicolor/scalable/apps/org.gajim.Gajim-symbolic.svg"])
|
| 171 | 179 | ]
|
| 172 | 180 | |
| 173 | -data_files = data_files_app_icon
|
|
| 181 | +data_files: DataFilesT = data_files_app_icon
|
|
| 174 | 182 | |
| 175 | 183 | setup(
|
| 176 | 184 | cmdclass={
|