From 71a441bdd874b38a150da0ff14575821babe2a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 17 Mar 2026 10:59:42 -0700 Subject: [PATCH] PlayerList: Use Gtk.ListBox --- src/Widgets/PlayerList.vala | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Widgets/PlayerList.vala b/src/Widgets/PlayerList.vala index 91d854fb..afcf207d 100644 --- a/src/Widgets/PlayerList.vala +++ b/src/Widgets/PlayerList.vala @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -public class Sound.Widgets.PlayerList : Gtk.Box { +public class Sound.Widgets.PlayerList : Gtk.Bin { public signal void close (); public Sound.Services.ObjectManager object_manager; @@ -27,9 +27,18 @@ public class Sound.Widgets.PlayerList : Gtk.Box { private HashTable ifaces; private Services.DBusImpl impl; + private Gtk.ListBox listbox; + construct { ifaces = new HashTable (str_hash, str_equal); + listbox = new Gtk.ListBox (); + + child = listbox; + + margin_bottom = 3; + show_all (); + Idle.add (() => { setup_dbus (); return false; @@ -45,11 +54,12 @@ public class Sound.Widgets.PlayerList : Gtk.Box { }); bluetooth_widget.show_all (); - pack_start (bluetooth_widget, false, false, 0); + listbox.prepend (bluetooth_widget); }); object_manager.media_player_removed.connect ((media_player) => { debug ("Media player %s removed", media_player.name); + listbox.remove (bluetooth_widget); bluetooth_widget.destroy (); }); @@ -63,10 +73,6 @@ public class Sound.Widgets.PlayerList : Gtk.Box { } } }); - - orientation = Gtk.Orientation.VERTICAL; - margin_bottom = 3; - show_all (); } public void update_default_player () { @@ -75,6 +81,7 @@ public class Sound.Widgets.PlayerList : Gtk.Box { default_player = new_player; if (default_widget != null) { + listbox.remove (default_widget); default_widget.destroy (); } @@ -85,7 +92,8 @@ public class Sound.Widgets.PlayerList : Gtk.Box { }); default_widget.show_all (); - pack_start (default_widget, false, false, 0); + + listbox.prepend (default_widget); } } @@ -105,7 +113,7 @@ public class Sound.Widgets.PlayerList : Gtk.Box { * @param name DBUS name (object path) * @param iface The constructed MprisClient instance */ - void add_iface (string name, Services.MprisClient iface) { + private void add_iface (string name, Services.MprisClient iface) { if ((default_player != null) && (iface.player.desktop_entry == default_player.get_id ().replace (".desktop", ""))) { default_widget.mpris_name = name; default_widget.client = iface; @@ -123,7 +131,7 @@ public class Sound.Widgets.PlayerList : Gtk.Box { close (); }); widg.show_all (); - pack_start (widg, false, false, 0); + listbox.add (widg); ifaces.insert (name, widg); } } @@ -133,13 +141,14 @@ public class Sound.Widgets.PlayerList : Gtk.Box { * * @param name DBUS name to remove handler for */ - void destroy_iface (string name) { + private void destroy_iface (string name) { if (default_widget.mpris_name == name) { default_widget.client = null; } else { var widg = ifaces[name]; if (widg != null) { - remove (widg); + listbox.remove (widg); + widg.destroy (); } }