aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-12-15 16:23:15 +0000
committerConor Curran <conor.curran@canonical.com>2010-12-15 16:23:15 +0000
commitbb13f9134c42480ada8128cfbd3b19ec2d68865b (patch)
treee1b6032db870c69f07af556540a43e0efdb098bb /src
parentaaf57407f00aa59df3699794496fd42a731ad7db (diff)
downloadayatana-indicator-sound-bb13f9134c42480ada8128cfbd3b19ec2d68865b.tar.gz
ayatana-indicator-sound-bb13f9134c42480ada8128cfbd3b19ec2d68865b.tar.bz2
ayatana-indicator-sound-bb13f9134c42480ada8128cfbd3b19ec2d68865b.zip
clients properly remembered using gsettings
Diffstat (limited to 'src')
-rw-r--r--src/music-player-bridge.vala62
-rw-r--r--src/settings-manager.vala12
2 files changed, 36 insertions, 38 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 6a45d0c..b13b7f3 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -37,42 +37,35 @@ public class MusicPlayerBridge : GLib.Object
construct{
this.registered_clients = new HashMap<string, PlayerController> ();
this.settings_manager = new SettingsManager();
- this.settings_manager.connect.blacklist_updates (on_blacklist_update);
+ this.settings_manager.blacklist_updates.connect ( this.on_blacklist_update );
}
- private void on_black_list_updated ( string[] blacklist )
+ private void on_blacklist_update ( string[] blacklist )
{
debug("some blacklist update");
}
-
- /*private void try_to_add_inactive_familiar_clients(){
- foreach(string app in this.playersDB.records()){
- if(app == null){
- warning("App string in keyfile is null therefore moving on to next player");
- continue;
- }
- debug("attempting to make an app info from %s", app);
-
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
-
- if(info == null){
- warning("Could not create a desktopappinfo instance from app,: %s , moving on to the next client", app);
+ private void try_to_add_inactive_familiar_clients()
+ {
+ foreach ( string desktop in this.settings_manager.fetch_interested()){
+ debug ( "interested client found : %s", desktop );
+ string path = DESKTOP_PREFIX.concat ( desktop.concat( ".desktop" ) );
+ AppInfo? app_info = create_app_info ( path );
+ if ( app_info == null ){
+ warning ( "Could not create app_info for path %s \n Getting out of here ", path);
continue;
}
-
- GLib.AppInfo app_info = info as GLib.AppInfo;
- var mpris_key = determine_key ( app );
- PlayerController ctrl = new PlayerController(this.root_menu,
- app_info,
- mpris_key,
- playersDB.fetch_icon_name(app),
- calculate_menu_position(),
- PlayerController.state.OFFLINE);
- this.registered_clients.set(mpris_key, ctrl);
- }
- }*/
-
+ var mpris_key = determine_key ( path );
+ PlayerController ctrl = new PlayerController ( this.root_menu,
+ app_info,
+ mpris_key,
+ this.fetch_icon_name(path),
+ calculate_menu_position(),
+ PlayerController.state.OFFLINE );
+ this.registered_clients.set(mpris_key, ctrl);
+ }
+ }
+
private int calculate_menu_position()
{
if(this.registered_clients.size == 0){
@@ -109,12 +102,14 @@ public class MusicPlayerBridge : GLib.Object
this.calculate_menu_position(),
PlayerController.state.READY );
this.registered_clients.set ( mpris_key, ctrl );
- debug ( "successfully created appinfo and instance from path and set it on the respective instance" );
+ debug ( "Have not seen this %s before, new controller created.", desktop );
+ this.settings_manager.add_interested ( desktop );
+ debug ( "application added to the interested list" );
}
else{
this.registered_clients[mpris_key].update_state ( PlayerController.state.READY );
this.registered_clients[mpris_key].activate ( );
- debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path);
+ debug("Application has already registered - awaken the hibernation: %s \n", path);
}
}
@@ -137,6 +132,7 @@ public class MusicPlayerBridge : GLib.Object
this.watcher = new Mpris2Watcher ();
this.watcher.client_appeared += this.client_has_become_available;
this.watcher.client_disappeared += this.client_has_vanished;
+ this.try_to_add_inactive_familiar_clients();
}
private static AppInfo? create_app_info ( string path )
@@ -176,8 +172,10 @@ public class MusicPlayerBridge : GLib.Object
}
/*
- Messy but necessary method to consolidate desktop filesnames and mpris dbus names
- into the one single word string (used as the key in the players hash).
+ Messy but necessary method to consolidate desktop filesnames and mpris dbus names
+ into the one single word string (used as the key in the players hash).
+ So this means that we can determine the key for the players_hash from the
+ dbus interface name or the desktop file name.
*/
private static string? determine_key(owned string path)
{
diff --git a/src/settings-manager.vala b/src/settings-manager.vala
index 9068c05..05db430 100644
--- a/src/settings-manager.vala
+++ b/src/settings-manager.vala
@@ -28,27 +28,27 @@ public class SettingsManager : GLib.Object
construct{
this.settings = new Settings ("com.canonical.indicators.sound");
settings.changed["blacklisted-media-players"].connect (on_blacklist_event);
- this.fetch_entries.begin();
}
public string[] fetch_blacklist()
{
- return this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players"));
+ return this.settings.get_strv ("blacklisted-media-players");
}
public string[] fetch_interested()
{
- return this.interested_updates(this.settings.get_strv ("interested-media-players"));
+ return this.settings.get_strv ("interested-media-players");
}
public bool add_interested(string app_desktop_name)
{
string[] already_interested = fetch_interested();
- already_interested.append ( app_desktop_name );
- return this.settings.set_strv( already_interested );
+ already_interested += (app_desktop_name);
+ return this.settings.set_strv( "interested-media-players",
+ already_interested );
}
- private on_blacklist_event()
+ private void on_blacklist_event()
{
this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players"));
}