From e9a955249e88474858861e944ace11d55245d967 Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Fri, 10 Sep 2010 17:49:49 +0200 Subject: Import upstream version 0.4.4 --- src/music-player-bridge.vala | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/music-player-bridge.vala') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index c677d15..61dfa2e 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -58,15 +58,33 @@ public class MusicPlayerBridge : GLib.Object continue; } GLib.AppInfo app_info = info as GLib.AppInfo; + // TODO refactor to remove need for further name refactoring in the player controller + // truncate should not do a down() on the name PlayerController ctrl = new PlayerController(this.root_menu, - app_info.get_name(), + truncate_player_name(app_info.get_name()), calculate_menu_position(), PlayerController.state.OFFLINE); - ctrl.set("app_info", app_info); - this.registered_clients.set(app_info.get_name().down().strip(), ctrl); + ctrl.app_info = app_info; + if(ctrl.app_info == null) + warning("for some reason the app info is null"); + + this.registered_clients.set(truncate_player_name(app_info.get_name()), ctrl); } } + private static string truncate_player_name(string app_info_name) + { + string result = app_info_name.down().strip(); + + var tokens = result.split(" "); + + if(tokens.length > 1){ + result = tokens[0]; + } + debug("truncate player name %s", result); + return result; + } + private int calculate_menu_position() { if(this.registered_clients.size == 0){ -- cgit v1.2.3