diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-10-06 18:39:39 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-10-06 18:39:39 +0100 |
commit | 9d49288df789fb210217c9715634cdbe78a64337 (patch) | |
tree | e8622a68074ef179d1df2616b8e14d3e8a97ae5e /src | |
parent | 6a2214ba0ab2dad2963f94f65639845eb35fafaa (diff) | |
download | ayatana-indicator-sound-9d49288df789fb210217c9715634cdbe78a64337.tar.gz ayatana-indicator-sound-9d49288df789fb210217c9715634cdbe78a64337.tar.bz2 ayatana-indicator-sound-9d49288df789fb210217c9715634cdbe78a64337.zip |
reorchestrating registration to handle translations
Diffstat (limited to 'src')
-rw-r--r-- | src/music-player-bridge.vala | 89 | ||||
-rw-r--r-- | src/sound-service.c | 4 |
2 files changed, 45 insertions, 48 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 61dfa2e..2cdb39b 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -99,42 +99,58 @@ public class MusicPlayerBridge : GLib.Object { debug("MusicPlayerBridge -> on_server_added with value %s", type); if(server_is_not_of_interest(type)) return; - string client_name = type.split(".")[1]; - if (root_menu != null && client_name != null){ - // If we have an instance already for this player, ensure it is switched to active - if(this.registered_clients.keys.contains(client_name)){ - debug("It figured out that it already has an instance for this player already"); - this.registered_clients[client_name].update_state(PlayerController.state.READY); - this.registered_clients[client_name].activate(); - } - else{ - //else init a new one - 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 - if(this.registered_clients[client_name].app_info == null){ - listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback; - this.listener.server_get_desktop(object, cb, this); - } + if ( this.root_menu != null ){ + listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback_on_addition; + this.listener.server_get_desktop(object, cb, this); } } + private void desktop_info_callback_on_addition ( Indicate.ListenerServer server, + owned string path, + void* data ) + { + MusicPlayerBridge bridge = data as MusicPlayerBridge; + AppInfo? app_info = create_app_info(path); + var name = truncate_player_name(app_info.get_name()); + if(path.contains("/") && bridge.playersDB.already_familiar(path) == false){ + debug("About to store desktop file path: %s", path); + bridge.playersDB.insert(path); + PlayerController ctrl = new PlayerController(bridge.root_menu, + name, + bridge.calculate_menu_position(), + PlayerController.state.READY); + ctrl.set("app_info", app_info); + bridge.registered_clients.set(name, ctrl); + debug("successfully created appinfo and instance from path and set it on the respective instance"); + } + else{ + bridge.registered_clients[name].update_state(PlayerController.state.READY); + bridge.registered_clients[name].activate(); + debug("Ignoring desktop file path callback because the db cache file has it already: %s", path); + } + } + public void on_server_removed(Indicate.ListenerServer object, string type) { debug("MusicPlayerBridge -> on_server_removed with value %s", type); if(server_is_not_of_interest(type)) return; - string client_name = type.split(".")[1]; - if (root_menu != null && client_name != null){ - registered_clients[client_name].hibernate(); - debug("Successively offlined client %s", client_name); + if (root_menu != null){ + listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback_on_removal; + this.listener.server_get_desktop(object, cb, this); } } - + + private void desktop_info_callback_on_removal ( Indicate.ListenerServer server, + owned string path, + void* data ) + { + MusicPlayerBridge bridge = data as MusicPlayerBridge; + AppInfo? app_info = create_app_info(path); + var name = truncate_player_name(app_info.get_name()); + registered_clients[name].hibernate(); + debug("Successively offlined client %s", name); + } + private bool server_is_not_of_interest(string type){ if (type == null) return true; if (type.contains("music") == false) { @@ -144,25 +160,6 @@ public class MusicPlayerBridge : GLib.Object return false; } - private void desktop_info_callback(Indicate.ListenerServer server, - owned string path, void* data) - { - MusicPlayerBridge bridge = data as MusicPlayerBridge; - if(path.contains("/") && bridge.playersDB.already_familiar(path) == false){ - debug("About to store desktop file path: %s", path); - bridge.playersDB.insert(path); - AppInfo? app_info = create_app_info(path); - if(app_info != null){ - PlayerController ctrl = bridge.registered_clients[app_info.get_name().down().strip()]; - ctrl.set("app_info", app_info); - debug("successfully created appinfo from path and set it on the respective instance"); - } - } - else{ - debug("Ignoring desktop file path because its either invalid of the db cache file has it already: %s", path); - } - } - public void set_root_menu_item(Dbusmenu.Menuitem menu) { this.root_menu = menu; diff --git a/src/sound-service.c b/src/sound-service.c index f19379d..51f5f37 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); //TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } |