Skip to content

Commit 1c503a0

Browse files
committed
Best icons
1 parent ec1e1a5 commit 1c503a0

4 files changed

Lines changed: 88 additions & 26 deletions

File tree

Binary file not shown.

bigcontrolcenter/usr/share/biglinux/bigcontrolcenter/ui/program_grid.py

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,47 +141,101 @@ def _create_program_button(self, program):
141141

142142
return button
143143

144+
# Icons that need special handling (manual search with size priority)
145+
_SPECIAL_ICONS = {
146+
'scanner',
147+
'network-workgroup',
148+
'smartphone',
149+
'network-wired-symbolic',
150+
}
151+
152+
# Cache for special icon paths
153+
_special_icon_cache = {}
154+
155+
def _find_special_icon(self, icon_name):
156+
"""
157+
Manual search for specific icons that GTK doesn't detect correctly.
158+
Priority order: scalable, 48, 64, 128, 32, 22, 16
159+
"""
160+
# Check cache first
161+
if icon_name in self._special_icon_cache:
162+
return self._special_icon_cache[icon_name]
163+
164+
# Get current theme
165+
theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
166+
theme_name = theme.get_theme_name()
167+
168+
# Directories to search (theme first, then common themes, then hicolor)
169+
search_bases = [
170+
f"/usr/share/icons/{theme_name}",
171+
]
172+
173+
# Add common inherited themes
174+
for parent_theme in ["bigicons-papient", "bigicons-papient-dark", "breeze", "breeze-dark", "Adwaita"]:
175+
if parent_theme != theme_name:
176+
search_bases.append(f"/usr/share/icons/{parent_theme}")
177+
178+
search_bases.append("/usr/share/icons/hicolor")
179+
180+
# Size priority
181+
size_dirs = ["scalable", "48x48", "64x64", "32x32", "48", "64", "128"]
182+
# Extended subdirs list
183+
subdirs = ["apps", "devices", "categories", "status", "actions", "places", "preferences", "emblems", "mimetypes", "symbolic"]
184+
extensions = ['.svg', '.png']
185+
186+
# Search with size priority
187+
for size_dir in size_dirs:
188+
for base in search_bases:
189+
for subdir in subdirs:
190+
for ext in extensions:
191+
icon_file = f"{base}/{size_dir}/{subdir}/{icon_name}{ext}"
192+
if os.path.exists(icon_file):
193+
self._special_icon_cache[icon_name] = icon_file
194+
return icon_file
195+
196+
# Try scalable as last resort
197+
for base in search_bases:
198+
for subdir in subdirs:
199+
icon_file = f"{base}/scalable/{subdir}/{icon_name}.svg"
200+
if os.path.exists(icon_file):
201+
self._special_icon_cache[icon_name] = icon_file
202+
return icon_file
203+
204+
# Cache miss
205+
self._special_icon_cache[icon_name] = None
206+
return None
207+
144208
def _create_icon_from_path_or_name(self, icon_path):
145209
"""Create an icon from either a file path or an icon name"""
146-
icon = None
210+
target_size = 64
147211

148212
# If empty path, use default icon
149213
if not icon_path:
150214
icon = Gtk.Image.new_from_icon_name("application-x-executable")
151-
icon.set_pixel_size(64)
215+
icon.set_pixel_size(target_size)
152216
return icon
153217

154218
# Check if it's an absolute path
155219
if icon_path.startswith("/") and os.path.exists(icon_path):
156220
try:
157-
# Load directly from file for absolute paths
158221
icon = Gtk.Image.new_from_file(icon_path)
159-
icon.set_pixel_size(64)
222+
icon.set_pixel_size(target_size)
160223
return icon
161-
except Exception as e:
162-
print(f"Error loading icon from file '{icon_path}': {e}")
163-
# Fall through to icon name handling on failure
164-
165-
# Try to load as an icon name with specific sizes in order of preference
166-
theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
224+
except Exception:
225+
pass
167226

168-
# Check if the icon exists in the theme
169-
if theme.has_icon(icon_path):
170-
# Try preferred sizes in order: scalable(SVG), 64x64, 48x48, 128x128
171-
for size in [64, 48, 128]:
227+
# Special handling for specific problematic icons
228+
if icon_path in self._SPECIAL_ICONS:
229+
found_path = self._find_special_icon(icon_path)
230+
if found_path:
172231
try:
173-
# Try to get the icon at preferred size
174-
paintable = theme.lookup_icon(
175-
icon_path, size, 1, Gtk.TextDirection.NONE, 0
176-
)
177-
if paintable:
178-
icon = Gtk.Image.new_from_paintable(paintable)
179-
icon.set_pixel_size(64)
180-
return icon
232+
icon = Gtk.Image.new_from_file(found_path)
233+
icon.set_pixel_size(target_size)
234+
return icon
181235
except Exception:
182236
pass
183237

184-
# Default approach - may not respect size preferences but will work
238+
# Use GTK icon theme lookup (fast) for all other icons
185239
icon = Gtk.Image.new_from_icon_name(icon_path)
186-
icon.set_pixel_size(64)
240+
icon.set_pixel_size(target_size)
187241
return icon
Binary file not shown.

bigcontrolcenter/usr/share/biglinux/bigcontrolcenter/utils/app_finder.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ def _find_app_desktop_files(self):
300300
"kcm_pulseaudio.desktop",
301301
"kcm_kwin_virtualdesktops.desktop",
302302
"kcm_mobile_power.desktop",
303+
"kcm_mobile_wifi.desktop",
304+
"kcm_mobile_hotspot.desktop",
303305
]
304306

305307
# Add session-based exclusions (exclude _x11 in Wayland, exclude non-_x11 in X11)
@@ -334,6 +336,7 @@ def _find_bcc_desktop_files(self):
334336
"klassy-settings.desktop",
335337
"kcm_pulseaudio.desktop",
336338
"stoken-gui-small.desktop",
339+
"org.fcitx.Fcitx5.desktop",
337340
]
338341

339342
# Add session-based exclusions (exclude _x11 in Wayland, exclude non-_x11 in X11)
@@ -504,7 +507,7 @@ def _get_replacements(self):
504507
"app_id": "avahi-discover",
505508
"app_name": _("Search for Zeroconf servers"),
506509
"app_categories": "Other",
507-
"app_icon": "network-wired-symbolic",
510+
"app_icon": "network-workgroup",
508511
},
509512
{
510513
"app_id": "br.com.biglinux.networkinfo",
@@ -753,6 +756,7 @@ def _get_replacements(self):
753756
"app_id": "kcm_app-permissions",
754757
"app_description": _("Manage permissions for Flatpak applications"),
755758
"app_categories": "System",
759+
"app_icon": "preferences"
756760
},
757761
{
758762
"app_id": "kcm_animations",
@@ -808,7 +812,7 @@ def _get_replacements(self):
808812
},
809813
{
810814
"app_id": "kcm_kscreen",
811-
"app_exec": "kcmshell6 kcm_kscreen kcm_nightlight kgamma kwinscreenedges",
815+
"app_exec": "kcmshell6 kcm_nightlight kgamma kcm_kscreen kwinscreenedges",
812816
"app_description": _(
813817
"Configure monitors, resolution, and screen arrangement"
814818
),
@@ -1032,6 +1036,10 @@ def _get_replacements(self):
10321036
"app_icon": "ios-usb",
10331037
"app_categories": "Phone",
10341038
},
1039+
{
1040+
"app_id": "kcm_cellular_network",
1041+
"app_categories": "Phone",
1042+
},
10351043
{
10361044
"app_id": "network-connect",
10371045
"app_name": _("Connect to Internet"),

0 commit comments

Comments
 (0)