Commit Graph

1343 Commits

Author SHA1 Message Date
Isaiah Odhner
52a9425b36 Try to allow canceling Set As Wallpaper (probably silly) 2023-07-19 20:45:25 -04:00
Isaiah Odhner
f865acd56c Fix error handling for Set As Wallpaper worker thread 2023-07-19 13:58:31 -04:00
Isaiah Odhner
8e7113e1b5 Match font names case-insensitively and ignoring spaces 2023-07-19 01:44:20 -04:00
Isaiah Odhner
ec7986f9dd Add font names for Windows 2023-07-19 01:31:57 -04:00
Isaiah Odhner
b63f303cf4 Set wallpaper in a worker, to keep UI responsive 2023-07-19 01:26:33 -04:00
Isaiah Odhner
1c64fdb78c Fix Python rocket icon showing in dock on macOS after Set As Wallpaper 2023-07-18 18:32:32 -04:00
Isaiah Odhner
5c7272db91 Clean up Tk root widget
I was hoping this would fix the Python rocket icon showing in the dock on macOS, but it doesn't. It still stays until the program exits.
Might still be good to do though.
2023-07-18 18:32:32 -04:00
Isaiah Odhner
e2308c2a91 Add font names for macOS 2023-07-18 14:15:36 -04:00
Isaiah Odhner
5a5d8b38af Colorize Text Tilt art 2023-07-18 14:15:36 -04:00
Isaiah Odhner
10ed661022 Use unique IDs to actually reliably update wallpaper 2023-07-18 14:15:36 -04:00
Isaiah Odhner
3106a311eb Alternate between files to reliably update wallpaper 2023-07-18 14:15:36 -04:00
Isaiah Odhner
eb0f781ca8 Get screen size with tkinter instead
screeninfo caused a bouncing python rocket in the dock on mac, and didn't work.
2023-07-18 14:15:36 -04:00
Isaiah Odhner
7f3fe53d3e Get screen size properly, with screeninfo module 2023-07-18 14:03:51 -04:00
Isaiah Odhner
fd7f3e8fcc Get screen size in the simplest way that could possibly work 2023-07-18 14:03:51 -04:00
Isaiah Odhner
8fb561f457 Implement tiling vs centering wallpaper 2023-07-18 14:03:51 -04:00
Isaiah Odhner
00e6dd70b0 Set dark mode wallpaper as well on Ubuntu
This gets it working on my machine! And the last of the big three!
2023-07-18 14:03:51 -04:00
Isaiah Odhner
5fd214182c DRY gsettings schema/key 2023-07-18 14:03:51 -04:00
Isaiah Odhner
fece1c48c6 Rasterize before setting as wallpaper
This makes Set As Wallpaper work on Windows 10 and macOS 10.14
2023-07-18 14:03:51 -04:00
Isaiah Odhner
ebbab737d4 Add compatibility section 2023-07-17 20:27:19 -04:00
Isaiah Odhner
2966ebf6da Be consistent about encoding name 2023-07-17 20:04:25 -04:00
Isaiah Odhner
fc395e2db9 Specify UTF-8 encoding, since it's not default on Windows
https://peps.python.org/pep-0597/#using-the-default-encoding-is-a-common-mistake
2023-07-17 20:04:24 -04:00
Isaiah Odhner
033e86f4e7 Make psutil optional
It's hard to install on Windows, and this seems to be misleading:

    ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
2023-07-17 19:18:31 -04:00
Isaiah Odhner
300291fcae Indicate non-regex raw string (conventionally)
Some tools highlight regex syntax when a lowercase `r` is used.
2023-07-17 13:49:41 -04:00
Isaiah Odhner
82dd98d8cb Fix invalid assertion on mac
os.name == "posix" (!)
2023-07-17 12:31:48 -04:00
Isaiah Odhner
321dd1284f Move "type: ignore" comment now serving a different purpose
Before this was presumably suppressing the `self.app` bogus error.
2023-07-17 12:25:33 -04:00
Isaiah Odhner
a0f837aad7 Remove unnecessary "type: ignore" comments 2023-07-16 01:06:24 -04:00
Isaiah Odhner
36e809bc97 Enable reporting unnecessary "type: ignore" comments 2023-07-16 00:47:15 -04:00
Isaiah Odhner
15b35eaf5c Fix new errors after updating pyright (v1.1.314 -> v1.1.317)
→ PYRIGHT_PYTHON_FORCE_VERSION=latest pyright

added 1 package, and audited 2 packages in 4s

found 0 vulnerabilities
/home/io/Projects/textual-paint/src/textual_paint/paint.py
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1173:64 - error: Condition will always evaluate to True since the types "Never" and "None" have no overlap (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1214:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1217:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1220:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1223:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1229:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1233:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
7 errors, 0 warnings, 0 informations
2023-07-15 23:32:18 -04:00
Isaiah Odhner
f21899fd1d Use LineFilter to avoid private _segments access
This fixes the last pyright error (on pyright v1.1.314)
2023-07-15 23:24:56 -04:00
Isaiah Odhner
f6a40028e8 Update and clarify help text 2023-07-15 23:05:41 -04:00
Isaiah Odhner
b62a92a782 Simplify using Segment.apply_style 2023-07-15 22:45:52 -04:00
Isaiah Odhner
96b2d08789 Ignore all but one last Pyright error
(on pyright v1.1.314)
2023-07-15 22:27:49 -04:00
Isaiah Odhner
26cf8c3e64 Annotate instruction from stransi 2023-07-15 22:26:41 -04:00
Isaiah Odhner
9c8c035d14 Add type stubs for Pillow and psutil 2023-07-15 21:53:09 -04:00
Isaiah Odhner
d5669f434f Fix type mismatch in unused code
error: Incompatible types in assignment (expression has type "None", variable has type "bool")  [assignment]
2023-07-15 21:52:47 -04:00
Isaiah Odhner
0a6fb29e10 Reorder None case for mypy
While Pyright can narrow down the type of format_id from `str | None` to `str` based on `format_id in Image.SAVE` (where `Image.SAVE` is `dict[str, Any]`), mypy does not.
2023-07-15 21:47:43 -04:00
Isaiah Odhner
641a46e368 Add type hints for mypy 2023-07-15 21:43:50 -04:00
Isaiah Odhner
3ff0b47650 Fix strange default for Window.title reactive var 2023-07-15 21:29:59 -04:00
Isaiah Odhner
eb81d5e934 Add missing annotations, needed for mypy 2023-07-15 21:22:25 -04:00
Isaiah Odhner
1c737fada2 Avoid shell=True and fix mypy errors about mismatching type for args 2023-07-15 21:09:08 -04:00
Isaiah Odhner
1ce0487a52 Fix reportOptionalMemberAccess errors for width/height 2023-07-15 21:09:08 -04:00
Isaiah Odhner
6c1b994598 Smooth over variable getpixel return type, for Pyright 2023-07-15 20:31:02 -04:00
Isaiah Odhner
87f1f50f06 Fix some stupid pyright errors 2023-07-15 20:27:20 -04:00
Isaiah Odhner
6f5cee0f7c Disable reportUnknownMemberType Pyright error 2023-07-15 20:27:20 -04:00
Isaiah Odhner
f50aef18e7 None pizza with left beef 2023-07-15 19:44:05 -04:00
Isaiah Odhner
16f4bc0a88 Fix some mypy errors (and a couple pyright errors) 2023-07-15 19:44:05 -04:00
Isaiah Odhner
dd4fea1e78 Add py.typed for mypy 2023-07-15 19:44:05 -04:00
Isaiah Odhner
4fc5a6e8e5 Clarify a comment
"optional" is ambiguous, between optional arguments (i.e. parameters with a default value), and a union with `None` (i.e. `Optional`, or `| None`)
2023-07-15 19:44:05 -04:00
Isaiah Odhner
cbcf22c4d7 Clean up old _expanding_directory_tree flag, and logging 2023-07-15 19:44:05 -04:00
Isaiah Odhner
54f29eabf1 Fix false positives and false negatives for when to populate file name
When opening the Open dialog, it shouldn't populate the file name input,
but when clicking a file, it should fill in the clicked file's name.

The `_expanding_directory_tree` flag gave false positives:
- When opening a file in a directory the program doesn't have permissions to via the CLI,
  such as with `python -m src.textual_paint.paint /root/nonexistent`,
  opening the Open dialog, and clicking a file, it wasn't populating the filename input,
  because the flag was never cleared if it couldn't find (access) the
  directories and file matching any of the path parts, working down the directory structure.
  
  This was broken in [b3ca55a3b1] "Use new callback to remove race condition"
  but before, it just cleared the flag after a delay, so it wasn't a good solution,

It also gave false negatives:
- When opening the Open dialog, it was populating the name input field
  with the file selected programmatically with `expand_to_path`,
  instead of leaving it blank.
  
  The automatic expansion was broken in [e9755637d6] "Update Textual to 0.26.0"
  due to changes 0.25.0, since directory contents are now loaded in a worker.
  This flag's behavior was broken since rewriting the code to handle asynchronous directory loading in
  [4e1f11ab23] "Fix expanding directory tree to current folder, in file dialogs"

An alternative I considered was to create a new message such as `EnhancedDirectoryTree.NodeHighlighted`, but let's call it `EnhancedNodeHighlighted`, then to have `on_tree_node_highlighted` in `EnhancedDirectoryTree` which sends `EnhancedNodeHighlighted` always with `from_expand_to_path=False`, and then do:

    | # Suppress EnhancedNodeHighlighted with from_expand_to_path=False
    | with self.prevent(self.EnhancedNodeHighlighted):
    | 	self.select_node(node)
    | # Send it with the flag set
    | self.post_message(self.EnhancedNodeHighlighted(..., from_expand_to_path=True))

The solution I settled on was to add an `on_tree_node_highlighted` method to my `EnhancedDirectoryTree` for the purpose of clearing the flag, with still a further delay so that the app's `on_tree_node_highlighted` can use the flag before its cleared.

(I left `_expanding_directory_tree` in at this commit for comparison of the behavior. For a fair estimate of the complexity of this change, include the following cleanup in the diff.)
2023-07-15 19:44:05 -04:00