aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-10-26 17:12:17 -0400
committerConor Curran <conor.curran@canonical.com>2011-10-26 17:12:17 -0400
commitc0b5f7feb198717d5c64dd35c32ea51bed8f88a5 (patch)
tree3956a1dda6b6e8aff994f6f772635c097ad8a22b /src
parentcc88e4292669c88a9600e7b61982cff6e2b6436c (diff)
parent617c08b80f214285f1049e4e118c0054e849cead (diff)
downloadayatana-indicator-sound-c0b5f7feb198717d5c64dd35c32ea51bed8f88a5.tar.gz
ayatana-indicator-sound-c0b5f7feb198717d5c64dd35c32ea51bed8f88a5.tar.bz2
ayatana-indicator-sound-c0b5f7feb198717d5c64dd35c32ea51bed8f88a5.zip
fixed the wide playlist name issue
Diffstat (limited to 'src')
-rw-r--r--src/playlists-menu-item.vala22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 9cb7ac7..4666a50 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -49,7 +49,8 @@ public class PlaylistsMenuitem : PlayerItem
continue;
Dbusmenu.Menuitem menuitem = new Menuitem();
- menuitem.property_set (MENUITEM_PROP_LABEL, detail.name);
+ menuitem.property_set (MENUITEM_PROP_LABEL,
+ truncate_item_label_if_needs_be (detail.name));
menuitem.property_set (MENUITEM_PROP_ICON_NAME, "playlist-symbolic");
menuitem.property_set (MENUITEM_PATH, (string)detail.path);
@@ -86,12 +87,14 @@ public class PlaylistsMenuitem : PlayerItem
{
foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){
if (new_detail.path == item.property_get (MENUITEM_PATH)){
- item.property_set (MENUITEM_PROP_LABEL, new_detail.name);
+ item.property_set (MENUITEM_PROP_LABEL,
+ truncate_item_label_if_needs_be (new_detail.name));
}
}
// If its active make sure the name is updated on the root item.
if (this.root_item.property_get (MENUITEM_PATH) == new_detail.path) {
- this.root_item.property_set (MENUITEM_PROP_LABEL, new_detail.name);
+ this.root_item.property_set (MENUITEM_PROP_LABEL,
+ truncate_item_label_if_needs_be (new_detail.name));
}
}
@@ -115,7 +118,8 @@ public class PlaylistsMenuitem : PlayerItem
{
var update = detail.name;
if ( update == "" ) update = _("Choose Playlist");
- this.root_item.property_set (MENUITEM_PROP_LABEL, update);
+ this.root_item.property_set (MENUITEM_PROP_LABEL,
+ truncate_item_label_if_needs_be(update));
this.root_item.property_set (MENUITEM_PATH, detail.path);
}
@@ -129,6 +133,16 @@ public class PlaylistsMenuitem : PlayerItem
this.owner.mpris_bridge.activate_playlist ( (GLib.ObjectPath)this.current_playlists[menu_item_id].property_get (MENUITEM_PATH) );
}
+ private string truncate_item_label_if_needs_be(string item_label)
+ {
+ var result = item_label;
+ if (item_label.char_count(-1) > 17){
+ result = item_label.slice ((long)0, (long)15);
+ result += "…";
+ }
+ return result;
+ }
+
public static HashSet<string> attributes_format()
{
HashSet<string> attrs = new HashSet<string>();