♻️ refactor(launcher): improve code structure and plugin functionality
This commit is contained in:
1 parent
4822693298
commit
5495233667
31 files changed
+536
-618
No files matched your search
@@ -52,10 +52,10 @@ def patched_do_update_properties(self, *_):
|
||||
def _try_load_icon_from_path(self, icon_path):
|
||||
try:
|
||||
# Check if it's a file path and handle it directly
|
||||
if os.path.isabs(icon_path) or '/' in icon_path:
|
||||
if os.path.isabs(icon_path) or "/" in icon_path:
|
||||
# Try to load as SVG from the original path if it exists
|
||||
if os.path.exists(icon_path):
|
||||
if icon_path.lower().endswith('.svg'):
|
||||
if icon_path.lower().endswith(".svg"):
|
||||
# Load SVG directly
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
|
||||
icon_path, self._icon_size, self._icon_size
|
||||
@@ -80,11 +80,13 @@ def _try_load_icon_from_path(self, icon_path):
|
||||
# Remove extension for theme lookup
|
||||
name_without_ext = os.path.splitext(filename)[0]
|
||||
default_theme = Gtk.IconTheme.get_default()
|
||||
|
||||
|
||||
# Try filename without extension
|
||||
if default_theme.has_icon(name_without_ext):
|
||||
pixbuf = default_theme.load_icon(
|
||||
name_without_ext, self._icon_size, Gtk.IconLookupFlags.FORCE_SIZE
|
||||
name_without_ext,
|
||||
self._icon_size,
|
||||
Gtk.IconLookupFlags.FORCE_SIZE,
|
||||
)
|
||||
if pixbuf:
|
||||
self._image.set_from_pixbuf(pixbuf)
|
||||
@@ -109,9 +111,9 @@ def _try_load_icon_from_path(self, icon_path):
|
||||
"/usr/local/share/icons",
|
||||
"/usr/local/share/pixmaps",
|
||||
os.path.expanduser("~/.local/share/icons"),
|
||||
os.path.expanduser("~/.icons")
|
||||
os.path.expanduser("~/.icons"),
|
||||
]
|
||||
|
||||
|
||||
filename = os.path.basename(icon_path)
|
||||
for icon_dir in common_icon_dirs:
|
||||
potential_path = os.path.join(icon_dir, filename)
|
||||
@@ -129,7 +131,7 @@ def _try_load_icon_from_path(self, icon_path):
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@@ -146,11 +148,11 @@ def apply_enhanced_system_tray():
|
||||
# Store original method
|
||||
global original_do_update_properties
|
||||
original_do_update_properties = SystemTrayItem.do_update_properties
|
||||
|
||||
|
||||
# Attach helper methods to SystemTrayItem class
|
||||
SystemTrayItem._try_load_icon_from_path = _try_load_icon_from_path
|
||||
SystemTrayItem._set_tooltip = _set_tooltip
|
||||
|
||||
|
||||
# Replace the do_update_properties method
|
||||
SystemTrayItem.do_update_properties = patched_do_update_properties
|
||||
|
||||
|
||||
Reference in new issue
Block a user