codis 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codis-1.1.1.dist-info/METADATA +194 -0
- codis-1.1.1.dist-info/RECORD +329 -0
- codis-1.1.1.dist-info/WHEEL +5 -0
- codis-1.1.1.dist-info/entry_points.txt +5 -0
- codis-1.1.1.dist-info/licenses/LICENSE +21 -0
- codis-1.1.1.dist-info/top_level.txt +2 -0
- run.py +190 -0
- src/__init__.py +1 -0
- src/__main__.py +81 -0
- src/_app_build.py +1507 -0
- src/_app_editor.py +1274 -0
- src/_app_kui.py +825 -0
- src/_app_lsp.py +625 -0
- src/_app_recovery.py +189 -0
- src/_app_settings.py +1385 -0
- src/_app_tools.py +2471 -0
- src/_app_webpreview.py +126 -0
- src/_font_safety.py +127 -0
- src/_shells.py +172 -0
- src/app.py +1488 -0
- src/chat/__init__.py +1 -0
- src/chat/adapters/__init__.py +33 -0
- src/chat/adapters/base.py +209 -0
- src/chat/adapters/discord.py +190 -0
- src/chat/adapters/http.py +78 -0
- src/chat/adapters/irc.py +360 -0
- src/chat/adapters/matrix.py +219 -0
- src/chat/adapters/mattermost.py +178 -0
- src/chat/adapters/mqtt.py +165 -0
- src/chat/adapters/slack.py +204 -0
- src/chat/adapters/telegram.py +117 -0
- src/chat/adapters/ws.py +154 -0
- src/chat/adapters/xmpp.py +337 -0
- src/chat/history.py +76 -0
- src/chat/models.py +207 -0
- src/chat/probe.py +79 -0
- src/chat/session.py +446 -0
- src/chat/util.py +125 -0
- src/collab/__init__.py +1 -0
- src/collab/net.py +411 -0
- src/collab/ot.py +311 -0
- src/collab/session.py +141 -0
- src/collab/tk_adapter.py +134 -0
- src/config.py +335 -0
- src/constants.py +2552 -0
- src/dep_catalog.py +446 -0
- src/diff/__init__.py +1 -0
- src/diff/engine.py +247 -0
- src/dpi.py +30 -0
- src/editor/__init__.py +1 -0
- src/editor/_pane_lsp.py +2937 -0
- src/editor/_pane_utils.py +171 -0
- src/editor/autocomplete.py +607 -0
- src/editor/code_folding.py +836 -0
- src/editor/color_preview.py +382 -0
- src/editor/complexity_lens.py +281 -0
- src/editor/diff_pane.py +623 -0
- src/editor/file_watcher.py +144 -0
- src/editor/focus_block.py +236 -0
- src/editor/heatmap.py +141 -0
- src/editor/inlay_hints.py +366 -0
- src/editor/inline_blame.py +429 -0
- src/editor/kdocs.py +3376 -0
- src/editor/large_file.py +488 -0
- src/editor/ligatures.py +180 -0
- src/editor/line_numbers.py +598 -0
- src/editor/minimap.py +691 -0
- src/editor/multi_cursor.py +269 -0
- src/editor/pane.py +2082 -0
- src/editor/rhythm.py +206 -0
- src/editor/save_hooks.py +43 -0
- src/editor/smart_selection.py +425 -0
- src/editor/smart_tips.py +719 -0
- src/editor/snippets.py +411 -0
- src/editor/sticky_note_gutter.py +410 -0
- src/editor/sticky_scroll.py +385 -0
- src/editor/suggest.py +464 -0
- src/editor/text_transforms.py +310 -0
- src/editor/vim_mode.py +1074 -0
- src/events/__init__.py +84 -0
- src/events/bus.py +427 -0
- src/events/correlator.py +244 -0
- src/events/kinds.py +125 -0
- src/events/pipeline.py +264 -0
- src/events/stream.py +416 -0
- src/events/window.py +204 -0
- src/extcompat/__init__.py +19 -0
- src/extcompat/code/__init__.py +13 -0
- src/extcompat/code/consent.py +162 -0
- src/extcompat/code/host.py +353 -0
- src/extcompat/code/hosts/py_host.py +763 -0
- src/extcompat/code/locate.py +105 -0
- src/extcompat/code/manager.py +325 -0
- src/extcompat/code/permissions.py +154 -0
- src/extcompat/code/sandbox.py +60 -0
- src/extcompat/colors.py +131 -0
- src/extcompat/common.py +184 -0
- src/extcompat/cson.py +269 -0
- src/extcompat/formats/__init__.py +22 -0
- src/extcompat/formats/_tm.py +189 -0
- src/extcompat/formats/_util.py +31 -0
- src/extcompat/formats/base16.py +66 -0
- src/extcompat/formats/brackets.py +172 -0
- src/extcompat/formats/eclipse.py +193 -0
- src/extcompat/formats/emacs.py +361 -0
- src/extcompat/formats/geany.py +147 -0
- src/extcompat/formats/generic.py +184 -0
- src/extcompat/formats/gtksource.py +117 -0
- src/extcompat/formats/helix.py +91 -0
- src/extcompat/formats/jetbrains.py +343 -0
- src/extcompat/formats/kate.py +130 -0
- src/extcompat/formats/micro.py +131 -0
- src/extcompat/formats/nano.py +111 -0
- src/extcompat/formats/notepadpp.py +140 -0
- src/extcompat/formats/pulsar.py +165 -0
- src/extcompat/formats/pyides.py +163 -0
- src/extcompat/formats/sublime.py +340 -0
- src/extcompat/jsonc.py +65 -0
- src/extcompat/lessish.py +128 -0
- src/extcompat/manager.py +122 -0
- src/extcompat/market/__init__.py +63 -0
- src/extcompat/market/sources.py +211 -0
- src/extcompat/model.py +88 -0
- src/extcompat/net.py +228 -0
- src/extcompat/openvsx.py +63 -0
- src/extcompat/readers.py +362 -0
- src/extcompat/registry.py +73 -0
- src/extcompat/safexml.py +63 -0
- src/extcompat/sexp.py +187 -0
- src/extcompat/sources.py +105 -0
- src/extcompat/store.py +276 -0
- src/extcompat/textmate.py +214 -0
- src/extcompat/themes.py +487 -0
- src/extcompat/yamlite.py +294 -0
- src/fileio.py +94 -0
- src/fs_ops.py +106 -0
- src/i18n.py +233 -0
- src/ia/__init__.py +1 -0
- src/ia/actions.py +295 -0
- src/ia/approval_gate.py +672 -0
- src/ia/checkpoints.py +308 -0
- src/ia/context_builder.py +921 -0
- src/ia/dialdiff.py +408 -0
- src/ia/iaspace.py +2078 -0
- src/ia/pair.py +296 -0
- src/ia/providers.py +954 -0
- src/ia/session.py +335 -0
- src/ia/toolbox.py +2524 -0
- src/launcher_actions.py +204 -0
- src/lint/__init__.py +1 -0
- src/lint/manager.py +1058 -0
- src/locales/.translate_manifest.json +64170 -0
- src/locales/de.json +4936 -0
- src/locales/en.json +4936 -0
- src/locales/es.json +4936 -0
- src/locales/fr.json +4936 -0
- src/locales/it.json +4936 -0
- src/locales/ja.json +4936 -0
- src/locales/ko.json +4936 -0
- src/locales/nl.json +4936 -0
- src/locales/pl.json +4936 -0
- src/locales/pt-BR.json +4936 -0
- src/locales/ru.json +4936 -0
- src/locales/tr.json +4936 -0
- src/locales/uk.json +4936 -0
- src/locales/zh-CN.json +4936 -0
- src/lsp/__init__.py +26 -0
- src/lsp/client.py +2300 -0
- src/lsp/dap_client.py +480 -0
- src/lsp/edits.py +84 -0
- src/lsp/framing.py +73 -0
- src/lsp/protocol.py +931 -0
- src/main.py +260 -0
- src/memtrim.py +91 -0
- src/plugins/__init__.py +1 -0
- src/plugins/api.py +1761 -0
- src/plugins/loader.py +571 -0
- src/plugins/process_runner.py +519 -0
- src/plugins/registry.py +342 -0
- src/plugins/safety.py +367 -0
- src/plugins/startup.py +195 -0
- src/plugins/store.py +1178 -0
- src/proc_registry.py +278 -0
- src/pyexec.py +394 -0
- src/recovery.py +259 -0
- src/stall_trace.py +92 -0
- src/standalone.py +1070 -0
- src/startup_profile.py +35 -0
- src/syntax/__init__.py +1 -0
- src/syntax/highlighter.py +776 -0
- src/syntax/patterns.py +584 -0
- src/system_profile.py +430 -0
- src/terminal/backends.py +658 -0
- src/terminal/internal.py +346 -0
- src/terminal/keys.py +138 -0
- src/terminal/palette.py +67 -0
- src/terminal/session.py +283 -0
- src/terminal/shells.py +79 -0
- src/terminal/view.py +489 -0
- src/terminal/vt.py +870 -0
- src/textfmt.py +22 -0
- src/theme/__init__.py +1 -0
- src/theme/base.py +1281 -0
- src/theme/colors.py +49 -0
- src/theme/manager.py +602 -0
- src/theme/utils.py +312 -0
- src/toolbox.py +329 -0
- src/trash_core.py +531 -0
- src/ui/__init__.py +1 -0
- src/ui/_perf_utils.py +285 -0
- src/ui/_persistence_utils.py +93 -0
- src/ui/accessibility.py +843 -0
- src/ui/activity_bar.py +860 -0
- src/ui/app_embed.py +434 -0
- src/ui/archive_panel.py +608 -0
- src/ui/bookmarks.py +314 -0
- src/ui/breadcrumb.py +383 -0
- src/ui/calculator_panel.py +982 -0
- src/ui/calendar_panel.py +1218 -0
- src/ui/chat_panel.py +1271 -0
- src/ui/chat_profile_dialog.py +278 -0
- src/ui/chat_render.py +128 -0
- src/ui/clock_panel.py +810 -0
- src/ui/code_outline.py +364 -0
- src/ui/code_runner.py +729 -0
- src/ui/code_stats.py +546 -0
- src/ui/collab_panel.py +1009 -0
- src/ui/color_picker.py +547 -0
- src/ui/command_palette.py +452 -0
- src/ui/cursor_manager.py +750 -0
- src/ui/custom_keywords_panel.py +413 -0
- src/ui/debug_panel.py +1037 -0
- src/ui/dependency_graph.py +692 -0
- src/ui/diff_panel.py +381 -0
- src/ui/docs_panel.py +514 -0
- src/ui/doom_embed.py +349 -0
- src/ui/dropdown.py +321 -0
- src/ui/easter_eggs.py +979 -0
- src/ui/env_manager.py +666 -0
- src/ui/extcode_bridge.py +215 -0
- src/ui/extcode_dialogs.py +412 -0
- src/ui/extcompat_dialog.py +583 -0
- src/ui/file_timeline.py +319 -0
- src/ui/file_tree.py +1208 -0
- src/ui/find_in_files.py +1355 -0
- src/ui/flowchart_panel.py +727 -0
- src/ui/formatter_panel.py +490 -0
- src/ui/git_auth.py +763 -0
- src/ui/git_clone_dialog.py +487 -0
- src/ui/git_panel.py +1483 -0
- src/ui/grab_safe.py +84 -0
- src/ui/internal_python_dialog.py +98 -0
- src/ui/k_ui/__init__.py +1305 -0
- src/ui/k_ui/_bgrenderer.py +317 -0
- src/ui/k_ui/_colors.py +213 -0
- src/ui/k_ui/_dock.py +545 -0
- src/ui/k_ui/_easter.py +290 -0
- src/ui/k_ui/_engine.py +5448 -0
- src/ui/k_ui/_perf.py +333 -0
- src/ui/k_ui/_tkutil.py +7 -0
- src/ui/k_ui/_tooltip.py +365 -0
- src/ui/k_ui/_widgets.py +1204 -0
- src/ui/k_ui/_world.py +837 -0
- src/ui/key_remapper.py +856 -0
- src/ui/launcher.py +1252 -0
- src/ui/lazy_panel.py +73 -0
- src/ui/macro_recorder.py +610 -0
- src/ui/menu_bar.py +898 -0
- src/ui/output_panel.py +321 -0
- src/ui/paint_canvas.py +1000 -0
- src/ui/paint_engine.py +535 -0
- src/ui/paint_panel.py +888 -0
- src/ui/panel_detach.py +112 -0
- src/ui/performance_panel.py +861 -0
- src/ui/pip_manager.py +1758 -0
- src/ui/plugin_panel.py +1586 -0
- src/ui/pomodoro_panel.py +447 -0
- src/ui/problems.py +566 -0
- src/ui/process_manager.py +1657 -0
- src/ui/project_templates.py +775 -0
- src/ui/recovery_dialog.py +122 -0
- src/ui/regex_playground.py +304 -0
- src/ui/remote_adapters.py +1398 -0
- src/ui/remote_browser.py +1224 -0
- src/ui/remote_profile_dialog.py +342 -0
- src/ui/render_panel.py +1293 -0
- src/ui/rest_client.py +549 -0
- src/ui/scratchpad.py +548 -0
- src/ui/search_bar.py +1274 -0
- src/ui/settings_editor.py +3349 -0
- src/ui/settings_window.py +1554 -0
- src/ui/snippets_panel.py +597 -0
- src/ui/sql_studio.py +1815 -0
- src/ui/status_bar.py +438 -0
- src/ui/tab_bar.py +654 -0
- src/ui/task_manager.py +1773 -0
- src/ui/terminal.py +525 -0
- src/ui/theme_preview_panel.py +851 -0
- src/ui/thread_safe_tk.py +152 -0
- src/ui/time_tracker.py +574 -0
- src/ui/tkbind.py +43 -0
- src/ui/todo_panel.py +358 -0
- src/ui/toolbox_panels.py +658 -0
- src/ui/trash_manager.py +657 -0
- src/ui/ui_scale.py +294 -0
- src/ui/ux_enhancements.py +41 -0
- src/ui/web_preview.py +397 -0
- src/ui/webdev.py +630 -0
- src/ui/welcome.py +567 -0
- src/ui/window_embed.py +1500 -0
- src/ui/wizard.py +1550 -0
- src/ui/workspace_switcher.py +418 -0
- src/ui/workspace_trust.py +370 -0
- src/ui/zen_audio.py +354 -0
- src/ui/zen_media.py +2271 -0
- src/ui/zen_media_client.py +303 -0
- src/ui/zen_media_host.py +329 -0
- src/ui/zen_player.py +907 -0
- src/ui/zen_player_widgets.py +700 -0
- src/updater/__init__.py +11 -0
- src/updater/assets.py +145 -0
- src/updater/backup.py +101 -0
- src/updater/channel.py +221 -0
- src/updater/dialog.py +492 -0
- src/updater/integrity.py +111 -0
- src/updater/manager.py +727 -0
- src/updater/result.py +114 -0
- src/venv_runtime.py +531 -0
- src/workspace_state.py +25 -0
src/ui/plugin_panel.py
ADDED
|
@@ -0,0 +1,1586 @@
|
|
|
1
|
+
"""Codis - _PluginTrustDialog + PluginPanel."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
import hashlib
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
import tkinter as tk
|
|
13
|
+
import webbrowser
|
|
14
|
+
from collections.abc import Callable
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from tkinter import filedialog, messagebox, ttk
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
from src.constants import (
|
|
20
|
+
FONT_MONO,
|
|
21
|
+
FONT_UI,
|
|
22
|
+
PLUGINS_DIR,
|
|
23
|
+
)
|
|
24
|
+
from src.i18n import _t
|
|
25
|
+
from src.plugins.api import (
|
|
26
|
+
PluginManifest,
|
|
27
|
+
_get_plugin_source,
|
|
28
|
+
_normalize_manifest,
|
|
29
|
+
_save_trusted_plugins,
|
|
30
|
+
)
|
|
31
|
+
from src.plugins.loader import PluginLoader
|
|
32
|
+
from src.plugins.store import open_plugin_store
|
|
33
|
+
from src.ui._perf_utils import bg_recursive, debounce_canvas
|
|
34
|
+
from src.ui.dropdown import DropDown
|
|
35
|
+
from src.ui.grab_safe import safe_grab_set
|
|
36
|
+
|
|
37
|
+
logger = logging.getLogger("Codis")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class _PluginTrustDialog(tk.Toplevel):
|
|
41
|
+
"""
|
|
42
|
+
Balão de aviso de segurança antes de instalar um plugin não confiável.
|
|
43
|
+
Exibe os imports perigosos encontrados e pede confirmação.
|
|
44
|
+
Tem opção _t("hc.plugin_panel.n_o_mostrar_novamente_para_est").
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
parent: tk.Widget,
|
|
50
|
+
tmgr: Any,
|
|
51
|
+
plugin_id: str,
|
|
52
|
+
blocked: list[str],
|
|
53
|
+
warned: list[str],
|
|
54
|
+
) -> None:
|
|
55
|
+
super().__init__(parent)
|
|
56
|
+
t = tmgr.theme
|
|
57
|
+
self.result = False
|
|
58
|
+
self.dont_ask = False
|
|
59
|
+
self.title("⚠ Aviso de Segurança - Plugin")
|
|
60
|
+
self.configure(bg=t.panel_bg)
|
|
61
|
+
self.resizable(False, False)
|
|
62
|
+
self.transient(parent)
|
|
63
|
+
safe_grab_set(self)
|
|
64
|
+
|
|
65
|
+
top = tk.Frame(self, bg=t.panel_bg, padx=16, pady=12)
|
|
66
|
+
top.pack(fill="x")
|
|
67
|
+
tk.Label(top, text="⚠", font=(FONT_UI, 28), bg=t.panel_bg, fg="#f0a500").pack(
|
|
68
|
+
side="left", padx=(0, 12)
|
|
69
|
+
)
|
|
70
|
+
right = tk.Frame(top, bg=t.panel_bg)
|
|
71
|
+
right.pack(side="left", fill="x", expand=True)
|
|
72
|
+
tk.Label(
|
|
73
|
+
right,
|
|
74
|
+
text=_t("hc.plugin_panel.plugin_possivelmente_n_o_confi"),
|
|
75
|
+
font=(FONT_UI, 11, "bold"),
|
|
76
|
+
bg=t.panel_bg,
|
|
77
|
+
fg=t.fg,
|
|
78
|
+
anchor="w",
|
|
79
|
+
).pack(fill="x")
|
|
80
|
+
tk.Label(
|
|
81
|
+
right,
|
|
82
|
+
text=f" {plugin_id}",
|
|
83
|
+
font=(FONT_UI, 9),
|
|
84
|
+
bg=t.panel_bg,
|
|
85
|
+
fg=t.comment_fg,
|
|
86
|
+
anchor="w",
|
|
87
|
+
).pack(fill="x")
|
|
88
|
+
|
|
89
|
+
tk.Frame(self, bg=t.border, height=1).pack(fill="x")
|
|
90
|
+
|
|
91
|
+
body = tk.Frame(self, bg=t.panel_bg, padx=16, pady=8)
|
|
92
|
+
body.pack(fill="x")
|
|
93
|
+
|
|
94
|
+
if blocked:
|
|
95
|
+
tk.Label(
|
|
96
|
+
body,
|
|
97
|
+
text=_t("hc.plugin_panel.m_dulos_bloqueados_detectados"),
|
|
98
|
+
font=(FONT_UI, 9, "bold"),
|
|
99
|
+
bg=t.panel_bg,
|
|
100
|
+
fg=t.err_fg,
|
|
101
|
+
anchor="w",
|
|
102
|
+
).pack(fill="x")
|
|
103
|
+
tk.Label(
|
|
104
|
+
body,
|
|
105
|
+
text=" " + ", ".join(blocked),
|
|
106
|
+
font=(FONT_MONO, 9),
|
|
107
|
+
bg=t.panel_bg,
|
|
108
|
+
fg=t.err_fg,
|
|
109
|
+
anchor="w",
|
|
110
|
+
wraplength=380,
|
|
111
|
+
).pack(fill="x", pady=(0, 6))
|
|
112
|
+
|
|
113
|
+
if warned:
|
|
114
|
+
tk.Label(
|
|
115
|
+
body,
|
|
116
|
+
text=_t("hc.plugin_panel.requisito_de_risco"),
|
|
117
|
+
font=(FONT_UI, 9, "bold"),
|
|
118
|
+
bg=t.panel_bg,
|
|
119
|
+
fg="#f0a500",
|
|
120
|
+
anchor="w",
|
|
121
|
+
).pack(fill="x")
|
|
122
|
+
tk.Label(
|
|
123
|
+
body,
|
|
124
|
+
text=" " + ", ".join(warned),
|
|
125
|
+
font=(FONT_MONO, 9),
|
|
126
|
+
bg=t.panel_bg,
|
|
127
|
+
fg="#f0a500",
|
|
128
|
+
anchor="w",
|
|
129
|
+
wraplength=380,
|
|
130
|
+
).pack(fill="x", pady=(0, 6))
|
|
131
|
+
|
|
132
|
+
tk.Label(
|
|
133
|
+
body,
|
|
134
|
+
text=_t("hc.plugin_panel.instale_apenas_plugins_de_font")
|
|
135
|
+
+ "\n"
|
|
136
|
+
+ "Plugins maliciosos podem danificar seu sistema.",
|
|
137
|
+
font=(FONT_UI, 9),
|
|
138
|
+
bg=t.panel_bg,
|
|
139
|
+
fg=t.comment_fg,
|
|
140
|
+
justify="left",
|
|
141
|
+
wraplength=380,
|
|
142
|
+
).pack(fill="x", pady=(4, 0))
|
|
143
|
+
|
|
144
|
+
self._dont_var = tk.BooleanVar(value=False)
|
|
145
|
+
cb_frame = tk.Frame(self, bg=t.panel_bg, padx=16, pady=4)
|
|
146
|
+
cb_frame.pack(fill="x")
|
|
147
|
+
tk.Checkbutton(
|
|
148
|
+
cb_frame,
|
|
149
|
+
text=_t("hc.plugin_panel.n_o_mostrar_novamente_para_est"),
|
|
150
|
+
variable=self._dont_var,
|
|
151
|
+
bg=t.panel_bg,
|
|
152
|
+
fg=t.comment_fg,
|
|
153
|
+
activebackground=t.panel_bg,
|
|
154
|
+
selectcolor=t.input_bg,
|
|
155
|
+
font=(FONT_UI, 8),
|
|
156
|
+
).pack(anchor="w")
|
|
157
|
+
|
|
158
|
+
tk.Frame(self, bg=t.border, height=1).pack(fill="x")
|
|
159
|
+
btn_row = tk.Frame(self, bg=t.panel_bg, padx=12, pady=10)
|
|
160
|
+
btn_row.pack(fill="x")
|
|
161
|
+
|
|
162
|
+
def _cancel():
|
|
163
|
+
self.result = False
|
|
164
|
+
self.dont_ask = self._dont_var.get()
|
|
165
|
+
self.destroy()
|
|
166
|
+
|
|
167
|
+
def _install():
|
|
168
|
+
self.result = True
|
|
169
|
+
self.dont_ask = self._dont_var.get()
|
|
170
|
+
self.destroy()
|
|
171
|
+
|
|
172
|
+
tk.Button(
|
|
173
|
+
btn_row,
|
|
174
|
+
text=_t("hc.plugin_panel.cancelar"),
|
|
175
|
+
command=_cancel,
|
|
176
|
+
bg=t.btn_bg,
|
|
177
|
+
fg=t.fg,
|
|
178
|
+
relief="flat",
|
|
179
|
+
padx=12,
|
|
180
|
+
pady=4,
|
|
181
|
+
font=(FONT_UI, 9),
|
|
182
|
+
cursor="hand2",
|
|
183
|
+
).pack(side="right", padx=4)
|
|
184
|
+
tk.Button(
|
|
185
|
+
btn_row,
|
|
186
|
+
text=_t("hc.plugin_panel.instalar_mesmo_assim"),
|
|
187
|
+
command=_install,
|
|
188
|
+
bg=t.err_fg,
|
|
189
|
+
fg="#ffffff",
|
|
190
|
+
relief="flat",
|
|
191
|
+
padx=12,
|
|
192
|
+
pady=4,
|
|
193
|
+
font=(FONT_UI, 9, "bold"),
|
|
194
|
+
cursor="hand2",
|
|
195
|
+
).pack(side="right")
|
|
196
|
+
|
|
197
|
+
self.update_idletasks()
|
|
198
|
+
pw = parent.winfo_rootx() + parent.winfo_width() // 2
|
|
199
|
+
ph = parent.winfo_rooty() + parent.winfo_height() // 2
|
|
200
|
+
w, h = self.winfo_width(), self.winfo_height()
|
|
201
|
+
self.geometry(f"+{pw - w // 2}+{ph - h // 2}")
|
|
202
|
+
self.wait_window()
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _render_markdown(widget: tk.Text, md: str, theme: Any) -> None:
|
|
206
|
+
"""
|
|
207
|
+
Renderiza Markdown simples num tk.Text (somente-leitura).
|
|
208
|
+
Suporta: # títulos, **bold**, `code`, ```blocos```, listas, ---
|
|
209
|
+
"""
|
|
210
|
+
t = theme
|
|
211
|
+
widget.config(state="normal")
|
|
212
|
+
widget.delete("1.0", "end")
|
|
213
|
+
|
|
214
|
+
widget.tag_configure(
|
|
215
|
+
"h1", font=(FONT_UI, 15, "bold"), foreground=t.fg, spacing1=10, spacing3=6
|
|
216
|
+
)
|
|
217
|
+
widget.tag_configure(
|
|
218
|
+
"h2", font=(FONT_UI, 13, "bold"), foreground=t.fg, spacing1=8, spacing3=4
|
|
219
|
+
)
|
|
220
|
+
widget.tag_configure(
|
|
221
|
+
"h3", font=(FONT_UI, 11, "bold"), foreground=t.fg, spacing1=6, spacing3=2
|
|
222
|
+
)
|
|
223
|
+
widget.tag_configure("bold", font=(FONT_UI, 10, "bold"), foreground=t.fg)
|
|
224
|
+
widget.tag_configure("italic", font=(
|
|
225
|
+
FONT_UI, 10, "italic"), foreground=t.fg)
|
|
226
|
+
widget.tag_configure(
|
|
227
|
+
"code_inline",
|
|
228
|
+
font=(FONT_MONO, 9),
|
|
229
|
+
background=getattr(t, "input_bg", t.panel_bg),
|
|
230
|
+
foreground=getattr(t, "string_fg", t.fg),
|
|
231
|
+
)
|
|
232
|
+
widget.tag_configure(
|
|
233
|
+
"code_block",
|
|
234
|
+
font=(FONT_MONO, 9),
|
|
235
|
+
background=getattr(t, "gutter_bg", t.panel_bg),
|
|
236
|
+
foreground=getattr(t, "string_fg", t.fg),
|
|
237
|
+
lmargin1=16,
|
|
238
|
+
lmargin2=16,
|
|
239
|
+
spacing1=2,
|
|
240
|
+
spacing3=2,
|
|
241
|
+
)
|
|
242
|
+
widget.tag_configure(
|
|
243
|
+
"hr", font=(FONT_UI, 4), foreground=t.border, spacing1=4, spacing3=4
|
|
244
|
+
)
|
|
245
|
+
widget.tag_configure("bullet", font=(FONT_UI, 10),
|
|
246
|
+
lmargin1=16, lmargin2=28)
|
|
247
|
+
widget.tag_configure("normal", font=(FONT_UI, 10),
|
|
248
|
+
foreground=t.fg, spacing1=1)
|
|
249
|
+
widget.tag_configure(
|
|
250
|
+
"link",
|
|
251
|
+
font=(FONT_UI, 10),
|
|
252
|
+
foreground=getattr(t, "accent", "#4fc3f7"),
|
|
253
|
+
underline=True,
|
|
254
|
+
)
|
|
255
|
+
widget.tag_configure(
|
|
256
|
+
"badge_ok",
|
|
257
|
+
font=(FONT_UI, 8, "bold"),
|
|
258
|
+
background="#1b5e20",
|
|
259
|
+
foreground="#a5d6a7",
|
|
260
|
+
relief="flat",
|
|
261
|
+
)
|
|
262
|
+
widget.tag_configure(
|
|
263
|
+
"badge_warn",
|
|
264
|
+
font=(FONT_UI, 8, "bold"),
|
|
265
|
+
background="#4a3000",
|
|
266
|
+
foreground="#ffcc02",
|
|
267
|
+
relief="flat",
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
lines = md.split("\n")
|
|
271
|
+
in_code_block = False
|
|
272
|
+
code_block_lines: list[str] = []
|
|
273
|
+
|
|
274
|
+
def flush_code():
|
|
275
|
+
"""Insere as linhas de código acumuladas no widget com a tag ``code_block``."""
|
|
276
|
+
if code_block_lines:
|
|
277
|
+
widget.insert("end", "\n".join(
|
|
278
|
+
code_block_lines) + "\n", "code_block")
|
|
279
|
+
code_block_lines.clear()
|
|
280
|
+
|
|
281
|
+
for line in lines:
|
|
282
|
+
if line.startswith("```"):
|
|
283
|
+
if in_code_block:
|
|
284
|
+
flush_code()
|
|
285
|
+
in_code_block = False
|
|
286
|
+
else:
|
|
287
|
+
in_code_block = True
|
|
288
|
+
continue
|
|
289
|
+
if in_code_block:
|
|
290
|
+
code_block_lines.append(line)
|
|
291
|
+
continue
|
|
292
|
+
|
|
293
|
+
if line.startswith("### "):
|
|
294
|
+
widget.insert("end", line[4:] + "\n", "h3")
|
|
295
|
+
continue
|
|
296
|
+
if line.startswith("## "):
|
|
297
|
+
widget.insert("end", line[3:] + "\n", "h2")
|
|
298
|
+
continue
|
|
299
|
+
if line.startswith("# "):
|
|
300
|
+
widget.insert("end", line[2:] + "\n", "h1")
|
|
301
|
+
continue
|
|
302
|
+
|
|
303
|
+
if re.match(r"^[-_*]{3,}$", line.strip()):
|
|
304
|
+
widget.insert("end", "-" * 48 + "\n", "hr")
|
|
305
|
+
continue
|
|
306
|
+
|
|
307
|
+
m = re.match(r"^(\s*)([-*+]|\d+\.)\s+(.+)", line)
|
|
308
|
+
if m:
|
|
309
|
+
widget.insert("end", f" {m.group(2)} ", "bullet")
|
|
310
|
+
_insert_inline(widget, m.group(3))
|
|
311
|
+
widget.insert("end", "\n")
|
|
312
|
+
continue
|
|
313
|
+
|
|
314
|
+
if not line.strip():
|
|
315
|
+
widget.insert("end", "\n", "normal")
|
|
316
|
+
continue
|
|
317
|
+
|
|
318
|
+
_insert_inline(widget, line)
|
|
319
|
+
widget.insert("end", "\n", "normal")
|
|
320
|
+
|
|
321
|
+
if in_code_block:
|
|
322
|
+
flush_code()
|
|
323
|
+
|
|
324
|
+
widget.config(state="disabled")
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def _insert_inline(widget: tk.Text, text: str) -> None:
|
|
328
|
+
"""Insere texto com formatação inline (bold, italic, code, links)."""
|
|
329
|
+
|
|
330
|
+
pattern = re.compile(
|
|
331
|
+
r"(\*\*(.+?)\*\*)"
|
|
332
|
+
r"|(\*(.+?)\*)"
|
|
333
|
+
r"|(`(.+?)`)"
|
|
334
|
+
r"|(\[(.+?)\]\((.+?)\))"
|
|
335
|
+
r"|(.+?(?=\*\*|\*|`|\[|$))"
|
|
336
|
+
)
|
|
337
|
+
pos = 0
|
|
338
|
+
for m in pattern.finditer(text):
|
|
339
|
+
if m.start() > pos:
|
|
340
|
+
widget.insert("end", text[pos: m.start()], "normal")
|
|
341
|
+
if m.group(1):
|
|
342
|
+
widget.insert("end", m.group(2), "bold")
|
|
343
|
+
elif m.group(3):
|
|
344
|
+
widget.insert("end", m.group(4), "italic")
|
|
345
|
+
elif m.group(5):
|
|
346
|
+
widget.insert("end", f" {m.group(6)} ", "code_inline")
|
|
347
|
+
elif m.group(7):
|
|
348
|
+
widget.insert("end", m.group(8), "link")
|
|
349
|
+
elif m.group(10):
|
|
350
|
+
widget.insert("end", m.group(10), "normal")
|
|
351
|
+
pos = m.end()
|
|
352
|
+
if pos < len(text):
|
|
353
|
+
widget.insert("end", text[pos:], "normal")
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
class PluginPanel(tk.Frame):
|
|
357
|
+
"""
|
|
358
|
+
Gerenciador de plugins com:
|
|
359
|
+
- Lista filtrada (instalado, erro, desativado, por tag, tipo, peso)
|
|
360
|
+
- Cards com ícone, nome, versão, autor, tags, peso
|
|
361
|
+
- Painel de detalhe com README Markdown renderizado (somente-leitura)
|
|
362
|
+
- Botões contextuais por estado (Enable/Disable, Uninstall, Reload, Homepage)
|
|
363
|
+
- Sandbox: análise estática de imports + balão de aviso na instalação
|
|
364
|
+
- Opção "editar conteúdo de plugins" para desbloquear o README
|
|
365
|
+
- Header com contadores por categoria
|
|
366
|
+
- Filtro avançado por tipo, tag, status, peso
|
|
367
|
+
- Sem duplicação de botões nem fantasmas após desinstalação
|
|
368
|
+
"""
|
|
369
|
+
|
|
370
|
+
_FILTER_OPTIONS = [
|
|
371
|
+
("Todos", "all"),
|
|
372
|
+
("Instalados", "installed"),
|
|
373
|
+
(_t("hc.plugin_panel.bulk_err", default="Erros"), "error"),
|
|
374
|
+
("Desativados", "disabled"),
|
|
375
|
+
]
|
|
376
|
+
|
|
377
|
+
def __init__(
|
|
378
|
+
self, parent: tk.Widget, tmgr: Any, loader: PluginLoader, cfg: Any = None
|
|
379
|
+
) -> None:
|
|
380
|
+
"""Cria o painel de gerenciamento de plugins.
|
|
381
|
+
|
|
382
|
+
Args:
|
|
383
|
+
parent: Widget pai Tkinter.
|
|
384
|
+
tmgr: Any (ThemeManager).
|
|
385
|
+
loader: Instância de PluginLoader.
|
|
386
|
+
cfg: ConfigManager (opcional, necessário para Plugin Store).
|
|
387
|
+
"""
|
|
388
|
+
t = tmgr.theme
|
|
389
|
+
super().__init__(parent, bg=t.panel_bg)
|
|
390
|
+
self._tmgr = tmgr
|
|
391
|
+
self._loader = loader
|
|
392
|
+
self._cfg = cfg
|
|
393
|
+
self._selected_id: str | None = None
|
|
394
|
+
self._filter_mode = tk.StringVar(value="all")
|
|
395
|
+
self._search_var = tk.StringVar()
|
|
396
|
+
self._tag_var = tk.StringVar(value="")
|
|
397
|
+
self._sort_var = tk.StringVar(value="name")
|
|
398
|
+
self._edit_mode = tk.BooleanVar(value=False)
|
|
399
|
+
self._card_widgets: dict[str, tk.Frame] = {}
|
|
400
|
+
self._selected_ids: set = set()
|
|
401
|
+
self._build()
|
|
402
|
+
self.refresh()
|
|
403
|
+
|
|
404
|
+
def _build(self) -> None:
|
|
405
|
+
t = self._tmgr.theme
|
|
406
|
+
|
|
407
|
+
hdr = tk.Frame(self, bg=t.panel_bg, height=36)
|
|
408
|
+
hdr.pack(fill="x", padx=0, pady=0)
|
|
409
|
+
hdr.pack_propagate(False)
|
|
410
|
+
|
|
411
|
+
tk.Label(
|
|
412
|
+
hdr,
|
|
413
|
+
text=_t("hc.plugin_panel.extens_es"),
|
|
414
|
+
bg=t.panel_bg,
|
|
415
|
+
fg=t.sidebar_header_fg,
|
|
416
|
+
font=(FONT_UI, 9, "bold"),
|
|
417
|
+
).pack(side="left", padx=4, pady=6)
|
|
418
|
+
|
|
419
|
+
self._install_btn = tk.Label(
|
|
420
|
+
hdr,
|
|
421
|
+
text=_t("hc.plugin_panel.instalar"),
|
|
422
|
+
bg=t.panel_bg,
|
|
423
|
+
fg=t.fg,
|
|
424
|
+
font=(FONT_UI, 8),
|
|
425
|
+
cursor="hand2",
|
|
426
|
+
padx=6,
|
|
427
|
+
)
|
|
428
|
+
self._install_btn.pack(side="right", padx=2)
|
|
429
|
+
self._install_btn.bind("<Button-1>", lambda _: self._install())
|
|
430
|
+
|
|
431
|
+
store_btn = tk.Label(
|
|
432
|
+
hdr,
|
|
433
|
+
text=_t("plugin.store_title"),
|
|
434
|
+
bg=t.panel_bg,
|
|
435
|
+
fg=getattr(t, "accent", "#4fc3f7"),
|
|
436
|
+
font=(FONT_UI, 8, "bold"),
|
|
437
|
+
cursor="hand2",
|
|
438
|
+
padx=6,
|
|
439
|
+
)
|
|
440
|
+
store_btn.pack(side="right", padx=2)
|
|
441
|
+
store_btn.bind("<Button-1>", lambda _: self._open_store())
|
|
442
|
+
self._ttp(store_btn, _t("plugin.store_title"))
|
|
443
|
+
|
|
444
|
+
self._bulk_btn = tk.Label(
|
|
445
|
+
hdr,
|
|
446
|
+
text=_t("hc.plugin_panel.bulk"),
|
|
447
|
+
bg=t.panel_bg,
|
|
448
|
+
fg=t.fg,
|
|
449
|
+
font=(FONT_UI, 8),
|
|
450
|
+
cursor="hand2",
|
|
451
|
+
padx=6,
|
|
452
|
+
)
|
|
453
|
+
self._bulk_btn.pack(side="right", padx=0)
|
|
454
|
+
self._bulk_btn.bind("<Button-1>", self._show_bulk_menu)
|
|
455
|
+
self._ttp(
|
|
456
|
+
self._bulk_btn,
|
|
457
|
+
_t("hc.plugin_panel.bulk_tooltip",
|
|
458
|
+
default="Ações em massa (Ctrl+clique)"),
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
ref_btn = tk.Label(
|
|
462
|
+
hdr,
|
|
463
|
+
text="↻",
|
|
464
|
+
bg=t.panel_bg,
|
|
465
|
+
fg=t.fg,
|
|
466
|
+
font=(FONT_UI, 10),
|
|
467
|
+
cursor="hand2",
|
|
468
|
+
padx=6,
|
|
469
|
+
)
|
|
470
|
+
ref_btn.pack(side="right", padx=0)
|
|
471
|
+
ref_btn.bind("<Button-1>", lambda _: self.refresh())
|
|
472
|
+
self._ttp(ref_btn, _t("hc.plugin_panel.recarrega_o_plugin_do_disco"))
|
|
473
|
+
|
|
474
|
+
search_outer = tk.Frame(
|
|
475
|
+
self, bg=t.input_bg, highlightthickness=1, highlightbackground=t.border
|
|
476
|
+
)
|
|
477
|
+
search_outer.pack(fill="x", padx=6, pady=(2, 0))
|
|
478
|
+
tk.Label(
|
|
479
|
+
search_outer, text="🔍", bg=t.input_bg, fg=t.comment_fg, font=(FONT_UI, 9)
|
|
480
|
+
).pack(side="left", padx=(4, 0))
|
|
481
|
+
self._search_entry = tk.Entry(
|
|
482
|
+
search_outer,
|
|
483
|
+
textvariable=self._search_var,
|
|
484
|
+
bg=t.input_bg,
|
|
485
|
+
fg=t.fg,
|
|
486
|
+
insertbackground=t.cursor,
|
|
487
|
+
relief="flat",
|
|
488
|
+
bd=0,
|
|
489
|
+
font=(FONT_UI, 9),
|
|
490
|
+
)
|
|
491
|
+
self._search_entry.pack(side="left", fill="x",
|
|
492
|
+
expand=True, padx=4, pady=3)
|
|
493
|
+
self._search_var.trace_add("write", lambda *_: self._apply_filter())
|
|
494
|
+
|
|
495
|
+
pills_frame = tk.Frame(self, bg=t.panel_bg)
|
|
496
|
+
pills_frame.pack(fill="x", padx=6, pady=(4, 0))
|
|
497
|
+
self._pill_btns: dict[str, tk.Label] = {}
|
|
498
|
+
for label, mode in self._FILTER_OPTIONS:
|
|
499
|
+
p = tk.Label(
|
|
500
|
+
pills_frame,
|
|
501
|
+
text=label,
|
|
502
|
+
bg=t.panel_bg,
|
|
503
|
+
fg=t.comment_fg,
|
|
504
|
+
font=(FONT_UI, 8),
|
|
505
|
+
padx=8,
|
|
506
|
+
pady=2,
|
|
507
|
+
cursor="hand2",
|
|
508
|
+
relief="flat",
|
|
509
|
+
highlightthickness=1,
|
|
510
|
+
highlightbackground=t.border,
|
|
511
|
+
)
|
|
512
|
+
p.pack(side="left", padx=2, pady=2)
|
|
513
|
+
p.bind("<Button-1>", lambda _, m=mode: self._set_filter(m))
|
|
514
|
+
self._pill_btns[mode] = p
|
|
515
|
+
self._update_pills()
|
|
516
|
+
|
|
517
|
+
adv = tk.Frame(self, bg=t.panel_bg)
|
|
518
|
+
adv.pack(fill="x", padx=6, pady=(2, 2))
|
|
519
|
+
tk.Label(
|
|
520
|
+
adv,
|
|
521
|
+
text=_t("hc.plugin_panel.ordenar"),
|
|
522
|
+
bg=t.panel_bg,
|
|
523
|
+
fg=t.comment_fg,
|
|
524
|
+
font=(FONT_UI, 8),
|
|
525
|
+
).pack(side="left")
|
|
526
|
+
sort_cb = DropDown(
|
|
527
|
+
adv,
|
|
528
|
+
textvariable=self._sort_var,
|
|
529
|
+
values=["name", "status", "weight", "author"],
|
|
530
|
+
state="readonly",
|
|
531
|
+
width=8,
|
|
532
|
+
font=(FONT_UI, 8),
|
|
533
|
+
)
|
|
534
|
+
sort_cb.pack(side="left", padx=(2, 8))
|
|
535
|
+
sort_cb.bind("<<ComboboxSelected>>", lambda _: self._apply_filter())
|
|
536
|
+
|
|
537
|
+
tk.Label(
|
|
538
|
+
adv,
|
|
539
|
+
text=_t("hc.plugin_panel.tag"),
|
|
540
|
+
bg=t.panel_bg,
|
|
541
|
+
fg=t.comment_fg,
|
|
542
|
+
font=(FONT_UI, 8),
|
|
543
|
+
).pack(side="left")
|
|
544
|
+
self._tag_cb = DropDown(
|
|
545
|
+
adv,
|
|
546
|
+
textvariable=self._tag_var,
|
|
547
|
+
values=[""],
|
|
548
|
+
state="readonly",
|
|
549
|
+
width=10,
|
|
550
|
+
font=(FONT_UI, 8),
|
|
551
|
+
)
|
|
552
|
+
self._tag_cb.pack(side="left", padx=2)
|
|
553
|
+
self._tag_cb.bind("<<ComboboxSelected>>",
|
|
554
|
+
lambda _: self._apply_filter())
|
|
555
|
+
|
|
556
|
+
paned = tk.PanedWindow(
|
|
557
|
+
self, orient="vertical", bg=t.border, sashwidth=4, sashrelief="flat", bd=0
|
|
558
|
+
)
|
|
559
|
+
paned.pack(fill="both", expand=True, padx=0, pady=4)
|
|
560
|
+
|
|
561
|
+
list_outer = tk.Frame(paned, bg=t.panel_bg)
|
|
562
|
+
paned.add(list_outer, minsize=100)
|
|
563
|
+
|
|
564
|
+
scroll_frame = tk.Frame(list_outer, bg=t.panel_bg)
|
|
565
|
+
scroll_frame.pack(fill="both", expand=True)
|
|
566
|
+
|
|
567
|
+
vsb = ttk.Scrollbar(
|
|
568
|
+
scroll_frame, orient="vertical", style="Thin.Vertical.TScrollbar"
|
|
569
|
+
)
|
|
570
|
+
vsb.pack(side="right", fill="y")
|
|
571
|
+
|
|
572
|
+
self._canvas = tk.Canvas(
|
|
573
|
+
scroll_frame,
|
|
574
|
+
bg=t.panel_bg,
|
|
575
|
+
bd=0,
|
|
576
|
+
highlightthickness=0,
|
|
577
|
+
yscrollcommand=vsb.set,
|
|
578
|
+
)
|
|
579
|
+
self._canvas.pack(side="left", fill="both", expand=True)
|
|
580
|
+
vsb.config(command=self._canvas.yview)
|
|
581
|
+
|
|
582
|
+
self._cards_frame = tk.Frame(self._canvas, bg=t.panel_bg)
|
|
583
|
+
self._canvas_window = self._canvas.create_window(
|
|
584
|
+
(0, 0), window=self._cards_frame, anchor="nw"
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
debounce_canvas(
|
|
588
|
+
self._canvas, self._canvas_window, ms=40, extra_widget=self._cards_frame
|
|
589
|
+
)
|
|
590
|
+
self._canvas.bind("<MouseWheel>", self._on_mousewheel)
|
|
591
|
+
self._canvas.bind(
|
|
592
|
+
"<Button-4>", lambda e: self._canvas.yview_scroll(-1, "units")
|
|
593
|
+
)
|
|
594
|
+
self._canvas.bind(
|
|
595
|
+
"<Button-5>", lambda e: self._canvas.yview_scroll(1, "units"))
|
|
596
|
+
|
|
597
|
+
self._count_label = tk.Label(
|
|
598
|
+
list_outer,
|
|
599
|
+
text="",
|
|
600
|
+
bg=t.panel_bg,
|
|
601
|
+
fg=t.comment_fg,
|
|
602
|
+
font=(FONT_UI, 8),
|
|
603
|
+
anchor="e",
|
|
604
|
+
)
|
|
605
|
+
self._count_label.pack(fill="x", padx=8, pady=2)
|
|
606
|
+
|
|
607
|
+
detail_outer = tk.Frame(paned, bg=t.panel_bg)
|
|
608
|
+
paned.add(detail_outer, minsize=80)
|
|
609
|
+
|
|
610
|
+
detail_hdr = tk.Frame(detail_outer, bg=t.panel_bg, height=28)
|
|
611
|
+
detail_hdr.pack(fill="x")
|
|
612
|
+
detail_hdr.pack_propagate(False)
|
|
613
|
+
|
|
614
|
+
self._detail_title = tk.Label(
|
|
615
|
+
detail_hdr,
|
|
616
|
+
text=_t("hc.plugin_panel.selecione_um_plugin"),
|
|
617
|
+
bg=t.panel_bg,
|
|
618
|
+
fg=t.sidebar_header_fg,
|
|
619
|
+
font=(FONT_UI, 9, "bold"),
|
|
620
|
+
anchor="w",
|
|
621
|
+
)
|
|
622
|
+
self._detail_title.pack(side="left", padx=8, pady=4)
|
|
623
|
+
|
|
624
|
+
self._edit_chk = tk.Checkbutton(
|
|
625
|
+
detail_hdr,
|
|
626
|
+
text=_t("hc.plugin_panel.editar"),
|
|
627
|
+
variable=self._edit_mode,
|
|
628
|
+
command=self._toggle_edit_mode,
|
|
629
|
+
bg=t.panel_bg,
|
|
630
|
+
fg=t.comment_fg,
|
|
631
|
+
activebackground=t.panel_bg,
|
|
632
|
+
selectcolor=t.input_bg,
|
|
633
|
+
font=(FONT_UI, 8),
|
|
634
|
+
cursor="hand2",
|
|
635
|
+
)
|
|
636
|
+
self._edit_chk.pack(side="right", padx=6)
|
|
637
|
+
self._ttp(
|
|
638
|
+
self._edit_chk, "Habilita edição do conteúdo do plugin (use com cuidado)"
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
tk.Frame(detail_outer, bg=t.border, height=1).pack(fill="x")
|
|
642
|
+
|
|
643
|
+
readme_frame = tk.Frame(detail_outer, bg=t.panel_bg)
|
|
644
|
+
readme_frame.pack(fill="both", expand=True)
|
|
645
|
+
rvsb = ttk.Scrollbar(
|
|
646
|
+
readme_frame, orient="vertical", style="Thin.Vertical.TScrollbar"
|
|
647
|
+
)
|
|
648
|
+
rvsb.pack(side="right", fill="y")
|
|
649
|
+
self._readme = tk.Text(
|
|
650
|
+
readme_frame,
|
|
651
|
+
bg=t.panel_bg,
|
|
652
|
+
fg=t.fg,
|
|
653
|
+
relief="flat",
|
|
654
|
+
bd=0,
|
|
655
|
+
font=(FONT_UI, 10),
|
|
656
|
+
state="disabled",
|
|
657
|
+
wrap="word",
|
|
658
|
+
highlightthickness=0,
|
|
659
|
+
padx=12,
|
|
660
|
+
pady=8,
|
|
661
|
+
yscrollcommand=rvsb.set,
|
|
662
|
+
cursor="arrow",
|
|
663
|
+
)
|
|
664
|
+
self._readme.pack(side="left", fill="both", expand=True)
|
|
665
|
+
rvsb.config(command=self._readme.yview)
|
|
666
|
+
|
|
667
|
+
tk.Frame(self, bg=t.border, height=1).pack(fill="x")
|
|
668
|
+
self._action_bar = tk.Frame(self, bg=t.panel_bg, height=36)
|
|
669
|
+
self._action_bar.pack(fill="x", padx=6, pady=4)
|
|
670
|
+
self._action_bar.pack_propagate(False)
|
|
671
|
+
|
|
672
|
+
def _ttp(self, widget: tk.Widget, text: str) -> None:
|
|
673
|
+
"""Adiciona tooltip simples."""
|
|
674
|
+
tip_win: list = [None]
|
|
675
|
+
|
|
676
|
+
def _show(_e):
|
|
677
|
+
x = widget.winfo_rootx() + 8
|
|
678
|
+
y = widget.winfo_rooty() + widget.winfo_height() + 4
|
|
679
|
+
t = self._tmgr.theme
|
|
680
|
+
tw = tk.Toplevel(widget)
|
|
681
|
+
tw.wm_overrideredirect(True)
|
|
682
|
+
tw.wm_attributes("-topmost", True)
|
|
683
|
+
fr = tk.Frame(
|
|
684
|
+
tw,
|
|
685
|
+
bg=t.floating_bg,
|
|
686
|
+
highlightthickness=1,
|
|
687
|
+
highlightbackground=t.floating_border,
|
|
688
|
+
)
|
|
689
|
+
fr.pack()
|
|
690
|
+
tk.Label(
|
|
691
|
+
fr,
|
|
692
|
+
text=text,
|
|
693
|
+
bg=t.floating_bg,
|
|
694
|
+
fg=t.fg,
|
|
695
|
+
font=(FONT_UI, 8),
|
|
696
|
+
padx=6,
|
|
697
|
+
pady=3,
|
|
698
|
+
).pack()
|
|
699
|
+
tw.geometry(f"+{x}+{y}")
|
|
700
|
+
tip_win[0] = tw
|
|
701
|
+
|
|
702
|
+
def _hide(_e):
|
|
703
|
+
if tip_win[0]:
|
|
704
|
+
with contextlib.suppress(tk.TclError):
|
|
705
|
+
tip_win[0].destroy()
|
|
706
|
+
tip_win[0] = None
|
|
707
|
+
|
|
708
|
+
widget.bind("<Enter>", _show, add="+")
|
|
709
|
+
widget.bind("<Leave>", _hide, add="+")
|
|
710
|
+
|
|
711
|
+
def _pill_btn(
|
|
712
|
+
self,
|
|
713
|
+
parent: tk.Widget,
|
|
714
|
+
text: str,
|
|
715
|
+
cmd: Callable,
|
|
716
|
+
color: str | None = None,
|
|
717
|
+
font_extra: str = "",
|
|
718
|
+
tooltip: str = "",
|
|
719
|
+
) -> tk.Label:
|
|
720
|
+
"""Cria um botão-pílula reutilizável."""
|
|
721
|
+
t = self._tmgr.theme
|
|
722
|
+
fg = color or t.fg
|
|
723
|
+
lbl = tk.Label(
|
|
724
|
+
parent,
|
|
725
|
+
text=text,
|
|
726
|
+
bg=t.btn_bg,
|
|
727
|
+
fg=fg,
|
|
728
|
+
font=(FONT_UI, 8) if not font_extra else (FONT_UI, 8, font_extra),
|
|
729
|
+
padx=8,
|
|
730
|
+
pady=3,
|
|
731
|
+
cursor="hand2",
|
|
732
|
+
relief="flat",
|
|
733
|
+
highlightthickness=1,
|
|
734
|
+
highlightbackground=t.border,
|
|
735
|
+
)
|
|
736
|
+
lbl.pack(side="left", padx=2)
|
|
737
|
+
lbl.bind("<Button-1>", lambda _: cmd())
|
|
738
|
+
if tooltip:
|
|
739
|
+
self._ttp(lbl, tooltip)
|
|
740
|
+
return lbl
|
|
741
|
+
|
|
742
|
+
def _update_pills(self) -> None:
|
|
743
|
+
t = self._tmgr.theme
|
|
744
|
+
mode = self._filter_mode.get()
|
|
745
|
+
for m, lbl in self._pill_btns.items():
|
|
746
|
+
if m == mode:
|
|
747
|
+
lbl.config(
|
|
748
|
+
bg=t.accent,
|
|
749
|
+
fg=getattr(t, "actbar_active_fg", "#fff"),
|
|
750
|
+
highlightbackground=t.accent,
|
|
751
|
+
)
|
|
752
|
+
else:
|
|
753
|
+
lbl.config(bg=t.panel_bg, fg=t.comment_fg,
|
|
754
|
+
highlightbackground=t.border)
|
|
755
|
+
|
|
756
|
+
def _on_mousewheel(self, e: Any) -> None:
|
|
757
|
+
self._canvas.yview_scroll(int(-1 * (e.delta / 120)), "units")
|
|
758
|
+
|
|
759
|
+
def _collect_all_ids(self) -> list[str]:
|
|
760
|
+
"""Retorna a lista de IDs de todos os plugins instalados."""
|
|
761
|
+
return self._loader.all_plugin_ids()
|
|
762
|
+
|
|
763
|
+
def _get_tags(self) -> list[str]:
|
|
764
|
+
"""Obtém e retorna 'tags'."""
|
|
765
|
+
tags: set = set()
|
|
766
|
+
for pid in self._loader.plugins:
|
|
767
|
+
m = self._loader.get_manifest(pid)
|
|
768
|
+
if m:
|
|
769
|
+
tags.update(m.tags)
|
|
770
|
+
return sorted(tags)
|
|
771
|
+
|
|
772
|
+
def _get_plugin_info(self, pid: str) -> dict[str, Any]:
|
|
773
|
+
"""Retorna dict com metadados consolidados do plugin."""
|
|
774
|
+
loaded = self._loader.plugins
|
|
775
|
+
errors = self._loader.errors
|
|
776
|
+
info = {}
|
|
777
|
+
mod = loaded.get(pid)
|
|
778
|
+
manifest = self._loader.get_manifest(pid)
|
|
779
|
+
info["manifest"] = (
|
|
780
|
+
_normalize_manifest(
|
|
781
|
+
manifest) if manifest else PluginManifest(name=pid)
|
|
782
|
+
)
|
|
783
|
+
if manifest is None:
|
|
784
|
+
manifest = PluginManifest(name=pid)
|
|
785
|
+
enabled = getattr(mod, "_enabled", True) if mod else False
|
|
786
|
+
status = (
|
|
787
|
+
"error"
|
|
788
|
+
if pid in errors
|
|
789
|
+
else (
|
|
790
|
+
"disabled"
|
|
791
|
+
if pid in self._loader._disabled
|
|
792
|
+
else "active" if enabled else "inactive"
|
|
793
|
+
)
|
|
794
|
+
)
|
|
795
|
+
return {
|
|
796
|
+
"id": pid,
|
|
797
|
+
"mod": mod,
|
|
798
|
+
"manifest": manifest,
|
|
799
|
+
"status": status,
|
|
800
|
+
"error": errors.get(pid, ""),
|
|
801
|
+
"weight": self._loader.get_plugin_weight(pid),
|
|
802
|
+
"loaded": mod is not None,
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
def _set_filter(self, mode: str) -> None:
|
|
806
|
+
self._filter_mode.set(mode)
|
|
807
|
+
self._update_pills()
|
|
808
|
+
self._apply_filter()
|
|
809
|
+
|
|
810
|
+
def _apply_filter(self) -> None:
|
|
811
|
+
"""Filtra os cards de plugins conforme o texto de busca e categoria."""
|
|
812
|
+
q = self._search_var.get().lower().strip()
|
|
813
|
+
mode = self._filter_mode.get()
|
|
814
|
+
tag_flt = self._tag_var.get().strip()
|
|
815
|
+
sort_by = self._sort_var.get()
|
|
816
|
+
|
|
817
|
+
all_ids = self._collect_all_ids()
|
|
818
|
+
infos = [self._get_plugin_info(pid) for pid in all_ids]
|
|
819
|
+
|
|
820
|
+
if mode == "installed":
|
|
821
|
+
infos = [i for i in infos if i["loaded"]]
|
|
822
|
+
elif mode == "error":
|
|
823
|
+
infos = [i for i in infos if i["status"] == "error"]
|
|
824
|
+
elif mode == "disabled":
|
|
825
|
+
infos = [i for i in infos if i["status"]
|
|
826
|
+
in ("disabled", "inactive")]
|
|
827
|
+
|
|
828
|
+
if q:
|
|
829
|
+
|
|
830
|
+
def _matches(info: dict) -> bool:
|
|
831
|
+
m = info["manifest"]
|
|
832
|
+
return (
|
|
833
|
+
q in info["id"].lower()
|
|
834
|
+
or q in m.name.lower()
|
|
835
|
+
or q in m.description.lower()
|
|
836
|
+
or q in m.author.lower()
|
|
837
|
+
or any(q in tg.lower() for tg in m.tags)
|
|
838
|
+
)
|
|
839
|
+
|
|
840
|
+
infos = [i for i in infos if _matches(i)]
|
|
841
|
+
|
|
842
|
+
if tag_flt:
|
|
843
|
+
infos = [i for i in infos if tag_flt in i["manifest"].tags]
|
|
844
|
+
|
|
845
|
+
if sort_by == "name":
|
|
846
|
+
infos.sort(key=lambda i: i["manifest"].name.lower())
|
|
847
|
+
elif sort_by == "status":
|
|
848
|
+
order = {"error": 0, "disabled": 1, "inactive": 2, "active": 3}
|
|
849
|
+
infos.sort(key=lambda i: order.get(i["status"], 9))
|
|
850
|
+
elif sort_by == "weight":
|
|
851
|
+
infos.sort(key=lambda i: i["weight"], reverse=True)
|
|
852
|
+
elif sort_by == "author":
|
|
853
|
+
infos.sort(key=lambda i: i["manifest"].author.lower())
|
|
854
|
+
|
|
855
|
+
self._render_cards(infos)
|
|
856
|
+
total = len(all_ids)
|
|
857
|
+
shown = len(infos)
|
|
858
|
+
self._count_label.config(
|
|
859
|
+
text=f"{shown} de {total} extensões - "
|
|
860
|
+
f"{len(self._loader.plugins)} ativas - "
|
|
861
|
+
f"{len(self._loader.errors)} com erro"
|
|
862
|
+
)
|
|
863
|
+
|
|
864
|
+
def _render_cards(self, infos: list[dict]) -> None:
|
|
865
|
+
"""Renderiza os cards dos plugins filtrados na grade de resultados."""
|
|
866
|
+
t = self._tmgr.theme
|
|
867
|
+
|
|
868
|
+
for child in self._cards_frame.winfo_children():
|
|
869
|
+
child.destroy()
|
|
870
|
+
self._card_widgets.clear()
|
|
871
|
+
|
|
872
|
+
self._selected_ids = set(self._selected_ids)
|
|
873
|
+
|
|
874
|
+
if not infos:
|
|
875
|
+
tk.Label(
|
|
876
|
+
self._cards_frame,
|
|
877
|
+
text=_t("hc.plugin_panel.nenhum_plugin_encontrado"),
|
|
878
|
+
bg=t.panel_bg,
|
|
879
|
+
fg=t.comment_fg,
|
|
880
|
+
font=(FONT_UI, 10),
|
|
881
|
+
pady=20,
|
|
882
|
+
).pack()
|
|
883
|
+
return
|
|
884
|
+
|
|
885
|
+
for info in infos:
|
|
886
|
+
self._create_card(info)
|
|
887
|
+
|
|
888
|
+
self._canvas.update_idletasks()
|
|
889
|
+
self._sync_cards_scrollregion()
|
|
890
|
+
|
|
891
|
+
def _sync_cards_scrollregion(self) -> None:
|
|
892
|
+
"""Ajusta a área rolável e a largura da grade ao conteúdo recém-criado."""
|
|
893
|
+
self._canvas.config(scrollregion=self._canvas.bbox("all"))
|
|
894
|
+
self._canvas.itemconfig(self._canvas_window, width=self._canvas.winfo_width())
|
|
895
|
+
|
|
896
|
+
def _create_card(self, info: dict) -> None:
|
|
897
|
+
t = self._tmgr.theme
|
|
898
|
+
pid = info["id"]
|
|
899
|
+
m = info["manifest"]
|
|
900
|
+
status = info["status"]
|
|
901
|
+
|
|
902
|
+
status_colors = {
|
|
903
|
+
"active": (getattr(t, "accent", "#4fc3f7"), "●"),
|
|
904
|
+
"inactive": (t.comment_fg, "○"),
|
|
905
|
+
"disabled": ("#f0a500", "⊘"),
|
|
906
|
+
"error": (t.err_fg, "✕"),
|
|
907
|
+
}
|
|
908
|
+
s_color, s_icon = status_colors.get(status, (t.comment_fg, "?"))
|
|
909
|
+
|
|
910
|
+
is_sel = pid == self._selected_id
|
|
911
|
+
card_bg = getattr(t, "sel_bg", t.input_bg) if is_sel else t.panel_bg
|
|
912
|
+
border_c = t.accent if is_sel else t.border
|
|
913
|
+
|
|
914
|
+
card = tk.Frame(
|
|
915
|
+
self._cards_frame,
|
|
916
|
+
bg=card_bg,
|
|
917
|
+
highlightthickness=1,
|
|
918
|
+
highlightbackground=border_c,
|
|
919
|
+
padx=0,
|
|
920
|
+
pady=0,
|
|
921
|
+
)
|
|
922
|
+
card.pack(fill="x", padx=6, pady=2)
|
|
923
|
+
self._card_widgets[pid] = card
|
|
924
|
+
|
|
925
|
+
row1 = tk.Frame(card, bg=card_bg, padx=8, pady=5)
|
|
926
|
+
row1.pack(fill="x")
|
|
927
|
+
|
|
928
|
+
tk.Label(
|
|
929
|
+
row1, text=m.icon or "🔌", bg=card_bg, fg=t.fg, font=(FONT_UI, 14)
|
|
930
|
+
).pack(side="left", padx=(0, 6))
|
|
931
|
+
|
|
932
|
+
info_frame = tk.Frame(row1, bg=card_bg)
|
|
933
|
+
info_frame.pack(side="left", fill="x", expand=True)
|
|
934
|
+
|
|
935
|
+
name_row = tk.Frame(info_frame, bg=card_bg)
|
|
936
|
+
name_row.pack(fill="x")
|
|
937
|
+
|
|
938
|
+
tk.Label(
|
|
939
|
+
name_row,
|
|
940
|
+
text=m.name,
|
|
941
|
+
bg=card_bg,
|
|
942
|
+
fg=t.fg,
|
|
943
|
+
font=(FONT_UI, 10, "bold"),
|
|
944
|
+
anchor="w",
|
|
945
|
+
).pack(side="left")
|
|
946
|
+
|
|
947
|
+
tk.Label(
|
|
948
|
+
name_row,
|
|
949
|
+
text=f" v{m.version}",
|
|
950
|
+
bg=card_bg,
|
|
951
|
+
fg=t.comment_fg,
|
|
952
|
+
font=(FONT_UI, 8),
|
|
953
|
+
anchor="w",
|
|
954
|
+
).pack(side="left")
|
|
955
|
+
|
|
956
|
+
tk.Label(
|
|
957
|
+
name_row, text=f" {s_icon}", bg=card_bg, fg=s_color, font=(FONT_UI, 9)
|
|
958
|
+
).pack(side="left")
|
|
959
|
+
|
|
960
|
+
weight = info["weight"]
|
|
961
|
+
if weight > 0:
|
|
962
|
+
tk.Label(
|
|
963
|
+
name_row,
|
|
964
|
+
text=f" {weight}KB",
|
|
965
|
+
bg=card_bg,
|
|
966
|
+
fg=t.comment_fg,
|
|
967
|
+
font=(FONT_UI, 7),
|
|
968
|
+
).pack(side="right")
|
|
969
|
+
|
|
970
|
+
if m.description:
|
|
971
|
+
desc = (
|
|
972
|
+
m.description
|
|
973
|
+
if len(m.description) <= 80
|
|
974
|
+
else m.description[:77] + "..."
|
|
975
|
+
)
|
|
976
|
+
tk.Label(
|
|
977
|
+
info_frame,
|
|
978
|
+
text=desc,
|
|
979
|
+
bg=card_bg,
|
|
980
|
+
fg=t.comment_fg,
|
|
981
|
+
font=(FONT_UI, 8),
|
|
982
|
+
anchor="w",
|
|
983
|
+
wraplength=260,
|
|
984
|
+
).pack(fill="x")
|
|
985
|
+
|
|
986
|
+
if m.tags:
|
|
987
|
+
tags_row = tk.Frame(info_frame, bg=card_bg)
|
|
988
|
+
tags_row.pack(fill="x", pady=(2, 0))
|
|
989
|
+
for tg in m.tags[:4]:
|
|
990
|
+
tk.Label(
|
|
991
|
+
tags_row,
|
|
992
|
+
text=tg,
|
|
993
|
+
bg=getattr(t, "gutter_bg", t.input_bg),
|
|
994
|
+
fg=t.comment_fg,
|
|
995
|
+
font=(FONT_UI, 7),
|
|
996
|
+
padx=4,
|
|
997
|
+
pady=1,
|
|
998
|
+
relief="flat",
|
|
999
|
+
).pack(side="left", padx=(0, 2))
|
|
1000
|
+
|
|
1001
|
+
def _click(e=None, p=pid):
|
|
1002
|
+
if e and (e.state & 0x4):
|
|
1003
|
+
self._toggle_multi_select(p)
|
|
1004
|
+
else:
|
|
1005
|
+
self._selected_ids.clear()
|
|
1006
|
+
self._select_plugin(p)
|
|
1007
|
+
|
|
1008
|
+
def _right_click(e=None, p=pid):
|
|
1009
|
+
if p not in self._selected_ids:
|
|
1010
|
+
self._selected_ids.clear()
|
|
1011
|
+
self._select_plugin(p)
|
|
1012
|
+
self._show_card_context_menu(e, p)
|
|
1013
|
+
|
|
1014
|
+
def _enter(_e=None, p=pid, fr=card, _bg=card_bg):
|
|
1015
|
+
if p != self._selected_id:
|
|
1016
|
+
fr.config(highlightbackground=t.accent)
|
|
1017
|
+
|
|
1018
|
+
def _leave(_e=None, p=pid, fr=card, _bg=card_bg, bc=border_c):
|
|
1019
|
+
if p != self._selected_id:
|
|
1020
|
+
fr.config(highlightbackground=bc)
|
|
1021
|
+
|
|
1022
|
+
for w in card.winfo_children() + [card]:
|
|
1023
|
+
w.bind("<Button-1>", _click, add="+")
|
|
1024
|
+
w.bind("<Button-3>", _right_click, add="+")
|
|
1025
|
+
w.bind("<Enter>", _enter, add="+")
|
|
1026
|
+
w.bind("<Leave>", _leave, add="+")
|
|
1027
|
+
|
|
1028
|
+
def _bind_all(widget):
|
|
1029
|
+
widget.bind("<Button-1>", _click, add="+")
|
|
1030
|
+
widget.bind("<Button-3>", _right_click, add="+")
|
|
1031
|
+
widget.bind("<Enter>", _enter, add="+")
|
|
1032
|
+
widget.bind("<Leave>", _leave, add="+")
|
|
1033
|
+
for c in widget.winfo_children():
|
|
1034
|
+
_bind_all(c)
|
|
1035
|
+
|
|
1036
|
+
_bind_all(card)
|
|
1037
|
+
|
|
1038
|
+
def _select_plugin(self, pid: str) -> None:
|
|
1039
|
+
old = self._selected_id
|
|
1040
|
+
self._selected_id = pid
|
|
1041
|
+
|
|
1042
|
+
if old and old in self._card_widgets:
|
|
1043
|
+
self._restyle_card(old, selected=False)
|
|
1044
|
+
if pid in self._card_widgets:
|
|
1045
|
+
self._restyle_card(pid, selected=True)
|
|
1046
|
+
|
|
1047
|
+
self._update_readme(pid)
|
|
1048
|
+
self._update_action_bar(pid)
|
|
1049
|
+
|
|
1050
|
+
def _restyle_card(self, pid: str, selected: bool) -> None:
|
|
1051
|
+
t = self._tmgr.theme
|
|
1052
|
+
card = self._card_widgets.get(pid)
|
|
1053
|
+
if not card or not card.winfo_exists():
|
|
1054
|
+
return
|
|
1055
|
+
bg = getattr(t, "sel_bg", t.input_bg) if selected else t.panel_bg
|
|
1056
|
+
bc = t.accent if selected else t.border
|
|
1057
|
+
with contextlib.suppress(tk.TclError):
|
|
1058
|
+
card.config(bg=bg, highlightbackground=bc)
|
|
1059
|
+
for child in card.winfo_children():
|
|
1060
|
+
bg_recursive(child, bg)
|
|
1061
|
+
|
|
1062
|
+
def _toggle_multi_select(self, pid: str) -> None:
|
|
1063
|
+
"""Ctrl+clique: adiciona/remove da seleção múltipla."""
|
|
1064
|
+
if pid in self._selected_ids:
|
|
1065
|
+
self._selected_ids.discard(pid)
|
|
1066
|
+
self._restyle_card(pid, selected=(pid == self._selected_id))
|
|
1067
|
+
else:
|
|
1068
|
+
self._selected_ids.add(pid)
|
|
1069
|
+
self._restyle_card_multi(pid, True)
|
|
1070
|
+
|
|
1071
|
+
def _restyle_card_multi(self, pid: str, selected: bool) -> None:
|
|
1072
|
+
"""Estilo de destaque para seleção múltipla (contorno laranja)."""
|
|
1073
|
+
t = self._tmgr.theme
|
|
1074
|
+
card = self._card_widgets.get(pid)
|
|
1075
|
+
if not card or not card.winfo_exists():
|
|
1076
|
+
return
|
|
1077
|
+
accent2 = getattr(t, "warn_fg", "#f0a500")
|
|
1078
|
+
bc = accent2 if selected else t.border
|
|
1079
|
+
bg = getattr(t, "sel_bg", t.input_bg) if selected else t.panel_bg
|
|
1080
|
+
with contextlib.suppress(tk.TclError):
|
|
1081
|
+
card.config(highlightbackground=bc, bg=bg)
|
|
1082
|
+
for child in card.winfo_children():
|
|
1083
|
+
bg_recursive(child, bg)
|
|
1084
|
+
|
|
1085
|
+
def _show_card_context_menu(self, e: tk.Event, pid: str) -> None:
|
|
1086
|
+
"""Menu flutuante (botão direito) sobre um card de plugin."""
|
|
1087
|
+
t = self._tmgr.theme
|
|
1088
|
+
info = self._get_plugin_info(pid)
|
|
1089
|
+
status = info["status"]
|
|
1090
|
+
multi = len(self._selected_ids) > 1
|
|
1091
|
+
targets = list(self._selected_ids) if multi else [pid]
|
|
1092
|
+
|
|
1093
|
+
menu = tk.Menu(
|
|
1094
|
+
self,
|
|
1095
|
+
tearoff=False,
|
|
1096
|
+
bg=t.floating_bg,
|
|
1097
|
+
fg=t.fg,
|
|
1098
|
+
activebackground=t.sel_bg,
|
|
1099
|
+
activeforeground=t.sel_fg,
|
|
1100
|
+
relief="flat",
|
|
1101
|
+
bd=1,
|
|
1102
|
+
)
|
|
1103
|
+
|
|
1104
|
+
if multi:
|
|
1105
|
+
menu.add_command(
|
|
1106
|
+
label=f"▶ Ativar {len(targets)} plugins",
|
|
1107
|
+
command=lambda: self._bulk_action("enable", targets),
|
|
1108
|
+
)
|
|
1109
|
+
menu.add_command(
|
|
1110
|
+
label=f"⊘ Desativar {len(targets)} plugins",
|
|
1111
|
+
command=lambda: self._bulk_action("disable", targets),
|
|
1112
|
+
)
|
|
1113
|
+
menu.add_command(
|
|
1114
|
+
label=f"↻ Recarregar {len(targets)} plugins",
|
|
1115
|
+
command=lambda: self._bulk_action("reload", targets),
|
|
1116
|
+
)
|
|
1117
|
+
menu.add_separator()
|
|
1118
|
+
menu.add_command(
|
|
1119
|
+
label=f"🗑 {_t('hc.plugin_panel.desinstalar')} ({len(targets)})",
|
|
1120
|
+
foreground=t.err_fg,
|
|
1121
|
+
command=lambda: self._bulk_uninstall(targets),
|
|
1122
|
+
)
|
|
1123
|
+
menu.add_separator()
|
|
1124
|
+
menu.add_command(
|
|
1125
|
+
label=_t("hc.plugin_panel.limpar_sele_o_m_ltipla"),
|
|
1126
|
+
command=self._clear_multi_select,
|
|
1127
|
+
)
|
|
1128
|
+
else:
|
|
1129
|
+
if status in ("active", "inactive", "disabled"):
|
|
1130
|
+
is_enabled = status == "active"
|
|
1131
|
+
toggle_label = (
|
|
1132
|
+
_t("hc.plugin_panel.desativar") if is_enabled else "▶ Ativar"
|
|
1133
|
+
)
|
|
1134
|
+
menu.add_command(
|
|
1135
|
+
label=toggle_label, command=lambda p=pid: self._toggle(p)
|
|
1136
|
+
)
|
|
1137
|
+
menu.add_command(
|
|
1138
|
+
label=_t("hc.plugin_panel.recarregar"),
|
|
1139
|
+
command=lambda p=pid: self._reload(p),
|
|
1140
|
+
)
|
|
1141
|
+
menu.add_command(
|
|
1142
|
+
label=_t("hc.plugin_panel.reinstalar"),
|
|
1143
|
+
command=lambda p=pid: self._reinstall(p),
|
|
1144
|
+
)
|
|
1145
|
+
menu.add_separator()
|
|
1146
|
+
menu.add_command(
|
|
1147
|
+
label=_t("hc.plugin_panel.localizar_no_explorador"),
|
|
1148
|
+
command=lambda p=pid: self._open_in_explorer(p),
|
|
1149
|
+
)
|
|
1150
|
+
if info["manifest"].homepage:
|
|
1151
|
+
menu.add_command(
|
|
1152
|
+
label=_t("hc.plugin_panel.homepage"),
|
|
1153
|
+
command=lambda url=info["manifest"].homepage: webbrowser.open(
|
|
1154
|
+
url),
|
|
1155
|
+
)
|
|
1156
|
+
menu.add_separator()
|
|
1157
|
+
menu.add_command(
|
|
1158
|
+
label=_t("hc.plugin_panel.desinstalar"),
|
|
1159
|
+
foreground=t.err_fg,
|
|
1160
|
+
command=lambda p=pid: self._uninstall(p),
|
|
1161
|
+
)
|
|
1162
|
+
|
|
1163
|
+
try:
|
|
1164
|
+
menu.tk_popup(e.x_root, e.y_root)
|
|
1165
|
+
finally:
|
|
1166
|
+
menu.grab_release()
|
|
1167
|
+
|
|
1168
|
+
def _show_bulk_menu(self, e: tk.Event) -> None:
|
|
1169
|
+
"""Exibe o menu contextual de ações em lote para plugins selecionados."""
|
|
1170
|
+
t = self._tmgr.theme
|
|
1171
|
+
selected = list(self._selected_ids)
|
|
1172
|
+
visible = list(self._card_widgets.keys())
|
|
1173
|
+
targets = selected if selected else visible
|
|
1174
|
+
label = (
|
|
1175
|
+
f"{len(targets)} selecionados" if selected else f"todos ({len(targets)})"
|
|
1176
|
+
)
|
|
1177
|
+
|
|
1178
|
+
menu = tk.Menu(
|
|
1179
|
+
self,
|
|
1180
|
+
tearoff=False,
|
|
1181
|
+
bg=t.floating_bg,
|
|
1182
|
+
fg=t.fg,
|
|
1183
|
+
activebackground=t.sel_bg,
|
|
1184
|
+
activeforeground=t.sel_fg,
|
|
1185
|
+
relief="flat",
|
|
1186
|
+
bd=1,
|
|
1187
|
+
)
|
|
1188
|
+
menu.add_command(
|
|
1189
|
+
label=f"▶ Ativar {label}",
|
|
1190
|
+
command=lambda: self._bulk_action("enable", targets),
|
|
1191
|
+
)
|
|
1192
|
+
menu.add_command(
|
|
1193
|
+
label=f"⊘ Desativar {label}",
|
|
1194
|
+
command=lambda: self._bulk_action("disable", targets),
|
|
1195
|
+
)
|
|
1196
|
+
menu.add_command(
|
|
1197
|
+
label=f"↻ Recarregar {label}",
|
|
1198
|
+
command=lambda: self._bulk_action("reload", targets),
|
|
1199
|
+
)
|
|
1200
|
+
menu.add_separator()
|
|
1201
|
+
menu.add_command(
|
|
1202
|
+
label=f"🗑 {_t('hc.plugin_panel.desinstalar')} {label}",
|
|
1203
|
+
foreground=t.err_fg,
|
|
1204
|
+
command=lambda: self._bulk_uninstall(targets),
|
|
1205
|
+
)
|
|
1206
|
+
menu.add_separator()
|
|
1207
|
+
menu.add_command(
|
|
1208
|
+
label=_t("hc.plugin_panel.selecionar_todos_vis_veis"),
|
|
1209
|
+
command=self._select_all_visible,
|
|
1210
|
+
)
|
|
1211
|
+
menu.add_command(
|
|
1212
|
+
label=_t("hc.plugin_panel.limpar_sele_o"), command=self._clear_multi_select
|
|
1213
|
+
)
|
|
1214
|
+
try:
|
|
1215
|
+
menu.tk_popup(e.x_root, e.y_root)
|
|
1216
|
+
finally:
|
|
1217
|
+
menu.grab_release()
|
|
1218
|
+
|
|
1219
|
+
def _select_all_visible(self) -> None:
|
|
1220
|
+
"""Seleciona todos os plugins visíveis na grade de resultados."""
|
|
1221
|
+
self._selected_ids = set(self._card_widgets.keys())
|
|
1222
|
+
for pid in self._selected_ids:
|
|
1223
|
+
self._restyle_card_multi(pid, True)
|
|
1224
|
+
|
|
1225
|
+
def _clear_multi_select(self) -> None:
|
|
1226
|
+
"""Remove o highlight de seleção múltipla."""
|
|
1227
|
+
for pid in list(self._selected_ids):
|
|
1228
|
+
self._restyle_card(pid, selected=(pid == self._selected_id))
|
|
1229
|
+
self._selected_ids.clear()
|
|
1230
|
+
|
|
1231
|
+
def _bulk_action(self, action: str, pids: list[str]) -> None:
|
|
1232
|
+
"""Executa ação em lote: enable / disable / reload."""
|
|
1233
|
+
errors: list[str] = []
|
|
1234
|
+
for pid in pids:
|
|
1235
|
+
try:
|
|
1236
|
+
if action == "enable":
|
|
1237
|
+
if self._get_plugin_info(pid)["status"] != "active":
|
|
1238
|
+
self._loader.toggle(pid)
|
|
1239
|
+
elif action == "disable":
|
|
1240
|
+
if self._get_plugin_info(pid)["status"] == "active":
|
|
1241
|
+
self._loader.toggle(pid)
|
|
1242
|
+
elif action == "reload" and not self._loader.reload(pid):
|
|
1243
|
+
errors.append(pid)
|
|
1244
|
+
except (OSError, RuntimeError) as exc:
|
|
1245
|
+
errors.append(f"{pid}: {exc}")
|
|
1246
|
+
self._clear_multi_select()
|
|
1247
|
+
self.refresh()
|
|
1248
|
+
if errors:
|
|
1249
|
+
messagebox.showerror(
|
|
1250
|
+
_t("hc.plugin_panel.bulk_err", default="Erros"),
|
|
1251
|
+
"Falhou em:\n" + "\n".join(errors),
|
|
1252
|
+
parent=self,
|
|
1253
|
+
)
|
|
1254
|
+
|
|
1255
|
+
def _bulk_uninstall(self, pids: list[str]) -> None:
|
|
1256
|
+
"""Desinstala múltiplos plugins com uma única confirmação."""
|
|
1257
|
+
if not pids:
|
|
1258
|
+
return
|
|
1259
|
+
names = [self._get_plugin_info(p)["manifest"].name for p in pids]
|
|
1260
|
+
if not messagebox.askyesno(
|
|
1261
|
+
_t("hc.plugin_panel.desinstalar"),
|
|
1262
|
+
f"Deseja remover permanentemente {len(pids)} plugin(s)?\n\n"
|
|
1263
|
+
+ "\n".join(f" - {n}" for n in names[:15])
|
|
1264
|
+
+ ("\n ..." if len(names) > 15 else ""),
|
|
1265
|
+
parent=self,
|
|
1266
|
+
):
|
|
1267
|
+
return
|
|
1268
|
+
errors: list[str] = []
|
|
1269
|
+
for pid in pids:
|
|
1270
|
+
if not self._loader.uninstall(pid):
|
|
1271
|
+
errors.append(pid)
|
|
1272
|
+
self._selected_ids.clear()
|
|
1273
|
+
self._selected_id = None
|
|
1274
|
+
self.refresh()
|
|
1275
|
+
self._readme.config(state="normal")
|
|
1276
|
+
self._readme.delete("1.0", "end")
|
|
1277
|
+
self._readme.config(state="disabled")
|
|
1278
|
+
for w in self._action_bar.winfo_children():
|
|
1279
|
+
w.destroy()
|
|
1280
|
+
self._detail_title.config(
|
|
1281
|
+
text=_t("hc.plugin_panel.selecione_um_plugin"))
|
|
1282
|
+
if errors:
|
|
1283
|
+
messagebox.showerror(
|
|
1284
|
+
_t("hc.plugin_panel.desinstalar_err",
|
|
1285
|
+
default="Erros ao desinstalar"),
|
|
1286
|
+
"Não foi possível remover:\n" + "\n".join(errors),
|
|
1287
|
+
parent=self,
|
|
1288
|
+
)
|
|
1289
|
+
|
|
1290
|
+
def _reinstall(self, pid: str) -> None:
|
|
1291
|
+
"""Reinstala: remove e pede novo arquivo."""
|
|
1292
|
+
info = self._get_plugin_info(pid)
|
|
1293
|
+
m = info["manifest"]
|
|
1294
|
+
if not messagebox.askyesno(
|
|
1295
|
+
_t("hc.plugin_panel.reinstalar"),
|
|
1296
|
+
f"'{m.name}' será removido e você escolherá um novo arquivo.\n\nDeseja continuar?",
|
|
1297
|
+
parent=self,
|
|
1298
|
+
):
|
|
1299
|
+
return
|
|
1300
|
+
if not self._loader.uninstall(pid):
|
|
1301
|
+
messagebox.showerror(
|
|
1302
|
+
_t("hc.plugin_panel.reinstalar_err",
|
|
1303
|
+
default="Erro ao reinstalar"),
|
|
1304
|
+
f"Não foi possível remover '{pid}' para reinstalação.",
|
|
1305
|
+
parent=self,
|
|
1306
|
+
)
|
|
1307
|
+
return
|
|
1308
|
+
self._selected_id = None
|
|
1309
|
+
self.refresh()
|
|
1310
|
+
self._install()
|
|
1311
|
+
|
|
1312
|
+
def _update_readme(self, pid: str) -> None:
|
|
1313
|
+
t = self._tmgr.theme
|
|
1314
|
+
info = self._get_plugin_info(pid)
|
|
1315
|
+
m = info["manifest"]
|
|
1316
|
+
|
|
1317
|
+
if hasattr(m, "icon"):
|
|
1318
|
+
icon = m.icon
|
|
1319
|
+
name = m.name
|
|
1320
|
+
author = m.author if hasattr(m, "author") else ""
|
|
1321
|
+
else:
|
|
1322
|
+
icon = m.get("icon", "🔌")
|
|
1323
|
+
name = m.get("name", pid)
|
|
1324
|
+
author = m.get("author", "")
|
|
1325
|
+
|
|
1326
|
+
self._detail_title.config(
|
|
1327
|
+
text=f" {icon} {name} - {author or 'autor desconhecido'}"
|
|
1328
|
+
)
|
|
1329
|
+
|
|
1330
|
+
if info["status"] == "error":
|
|
1331
|
+
err_md = f"# ❌ Erro ao carregar {name}\n\n```\n{info['error']}\n```\n"
|
|
1332
|
+
_render_markdown(self._readme, err_md, t)
|
|
1333
|
+
else:
|
|
1334
|
+
readme_content = self._loader.get_readme(pid)
|
|
1335
|
+
|
|
1336
|
+
blocked, warned = self._loader.get_security_info(pid)
|
|
1337
|
+
prefix = ""
|
|
1338
|
+
if blocked:
|
|
1339
|
+
prefix += f"⚠ **AVISO DE SEGURANÇA** - Imports bloqueados: `{'`, `'.join(blocked)}`\n\n"
|
|
1340
|
+
if warned:
|
|
1341
|
+
prefix += f"ℹ️ Requisito de Risco: `{'`, `'.join(warned)}`\n\n"
|
|
1342
|
+
_render_markdown(self._readme, prefix + readme_content, t)
|
|
1343
|
+
|
|
1344
|
+
def _update_action_bar(self, pid: str) -> None:
|
|
1345
|
+
t = self._tmgr.theme
|
|
1346
|
+
info = self._get_plugin_info(pid)
|
|
1347
|
+
m = info["manifest"]
|
|
1348
|
+
m = _normalize_manifest(m)
|
|
1349
|
+
logger.debug("manifest: %s", m)
|
|
1350
|
+
|
|
1351
|
+
for w in self._action_bar.winfo_children():
|
|
1352
|
+
w.destroy()
|
|
1353
|
+
|
|
1354
|
+
info = self._get_plugin_info(pid)
|
|
1355
|
+
m = info["manifest"]
|
|
1356
|
+
m = _normalize_manifest(m)
|
|
1357
|
+
status = info["status"]
|
|
1358
|
+
|
|
1359
|
+
if status in ("active", "inactive"):
|
|
1360
|
+
is_enabled = status == "active"
|
|
1361
|
+
toggle_text = _t(
|
|
1362
|
+
"hc.plugin_panel.desativar") if is_enabled else "▶ Ativar"
|
|
1363
|
+
toggle_color = "#f0a500" if is_enabled else getattr(
|
|
1364
|
+
t, "accent", "#4fc3f7")
|
|
1365
|
+
self._pill_btn(
|
|
1366
|
+
self._action_bar,
|
|
1367
|
+
toggle_text,
|
|
1368
|
+
lambda p=pid: self._toggle(p),
|
|
1369
|
+
color=toggle_color,
|
|
1370
|
+
tooltip=_t("hc.plugin_panel.ativar_desativar_plugin"),
|
|
1371
|
+
)
|
|
1372
|
+
elif status == "disabled":
|
|
1373
|
+
self._pill_btn(
|
|
1374
|
+
self._action_bar,
|
|
1375
|
+
"▶ Ativar",
|
|
1376
|
+
lambda p=pid: self._toggle(p),
|
|
1377
|
+
color=getattr(t, "accent", "#4fc3f7"),
|
|
1378
|
+
tooltip=_t("hc.plugin_panel.reativar_plugin"),
|
|
1379
|
+
)
|
|
1380
|
+
elif status == "error":
|
|
1381
|
+
self._pill_btn(
|
|
1382
|
+
self._action_bar,
|
|
1383
|
+
"↻ Tentar Recarregar",
|
|
1384
|
+
lambda p=pid: self._reload(p),
|
|
1385
|
+
tooltip=_t("hc.plugin_panel.tenta_recarregar_o_plugin_com_"),
|
|
1386
|
+
)
|
|
1387
|
+
|
|
1388
|
+
if status != "error":
|
|
1389
|
+
self._pill_btn(
|
|
1390
|
+
self._action_bar,
|
|
1391
|
+
_t("hc.plugin_panel.recarregar"),
|
|
1392
|
+
lambda p=pid: self._reload(p),
|
|
1393
|
+
tooltip=_t("hc.plugin_panel.recarrega_o_plugin_do_disco"),
|
|
1394
|
+
)
|
|
1395
|
+
|
|
1396
|
+
if m.homepage:
|
|
1397
|
+
self._pill_btn(
|
|
1398
|
+
self._action_bar,
|
|
1399
|
+
_t("hc.plugin_panel.homepage"),
|
|
1400
|
+
lambda url=m.homepage: webbrowser.open(url),
|
|
1401
|
+
tooltip=m.homepage,
|
|
1402
|
+
)
|
|
1403
|
+
|
|
1404
|
+
self._pill_btn(
|
|
1405
|
+
self._action_bar,
|
|
1406
|
+
"📂 Localizar",
|
|
1407
|
+
lambda p=pid: self._open_in_explorer(p),
|
|
1408
|
+
tooltip=_t("hc.plugin_panel.abre_a_pasta_do_plugin_no_expl"),
|
|
1409
|
+
)
|
|
1410
|
+
|
|
1411
|
+
self._pill_btn(
|
|
1412
|
+
self._action_bar,
|
|
1413
|
+
_t("hc.plugin_panel.desinstalar"),
|
|
1414
|
+
lambda p=pid: self._uninstall(p),
|
|
1415
|
+
color=t.err_fg,
|
|
1416
|
+
font_extra="",
|
|
1417
|
+
tooltip=_t("hc.plugin_panel.remove_permanentemente_o_plugi"),
|
|
1418
|
+
)
|
|
1419
|
+
|
|
1420
|
+
def _toggle_edit_mode(self) -> None:
|
|
1421
|
+
"""Alterna o modo de edição avançada do painel de plugins."""
|
|
1422
|
+
editing = self._edit_mode.get()
|
|
1423
|
+
self._readme.config(
|
|
1424
|
+
state="normal" if editing else "disabled",
|
|
1425
|
+
cursor="xterm" if editing else "arrow",
|
|
1426
|
+
)
|
|
1427
|
+
|
|
1428
|
+
def _toggle(self, pid: str) -> None:
|
|
1429
|
+
"""Alterna o estado do componente (ativo/inativo ou visível/oculto)."""
|
|
1430
|
+
_ = self._loader.toggle(pid)
|
|
1431
|
+
self.refresh(keep_selection=pid)
|
|
1432
|
+
|
|
1433
|
+
def _reload(self, pid: str) -> None:
|
|
1434
|
+
"""Recarrega o componente sem reiniciar."""
|
|
1435
|
+
ok = self._loader.reload(pid)
|
|
1436
|
+
self.refresh(keep_selection=pid)
|
|
1437
|
+
if ok:
|
|
1438
|
+
logger.info("Plugin %s recarregado com sucesso.", pid)
|
|
1439
|
+
else:
|
|
1440
|
+
messagebox.showerror(
|
|
1441
|
+
"Reload Failed",
|
|
1442
|
+
f"Não foi possível recarregar o plugin '{pid}'.\n\n"
|
|
1443
|
+
+ self._loader.errors.get(pid, "(sem detalhes)"),
|
|
1444
|
+
parent=self,
|
|
1445
|
+
)
|
|
1446
|
+
|
|
1447
|
+
def _install(self) -> None:
|
|
1448
|
+
"""Instala componente ou plugin."""
|
|
1449
|
+
paths = filedialog.askopenfilenames(
|
|
1450
|
+
title=_t("hc.app.instalar_plugin"),
|
|
1451
|
+
filetypes=[
|
|
1452
|
+
("Plugins Codis", "*.py *.zip"),
|
|
1453
|
+
("Python", "*.py"),
|
|
1454
|
+
("ZIP", "*.zip"),
|
|
1455
|
+
("Todos", "*.*"),
|
|
1456
|
+
],
|
|
1457
|
+
parent=self,
|
|
1458
|
+
)
|
|
1459
|
+
if not paths:
|
|
1460
|
+
return
|
|
1461
|
+
errors: list[str] = []
|
|
1462
|
+
installed: list[str] = []
|
|
1463
|
+
|
|
1464
|
+
for p in paths:
|
|
1465
|
+
src = Path(p)
|
|
1466
|
+
pid = src.stem
|
|
1467
|
+
|
|
1468
|
+
def _confirm_cb(
|
|
1469
|
+
plugin_id: str, blocked: list[str], warned: list[str], _src=src
|
|
1470
|
+
) -> bool:
|
|
1471
|
+
dlg = _PluginTrustDialog(
|
|
1472
|
+
self, self._tmgr, plugin_id, blocked, warned)
|
|
1473
|
+
if dlg.dont_ask:
|
|
1474
|
+
with contextlib.suppress(OSError):
|
|
1475
|
+
source_text = _get_plugin_source(_src)
|
|
1476
|
+
content_hash = hashlib.sha256(
|
|
1477
|
+
source_text.encode("utf-8")
|
|
1478
|
+
).hexdigest()
|
|
1479
|
+
self._loader._trusted[plugin_id] = content_hash
|
|
1480
|
+
_save_trusted_plugins(self._loader._trusted)
|
|
1481
|
+
return dlg.result
|
|
1482
|
+
|
|
1483
|
+
try:
|
|
1484
|
+
ok = self._loader.install_from_path(
|
|
1485
|
+
src, confirm_cb=_confirm_cb)
|
|
1486
|
+
if ok:
|
|
1487
|
+
installed.append(pid)
|
|
1488
|
+
else:
|
|
1489
|
+
errors.append(f"{pid}: instalação cancelada ou falhou")
|
|
1490
|
+
except (OSError, RuntimeError) as exc:
|
|
1491
|
+
errors.append(f"{pid}: {exc}")
|
|
1492
|
+
|
|
1493
|
+
self.refresh()
|
|
1494
|
+
|
|
1495
|
+
if installed:
|
|
1496
|
+
logger.info("Plugins instalados: %s", ", ".join(installed))
|
|
1497
|
+
if errors:
|
|
1498
|
+
messagebox.showerror(
|
|
1499
|
+
_t("hc.plugin_panel.instalar_err",
|
|
1500
|
+
default="Erros na instalação"),
|
|
1501
|
+
"Os seguintes plugins não foram instalados:\n\n" +
|
|
1502
|
+
"\n".join(errors),
|
|
1503
|
+
parent=self,
|
|
1504
|
+
)
|
|
1505
|
+
|
|
1506
|
+
def _uninstall(self, pid: str) -> None:
|
|
1507
|
+
"""Remove componente ou plugin instalado."""
|
|
1508
|
+
info = self._get_plugin_info(pid)
|
|
1509
|
+
m = info["manifest"]
|
|
1510
|
+
if not messagebox.askyesno(
|
|
1511
|
+
_t("hc.plugin_panel.desinstalar"),
|
|
1512
|
+
f"Deseja remover permanentemente '{m.name}'?\n\n"
|
|
1513
|
+
f"Todos os arquivos do plugin serão apagados.",
|
|
1514
|
+
parent=self,
|
|
1515
|
+
):
|
|
1516
|
+
return
|
|
1517
|
+
ok = self._loader.uninstall(pid)
|
|
1518
|
+
if ok:
|
|
1519
|
+
self._selected_id = None
|
|
1520
|
+
self.refresh()
|
|
1521
|
+
|
|
1522
|
+
self._readme.config(state="normal")
|
|
1523
|
+
self._readme.delete("1.0", "end")
|
|
1524
|
+
self._readme.config(state="disabled")
|
|
1525
|
+
for w in self._action_bar.winfo_children():
|
|
1526
|
+
w.destroy()
|
|
1527
|
+
self._detail_title.config(
|
|
1528
|
+
text=_t("hc.plugin_panel.selecione_um_plugin"))
|
|
1529
|
+
else:
|
|
1530
|
+
messagebox.showerror(
|
|
1531
|
+
_t("hc.plugin_panel.desinstalar_err",
|
|
1532
|
+
default="Erro ao desinstalar"),
|
|
1533
|
+
f"Não foi possível remover completamente '{pid}'.\n"
|
|
1534
|
+
"Verifique permissões do sistema de arquivos.",
|
|
1535
|
+
parent=self,
|
|
1536
|
+
)
|
|
1537
|
+
|
|
1538
|
+
def _open_in_explorer(self, pid: str) -> None:
|
|
1539
|
+
path = self._loader._paths.get(pid, PLUGINS_DIR)
|
|
1540
|
+
if path:
|
|
1541
|
+
folder = path.parent if path.is_file() else path
|
|
1542
|
+
try:
|
|
1543
|
+
if sys.platform == "win32":
|
|
1544
|
+
os.startfile(folder)
|
|
1545
|
+
elif sys.platform == "darwin":
|
|
1546
|
+
subprocess.Popen(["open", str(folder)])
|
|
1547
|
+
else:
|
|
1548
|
+
subprocess.Popen(["xdg-open", str(folder)])
|
|
1549
|
+
except OSError as exc:
|
|
1550
|
+
messagebox.showerror(
|
|
1551
|
+
_t("hc.plugin_panel.erro"), str(exc), parent=self)
|
|
1552
|
+
|
|
1553
|
+
def refresh(self, keep_selection: str | None = None) -> None:
|
|
1554
|
+
"""Atualiza completamente a UI de plugins."""
|
|
1555
|
+
|
|
1556
|
+
tags = [""] + self._get_tags()
|
|
1557
|
+
self._tag_cb.config(values=tags)
|
|
1558
|
+
|
|
1559
|
+
sel = keep_selection or self._selected_id
|
|
1560
|
+
self._apply_filter()
|
|
1561
|
+
|
|
1562
|
+
if sel and sel in self._card_widgets:
|
|
1563
|
+
self._select_plugin(sel)
|
|
1564
|
+
elif sel:
|
|
1565
|
+
self._selected_id = None
|
|
1566
|
+
self._detail_title.config(
|
|
1567
|
+
text=_t("hc.plugin_panel.selecione_um_plugin"))
|
|
1568
|
+
self._readme.config(state="normal")
|
|
1569
|
+
self._readme.delete("1.0", "end")
|
|
1570
|
+
self._readme.config(state="disabled")
|
|
1571
|
+
for w in self._action_bar.winfo_children():
|
|
1572
|
+
w.destroy()
|
|
1573
|
+
|
|
1574
|
+
def _open_store(self) -> None:
|
|
1575
|
+
"""Abre a Plugin Store para buscar e instalar plugins do repositório remoto."""
|
|
1576
|
+
open_plugin_store(
|
|
1577
|
+
parent=self,
|
|
1578
|
+
tmgr=self._tmgr,
|
|
1579
|
+
cfg=self._cfg,
|
|
1580
|
+
loader=self._loader,
|
|
1581
|
+
on_refresh=self.refresh,
|
|
1582
|
+
)
|
|
1583
|
+
|
|
1584
|
+
def apply_theme(self, t: Any) -> None:
|
|
1585
|
+
self.config(bg=t.panel_bg)
|
|
1586
|
+
self.refresh()
|