Skip to content

Commit

Permalink
refactor(terminal: *): rename app arg to window and make it optional
Browse files Browse the repository at this point in the history
  • Loading branch information
actionless committed Sep 25, 2024
1 parent a6bb1ac commit 5be9954
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion oomox_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def _generate_terminal_colors(colors: "ThemeT") -> None:

generate_terminal_colors_for_oomox(
self.colorscheme,
app=self,
window=self,
result_callback=_generate_terminal_colors,
)

Expand Down
2 changes: 1 addition & 1 deletion oomox_gui/multi_export_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def do_multi_export(args: argparse.Namespace) -> None:
def callback1(theme: "ThemeT") -> None:
generate_terminal_colors_for_oomox(
colorscheme=theme,
app=app.window,
window=app.window,
result_callback=callback2,
)

Expand Down
35 changes: 18 additions & 17 deletions oomox_gui/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ def generate_theme_from_full_palette( # pylint: disable=too-many-arguments,too-
theme_bg: str,
theme_fg: str,
template_path: str,
app: "OomoxApplicationWindow",
result_callback: "Callable[[TerminalThemeT], None]",
*,
auto_swap_colors: bool = True,
accuracy: int | None = None,
extend_palette: bool = False,
window: "OomoxApplicationWindow | None" = None,
**kwargs: "Any",
) -> None:

Expand Down Expand Up @@ -437,18 +437,19 @@ def _callback(generated_colors: TerminalThemeT) -> None:
)
# from time import time
# before = time()
app.disable(translate("Generating terminal palette…"))
app.schedule_task(
lambda: _generate_theme_from_full_palette(
_callback,
reference_colors,
all_colors,
theme_bg,
accuracy,
extend_palette=extend_palette,
),
)
app.enable()
if window:
window.disable(translate("Generating terminal palette…"))
window.schedule_task(
lambda: _generate_theme_from_full_palette(
_callback,
reference_colors,
all_colors,
theme_bg,
accuracy,
extend_palette=extend_palette,
),
)
window.enable()
# print(time() - before)


Expand All @@ -471,8 +472,8 @@ def _generate_theme_from_full_palette_callback(

def _generate_themes_from_oomox(
original_colorscheme: "ThemeT",
app: "OomoxApplicationWindow",
result_callback: "Callable[[ThemeT], None]",
window: "OomoxApplicationWindow | None" = None,
) -> None:
colorscheme = {}
colorscheme.update(original_colorscheme)
Expand Down Expand Up @@ -512,7 +513,7 @@ def _callback(term_colorscheme: TerminalThemeT) -> None:
auto_swap_colors=terminal_theme_auto_bgfg,
extend_palette=terminal_theme_extend_palette,
accuracy=255 + 8 - terminal_theme_accuracy,
app=app,
window=window,
result_callback=_callback,
)
return
Expand Down Expand Up @@ -566,12 +567,12 @@ def generate_xrdb_theme_from_oomox(colorscheme: "ThemeT") -> TerminalThemeT:

def generate_terminal_colors_for_oomox(
colorscheme: "ThemeT",
app: "OomoxApplicationWindow",
result_callback: "Callable[[ThemeT], None]",
window: "OomoxApplicationWindow | None" = None,
) -> None:
_generate_themes_from_oomox(
colorscheme,
app=app,
window=window,
result_callback=result_callback,
)

Expand Down

0 comments on commit 5be9954

Please sign in to comment.