diff options
| author | Ken VanDine <ken.vandine@canonical.com> | 2010-11-12 05:14:49 -0500 |
|---|---|---|
| committer | Bazaar Package Importer <james.westby@ubuntu.com> | 2010-11-12 05:14:49 -0500 |
| commit | b9362ee860ea6216043e0b988e4d08a025cee9a8 (patch) | |
| tree | 9ba8897f7bcc24b669fe7f38f6ca25e6260aa374 /src/player-controller.vala | |
| parent | 6db5598e3ec6ddf626c7335105fde807ff964e72 (diff) | |
| parent | a8f18b2780b52eb09233c4279288f6ba0887552b (diff) | |
| download | ayatana-indicator-sound-b9362ee860ea6216043e0b988e4d08a025cee9a8.tar.gz ayatana-indicator-sound-b9362ee860ea6216043e0b988e4d08a025cee9a8.tar.bz2 ayatana-indicator-sound-b9362ee860ea6216043e0b988e4d08a025cee9a8.zip | |
Import upstream version 0.5.1
Diffstat (limited to 'src/player-controller.vala')
| -rw-r--r-- | src/player-controller.vala | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala index ad8e989..e2ae4d7 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -49,22 +49,26 @@ public class PlayerController : GLib.Object public Mpris2Controller mpris_bridge; public AppInfo? app_info { get; set;} public int menu_offset { get; set;} + public string icon_name { get; set; } public PlayerController(Dbusmenu.Menuitem root, - string client_name, + GLib.AppInfo app, string mpris_name, + string icon_name, int offset, state initial_state) { this.root_menu = root; - this.name = format_client_name(client_name.strip()); + this.app_info = app; + this.name = format_player_name(this.app_info.get_name()); this.mpris_name = mpris_name; + this.icon_name = icon_name; this.custom_items = new ArrayList<PlayerItem>(); this.current_state = initial_state; this.menu_offset = offset; construct_widgets(); establish_mpris_connection(); - this.update_layout(); + this.update_layout(); } public void update_state(state new_state) @@ -160,15 +164,19 @@ public class PlayerController : GLib.Object } } - private static string format_client_name(string client_name) - { - string formatted = client_name; - if(formatted.length > 1){ - formatted = client_name.up(1).concat(client_name.slice(1, client_name.length)); - debug("PlayerController->format_client_name - : %s", formatted); + private static string format_player_name(owned string app_info_name) + { + string result = app_info_name.down().strip(); + var tokens = result.split(" "); + if(tokens.length > 1){ + result = tokens[0]; + } + if(result.length > 1){ + result = result.up(1).concat(result.slice(1, result.length)); + debug("PlayerController->format_player_name - : %s", result); } - return formatted; - } + return result; + } // Temporarily we will need to handle to different mpris implemenations // Do it for now - a couple of weeks should see this messy carry on out of @@ -178,12 +186,11 @@ public class PlayerController : GLib.Object if(this.mpris_bridge.connected() == true){ this.update_state(state.CONNECTED); TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem; - title.toggle_active_triangle(true); - TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem; - transport.change_play_state(TransportMenuitem.state.PAUSED); + title.toggle_active_triangle(true); + this.mpris_bridge.initial_update(); } else{ this.update_state(state.DISCONNECTED); } - } -}
\ No newline at end of file + } +} |
