diff options
Diffstat (limited to 'src/music-player-bridge.vala')
-rw-r--r-- | src/music-player-bridge.vala | 24 |
1 files changed, 21 insertions, 3 deletions
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){ |