aboutsummaryrefslogtreecommitdiff
path: root/src/music-player-bridge.vala
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2010-07-12 17:49:25 +0200
committerSebastien Bacher <seb128@ubuntu.com>2010-07-12 17:49:25 +0200
commit69f91546fb17d7209e5267a5ce7e0ae6b9bbd9d9 (patch)
tree0b7bbb46adea718590192731eaad1f152571b6e6 /src/music-player-bridge.vala
parent1584af2971970dfb3484329a5307e5e770b34094 (diff)
parentf6ffb190261dfdbbf55e90b63c1cd06f03037e35 (diff)
downloadayatana-indicator-sound-69f91546fb17d7209e5267a5ce7e0ae6b9bbd9d9.tar.gz
ayatana-indicator-sound-69f91546fb17d7209e5267a5ce7e0ae6b9bbd9d9.tar.bz2
ayatana-indicator-sound-69f91546fb17d7209e5267a5ce7e0ae6b9bbd9d9.zip
releasing version 0.3.6-0ubuntu1
Diffstat (limited to 'src/music-player-bridge.vala')
-rw-r--r--src/music-player-bridge.vala47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index d771192..2f87b2d 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -52,28 +52,34 @@ public class MusicPlayerBridge : GLib.Object
warning("App string in keyfile is null therefore moving on to next player");
continue;
}
- try{
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
- if(info == null){
- warning("Could not create a desktopappinfo instance from app: %s", app);
- continue;
- }
- GLib.AppInfo app_info = info as GLib.AppInfo;
- PlayerController ctrl = new PlayerController(this.root_menu,
- app_info.get_name(),
- PlayerController.state.OFFLINE);
- ctrl.set("app_info", app_info);
- this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
- debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
- count += 1;
- }
- catch(Error er){
- warning("desktop path in cache is not formatted as we have anticipated");
+ DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
+ if(info == null){
+ warning("Could not create a desktopappinfo instance from app: %s", app);
+ continue;
}
+ GLib.AppInfo app_info = info as GLib.AppInfo;
+ PlayerController ctrl = new PlayerController(this.root_menu,
+ app_info.get_name(),
+ calculate_menu_position(),
+ PlayerController.state.OFFLINE);
+ ctrl.set("app_info", app_info);
+ this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
+ debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
+ count += 1;
}
break;
}
}
+
+ private int calculate_menu_position()
+ {
+ if(this.registered_clients.size == 0){
+ return 2;
+ }
+ else{
+ return (2 + (this.registered_clients.size * 4));
+ }
+ }
public void on_server_added(Indicate.ListenerServer object, string type)
{
@@ -89,8 +95,13 @@ public class MusicPlayerBridge : GLib.Object
}
//else init a new one
else{
- PlayerController ctrl = new PlayerController(root_menu, client_name, PlayerController.state.READY);
+
+ PlayerController ctrl = new PlayerController(root_menu,
+ client_name,
+ calculate_menu_position(),
+ PlayerController.state.READY);
registered_clients.set(client_name, ctrl);
+
debug("New Client of name %s has successfully registered with us", client_name);
}
// irregardless check that it has a desktop file if not kick off a request for it