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.
Files changed (329) hide show
  1. codis-1.1.1.dist-info/METADATA +194 -0
  2. codis-1.1.1.dist-info/RECORD +329 -0
  3. codis-1.1.1.dist-info/WHEEL +5 -0
  4. codis-1.1.1.dist-info/entry_points.txt +5 -0
  5. codis-1.1.1.dist-info/licenses/LICENSE +21 -0
  6. codis-1.1.1.dist-info/top_level.txt +2 -0
  7. run.py +190 -0
  8. src/__init__.py +1 -0
  9. src/__main__.py +81 -0
  10. src/_app_build.py +1507 -0
  11. src/_app_editor.py +1274 -0
  12. src/_app_kui.py +825 -0
  13. src/_app_lsp.py +625 -0
  14. src/_app_recovery.py +189 -0
  15. src/_app_settings.py +1385 -0
  16. src/_app_tools.py +2471 -0
  17. src/_app_webpreview.py +126 -0
  18. src/_font_safety.py +127 -0
  19. src/_shells.py +172 -0
  20. src/app.py +1488 -0
  21. src/chat/__init__.py +1 -0
  22. src/chat/adapters/__init__.py +33 -0
  23. src/chat/adapters/base.py +209 -0
  24. src/chat/adapters/discord.py +190 -0
  25. src/chat/adapters/http.py +78 -0
  26. src/chat/adapters/irc.py +360 -0
  27. src/chat/adapters/matrix.py +219 -0
  28. src/chat/adapters/mattermost.py +178 -0
  29. src/chat/adapters/mqtt.py +165 -0
  30. src/chat/adapters/slack.py +204 -0
  31. src/chat/adapters/telegram.py +117 -0
  32. src/chat/adapters/ws.py +154 -0
  33. src/chat/adapters/xmpp.py +337 -0
  34. src/chat/history.py +76 -0
  35. src/chat/models.py +207 -0
  36. src/chat/probe.py +79 -0
  37. src/chat/session.py +446 -0
  38. src/chat/util.py +125 -0
  39. src/collab/__init__.py +1 -0
  40. src/collab/net.py +411 -0
  41. src/collab/ot.py +311 -0
  42. src/collab/session.py +141 -0
  43. src/collab/tk_adapter.py +134 -0
  44. src/config.py +335 -0
  45. src/constants.py +2552 -0
  46. src/dep_catalog.py +446 -0
  47. src/diff/__init__.py +1 -0
  48. src/diff/engine.py +247 -0
  49. src/dpi.py +30 -0
  50. src/editor/__init__.py +1 -0
  51. src/editor/_pane_lsp.py +2937 -0
  52. src/editor/_pane_utils.py +171 -0
  53. src/editor/autocomplete.py +607 -0
  54. src/editor/code_folding.py +836 -0
  55. src/editor/color_preview.py +382 -0
  56. src/editor/complexity_lens.py +281 -0
  57. src/editor/diff_pane.py +623 -0
  58. src/editor/file_watcher.py +144 -0
  59. src/editor/focus_block.py +236 -0
  60. src/editor/heatmap.py +141 -0
  61. src/editor/inlay_hints.py +366 -0
  62. src/editor/inline_blame.py +429 -0
  63. src/editor/kdocs.py +3376 -0
  64. src/editor/large_file.py +488 -0
  65. src/editor/ligatures.py +180 -0
  66. src/editor/line_numbers.py +598 -0
  67. src/editor/minimap.py +691 -0
  68. src/editor/multi_cursor.py +269 -0
  69. src/editor/pane.py +2082 -0
  70. src/editor/rhythm.py +206 -0
  71. src/editor/save_hooks.py +43 -0
  72. src/editor/smart_selection.py +425 -0
  73. src/editor/smart_tips.py +719 -0
  74. src/editor/snippets.py +411 -0
  75. src/editor/sticky_note_gutter.py +410 -0
  76. src/editor/sticky_scroll.py +385 -0
  77. src/editor/suggest.py +464 -0
  78. src/editor/text_transforms.py +310 -0
  79. src/editor/vim_mode.py +1074 -0
  80. src/events/__init__.py +84 -0
  81. src/events/bus.py +427 -0
  82. src/events/correlator.py +244 -0
  83. src/events/kinds.py +125 -0
  84. src/events/pipeline.py +264 -0
  85. src/events/stream.py +416 -0
  86. src/events/window.py +204 -0
  87. src/extcompat/__init__.py +19 -0
  88. src/extcompat/code/__init__.py +13 -0
  89. src/extcompat/code/consent.py +162 -0
  90. src/extcompat/code/host.py +353 -0
  91. src/extcompat/code/hosts/py_host.py +763 -0
  92. src/extcompat/code/locate.py +105 -0
  93. src/extcompat/code/manager.py +325 -0
  94. src/extcompat/code/permissions.py +154 -0
  95. src/extcompat/code/sandbox.py +60 -0
  96. src/extcompat/colors.py +131 -0
  97. src/extcompat/common.py +184 -0
  98. src/extcompat/cson.py +269 -0
  99. src/extcompat/formats/__init__.py +22 -0
  100. src/extcompat/formats/_tm.py +189 -0
  101. src/extcompat/formats/_util.py +31 -0
  102. src/extcompat/formats/base16.py +66 -0
  103. src/extcompat/formats/brackets.py +172 -0
  104. src/extcompat/formats/eclipse.py +193 -0
  105. src/extcompat/formats/emacs.py +361 -0
  106. src/extcompat/formats/geany.py +147 -0
  107. src/extcompat/formats/generic.py +184 -0
  108. src/extcompat/formats/gtksource.py +117 -0
  109. src/extcompat/formats/helix.py +91 -0
  110. src/extcompat/formats/jetbrains.py +343 -0
  111. src/extcompat/formats/kate.py +130 -0
  112. src/extcompat/formats/micro.py +131 -0
  113. src/extcompat/formats/nano.py +111 -0
  114. src/extcompat/formats/notepadpp.py +140 -0
  115. src/extcompat/formats/pulsar.py +165 -0
  116. src/extcompat/formats/pyides.py +163 -0
  117. src/extcompat/formats/sublime.py +340 -0
  118. src/extcompat/jsonc.py +65 -0
  119. src/extcompat/lessish.py +128 -0
  120. src/extcompat/manager.py +122 -0
  121. src/extcompat/market/__init__.py +63 -0
  122. src/extcompat/market/sources.py +211 -0
  123. src/extcompat/model.py +88 -0
  124. src/extcompat/net.py +228 -0
  125. src/extcompat/openvsx.py +63 -0
  126. src/extcompat/readers.py +362 -0
  127. src/extcompat/registry.py +73 -0
  128. src/extcompat/safexml.py +63 -0
  129. src/extcompat/sexp.py +187 -0
  130. src/extcompat/sources.py +105 -0
  131. src/extcompat/store.py +276 -0
  132. src/extcompat/textmate.py +214 -0
  133. src/extcompat/themes.py +487 -0
  134. src/extcompat/yamlite.py +294 -0
  135. src/fileio.py +94 -0
  136. src/fs_ops.py +106 -0
  137. src/i18n.py +233 -0
  138. src/ia/__init__.py +1 -0
  139. src/ia/actions.py +295 -0
  140. src/ia/approval_gate.py +672 -0
  141. src/ia/checkpoints.py +308 -0
  142. src/ia/context_builder.py +921 -0
  143. src/ia/dialdiff.py +408 -0
  144. src/ia/iaspace.py +2078 -0
  145. src/ia/pair.py +296 -0
  146. src/ia/providers.py +954 -0
  147. src/ia/session.py +335 -0
  148. src/ia/toolbox.py +2524 -0
  149. src/launcher_actions.py +204 -0
  150. src/lint/__init__.py +1 -0
  151. src/lint/manager.py +1058 -0
  152. src/locales/.translate_manifest.json +64170 -0
  153. src/locales/de.json +4936 -0
  154. src/locales/en.json +4936 -0
  155. src/locales/es.json +4936 -0
  156. src/locales/fr.json +4936 -0
  157. src/locales/it.json +4936 -0
  158. src/locales/ja.json +4936 -0
  159. src/locales/ko.json +4936 -0
  160. src/locales/nl.json +4936 -0
  161. src/locales/pl.json +4936 -0
  162. src/locales/pt-BR.json +4936 -0
  163. src/locales/ru.json +4936 -0
  164. src/locales/tr.json +4936 -0
  165. src/locales/uk.json +4936 -0
  166. src/locales/zh-CN.json +4936 -0
  167. src/lsp/__init__.py +26 -0
  168. src/lsp/client.py +2300 -0
  169. src/lsp/dap_client.py +480 -0
  170. src/lsp/edits.py +84 -0
  171. src/lsp/framing.py +73 -0
  172. src/lsp/protocol.py +931 -0
  173. src/main.py +260 -0
  174. src/memtrim.py +91 -0
  175. src/plugins/__init__.py +1 -0
  176. src/plugins/api.py +1761 -0
  177. src/plugins/loader.py +571 -0
  178. src/plugins/process_runner.py +519 -0
  179. src/plugins/registry.py +342 -0
  180. src/plugins/safety.py +367 -0
  181. src/plugins/startup.py +195 -0
  182. src/plugins/store.py +1178 -0
  183. src/proc_registry.py +278 -0
  184. src/pyexec.py +394 -0
  185. src/recovery.py +259 -0
  186. src/stall_trace.py +92 -0
  187. src/standalone.py +1070 -0
  188. src/startup_profile.py +35 -0
  189. src/syntax/__init__.py +1 -0
  190. src/syntax/highlighter.py +776 -0
  191. src/syntax/patterns.py +584 -0
  192. src/system_profile.py +430 -0
  193. src/terminal/backends.py +658 -0
  194. src/terminal/internal.py +346 -0
  195. src/terminal/keys.py +138 -0
  196. src/terminal/palette.py +67 -0
  197. src/terminal/session.py +283 -0
  198. src/terminal/shells.py +79 -0
  199. src/terminal/view.py +489 -0
  200. src/terminal/vt.py +870 -0
  201. src/textfmt.py +22 -0
  202. src/theme/__init__.py +1 -0
  203. src/theme/base.py +1281 -0
  204. src/theme/colors.py +49 -0
  205. src/theme/manager.py +602 -0
  206. src/theme/utils.py +312 -0
  207. src/toolbox.py +329 -0
  208. src/trash_core.py +531 -0
  209. src/ui/__init__.py +1 -0
  210. src/ui/_perf_utils.py +285 -0
  211. src/ui/_persistence_utils.py +93 -0
  212. src/ui/accessibility.py +843 -0
  213. src/ui/activity_bar.py +860 -0
  214. src/ui/app_embed.py +434 -0
  215. src/ui/archive_panel.py +608 -0
  216. src/ui/bookmarks.py +314 -0
  217. src/ui/breadcrumb.py +383 -0
  218. src/ui/calculator_panel.py +982 -0
  219. src/ui/calendar_panel.py +1218 -0
  220. src/ui/chat_panel.py +1271 -0
  221. src/ui/chat_profile_dialog.py +278 -0
  222. src/ui/chat_render.py +128 -0
  223. src/ui/clock_panel.py +810 -0
  224. src/ui/code_outline.py +364 -0
  225. src/ui/code_runner.py +729 -0
  226. src/ui/code_stats.py +546 -0
  227. src/ui/collab_panel.py +1009 -0
  228. src/ui/color_picker.py +547 -0
  229. src/ui/command_palette.py +452 -0
  230. src/ui/cursor_manager.py +750 -0
  231. src/ui/custom_keywords_panel.py +413 -0
  232. src/ui/debug_panel.py +1037 -0
  233. src/ui/dependency_graph.py +692 -0
  234. src/ui/diff_panel.py +381 -0
  235. src/ui/docs_panel.py +514 -0
  236. src/ui/doom_embed.py +349 -0
  237. src/ui/dropdown.py +321 -0
  238. src/ui/easter_eggs.py +979 -0
  239. src/ui/env_manager.py +666 -0
  240. src/ui/extcode_bridge.py +215 -0
  241. src/ui/extcode_dialogs.py +412 -0
  242. src/ui/extcompat_dialog.py +583 -0
  243. src/ui/file_timeline.py +319 -0
  244. src/ui/file_tree.py +1208 -0
  245. src/ui/find_in_files.py +1355 -0
  246. src/ui/flowchart_panel.py +727 -0
  247. src/ui/formatter_panel.py +490 -0
  248. src/ui/git_auth.py +763 -0
  249. src/ui/git_clone_dialog.py +487 -0
  250. src/ui/git_panel.py +1483 -0
  251. src/ui/grab_safe.py +84 -0
  252. src/ui/internal_python_dialog.py +98 -0
  253. src/ui/k_ui/__init__.py +1305 -0
  254. src/ui/k_ui/_bgrenderer.py +317 -0
  255. src/ui/k_ui/_colors.py +213 -0
  256. src/ui/k_ui/_dock.py +545 -0
  257. src/ui/k_ui/_easter.py +290 -0
  258. src/ui/k_ui/_engine.py +5448 -0
  259. src/ui/k_ui/_perf.py +333 -0
  260. src/ui/k_ui/_tkutil.py +7 -0
  261. src/ui/k_ui/_tooltip.py +365 -0
  262. src/ui/k_ui/_widgets.py +1204 -0
  263. src/ui/k_ui/_world.py +837 -0
  264. src/ui/key_remapper.py +856 -0
  265. src/ui/launcher.py +1252 -0
  266. src/ui/lazy_panel.py +73 -0
  267. src/ui/macro_recorder.py +610 -0
  268. src/ui/menu_bar.py +898 -0
  269. src/ui/output_panel.py +321 -0
  270. src/ui/paint_canvas.py +1000 -0
  271. src/ui/paint_engine.py +535 -0
  272. src/ui/paint_panel.py +888 -0
  273. src/ui/panel_detach.py +112 -0
  274. src/ui/performance_panel.py +861 -0
  275. src/ui/pip_manager.py +1758 -0
  276. src/ui/plugin_panel.py +1586 -0
  277. src/ui/pomodoro_panel.py +447 -0
  278. src/ui/problems.py +566 -0
  279. src/ui/process_manager.py +1657 -0
  280. src/ui/project_templates.py +775 -0
  281. src/ui/recovery_dialog.py +122 -0
  282. src/ui/regex_playground.py +304 -0
  283. src/ui/remote_adapters.py +1398 -0
  284. src/ui/remote_browser.py +1224 -0
  285. src/ui/remote_profile_dialog.py +342 -0
  286. src/ui/render_panel.py +1293 -0
  287. src/ui/rest_client.py +549 -0
  288. src/ui/scratchpad.py +548 -0
  289. src/ui/search_bar.py +1274 -0
  290. src/ui/settings_editor.py +3349 -0
  291. src/ui/settings_window.py +1554 -0
  292. src/ui/snippets_panel.py +597 -0
  293. src/ui/sql_studio.py +1815 -0
  294. src/ui/status_bar.py +438 -0
  295. src/ui/tab_bar.py +654 -0
  296. src/ui/task_manager.py +1773 -0
  297. src/ui/terminal.py +525 -0
  298. src/ui/theme_preview_panel.py +851 -0
  299. src/ui/thread_safe_tk.py +152 -0
  300. src/ui/time_tracker.py +574 -0
  301. src/ui/tkbind.py +43 -0
  302. src/ui/todo_panel.py +358 -0
  303. src/ui/toolbox_panels.py +658 -0
  304. src/ui/trash_manager.py +657 -0
  305. src/ui/ui_scale.py +294 -0
  306. src/ui/ux_enhancements.py +41 -0
  307. src/ui/web_preview.py +397 -0
  308. src/ui/webdev.py +630 -0
  309. src/ui/welcome.py +567 -0
  310. src/ui/window_embed.py +1500 -0
  311. src/ui/wizard.py +1550 -0
  312. src/ui/workspace_switcher.py +418 -0
  313. src/ui/workspace_trust.py +370 -0
  314. src/ui/zen_audio.py +354 -0
  315. src/ui/zen_media.py +2271 -0
  316. src/ui/zen_media_client.py +303 -0
  317. src/ui/zen_media_host.py +329 -0
  318. src/ui/zen_player.py +907 -0
  319. src/ui/zen_player_widgets.py +700 -0
  320. src/updater/__init__.py +11 -0
  321. src/updater/assets.py +145 -0
  322. src/updater/backup.py +101 -0
  323. src/updater/channel.py +221 -0
  324. src/updater/dialog.py +492 -0
  325. src/updater/integrity.py +111 -0
  326. src/updater/manager.py +727 -0
  327. src/updater/result.py +114 -0
  328. src/venv_runtime.py +531 -0
  329. src/workspace_state.py +25 -0
src/ui/activity_bar.py ADDED
@@ -0,0 +1,860 @@
1
+ """Codis - ActivityBar com visibilidade customizável de itens.
2
+
3
+ - Visibilidade é salva na config sob a chave "actbar_visible_items"
4
+ - Um botão ⋮ no rodapé abre/fecha o painel de personalização
5
+ - Itens de plugin são adicionados após os nativos e também são alternáveis
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import contextlib
11
+ import json
12
+ import logging
13
+ import tkinter as tk
14
+ from collections.abc import Callable
15
+
16
+ from src.config import ConfigManager
17
+ from src.constants import FONT_UI
18
+ from src.i18n import _t
19
+ from src.theme.manager import ThemeManager
20
+
21
+ logger = logging.getLogger("Codis")
22
+
23
+
24
+ class ActivityBar(tk.Frame):
25
+ """
26
+ Vertical activity bar with:
27
+ - Configurable item visibility (persisted to cfg)
28
+ - Tooltip on hover
29
+ - Badge counters
30
+ - Active indicator
31
+ - Customise panel (flyout) toggled by ⋮ button
32
+ """
33
+
34
+ ITEMS_TOP: list[tuple[str, str, str, str]] = [
35
+ ("explorer", "📁", "actbar.explorer", "Ctrl+Shift+E"),
36
+ ("search", "🔍", "actbar.search", "Ctrl+Shift+F"),
37
+ ("git", "🌿", "actbar.git", "Ctrl+Shift+G"),
38
+ ("run", "▶ ", "actbar.run", "Ctrl+Shift+D"),
39
+ ("extensions", "🔌", "actbar.extensions", "Ctrl+Shift+X"),
40
+ ("ia", "[IA]", "actbar.ia", "Ctrl+Shift+A"),
41
+ ("outline", "🔷", "actbar.outline", ""),
42
+ ("bookmarks", "🔖", "actbar.bookmarks", "Ctrl+Shift+B"),
43
+ ("scratchpad", "📝", "actbar.scratchpad", "Ctrl+Shift+N"),
44
+ ("problems", "⚠ ", "actbar.problems", "Ctrl+Shift+M"),
45
+ ("remote_ssh", "🗂", "actbar.remote_ssh", "Ctrl+Shift+H"),
46
+ ("chat", "💬", "actbar.chat", "Ctrl+Alt+L"),
47
+ ("collab", "🤝", "actbar.collab", ""),
48
+ ("accessibility", "♿", "actbar.accessibility", "Ctrl+Shift+U"),
49
+ ]
50
+ ITEMS_BOTTOM: list[tuple[str, str, str, str]] = [
51
+ ("terminal", "⊟", "actbar.terminal", "Ctrl+`"),
52
+ ("settings", "⚙ ", "actbar.settings", "Ctrl+,"),
53
+ ("theme", "Th", "actbar.theme", ""),
54
+ ]
55
+
56
+ ITEM_GROUPS: dict[str, str] = {
57
+ "explorer": "",
58
+ "git": "",
59
+ "run": "",
60
+ "extensions": "",
61
+ "problems": "",
62
+ }
63
+
64
+ _DEFAULT_VISIBLE = {
65
+ "explorer",
66
+ "search",
67
+ "git",
68
+ "run",
69
+ "terminal",
70
+ "settings",
71
+ "chat",
72
+ }
73
+
74
+ _HEIGHT_PER_ICON = 40
75
+ _WIDE_THRESHOLD = 100
76
+
77
+ def __init__(
78
+ self,
79
+ parent: tk.Widget,
80
+ tmgr: ThemeManager,
81
+ on_activate: Callable[[str], None],
82
+ cfg: ConfigManager = None,
83
+ ) -> None:
84
+ """Cria a barra de atividades lateral do Codis.
85
+
86
+ Args:
87
+ parent: Widget pai Tkinter.
88
+ cfg: Instância de ConfigManager.
89
+ on_panel_change: Callback(panel_id) invocado ao mudar o painel ativo.
90
+ """
91
+ t = tmgr.theme
92
+ super().__init__(parent, bg=t.actbar_bg, width=48, highlightthickness=0, bd=0)
93
+ self.pack_propagate(False)
94
+ self._tmgr = tmgr
95
+ self._on_activate = on_activate
96
+ self._cfg = cfg
97
+ self._active = "explorer"
98
+ self._badges: dict[str, int] = {}
99
+ self._tooltips: dict[str, tk.Toplevel] = {}
100
+ self._tooltip_after_id: str | None = None
101
+ self._plugin_items: list[tuple[str, str, str]] = []
102
+ self._customise_win: tk.Toplevel | None = None
103
+ self._resize_job: str | None = None
104
+ self._item_entries: dict[str, tuple[tk.Frame,
105
+ tk.Label, tk.Label | None]] = {}
106
+
107
+ self._visible: set = self._load_visible()
108
+ self._top_frame: tk.Frame | None = None
109
+ self._bot_frame: tk.Frame | None = None
110
+ self._custom_vars: dict[str, tk.BooleanVar] = {}
111
+ self._build()
112
+
113
+ self.bind("<Configure>", self._on_configure)
114
+
115
+ def _load_visible(self) -> set:
116
+ """Carrega do disco quais painéis estão visíveis e em que ordem."""
117
+ if self._cfg:
118
+ raw = self._cfg.get("actbar_visible_items", None)
119
+ if raw and isinstance(raw, (list, str)):
120
+ with contextlib.suppress(json.JSONDecodeError, ValueError):
121
+ items = json.loads(raw) if isinstance(raw, str) else raw
122
+ return set(items)
123
+ return set(self._DEFAULT_VISIBLE)
124
+
125
+ def _save_visible(self) -> None:
126
+ """Persiste no disco a lista de painéis visíveis e a ordem atual."""
127
+ if self._cfg:
128
+ self._cfg.set("actbar_visible_items", list(self._visible))
129
+
130
+ def _on_configure(self, _e: tk.Event) -> None:
131
+ """Debounced: re-evaluate which icons fit after a resize."""
132
+ if self._resize_job:
133
+ with contextlib.suppress(tk.TclError):
134
+ self.after_cancel(self._resize_job)
135
+ self._resize_job = self.after(120, self._apply_resize)
136
+
137
+ def _apply_resize(self) -> None:
138
+ """Aplica tanto o overflow vertical quanto o deslize horizontal dos ícones."""
139
+ self._auto_hide_overflow()
140
+ self._apply_wide_mode()
141
+
142
+ def _apply_wide_mode(self) -> None:
143
+ """Exibe/oculta rótulo de texto ao lado do ícone conforme a largura da barra.
144
+
145
+ Modo estreito (< _WIDE_THRESHOLD): ícone centralizado, sem texto.
146
+ Modo largo (≥ _WIDE_THRESHOLD): indicador | ícone | texto, usando place
147
+ com coordenadas fixas para garantir ordem visual correta.
148
+ """
149
+ try:
150
+ self.update_idletasks()
151
+ w = self.winfo_width()
152
+ except tk.TclError:
153
+ return
154
+ if w <= 1:
155
+ return
156
+ wide = w >= self._WIDE_THRESHOLD
157
+ t = self._tmgr.theme
158
+
159
+ for key, _icon_str, label_str, _ in (*self.ITEMS_TOP, *self.ITEMS_BOTTOM):
160
+ if key not in self._item_entries:
161
+ continue
162
+ frame, icon_lbl, name_lbl = self._item_entries[key]
163
+ try:
164
+ if not frame.winfo_exists():
165
+ continue
166
+ except tk.TclError:
167
+ continue
168
+
169
+ if wide:
170
+ frame.config(height=40)
171
+ icon_lbl.place_forget()
172
+ icon_lbl.place(x=14, rely=0.5, anchor="w")
173
+ icon_lbl.lift()
174
+ if name_lbl is None:
175
+ cur_bg = t.actbar_active_bg if key == self._active else t.actbar_bg
176
+ cur_fg = t.actbar_active_fg if key == self._active else t.actbar_fg
177
+ name_lbl = tk.Label(
178
+ frame,
179
+ text=_t(label_str),
180
+ bg=cur_bg,
181
+ fg=cur_fg,
182
+ font=(FONT_UI, 9),
183
+ cursor="hand2",
184
+ anchor="w",
185
+ )
186
+ name_lbl.bind(
187
+ "<Button-1>", lambda _e=None, k=key: self._activate(k)
188
+ )
189
+ name_lbl.bind(
190
+ "<Enter>",
191
+ lambda _e=None, k=key, fl=frame, il=icon_lbl, nl_ref=[
192
+ name_lbl
193
+ ]: (
194
+ (
195
+ fl.config(bg=t.actbar_active_bg),
196
+ il.config(bg=t.actbar_active_bg,
197
+ fg=t.actbar_active_fg),
198
+ nl_ref[0].config(
199
+ bg=t.actbar_active_bg, fg=t.actbar_active_fg
200
+ ),
201
+ )
202
+ if k != self._active
203
+ else None
204
+ ),
205
+ )
206
+ name_lbl.bind(
207
+ "<Leave>",
208
+ lambda _e=None, k=key, fl=frame, il=icon_lbl, nl_ref=[
209
+ name_lbl
210
+ ]: (
211
+ (
212
+ fl.config(bg=t.actbar_bg),
213
+ il.config(bg=t.actbar_bg, fg=t.actbar_fg),
214
+ nl_ref[0].config(
215
+ bg=t.actbar_bg, fg=t.actbar_fg),
216
+ )
217
+ if k != self._active
218
+ else None
219
+ ),
220
+ )
221
+ self._item_entries[key] = (frame, icon_lbl, name_lbl)
222
+ name_lbl.place_forget()
223
+ name_lbl.place(x=46, rely=0.5, anchor="w")
224
+ name_lbl.lift()
225
+ else:
226
+ frame.config(height=46)
227
+ icon_lbl.place_forget()
228
+ icon_lbl.place(relx=0.5, rely=0.5, anchor="center")
229
+ if name_lbl is not None:
230
+ name_lbl.place_forget()
231
+
232
+ def _auto_hide_overflow(self) -> None:
233
+ """Oculta itens de menor prioridade se houver transbordamento da barra.
234
+
235
+ Itens ocultados são agrupados num botão '+' que exibe
236
+ um flyout com os ícones ocultos.
237
+ """
238
+ self._resize_job = None
239
+ try:
240
+ available_h = self.winfo_height()
241
+ except tk.TclError:
242
+ return
243
+
244
+ bottom_count = (
245
+ len([k for k, _, _, _ in self.ITEMS_BOTTOM if k in self._visible]) + 1
246
+ )
247
+ top_available = available_h - bottom_count * self._HEIGHT_PER_ICON - 8
248
+
249
+ all_top: list[tuple[str, str, str]] = []
250
+ for k, icon, lbl, _ in self.ITEMS_TOP:
251
+ if k in self._visible:
252
+ all_top.append((k, icon, _t(lbl)))
253
+ for k, icon, lbl in self._plugin_items:
254
+ if k in self._visible:
255
+ all_top.append((k, icon, lbl))
256
+
257
+ max_slots = max(1, top_available // self._HEIGHT_PER_ICON)
258
+
259
+ overflows = all_top[max_slots:]
260
+ if overflows:
261
+ max_slots = max(1, max_slots - 1)
262
+ overflows = all_top[max_slots:]
263
+
264
+ visible_keys = {k for k, _, _ in all_top[:max_slots]}
265
+ overflow_items = all_top[max_slots:]
266
+
267
+ for frame in list(self._top_frame.winfo_children()):
268
+ key = getattr(frame, "_key", None)
269
+ if key is None:
270
+ continue
271
+ if key == "__overflow__":
272
+ frame.destroy()
273
+ continue
274
+ if key in visible_keys:
275
+ if not frame.winfo_ismapped():
276
+ frame.pack(fill="x")
277
+ else:
278
+ if frame.winfo_ismapped():
279
+ frame.pack_forget()
280
+
281
+ if overflow_items:
282
+ self._add_overflow_btn(overflow_items)
283
+
284
+ def _add_overflow_btn(self, items: list[tuple[str, str, str]]) -> None:
285
+ """Add a '⋯' overflow button to the top frame with a flyout menu."""
286
+ t = self._tmgr.theme
287
+ frame = tk.Frame(self._top_frame, bg=t.actbar_bg, width=48, height=40)
288
+ frame.pack(fill="x")
289
+ frame.pack_propagate(False)
290
+ object.__setattr__(frame, "_key", "__overflow__")
291
+
292
+ lbl = tk.Label(
293
+ frame,
294
+ text="⋯",
295
+ bg=t.actbar_bg,
296
+ fg=t.fg_muted,
297
+ font=(FONT_UI, 14),
298
+ cursor="hand2",
299
+ )
300
+ lbl.place(relx=0.5, rely=0.5, anchor="center")
301
+
302
+ badge = tk.Label(
303
+ frame,
304
+ text=str(len(items)),
305
+ bg=t.accent,
306
+ fg="#fff",
307
+ font=(FONT_UI, 6, "bold"),
308
+ padx=2,
309
+ )
310
+ badge.place(relx=0.72, rely=0.15)
311
+
312
+ def _show_flyout(_e=None):
313
+ self._show_overflow_flyout(items)
314
+
315
+ for w in (frame, lbl):
316
+ w.bind("<Button-1>", _show_flyout)
317
+ w.bind("<Enter>", lambda _, ic=lbl: ic.config(fg=t.actbar_active_fg))
318
+ w.bind("<Leave>", lambda _, ic=lbl: ic.config(fg=t.fg_muted))
319
+
320
+ def _show_overflow_flyout(self, items: list[tuple[str, str, str]]) -> None:
321
+ """Show a flyout menu with the overflow icons."""
322
+ t = self._tmgr.theme
323
+ win = tk.Toplevel(self)
324
+ win.wm_overrideredirect(True)
325
+ win.wm_attributes("-topmost", True)
326
+ win.config(bg=t.floating_bg)
327
+ win.geometry("+9999+9999")
328
+
329
+ outer = tk.Frame(
330
+ win,
331
+ bg=t.floating_bg,
332
+ highlightthickness=1,
333
+ highlightbackground=getattr(t, "floating_border", "#3d4455"),
334
+ )
335
+ outer.pack(fill="both", expand=True)
336
+
337
+ for key, icon, label in items:
338
+ row = tk.Frame(outer, bg=t.floating_bg, cursor="hand2")
339
+ row.pack(fill="x", padx=2, pady=1)
340
+ icon_lbl = tk.Label(
341
+ row, text=icon, bg=t.floating_bg, fg=t.fg, font=(FONT_UI, 16), width=3
342
+ )
343
+ icon_lbl.pack(side="left", padx=4, pady=4)
344
+ name_lbl = tk.Label(
345
+ row,
346
+ text=label,
347
+ bg=t.floating_bg,
348
+ fg=t.fg,
349
+ font=(FONT_UI, 9),
350
+ anchor="w",
351
+ )
352
+ name_lbl.pack(side="left", fill="x", expand=True, padx=4)
353
+
354
+ def _click(_, k=key, w=win):
355
+ w.destroy()
356
+ self._activate(k)
357
+
358
+ def _enter(_, r=row, il=icon_lbl, nl=name_lbl):
359
+ r.config(bg=t.sel_bg)
360
+ il.config(bg=t.sel_bg)
361
+ nl.config(bg=t.sel_bg)
362
+
363
+ def _leave(_, r=row, il=icon_lbl, nl=name_lbl):
364
+ r.config(bg=t.floating_bg)
365
+ il.config(bg=t.floating_bg)
366
+ nl.config(bg=t.floating_bg)
367
+
368
+ for w2 in (row, icon_lbl, name_lbl):
369
+ w2.bind("<Button-1>", _click)
370
+ w2.bind("<Enter>", _enter)
371
+ w2.bind("<Leave>", _leave)
372
+
373
+ win.update_idletasks()
374
+ h_req = win.winfo_reqheight()
375
+ bx = self.winfo_rootx() + self.winfo_width() + 2
376
+ by = self.winfo_rooty() + self.winfo_height() - h_req
377
+ win.geometry(f"+{bx}+{by}")
378
+ win.bind("<FocusOut>", lambda _: win.destroy()
379
+ if win.winfo_exists() else None)
380
+ win.focus_set()
381
+
382
+ def _build(self) -> None:
383
+ t = self._tmgr.theme
384
+
385
+ for child in self.winfo_children():
386
+ with contextlib.suppress(tk.TclError):
387
+ child.destroy()
388
+
389
+ self._top_frame = tk.Frame(self, bg=t.actbar_bg)
390
+ self._top_frame.pack(side="top", fill="x")
391
+
392
+ self._bot_frame = tk.Frame(self, bg=t.actbar_bg)
393
+ self._bot_frame.pack(side="bottom", fill="x")
394
+
395
+ for key, icon, label, shortcut in self.ITEMS_TOP:
396
+ if key in self._visible:
397
+ self._add_item(self._top_frame, key, icon, label, shortcut)
398
+
399
+ self._add_customise_btn()
400
+
401
+ for key, icon, label, shortcut in self.ITEMS_BOTTOM:
402
+ if key in self._visible:
403
+ self._add_item(self._bot_frame, key, icon, label, shortcut)
404
+
405
+ for key, icon, label in self._plugin_items:
406
+ if key in self._visible:
407
+ self._add_item(self._top_frame, key, icon, label, "")
408
+
409
+ def _add_customise_btn(self) -> None:
410
+ """Adiciona o botão de personalização ao final da barra de atividades."""
411
+ t = self._tmgr.theme
412
+ frame = tk.Frame(self._bot_frame, bg=t.actbar_bg, width=48, height=36)
413
+ frame.pack(fill="x")
414
+ frame.pack_propagate(False)
415
+ lbl = tk.Label(
416
+ frame,
417
+ text="⋮",
418
+ bg=t.actbar_bg,
419
+ fg=t.fg_muted,
420
+ font=(FONT_UI, 14),
421
+ cursor="hand2",
422
+ )
423
+ lbl.place(relx=0.5, rely=0.5, anchor="center")
424
+ for w in (frame, lbl):
425
+ w.bind("<Button-1>", lambda _: self._toggle_customise())
426
+ w.bind("<Enter>", lambda _, ic=lbl: ic.config(fg=t.actbar_active_fg))
427
+ w.bind("<Leave>", lambda _, ic=lbl: ic.config(fg=t.fg_muted))
428
+
429
+ def _add_item(
430
+ self, parent: tk.Widget, key: str, icon: str, label: str, shortcut: str
431
+ ) -> None:
432
+ """Adiciona um item à activity bar com visual aprimorado."""
433
+ t = self._tmgr.theme
434
+ is_active = key == self._active
435
+
436
+ bg = t.actbar_active_bg if is_active else t.actbar_bg
437
+ fg = t.actbar_active_fg if is_active else t.actbar_fg
438
+
439
+ frame = tk.Frame(parent, bg=bg, width=48, height=46)
440
+ frame.pack(fill="x")
441
+ frame.pack_propagate(False)
442
+
443
+ indicator = tk.Frame(
444
+ frame,
445
+ bg=t.accent if is_active else t.actbar_bg,
446
+ width=3,
447
+ )
448
+ indicator.place(x=0, y=6, height=34)
449
+
450
+ lbl = tk.Label(
451
+ frame,
452
+ text=icon,
453
+ bg=bg,
454
+ fg=fg,
455
+ font=(FONT_UI, 16),
456
+ cursor="hand2",
457
+ )
458
+ lbl.place(relx=0.5, rely=0.5, anchor="center")
459
+
460
+ badge = tk.Label(
461
+ frame,
462
+ text="",
463
+ bg=t.err_fg,
464
+ fg="#fff",
465
+ font=(FONT_UI, 7, "bold"),
466
+ padx=2,
467
+ pady=0,
468
+ )
469
+ if key in self._badges and self._badges[key] > 0:
470
+ badge.config(text=str(min(self._badges[key], 99)))
471
+ badge.place(relx=0.68, rely=0.08)
472
+
473
+ def on_click(_e=None, k=key):
474
+ self._activate(k)
475
+
476
+ def on_enter(_e=None, k=key, fl=frame, ic=lbl):
477
+ if k != self._active:
478
+ fl.config(bg=t.actbar_active_bg)
479
+ ic.config(fg=t.actbar_active_fg, bg=t.actbar_active_bg)
480
+ if self._tooltip_after_id:
481
+ self.after_cancel(self._tooltip_after_id)
482
+ self._tooltip_after_id = None
483
+ self._tooltip_after_id = self.after(
484
+ 350, lambda: self._show_tooltip(k, label, shortcut, fl)
485
+ )
486
+
487
+ def on_leave(_e=None, k=key, fl=frame, ic=lbl):
488
+ if k != self._active:
489
+ fl.config(bg=t.actbar_bg)
490
+ ic.config(fg=t.actbar_fg, bg=t.actbar_bg)
491
+ if self._tooltip_after_id:
492
+ self.after_cancel(self._tooltip_after_id)
493
+ self._tooltip_after_id = None
494
+ self._hide_tooltip(k)
495
+
496
+ for w in (frame, lbl):
497
+ w.bind("<Button-1>", on_click)
498
+ w.bind("<Enter>", on_enter)
499
+ w.bind("<Leave>", on_leave)
500
+
501
+ object.__setattr__(frame, "_key", key)
502
+ object.__setattr__(frame, "_indicator", indicator)
503
+ object.__setattr__(frame, "_icon_lbl", lbl)
504
+ object.__setattr__(frame, "_badge", badge)
505
+ self._item_entries[key] = (frame, lbl, None)
506
+
507
+ def _show_tooltip(
508
+ self, key: str, label: str, shortcut: str, frame: tk.Widget
509
+ ) -> None:
510
+ """Exibe tooltip aprimorado com label + shortcut para o botão."""
511
+ if not frame.winfo_exists():
512
+ return
513
+ self._hide_tooltip(key)
514
+ t = self._tmgr.theme
515
+ tip = tk.Toplevel(self)
516
+ tip.wm_overrideredirect(True)
517
+ tip.wm_attributes("-topmost", True)
518
+
519
+ outer = tk.Frame(
520
+ tip,
521
+ bg=t.floating_bg,
522
+ highlightthickness=1,
523
+ highlightbackground=t.floating_border,
524
+ )
525
+ outer.pack()
526
+
527
+ display_label = _t(label) if "." in label else label
528
+
529
+ name_row = tk.Frame(outer, bg=t.floating_bg)
530
+ name_row.pack(fill="x", padx=10, pady=(6, 2 if shortcut else 6))
531
+ tk.Label(
532
+ name_row,
533
+ text=display_label,
534
+ bg=t.floating_bg,
535
+ fg=t.fg,
536
+ font=(FONT_UI, 9, "bold"),
537
+ anchor="w",
538
+ ).pack(side="left")
539
+
540
+ if shortcut:
541
+ sc_row = tk.Frame(outer, bg=t.floating_bg)
542
+ sc_row.pack(fill="x", padx=10, pady=(0, 6))
543
+ sc_bg = getattr(t, "sel_bg", t.floating_bg)
544
+ sc_label = tk.Label(
545
+ sc_row,
546
+ text=f" {shortcut} ",
547
+ bg=sc_bg,
548
+ fg=getattr(t, "accent", t.fg_muted),
549
+ font=(FONT_UI, 8),
550
+ relief="flat",
551
+ padx=2,
552
+ )
553
+ sc_label.pack(side="left")
554
+
555
+ try:
556
+ x = self.winfo_rootx() + self.winfo_width() + 6
557
+ y = frame.winfo_rooty() + frame.winfo_height() // 2 - 16
558
+ tip.geometry(f"+{x}+{y}")
559
+ except tk.TclError:
560
+ tip.destroy()
561
+ return
562
+ self._tooltips[key] = tip
563
+
564
+ def _hide_tooltip(self, key: str) -> None:
565
+ """Oculta o tooltip atual."""
566
+ tip = self._tooltips.pop(key, None)
567
+ if tip and tip.winfo_exists():
568
+ with contextlib.suppress(tk.TclError):
569
+ tip.destroy()
570
+
571
+ def _destroy_all_tooltips(self) -> None:
572
+ """Remove todos os tooltips flutuantes ativos da activity bar."""
573
+ for tip in self._tooltips.values():
574
+ if tip and tip.winfo_exists():
575
+ with contextlib.suppress(tk.TclError):
576
+ tip.destroy()
577
+ self._tooltips.clear()
578
+
579
+ def _activate(self, key: str) -> None:
580
+ """Ativa o item indicado, atualizando visual de todos os itens."""
581
+ t = self._tmgr.theme
582
+ self._active = key
583
+ for parent in (self._top_frame, self._bot_frame):
584
+ if parent is None:
585
+ continue
586
+ for frame in parent.winfo_children():
587
+ k = getattr(frame, "_key", None)
588
+ ind = getattr(frame, "_indicator", None)
589
+ ic = getattr(frame, "_icon_lbl", None)
590
+ if not k or not ind or not ic:
591
+ continue
592
+ if k == key:
593
+ ind.config(bg=t.accent)
594
+ ic.config(fg=t.actbar_active_fg, bg=t.actbar_active_bg)
595
+ frame.config(bg=t.actbar_active_bg)
596
+ else:
597
+ ind.config(bg=t.actbar_bg)
598
+ ic.config(fg=t.actbar_fg, bg=t.actbar_bg)
599
+ frame.config(bg=t.actbar_bg)
600
+ self._on_activate(key)
601
+
602
+ def set_badge(self, key: str, count: int) -> None:
603
+ """Atualiza o badge numérico de um item da activity bar."""
604
+ self._badges[key] = count
605
+ for parent in (self._top_frame, self._bot_frame):
606
+ for frame in parent.winfo_children():
607
+ if getattr(frame, "_key", None) == key:
608
+ badge = getattr(frame, "_badge", None)
609
+ if badge:
610
+ if count > 0:
611
+ badge.config(
612
+ text=str(min(count, 99)), bg=self._tmgr.theme.err_fg
613
+ )
614
+ badge.place(relx=0.7, rely=0.1)
615
+ else:
616
+ badge.config(text="")
617
+ badge.place_forget()
618
+
619
+ def add_plugin_item(self, key: str, icon: str, label: str) -> None:
620
+ """Adiciona um item de plugin à activity bar."""
621
+ if any(k == key for k, _, _ in self._plugin_items):
622
+ return
623
+ self._plugin_items.append((key, icon, label))
624
+
625
+ if key not in self._visible:
626
+ self._visible.add(key)
627
+ if key in self._visible:
628
+ self._add_item(self._top_frame, key, icon, label, "")
629
+
630
+ def remove_plugin_item(self, key: str) -> None:
631
+ """Remove da activity bar o item de um plugin."""
632
+ self._plugin_items = [item for item in self._plugin_items if item[0] != key]
633
+ self._visible.discard(key)
634
+ entry = self._item_entries.pop(key, None)
635
+ if entry is not None:
636
+ with contextlib.suppress(tk.TclError):
637
+ entry[0].destroy()
638
+
639
+ def _toggle_customise(self) -> None:
640
+ """Alterna a visibilidade do painel de personalização da barra."""
641
+ if self._customise_win and self._customise_win.winfo_exists():
642
+ self._customise_win.destroy()
643
+ self._customise_win = None
644
+ else:
645
+ self._open_customise()
646
+
647
+ def _open_customise(self) -> None:
648
+
649
+ t = self._tmgr.theme
650
+ win = tk.Toplevel(self)
651
+ win.wm_overrideredirect(True)
652
+ win.wm_attributes("-topmost", True)
653
+ win.config(bg=t.floating_bg)
654
+ self._customise_win = win
655
+
656
+ outer = tk.Frame(
657
+ win,
658
+ bg=t.floating_bg,
659
+ highlightthickness=1,
660
+ highlightbackground=t.floating_border,
661
+ )
662
+ outer.pack(fill="both", expand=True)
663
+
664
+ hdr = tk.Frame(outer, bg=t.activity_bg)
665
+ hdr.pack(fill="x")
666
+ tk.Label(
667
+ hdr,
668
+ text=" ⚙ " + _t("ui.settings_title"),
669
+ bg=t.activity_bg,
670
+ fg=t.fg,
671
+ font=(FONT_UI, 9, "bold"),
672
+ ).pack(side="left", padx=4, pady=6)
673
+ close_btn = tk.Label(
674
+ hdr,
675
+ text="✕",
676
+ bg=t.activity_bg,
677
+ fg=t.fg_muted,
678
+ font=(FONT_UI, 9),
679
+ cursor="hand2",
680
+ padx=8,
681
+ )
682
+ close_btn.pack(side="right", pady=6)
683
+ close_btn.bind("<Button-1>", lambda _: win.destroy())
684
+
685
+ tk.Frame(outer, bg=t.border, height=1).pack(fill="x")
686
+
687
+ canvas = tk.Canvas(outer, bg=t.floating_bg,
688
+ highlightthickness=0, width=220)
689
+ vsb = tk.Scrollbar(outer, orient="vertical", command=canvas.yview)
690
+ canvas.config(yscrollcommand=vsb.set)
691
+ vsb.pack(side="right", fill="y")
692
+ canvas.pack(fill="both", expand=True)
693
+
694
+ content = tk.Frame(canvas, bg=t.floating_bg)
695
+ win_id = canvas.create_window((0, 0), window=content, anchor="nw")
696
+
697
+ def _on_cfg(_e=None):
698
+ canvas.config(scrollregion=canvas.bbox("all"))
699
+ canvas.itemconfig(win_id, width=canvas.winfo_width())
700
+
701
+ content.bind("<Configure>", _on_cfg)
702
+ canvas.bind("<Configure>", _on_cfg)
703
+
704
+ def _on_wheel(e):
705
+ delta = -1 * \
706
+ (e.delta // 120) if e.delta else (1 if e.num == 5 else -1)
707
+ canvas.yview_scroll(delta, "units")
708
+
709
+ canvas.bind("<MouseWheel>", _on_wheel)
710
+ canvas.bind("<Button-4>", _on_wheel)
711
+ canvas.bind("<Button-5>", _on_wheel)
712
+
713
+ all_items: list[tuple[str, str, str]] = []
714
+ for key, icon, label, _ in self.ITEMS_TOP:
715
+ all_items.append((key, icon, label))
716
+ for key, icon, label in self._plugin_items:
717
+ all_items.append((key, icon, label))
718
+ for key, icon, label, _ in self.ITEMS_BOTTOM:
719
+ all_items.append((key, icon, label))
720
+
721
+ self._custom_vars = {}
722
+
723
+ tk.Label(
724
+ content,
725
+ text=_t("hc.activity_bar.top_items"),
726
+ bg=t.floating_bg,
727
+ fg=t.fg_muted,
728
+ font=(FONT_UI, 7, "bold"),
729
+ ).pack(anchor="w", padx=8, pady=(8, 2))
730
+
731
+ sections = [
732
+ (
733
+ _t("actbar.customise_top"),
734
+ [(k, i, _t(ln_)) for k, i, ln_, _ in self.ITEMS_TOP],
735
+ ),
736
+ (_t("actbar.customise_plugins"), self._plugin_items),
737
+ (
738
+ _t("actbar.customise_bottom"),
739
+ [(k, i, _t(ln_)) for k, i, ln_, _ in self.ITEMS_BOTTOM],
740
+ ),
741
+ ]
742
+ for sec_title, items in sections:
743
+ if not items:
744
+ continue
745
+ tk.Frame(content, bg=t.border, height=1).pack(
746
+ fill="x", padx=8, pady=2)
747
+ tk.Label(
748
+ content,
749
+ text=f" {sec_title}",
750
+ bg=t.floating_bg,
751
+ fg=t.fg_muted,
752
+ font=(FONT_UI, 7, "bold"),
753
+ ).pack(anchor="w", padx=8, pady=(4, 0))
754
+ for key, icon, label in items:
755
+ row = tk.Frame(content, bg=t.floating_bg)
756
+ row.pack(fill="x", padx=8, pady=1)
757
+ var = tk.BooleanVar(value=key in self._visible)
758
+ self._custom_vars[key] = var
759
+ cb = tk.Checkbutton(
760
+ row,
761
+ variable=var,
762
+ bg=t.floating_bg,
763
+ fg=t.fg,
764
+ activebackground=t.floating_bg,
765
+ selectcolor=t.sel_bg,
766
+ relief="flat",
767
+ command=lambda k=key, v=var: self._toggle_item(k, v.get()),
768
+ )
769
+ cb.pack(side="left")
770
+ tk.Label(
771
+ row,
772
+ text=f"{icon} {label}",
773
+ bg=t.floating_bg,
774
+ fg=t.fg,
775
+ font=(FONT_UI, 9),
776
+ ).pack(side="left", padx=2)
777
+
778
+ tk.Frame(outer, bg=t.border, height=1).pack(fill="x")
779
+ footer = tk.Frame(outer, bg=t.floating_bg)
780
+ footer.pack(fill="x", padx=8, pady=4)
781
+ reset_btn = tk.Label(
782
+ footer,
783
+ text=_t("hc.activity_bar.reset_defaults"),
784
+ bg=t.floating_bg,
785
+ fg=t.fg_muted,
786
+ font=(FONT_UI, 8),
787
+ cursor="hand2",
788
+ )
789
+ reset_btn.pack(side="left")
790
+ reset_btn.bind("<Button-1>", lambda _: self._reset_defaults())
791
+ reset_btn.bind("<Enter>", lambda _, w=reset_btn: w.config(fg=t.accent))
792
+ reset_btn.bind("<Leave>", lambda _,
793
+ w=reset_btn: w.config(fg=t.fg_muted))
794
+
795
+ win.update_idletasks()
796
+ with contextlib.suppress(tk.TclError):
797
+ x = self.winfo_rootx() + self.winfo_width() + 2
798
+ y = self.winfo_rooty() + self.winfo_height() - win.winfo_reqheight() - 10
799
+ y = max(y, self.winfo_rooty())
800
+ win.geometry(f"+{x}+{y}")
801
+
802
+ win.bind("<FocusOut>", lambda _: win.destroy()
803
+ if win.winfo_exists() else None)
804
+
805
+ def _toggle_item(self, key: str, visible: bool) -> None:
806
+ if visible:
807
+ self._visible.add(key)
808
+ else:
809
+ self._visible.discard(key)
810
+ self._save_visible()
811
+ self._rebuild()
812
+
813
+ def _reset_defaults(self) -> None:
814
+ """Restaura configurações padrão de fábrica."""
815
+ self._visible = set(self._DEFAULT_VISIBLE)
816
+
817
+ for key, _, _ in self._plugin_items:
818
+ self._visible.add(key)
819
+ self._save_visible()
820
+ if self._customise_win and self._customise_win.winfo_exists():
821
+ self._customise_win.destroy()
822
+ self._customise_win = None
823
+ self._rebuild()
824
+
825
+ def _rebuild(self) -> None:
826
+ """Reconstrói a activity bar completa refletindo o estado atual dos painéis."""
827
+ self._destroy_all_tooltips()
828
+ active = self._active
829
+ plugins = list(self._plugin_items)
830
+ self._plugin_items = []
831
+ for child in self.winfo_children():
832
+ child.destroy()
833
+ self._top_frame = None
834
+ self._bot_frame = None
835
+ self._build()
836
+
837
+ for key, icon, label in plugins:
838
+ if not any(k == key for k, _, _ in self._plugin_items):
839
+ self.add_plugin_item(key, icon, label)
840
+
841
+ if active in self._visible:
842
+ self._active = active
843
+ self._activate(active)
844
+
845
+ def apply_theme(self, tmgr: ThemeManager) -> None:
846
+ """Aplica o tema reconstruindo a activity bar. Aceita ThemeManager ou Theme."""
847
+
848
+ if hasattr(tmgr, "theme"):
849
+ self._tmgr = tmgr
850
+ else:
851
+ pass
852
+ self.config(bg=self._tmgr.theme.actbar_bg)
853
+ self._destroy_all_tooltips()
854
+ saved_plugins = list(self._plugin_items)
855
+ self._plugin_items = []
856
+ for child in self.winfo_children():
857
+ child.destroy()
858
+ self._build()
859
+ for key, icon, label in saved_plugins:
860
+ self.add_plugin_item(key, icon, label)