Repository: lutris/lutris

Issue:
Long names cause window expansion
Lutris 0.5.8.3
Very long names cause the window to expand far to the right, even outside of the screenspace, when you set the name in configure and then click on the game icon to activate it (zoom level max, toggle view to four rectangles). 


Discussion:
can you demonstrate?

Resolving patch:
diff --git a/lutris/gui/widgets/game_bar.py b/lutris/gui/widgets/game_bar.py
--- a/lutris/gui/widgets/game_bar.py
+++ b/lutris/gui/widgets/game_bar.py
@@ -10,12 +10,15 @@
 from lutris.util.strings import gtk_safe
 
 
-class GameBar(Gtk.Fixed):
-    play_button_position = (12, 42)
-
+class GameBar(Gtk.Box):
     def __init__(self, db_game, game_actions, application):
         """Create the game bar with a database row"""
-        super().__init__(visible=True)
+        super().__init__(orientation=Gtk.Orientation.VERTICAL, visible=True,
+                         margin_top=12,
+                         margin_left=12,
+                         margin_bottom=12,
+                         margin_right=12,
+                         spacing=6)
         GObject.add_emission_hook(Game, "game-start", self.on_game_state_changed)
         GObject.add_emission_hook(Game, "game-started", self.on_game_state_changed)
         GObject.add_emission_hook(Game, "game-stopped", self.on_game_state_changed)
@@ -63,22 +66,24 @@ def clear_view(self):
 
     def update_view(self):
         """Populate the view with widgets"""
-        self.put(self.get_game_name_label(), 16, 8)
-        x_offset = 140
-        y_offset = 40
+        game_label = self.get_game_name_label()
+        game_label.set_halign(Gtk.Align.START)
+        self.pack_start(game_label, False, False, 0)
+
+        hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, spacing=6)
+        self.pack_start(hbox, False, False, 0)
+
+        self.play_button = self.get_play_button()
+        hbox.pack_start(self.play_button, False, False, 0)
+
         if self.game.is_installed:
-            self.put(self.get_runner_button(), x_offset, y_offset + 2)
-            x_offset += 80
-            self.put(self.get_platform_label(), x_offset, y_offset)
-            x_offset += 120
+            hbox.pack_start(self.get_runner_button(), False, False, 0)
+            hbox.pack_start(self.get_platform_label(), False, False, 0)
         if self.game.lastplayed:
-            self.put(self.get_last_played_label(), x_offset, y_offset)
-            x_offset += 120
+            hbox.pack_start(self.get_last_played_label(), False, False, 0)
         if self.game.playtime:
-            self.put(self.get_playtime_label(), x_offset, y_offset)
-
-        self.play_button = self.get_play_button()
-        self.put(self.play_button, self.play_button_position[0], self.play_button_position[1])
+            hbox.pack_start(self.get_playtime_label(), False, False, 0)
+        hbox.show_all()
 
     def get_popover(self, buttons, parent):
         """Return the popover widget containing a list of link buttons"""
@@ -104,6 +109,7 @@ def get_icon(self):
     def get_game_name_label(self):
         """Return the label with the game's title"""
         title_label = Gtk.Label(visible=True)
+        title_label.set_ellipsize(Pango.EllipsizeMode.END)
         title_label.set_markup("<span font_desc='16'><b>%s</b></span>" % gtk_safe(self.game.name))
         return title_label
 
@@ -126,8 +132,8 @@ def get_runner_button(self):
             style_context = box.get_style_context()
             style_context.add_class("linked")
         else:
-            runner_icon.set_margin_top(8)
-            runner_icon.set_margin_left(48)
+            runner_icon.set_margin_left(49)
+            runner_icon.set_margin_right(6)
             box.add(runner_icon)
         return box
 
@@ -144,12 +150,16 @@ def get_platform_label(self):
     def get_playtime_label(self):
         """Return the label containing the playtime info"""
         playtime_label = Gtk.Label(visible=True)
+        playtime_label.set_size_request(120, -1)
+        playtime_label.set_alignment(0, 0.5)
         playtime_label.set_markup(_("Time played:\n<b>%s</b>") % self.game.formatted_playtime)
         return playtime_label
 
     def get_last_played_label(self):
         """Return the label containing the last played info"""
         last_played_label = Gtk.Label(visible=True)
+        last_played_label.set_size_request(120, -1)
+        last_played_label.set_alignment(0, 0.5)
         lastplayed = datetime.fromtimestamp(self.game.lastplayed)
         last_played_label.set_markup(_("Last played:\n<b>%s</b>") % lastplayed.strftime("%x"))
         return last_played_label


Test patch: