aboutsummaryrefslogtreecommitdiff
path: root/src/player-item.vala
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-24 18:16:23 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-24 18:16:23 +0100
commit0336970086fb3bbd00b3a906e9879f4a50ae015c (patch)
tree5a567be23e2f1dcf6bfdbda4d8b461fd8314e41c /src/player-item.vala
parent49db751d456ee144f7c7910278b35613dc90db8a (diff)
parent1d721c275ba6962d60f47b184849db7bd2a5290a (diff)
downloadayatana-indicator-sound-0336970086fb3bbd00b3a906e9879f4a50ae015c.tar.gz
ayatana-indicator-sound-0336970086fb3bbd00b3a906e9879f4a50ae015c.tar.bz2
ayatana-indicator-sound-0336970086fb3bbd00b3a906e9879f4a50ae015c.zip
merge the familiar players db work
Diffstat (limited to 'src/player-item.vala')
-rw-r--r--src/player-item.vala26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/player-item.vala b/src/player-item.vala
index 09b0e6b..7fcf912 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -27,18 +27,21 @@ public class PlayerItem : Dbusmenu.Menuitem
public PlayerItem()
{
}
-
+
public void update(HashTable<string, Value?> data, HashSet<string> 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!");
+ return;
+ }
foreach(string property in attributes){
string[] input_keys = property.split("-");
string search_key = input_keys[input_keys.length-1 : input_keys.length][0];
debug("search key = %s", search_key);
-
Value v = data.lookup(search_key);
-
if (v.holds (typeof (string))){
+ debug("with value : %s", v.get_string());
this.property_set(property, this.sanitize_string(v.get_string()));
}
else if (v.holds (typeof (int))){
@@ -49,6 +52,8 @@ public class PlayerItem : Dbusmenu.Menuitem
this.property_set_bool(property, v.get_boolean());
}
}
+ // TODO: not working
+ //this.check_layout();
}
public void set_adaptor(MprisController adaptor)
@@ -56,6 +61,17 @@ public class PlayerItem : Dbusmenu.Menuitem
this.mpris_adaptor = adaptor;
}
+ private static bool ensure_valid_updates(HashTable<string, Value?> data, HashSet<string> attributes)
+ {
+ if(data == null){
+ return false;
+ }
+ if(data.size() < attributes.size){
+ warning("update hash was too small for the target");
+ return false;
+ }
+ return true;
+ }
public static string sanitize_string(string st)
{
@@ -85,5 +101,9 @@ public class PlayerItem : Dbusmenu.Menuitem
separator.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR);
return separator;
}
+
+ public virtual void check_layout(){
+ warning("this should not be hit");
+ }
}