~nhanb/mcross

b26c4f1a14ae45daad956c64f42fb6dd47ff8886 — Bùi Thành Nhân 1 year, 1 month ago 12cc941
bring back Windows support

Necessary evil I guess.
4 files changed, 28 insertions(+), 20 deletions(-)

M README.md
M pyproject.toml
M src/mcross/gui/controller.py
M src/mcross/gui/view.py
M README.md => README.md +6 -6
@@ 1,7 1,7 @@
McRoss is a minimal and usable [gemini://](https://gemini.circumlunar.space/)
browser written in python and tkinter. I use it on Linux but it should work on
other Unix-likes without trouble. Windows isn't supported until I can find an
alternative to tkinter's [createfilehandler()][7].
browser written in python and tkinter, meaning it Just Works (tm) on any
self-respecting desktop OS. I use and test it on Linux & Windows, but it should
also run fine on macOS or any of the BSDs.

It currently looks like this:



@@ 168,9 168,9 @@ this program.  If not, see <https://www.gnu.org/licenses/>.

# Forks

McRoss development is... conservative and slow. If that bothers you, check out
[picross][6] which is a nice fork with more features (TOFU, tabs, among other
things).
McRoss development is... conservative and sporadic.
If that bothers you, check out [picross][6] which is a nice fork with more
features (TOFU, tabs, among other things).

[1]: https://hi.imnhan.com/posts/introducing-mcross-a-minimal-gemini-browser/
[2]: https://todo.sr.ht/~nhanb/mcross/3

M pyproject.toml => pyproject.toml +1 -1
@@ 1,6 1,6 @@
[tool.poetry]
name = "mcross"
version = "0.5.18"
version = "0.5.19"
description = "Do you remember www?"
authors = ["nhanb <hi@imnhan.com>"]
license = "AGPL-3.0-only"

M src/mcross/gui/controller.py => src/mcross/gui/controller.py +20 -12
@@ 7,13 7,9 @@ from tkinter import READABLE, Tk, messagebox

import curio

from ..transport import (
    MAX_REQUEST_SECONDS,
    GeminiUrl,
    NonAbsoluteUrlWithoutContextError,
    UnsupportedProtocolError,
    get,
)
from ..transport import (MAX_REQUEST_SECONDS, GeminiUrl,
                         NonAbsoluteUrlWithoutContextError,
                         UnsupportedProtocolError, get)
from .model import Model
from .view import WAITING_CURSOR, View



@@ 32,9 28,6 @@ class Controller:
        self.gui_ops = curio.UniversalQueue(withfd=True)
        self.coro_ops = curio.UniversalQueue()

        # Set up event handler for queued GUI updates
        self.root.createfilehandler(self.gui_ops, READABLE, self.process_gui_ops)

        # When in the middle of an action, this flag is set to False to prevent user
        # from clicking other random stuff:
        self.allow_user_interaction = True


@@ 46,6 39,20 @@ class Controller:

            return inner

        # Make sure queued GUI operations are executed as soon as they become available
        if hasattr(self.root, "createfilehandler"):
            self.root.createfilehandler(self.gui_ops, READABLE, self.process_gui_ops)
        else:
            print("Running poll-based workaround for Windows.")
            # This is way more inefficient (5% CPU usage on a Surface Go at idle) but
            # hey it's better than not working at all!

            def after_cb():
                self.process_gui_ops()
                self.root.after(10, after_cb)

            self.root.after(10, after_cb)

        self.view.go_callback = put_coro_op(self.go_callback)
        self.view.link_click_callback = put_coro_op(self.link_click_callback)
        self.view.back_callback = put_coro_op(self.back_callback)


@@ 63,7 70,7 @@ class Controller:
    async def put_gui_op(self, func, *args, **kwargs):
        await self.gui_ops.put((func, args, kwargs))

    def process_gui_ops(self, file, mask):
    def process_gui_ops(self, *args):
        while not self.gui_ops.empty():
            func, args, kwargs = self.gui_ops.get()
            func(*args, **kwargs)


@@ 126,7 133,8 @@ class Controller:

        except curio.errors.TaskTimeout:
            await self.put_gui_op(
                statusbar_logger.info, f"Request timed out: {MAX_REQUEST_SECONDS}s",
                statusbar_logger.info,
                f"Request timed out: {MAX_REQUEST_SECONDS}s",
            )
            await self.put_gui_op(
                messagebox.showwarning,

M src/mcross/gui/view.py => src/mcross/gui/view.py +1 -1
@@ 11,7 11,7 @@ from .widgets import AltButton, McEntry, ReadOnlyText
# OS-specific values
if sys.platform == "win32":
    TTK_THEME = "vista"
    POINTER_CURSOR = "center_ptr"
    POINTER_CURSOR = "hand2"
    WAITING_CURSOR = "wait"
elif sys.platform == "darwin":
    TTK_THEME = "aqua"