-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon_style.py
More file actions
77 lines (68 loc) · 2.89 KB
/
Copy pathicon_style.py
File metadata and controls
77 lines (68 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""Colour vs glyph icon style.
Every concept ships two icons: a colour tile ``linuxpop-<concept>`` and a
mono glyph ``linuxpop-<concept>-symbolic`` (the same mark, GTK-recolourable).
The user picks between them in Settings via the ``icon_style`` setting:
* ``color`` (default) - vibrant gradient tiles for branded/destination
actions; plain text-edit actions (cut, bold, ...) stay as their system
symbolic glyphs.
* ``glyph`` - every concept renders as its mono glyph, matching the system
symbolic icons so the whole popup is one uniform style.
`resolve()` maps whatever icon name a plugin declares to the right variant.
Unmapped names (edit-cut-symbolic etc.) pass through untouched.
"""
from __future__ import annotations
# plugin-declared icon name -> concept that has colour + mono variants
_CONCEPT_BY_ICON = {
"linuxpop-google-ai": "google-ai",
"linuxpop-claude": "claude",
"linuxpop-chatgpt": "chatgpt",
"linuxpop-gemini": "gemini",
"linuxpop-perplexity": "perplexity",
"linuxpop-youtube": "youtube",
"linuxpop-wikipedia": "wikipedia",
"mark-location-symbolic": "maps",
"applications-development-symbolic": "github",
"help-faq-symbolic": "stackoverflow",
"system-search-symbolic": "google",
"preferences-desktop-locale-symbolic": "translate",
"accessories-dictionary-symbolic": "dictionary",
"package-x-generic-symbolic": "package",
"linuxpop-calculator-symbolic": "calculator",
"linuxpop-clipboard-symbolic": "clipboard",
"linuxpop-json-symbolic": "json",
"linuxpop-qr-symbolic": "qr",
"linuxpop-base64-encode-symbolic": "base64",
"linuxpop-case-upper-symbolic": "case",
"linuxpop-url-encode-symbolic": "url",
"linuxpop-wordcount-symbolic": "wordcount",
}
# Concept ordering for the Settings preview (most recognisable first).
PREVIEW_CONCEPTS = [
"claude", "chatgpt", "gemini", "google-ai", "youtube",
"maps", "translate", "github", "package", "clipboard",
]
def current_style() -> str:
try:
from settings import get_settings
s = (get_settings().get("icon_style") or "color").strip().lower()
except Exception:
s = "color"
return s if s in ("color", "glyph") else "color"
def resolve(icon_name: str, style: "str | None" = None) -> str:
"""Return the icon name to actually load for the current icon_style."""
if not icon_name:
return icon_name
concept = _CONCEPT_BY_ICON.get(icon_name)
if concept is None:
# Already a concept colour name? (e.g. a future plugin sets
# icon="linuxpop-maps" directly.)
if icon_name.startswith("linuxpop-") and icon_name[9:] in set(
_CONCEPT_BY_ICON.values()):
concept = icon_name[9:]
else:
return icon_name
if style is None:
style = current_style()
if style == "glyph":
return f"linuxpop-{concept}-symbolic"
return f"linuxpop-{concept}"