diff options
Diffstat (limited to 'src/player-controller.vala')
-rw-r--r-- | src/player-controller.vala | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala index 06a5b4e..537eccc 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -45,6 +45,7 @@ public class PlayerController : GLib.Object private Dbusmenu.Menuitem root_menu; public string name { get; set;} + public string mpris_name { get; set;} public ArrayList<PlayerItem> custom_items; public Mpris2Controller mpris_bridge; public AppInfo? app_info { get; set;} @@ -52,15 +53,17 @@ public class PlayerController : GLib.Object public string icon_name { get; set; } public PlayerController(Dbusmenu.Menuitem root, - AppInfo app_info, + GLib.AppInfo app, + string mpris_name, string icon_name, int offset, state initial_state) { this.root_menu = root; - this.app_info = app_info; + 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.name = format_client_name(truncate_player_name(app_info.get_name())); this.custom_items = new ArrayList<PlayerItem>(); this.current_state = initial_state; this.menu_offset = offset; @@ -162,16 +165,20 @@ 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 // the codebase. @@ -180,26 +187,12 @@ 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); } } - - private static string truncate_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]; - } - debug("truncate player name %s", result); - return result; - } }
\ No newline at end of file |