aboutsummaryrefslogtreecommitdiff
path: root/src/media-player-user.vala
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-02-24 16:46:33 -0600
committerTed Gould <ted@gould.cx>2014-02-24 16:46:33 -0600
commit19fd5a77a5a820f320d71ffa364b978a69345317 (patch)
treee158bf3850fab7b4d7165b78cda340a4ab5f65a0 /src/media-player-user.vala
parentabe2227e7dfecdec4c28c9447e2b2d298ba8eb89 (diff)
downloadayatana-indicator-sound-19fd5a77a5a820f320d71ffa364b978a69345317.tar.gz
ayatana-indicator-sound-19fd5a77a5a820f320d71ffa364b978a69345317.tar.bz2
ayatana-indicator-sound-19fd5a77a5a820f320d71ffa364b978a69345317.zip
Signalling some properties!
Diffstat (limited to 'src/media-player-user.vala')
-rw-r--r--src/media-player-user.vala42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/media-player-user.vala b/src/media-player-user.vala
index c4d0e42..798c8c8 100644
--- a/src/media-player-user.vala
+++ b/src/media-player-user.vala
@@ -23,6 +23,9 @@ public class MediaPlayerUser : MediaPlayer {
Act.User? actuser = null;
AccountsServiceSoundSettings? proxy = null;
+ HashTable<string, bool> properties_queued = new HashTable<string, bool>(str_hash, str_equal);
+ uint properties_timeout = 0;
+
/* Grab the user from the Accounts service and, when it is loaded then
set up a proxy to its sound settings */
public MediaPlayerUser(string user) {
@@ -44,23 +47,53 @@ public class MediaPlayerUser : MediaPlayer {
});
}
+ ~MediaPlayerUser () {
+ if (properties_timeout != 0) {
+ Source.remove(properties_timeout);
+ properties_timeout = 0;
+ }
+ }
+
+ /* Ensure that we've collected all the changes so that we only signal
+ once for variables like 'track' */
+ bool properties_idle () {
+ properties_timeout = 0;
+
+ properties_queued.@foreach((key, value) => {
+ this.notify_property(key);
+ });
+
+ /* Remove source */
+ return false;
+ }
+
+ /* Turns the DBus names into the object properties */
void queue_property_notification (string dbus_property_name) {
+ if (properties_timeout == 0) {
+ properties_timeout = Idle.add(properties_idle);
+ }
+
switch (dbus_property_name) {
case "Timestamp":
+ properties_queued.insert("name", true);
+ properties_queued.insert("icon", true);
+ properties_queued.insert("state", true);
+ properties_queued.insert("current-track", true);
break;
case "PlayerName":
+ properties_queued.insert("name", true);
break;
case "PlayerIcon":
+ properties_queued.insert("icon", true);
break;
case "State":
+ properties_queued.insert("state", true);
break;
case "Title":
- break;
case "Artist":
- break;
case "Album":
- break;
case "ArtUrl":
+ properties_queued.insert("current-track", true);
break;
}
}
@@ -84,7 +117,8 @@ public class MediaPlayerUser : MediaPlayer {
}
});
- /* TODO: Update settings */
+ /* Update all of them -- we've got a proxy! */
+ queue_property_notification("Timestamp");
} catch (Error e) {
this.proxy = null;
warning("Unable to get proxy to user '%s' sound settings: %s", username, e.message);