diff --git a/builder/applbuild/generator.py b/builder/applbuild/generator.py index 64bd82c..34646de 100644 --- a/builder/applbuild/generator.py +++ b/builder/applbuild/generator.py @@ -7,10 +7,11 @@ from typing import Any from clickgen.builders import WindowsCursor, XCursor from clickgen.core import CursorAlias from clickgen.packagers import WindowsPackager, XPackager -from clickgen.util import LikePath, add_missing_xcursors +from clickgen.util import LikePath from applbuild.configure import get_config from applbuild.constants import * +from applbuild.symlinks import add_missing_xcursor # # 📝 Note: All CONSTANT variables are imported from `applbuild.constants` module. @@ -37,7 +38,7 @@ def xbuild(bitmaps_dir: LikePath, x_out_dir: Path) -> None: x_cfg = alias.create(X_SIZES, delay) XCursor.create(x_cfg, x_out_dir) - add_missing_xcursors(x_out_dir / "cursors", rename=True, force=True) + add_missing_xcursor(x_out_dir / "cursors") XPackager(x_out_dir, THEME_NAME, COMMENT) @@ -108,7 +109,7 @@ def build(bitmaps_dir: LikePath, x_out_dir: Path, win_out_dir: Path) -> None: if item.get("win_key"): win_build(item, alias) - add_missing_xcursors(x_out_dir / "cursors", rename=True, force=True) - + add_missing_xcursor(x_out_dir / "cursors") XPackager(x_out_dir, THEME_NAME, COMMENT) + WindowsPackager(win_out_dir, THEME_NAME, COMMENT, AUTHOR, URL) diff --git a/builder/applbuild/symlinks.py b/builder/applbuild/symlinks.py new file mode 100644 index 0000000..bed9d9c --- /dev/null +++ b/builder/applbuild/symlinks.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +from typing import Dict, List, Union + +from clickgen.util import LikePath, chdir + + +def add_missing_xcursor(directory: LikePath) -> None: + """Add missing `XCursor` to the Unix cursor package. + + :directory: (Path|str) directory where XCursors are available. + """ + + symlinks: List[Dict[str, Union[str, List[str]]]] = [ + {"src": "all-scroll", "links": ["fleur", "size_all"]}, + { + "src": "bottom_left_corner", + "links": ["sw-resize", "top_right_corner", "fd_double_arrow"], + }, + { + "src": "bottom_right_corner", + "links": ["top_left_corner", "se-resize", "bd_double_arrow"], + }, + {"src": "circle", "links": ["not-allowed", "forbidden"]}, + { + "src": "copy", + "links": [ + "1081e37283d90000800003c07f3ef6bf", + "6407b0e94181790501fd1e167b474872", + "b66166c04f8c3109214a4fbd64a50fc8", + "dnd_copy", + ], + }, + {"src": "cross", "links": ["cross_reverse", "diamond_cross", "tcross"]}, + { + "src": "crossed_circle", + "links": ["03b6e0fcb3499374a867c041f52298f0", "not-allowed"], + }, + {"src": "dnd_no_drop", "links": ["no-drop"]}, + {"src": "dotbox", "links": ["dot_box_mask", "draped_box", "icon", "target"]}, + {"src": "hand1", "links": ["grab", "openhand"]}, + { + "src": "hand2", + "links": [ + "9d800788f1b08800ae810202380a0822", + "e29285e634086352946a0e7090d73106", + "pointer", + "pointing_hand", + ], + }, + {"src": "left_ptr", "links": ["arrow", "default"]}, + {"src": "left_side", "links": ["w-resize", "right_side"]}, + { + "src": "link", + "links": [ + "3085a0e285430894940527032f8b26df", + "640fb0e74195791501fd1ed57b41487f", + "a2a266d0498c3104214a47bd64ab0fc8", + "alias", + "dnd_link", + "dnd-link", + "dnd_link", + ], + }, + { + "src": "move", + "links": [ + "4498f0e0c1937ffe01fd06f973665830", + "9081237383d90e509aa00f00170e968f", + "grabbing", + "pointer_move", + "dnd_move", + "dnd_none", + ], + }, + {"src": "pencil", "links": ["draft"]}, + {"src": "plus", "links": ["cell"]}, + { + "src": "question_arrow", + "links": [ + "5c6cd98b3f3ebcb1f9c7f1c204630408", + "d9ce0ab605698f320427677b458ad60b", + "help", + "left_ptr_help", + "whats_this", + "dnd_ask", + ], + }, + {"src": "right_ptr", "links": ["draft_large", "draft_small"]}, + {"src": "sb_down_arrow", "links": ["down-arrow"]}, + { + "src": "sb_h_double_arrow", + "links": [ + "028006030e0e7ebffc7f7070c0600140", + "14fef782d02440884392942c1120523", + "col-resize", + "ew-resize", + "h_double_arrow", + "size-hor", + "size_hor", + "split_h", + ], + }, + {"src": "sb_left_arrow", "links": ["left-arrow"]}, + {"src": "sb_right_arrow", "links": ["right-arrow"]}, + {"src": "sb_up_arrow", "links": ["up-arrow"]}, + { + "src": "sb_v_double_arrow", + "links": [ + "00008160000006810000408080010102", + "2870a09082c103050810ffdffffe0204", + "double_arrow", + "ns-resize", + "row-resize", + "size-ver", + "size_ver", + "split_v", + "v_double_arrow", + ], + }, + {"src": "top_side", "links": ["n-resize", "bottom_side"]}, + {"src": "X_cursor", "links": ["pirate", "x-cursor"]}, + {"src": "xterm", "links": ["ibeam", "text"]}, + ] + + with chdir(directory): + for item in symlinks: + src = item.get("src") + for link in item.get("links"): + os.symlink(src, link)