From 91aa6c3f4cdf7fdf3c5b96fa9c24c6ba089c8c42 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 27 Jul 2010 12:39:51 +0100 Subject: tidy ups across the ui --- src/player-item.vala | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/player-item.vala') diff --git a/src/player-item.vala b/src/player-item.vala index 2952f71..288ac47 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -24,7 +24,8 @@ public class PlayerItem : Dbusmenu.Menuitem { public PlayerController owner {get; construct;} public string item_type { get; construct; } - + private const int EMPTY = -1; + public PlayerItem(string type) { Object(item_type: type); @@ -36,17 +37,16 @@ public class PlayerItem : Dbusmenu.Menuitem public void reset(HashSet attrs){ foreach(string s in attrs){ - debug("attempting to set prop %s to null", s); - this.property_set(s, null); - this.property_set_int(s, 0); + debug("attempting to set prop %s to EMPTY", s); + this.property_set_int(s, EMPTY); } } public void update(HashTable data, HashSet attributes) { debug("PlayerItem::update()"); - if(ensure_valid_updates(data, attributes) == false){ - debug("PlayerItem::Update -> The hashtable update does not contain what we were expecting - just leave it!"); + if(data == null){ + debug("PlayerItem::Update -> The hashtable was null - just leave it!"); return; } @@ -82,19 +82,21 @@ public class PlayerItem : Dbusmenu.Menuitem this.property_set_bool(property, v.get_boolean()); } } + if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){ + this.property_set_bool(MENUITEM_PROP_VISIBLE, true); + } } - - private static bool ensure_valid_updates(HashTable data, HashSet attributes) + + public bool populated(HashSet attrs) { - if(data == null){ - return false; + foreach(string prop in attrs){ + int value_int = property_get_int(prop); + debug("populate - prop %s and value %i", prop, value_int); + if(property_get_int(prop) != EMPTY){ + return true; + } } - /*if(data.size() < attributes.size){ - warning("update hash was too small for the target"); - return false; - }*/ - return true; + return false; } - } -- cgit v1.2.3