Repository: lutris/lutris

Issue:
Sidebar running icons don't fallback to the 'package' icon
### Bug description

While runners in the preferences dialog fall back to a 'package' icon if they have no icon, the runners in the side bar do not- you get the generic broken image icon instead.

### How to Reproduce

Install the MicroM8 runner; when you do you'll see the preferences shows a generic package icon for it.

Now check out the sidebar. Not the same icon!

### Expected behavior

I think the same icon should be shown in the sidebar as in the preferences.

### Log output

```shell
INFO     2021-12-26 07:57:55,502 [startup.check_driver:53]:Using NVIDIA drivers 470.86 for x86_64
INFO     2021-12-26 07:57:55,502 [startup.check_driver:57]:GPU: NVIDIA GeForce RTX 3060
INFO     2021-12-26 07:57:55,502 [startup.check_driver:73]:GPU: 10DE:2503 196E:1377 (nvidia drivers)
DEBUG    2021-12-26 07:57:55,676 [lutriswindow.update_store:451]:Showing 0 games
DEBUG    2021-12-26 07:57:58,477 [application.show_window:259]:Showing window <class 'lutris.gui.config.preferences_dialog.PreferencesDialog'>{}
DEBUG    2021-12-26 07:58:09,782 [runner_box.on_install_clicked:96]:Install of <lutris.runners.json.microm8 object at 0x7f9f880f9eb0> requested
DEBUG    2021-12-26 07:58:09,782 [runner.install:340]:Installing microm8 (version=None, downloader=<function simple_downloader at 0x7f9f994b3b80>, callback=None)
DEBUG    2021-12-26 07:58:09,787 [downloader.start:65]:⬇ http://paleotronic.com/download/microm8-linux.zip
DEBUG    2021-12-26 07:58:11,653 [downloader.download_cb:125]:Finished downloading http://paleotronic.com/download/microm8-linux.zip
DEBUG    2021-12-26 07:58:11,791 [extract.extract_archive:119]:Extracting /home/danj/.cache/lutris/microm8-linux.zip to /home/danj/.local/share/lutris/runners/microm8

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs x64)

Scanning the drive for archives:
1 file, 19056423 bytes (19 MiB)

Extracting archive: /home/danj/.cache/lutris/microm8-linux.zip
--
Path = /home/danj/.cache/lutris/microm8-linux.zip
Type = zip
Physical Size = 19056423

Everything is Ok

Size:       43457896
Compressed: 19056423
DEBUG    2021-12-26 07:58:11,971 [system.remove_folder:230]:Removing folder /home/danj/.local/share/lutris/runners/microm8/.extract-1182a35c
DEBUG    2021-12-26 07:58:11,972 [extract.extract_archive:171]:Finished extracting /home/danj/.cache/lutris/microm8-linux.zip to /home/danj/.local/share/lutris/runners/microm8
DEBUG    2021-12-26 07:58:20,576 [application.on_app_window_destroyed:276]:Removed window <class 'lutris.gui.config.preferences_dialog.PreferencesDialog'>{}
DEBUG    2021-12-26 07:58:22,213 [lutriswindow.update_store:451]:Showing 0 games
INFO     2021-12-26 07:58:36,489 [application.do_shutdown:631]:Shutting down Lutris
```


### System Information

```shell
[System]
OS:              Pop!_OS 21.10 impish
Arch:            x86_64
Kernel:          5.15.8-76051508-generic
Desktop:         GNOME
Display Server:  x11

[CPU]
Vendor:          AuthenticAMD
Model:           AMD Ryzen 7 5800X 8-Core Processor
Physical cores:  8
Logical cores:   16

[Memory]
RAM:             31.4 GB
Swap:            0.0 GB

[Graphics]
Vendor:          NVIDIA Corporation
OpenGL Renderer: NVIDIA GeForce RTX 3060/PCIe/SSE2
OpenGL Version:  4.6.0 NVIDIA 470.86
OpenGL Core:     4.6.0 NVIDIA 470.86
OpenGL ES:       OpenGL ES 3.2 NVIDIA 470.86
Vulkan:          Supported
```


### Media (optional)

![Screenshot from 2021-12-26 07-58-31](https://user-images.githubusercontent.com/6507403/147408849-38fab75d-eb18-4043-9349-56c5e79008ef.png)


### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:

Resolving patch:
diff --git a/lutris/gui/widgets/sidebar.py b/lutris/gui/widgets/sidebar.py
--- a/lutris/gui/widgets/sidebar.py
+++ b/lutris/gui/widgets/sidebar.py
@@ -12,6 +12,7 @@
 from lutris.gui.config.services_box import ServicesBox
 from lutris.gui.dialogs import ErrorDialog
 from lutris.gui.dialogs.runner_install import RunnerInstallDialog
+from lutris.gui.widgets.utils import has_stock_icon
 from lutris.services.base import AuthTokenExpired, BaseService
 from lutris.util.jobs import AsyncCall
 
@@ -276,7 +277,8 @@ def __init__(self, application, selected=None):
         self.show_all()
 
     def get_sidebar_icon(self, icon_name):
-        icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
+        name = icon_name if has_stock_icon(icon_name) else "package-x-generic-symbolic"
+        icon = Gtk.Image.new_from_icon_name(name, Gtk.IconSize.MENU)
 
         # We can wind up with an icon of the wrong size, if that's what is
         # available. So we'll fix that.
diff --git a/lutris/gui/widgets/utils.py b/lutris/gui/widgets/utils.py
--- a/lutris/gui/widgets/utils.py
+++ b/lutris/gui/widgets/utils.py
@@ -76,6 +76,12 @@ def get_pixbuf(image, size, fallback=None, is_installed=True):
     return transparent_pixbuf
 
 
+def has_stock_icon(name):
+    """This tests if a GTK stock icon is known; if not we can try a fallback."""
+    theme = Gtk.IconTheme.get_default()
+    return theme.has_icon(name)
+
+
 def get_stock_icon(name, size):
     """Return a pixbuf from a stock icon name"""
     theme = Gtk.IconTheme.get_default()


Test patch: