Skip to content

basic support for custom workspace icons #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def load_config():
"bar_workspace_use_chinese_numerals", False
)
BAR_HIDE_SPECIAL_WORKSPACE = config.get("bar_hide_special_workspace", True)
BAR_WORKSPACE_ICONS = config.get("bar_workspace_icons", {})
BAR_THEME = config.get("bar_theme", "Pills")
DOCK_THEME = config.get("dock_theme", "Pills")
PANEL_THEME = config.get("panel_theme", "Pills")
Expand Down
25 changes: 17 additions & 8 deletions modules/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@
tooltip_overview = """<b>Overview</b>"""


def build_caption(i: int):
"""Build the label for a given workspace number"""
label = data.BAR_WORKSPACE_ICONS.get(str(i)) or data.BAR_WORKSPACE_ICONS.get('default')
if label is None:
return (
CHINESE_NUMERALS[i - 1]
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS
and 1 <= i <= len(CHINESE_NUMERALS)
else str(i)
)
else:
return label


class Bar(Window):
def __init__(self, **kwargs):
super().__init__(
Expand Down Expand Up @@ -135,12 +149,7 @@ def __init__(self, **kwargs):
h_align="center",
v_align="center",
id=i,
label=(
CHINESE_NUMERALS[i - 1]
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS
and 1 <= i <= len(CHINESE_NUMERALS)
else str(i)
),
label=build_caption(i),
)
for i in range(1, 11)
],
Expand All @@ -155,7 +164,7 @@ def __init__(self, **kwargs):
name="workspaces-container",
children=(
self.workspaces
if not data.BAR_WORKSPACE_SHOW_NUMBER
if not (data.BAR_WORKSPACE_SHOW_NUMBER or data.BAR_WORKSPACE_ICONS)
else self.workspaces_num
),
)
Expand Down Expand Up @@ -603,7 +612,7 @@ def toggle_hidden(self):
self.bar_inner.remove_style_class("hidden")

def chinese_numbers(self):
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS:
if data.BAR_WORKSPACE_USE_CHINESE_NUMERALS or data.BAR_WORKSPACE_ICONS:
self.workspaces_num.add_style_class("chinese")
else:
self.workspaces_num.remove_style_class("chinese")