Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/Widgets/PlayerList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

public class Sound.Widgets.PlayerList : Gtk.Box {
public class Sound.Widgets.PlayerList : Gtk.Bin {
public signal void close ();

public Sound.Services.ObjectManager object_manager;
Expand All @@ -27,9 +27,18 @@ public class Sound.Widgets.PlayerList : Gtk.Box {
private HashTable<string,PlayerRow> ifaces;
private Services.DBusImpl impl;

private Gtk.ListBox listbox;

construct {
ifaces = new HashTable<string,PlayerRow> (str_hash, str_equal);

listbox = new Gtk.ListBox ();

child = listbox;

margin_bottom = 3;
show_all ();

Idle.add (() => {
setup_dbus ();
return false;
Expand All @@ -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 ();
});

Expand All @@ -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 () {
Expand All @@ -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 ();
}

Expand All @@ -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);
}
}

Expand All @@ -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;
Expand All @@ -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);
}
}
Expand All @@ -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 ();
}
}

Expand Down