diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-10-28 05:45:22 -0400 |
---|---|---|
committer | Package Import Robot <package-import@ubuntu.com> | 2011-10-28 05:45:22 -0400 |
commit | d7f1d275d05edb3e0a25bb19d340e351e65e2b79 (patch) | |
tree | 8d5e2ee74ab2a728a2af4e514740266424b5b955 /src/playlists-menu-item.vala | |
parent | bf58931fb653267839b32c980425c3d2183157d2 (diff) | |
parent | 6c40e13a44770e9bda393e5b0b1ebefa6b8077d5 (diff) | |
download | ayatana-indicator-sound-d7f1d275d05edb3e0a25bb19d340e351e65e2b79.tar.gz ayatana-indicator-sound-d7f1d275d05edb3e0a25bb19d340e351e65e2b79.tar.bz2 ayatana-indicator-sound-d7f1d275d05edb3e0a25bb19d340e351e65e2b79.zip |
Import upstream version 0.7.9.1
Diffstat (limited to 'src/playlists-menu-item.vala')
-rw-r--r-- | src/playlists-menu-item.vala | 22 |
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>(); |