diff options
Diffstat (limited to 'src/metadata-menu-item.vala')
-rw-r--r-- | src/metadata-menu-item.vala | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 82926b1..541fbf4 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -1,40 +1,52 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + using Dbusmenu; using Gee; +using DbusmenuMetadata; -public class MetadataMenuitem : Dbusmenu.Menuitem +public class MetadataMenuitem : PlayerItem { - /* Not ideal duplicate definition of const - see common-defs/h */ - const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; - const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; - const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece"; - const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container"; - const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image"; - public MetadataMenuitem() { - this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); + this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE); } - public void update(HashMap<string, string> data) + public static HashSet<string> attributes_format() { - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, data.get("album").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); + HashSet<string> attrs = new HashSet<string>(); + attrs.add(MENUITEM_TEXT_TITLE); + attrs.add(MENUITEM_TEXT_ARTIST); + attrs.add(MENUITEM_TEXT_ALBUM); + attrs.add(MENUITEM_ARTURL); + return attrs; } - public static string sanitize_image_path(string path) + public override void check_layout(){ + this.property_set_bool(MENUITEM_PROP_VISIBLE, this.populated()); + debug("check layout for the metadata = %s", this.populated().to_string()); + } + + public bool populated() { - string result = path.strip(); - if(result.has_prefix("file:///")){ - result = result.slice(7, result.len()); - } - debug("Sanitize image path - result = %s", result); - return result; + return (this.property_get(MENUITEM_TEXT_TITLE) != null && + this.property_get(MENUITEM_TEXT_TITLE) != ""); } - public override void handle_event(string name, GLib.Value input_value, uint timestamp) - { - debug("MetadataItem -> handle event caught!"); - } }
\ No newline at end of file |