Repository: lutris/lutris

Issue:
Lutris does not initialize the main view when the side panel is hidden
To reproduce this, use the little drop down menu thingy and uncheck "Show Side Panel". Next, close Lutris completely. Re-open it.

It opens to a blank window. I expect to see something here; either the last view I had used, or some default view. If you go back and recheck "Show Side Panel", the view will then appear.

I think this is happening because the side panel will not be realized if hidden, and it is the handler for the realize signal that is selecting the initial view. The signal emitted upon selection is what triggers the view to initialize, but this does not happen.


Discussion:

Resolving patch:
diff --git a/lutris/gui/lutriswindow.py b/lutris/gui/lutriswindow.py
--- a/lutris/gui/lutriswindow.py
+++ b/lutris/gui/lutriswindow.py
@@ -110,6 +110,9 @@ def __init__(self, application, **kwargs):
         self.sidebar.connect("selected-rows-changed", self.on_sidebar_changed)
         self.sidebar_scrolled.add(self.sidebar)
 
+        # This must wait until the selected-rows-changed signal is connected
+        self.sidebar.initialize_rows()
+
         self.sidebar_revealer.set_reveal_child(self.side_panel_visible)
         self.sidebar_revealer.set_transition_duration(300)
         self.tabs_box.hide()
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
@@ -271,7 +271,6 @@ def __init__(self, application, selected=None):
         GObject.add_emission_hook(BaseService, "service-logout", self.on_service_auth_changed)
         GObject.add_emission_hook(BaseService, "service-games-load", self.on_service_games_updating)
         GObject.add_emission_hook(BaseService, "service-games-loaded", self.on_service_games_updated)
-        self.connect("realize", self.on_realize)
         self.set_filter_func(self._filter_func)
         self.set_header_func(self._header_func)
         self.show_all()
@@ -279,7 +278,12 @@ def __init__(self, application, selected=None):
     def get_sidebar_icon(self, icon_name):
         return Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
 
-    def on_realize(self, widget):
+    def initialize_rows(self):
+        """
+        Select the initial row; this triggers the initialization of the game view
+        so we must do this even if this sidebar is never realized, but only after
+        the sidebar's signals are connected.
+        """
         self.active_platforms = games_db.get_used_platforms()
         self.runners = sorted(runners.__all__)
         self.platforms = sorted(runners.RUNNER_PLATFORMS)
@@ -345,10 +349,12 @@ def on_realize(self, widget):
             self.add(SidebarRow(platform, "platform", platform, self.get_sidebar_icon(icon_name)))
 
         self.update()
+
         for row in self.get_children():
             if row.type == self.selected_row_type and row.id == self.selected_row_id:
                 self.select_row(row)
                 break
+
         self.show_all()
         self.running_row.hide()
 
@@ -408,5 +414,5 @@ def on_service_games_updated(self, service):
     def on_services_changed(self, _widget):
         for child in self.get_children():
             child.destroy()
-        self.on_realize(self)
+        self.initialize_rows()
         return True


Test patch: