diff options
-rw-r--r-- | src/player-controller.vala | 4 | ||||
-rw-r--r-- | src/playlists-menu-item.vala | 2 | ||||
-rw-r--r-- | src/settings-manager.vala | 1 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 61 |
4 files changed, 40 insertions, 28 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala index d24eaa0..3ce121e 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -124,6 +124,10 @@ public class PlayerController : GLib.Object foreach(PlayerItem item in this.custom_items){ this.root_menu.child_delete(item); } + if (this.use_playlists == true){ + PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem; + this.root_menu.child_delete (playlists_menuitem.root_item); + } } public void hibernate() diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 024839c..b8c6e7d 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -50,7 +50,7 @@ public class PlaylistsMenuitem : PlayerItem this.root_item.child_append( menuitem ); } } - + private bool already_observed (PlaylistDetails new_detail) { foreach ( PlaylistDetails detail in this.current_playlists.values ){ diff --git a/src/settings-manager.vala b/src/settings-manager.vala index b5322c0..057a47b 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -28,7 +28,6 @@ public class SettingsManager : GLib.Object construct{ this.settings = new Settings ("com.canonical.indicators.sound"); this.settings.changed["blacklisted-media-players"].connect (on_blacklist_event); - //this.reveal_contents(); } public string[] fetch_blacklist() diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index f29fab4..9ae0fd7 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -427,68 +427,77 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, gboolean blacklist) { gboolean result = FALSE; - GSettings* our_settings = g_settings_new ("com.canonical.indicators.sound"); + GSettings* our_settings = NULL; + our_settings = g_settings_new ("com.canonical.indicators.sound"); GVariant* the_black_list = g_settings_get_value (our_settings, "blacklisted-media-players"); - - GVariantIter *iter; + GVariantIter iter; gchar *str; // Firstly prep new array which will be set on the key. - GVariantBuilder *builder; - g_variant_get (the_black_list, "as", &iter); - builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); + GVariantBuilder builder; + + g_variant_iter_init (&iter, the_black_list); + g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY); - while (g_variant_iter_loop (iter, "s", &str)){ - g_variant_builder_add (builder, "s", str); + while (g_variant_iter_loop (&iter, "s", &str)){ + g_variant_builder_add (&builder, "s", str); } - - g_variant_get (the_black_list, "as", &iter); + g_variant_iter_init (&iter, the_black_list); if (blacklist == TRUE){ - while (g_variant_iter_loop (iter, "s", &str)){ + while (g_variant_iter_loop (&iter, "s", &str)){ g_print ("first pass to check if %s is present\n", str); if (g_strcmp0 (player_name, str) == 0){ // Return if its already there - g_debug ("we have this already blacklisted"); + g_debug ("we have this already blacklisted, no need to do anything"); + g_variant_builder_end (&builder); + g_object_unref (our_settings); return result; } } // Otherwise blacklist it ! g_debug ("about to blacklist %s", player_name); - g_variant_builder_add (builder, "s", player_name); + g_variant_builder_add (&builder, "s", player_name); } else{ gboolean present = FALSE; - g_variant_get (the_black_list, "as", &iter); - - while (g_variant_iter_loop (iter, "s", &str)){ + g_variant_iter_init (&iter, the_black_list); + g_debug ("attempting to UN-blacklist %s", player_name); + + while (g_variant_iter_loop (&iter, "s", &str)){ if (g_strcmp0 (player_name, str) == 0){ present = TRUE; } } // It was not there anyway, return false - if (present == FALSE) + if (present == FALSE){ + g_debug ("it was not blacklisted ?, no need to do anything"); + g_variant_builder_end (&builder); + g_object_unref (our_settings); return result; - + } + // Otherwise free the builder and reconstruct ensuring no duplicates. - g_variant_builder_unref (builder); - builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); + g_variant_builder_end (&builder); + g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY); - g_variant_get (the_black_list, "as", &iter); + g_variant_iter_init (&iter, the_black_list); - while (g_variant_iter_loop (iter, "s", &str)){ + while (g_variant_iter_loop (&iter, "s", &str)){ if (g_strcmp0 (player_name, str) != 0){ - g_variant_builder_add (builder, "s", str); + g_variant_builder_add (&builder, "s", str); } } } - GVariant* value = g_variant_new ("as", builder); - g_variant_builder_unref (builder); - g_variant_iter_free (iter); + GVariant* value = g_variant_builder_end (&builder); + g_variant_ref (value); result = g_settings_set_value (our_settings, "blacklisted-media-players", value); + g_variant_unref (value); + g_object_unref (our_settings); + return result; } |