From e2792ab0a1dfd8ca0c96b59b675fa09e8cd0e5d7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Oct 2010 17:58:42 +0100 Subject: moving towards getting the icon across the divide --- src/player-controller.vala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index d5b79e7..4b5144a 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -19,6 +19,7 @@ with this program. If not, see . */ using Dbusmenu; +using DbusmenuGtk; using Gee; public class PlayerController : GLib.Object @@ -62,6 +63,7 @@ public class PlayerController : GLib.Object construct_widgets(); establish_mpris_connection(); this.update_layout(); + } public void update_state(state new_state) @@ -167,6 +169,20 @@ public class PlayerController : GLib.Object return formatted; } + public void set_icon_path() + { + if(this.app_info != null){ + /*Gtk.IconTheme icon_t = Gtk.IconTheme.get_default(); + Gtk.IconInfo iconInfo = icon_t.lookup_icon(app_info.get_icon(), + getIconSize(), + Gtk.ICON_LOOKUP_USE_BUILTIN);*/ + //return iconInfo.load_icon(); + dbusmenu_menuitem_property_set_image(this.custom_items[widget_order.TITLE], + MENUITEM_PROP_ICON_DATA, + app_info.get_icon()); + } + } + // 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. -- cgit v1.2.3 From 2d40c713f6d5fab70c952e757d0690c7dad63d2d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 15 Oct 2010 13:59:45 +0100 Subject: updates done for now --- src/player-controller.vala | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 4b5144a..06a5b4e 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -49,21 +49,24 @@ 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, + AppInfo app_info, + string icon_name, int offset, state initial_state) { this.root_menu = root; - this.name = format_client_name(client_name.strip()); + this.app_info = app_info; + this.icon_name = icon_name; + this.name = format_client_name(truncate_player_name(app_info.get_name())); this.custom_items = new ArrayList(); 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) @@ -168,20 +171,6 @@ public class PlayerController : GLib.Object } return formatted; } - - public void set_icon_path() - { - if(this.app_info != null){ - /*Gtk.IconTheme icon_t = Gtk.IconTheme.get_default(); - Gtk.IconInfo iconInfo = icon_t.lookup_icon(app_info.get_icon(), - getIconSize(), - Gtk.ICON_LOOKUP_USE_BUILTIN);*/ - //return iconInfo.load_icon(); - dbusmenu_menuitem_property_set_image(this.custom_items[widget_order.TITLE], - MENUITEM_PROP_ICON_DATA, - app_info.get_icon()); - } - } // 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 @@ -199,4 +188,18 @@ public class PlayerController : GLib.Object 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 -- cgit v1.2.3 From 6c1c1d706fa7e8670ce3fb46329647e20a307911 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 5 Nov 2010 15:19:52 +0000 Subject: refactored the constructor for the player controller enforcing app_info pattern --- src/player-controller.vala | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index f9cbe71..cc2e4e1 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -51,13 +51,14 @@ public class PlayerController : GLib.Object public int menu_offset { get; set;} public PlayerController(Dbusmenu.Menuitem root, - string client_name, + GLib.AppInfo app, string mpris_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.custom_items = new ArrayList(); this.current_state = initial_state; @@ -170,6 +171,20 @@ public class PlayerController : GLib.Object return 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 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. -- cgit v1.2.3 From fa06a4441287f76de3033f15cf1346b4e91004c4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 5 Nov 2010 17:39:06 +0000 Subject: tidy up unwanted deps --- src/player-controller.vala | 1 - 1 file changed, 1 deletion(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 537eccc..7d3aad0 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -19,7 +19,6 @@ with this program. If not, see . */ using Dbusmenu; -using DbusmenuGtk; using Gee; public class PlayerController : GLib.Object -- cgit v1.2.3 From dd80c00e460cf1857eb8a76b62e2058b49f62d88 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 5 Nov 2010 17:43:57 +0000 Subject: tidy up unwanted deps --- src/player-controller.vala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/player-controller.vala') diff --git a/src/player-controller.vala b/src/player-controller.vala index 7d3aad0..e2ae4d7 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -192,6 +192,5 @@ public class PlayerController : GLib.Object else{ this.update_state(state.DISCONNECTED); } - } - -} \ No newline at end of file + } +} -- cgit v1.2.3