diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-08-10 13:41:08 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-08-10 13:41:08 +0100 |
commit | 023090260c73fad2f22c8937fad70215d56319d1 (patch) | |
tree | 0b7e27a0c06c038c8b19633e281d065751f18074 /src | |
parent | 8594ebfd7953488650107625622cba9f343c051f (diff) | |
download | ayatana-indicator-sound-023090260c73fad2f22c8937fad70215d56319d1.tar.gz ayatana-indicator-sound-023090260c73fad2f22c8937fad70215d56319d1.tar.bz2 ayatana-indicator-sound-023090260c73fad2f22c8937fad70215d56319d1.zip |
track specific ordering correct, player specific under way
Diffstat (limited to 'src')
-rw-r--r-- | src/player-controller.vala | 11 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 6 | ||||
-rw-r--r-- | src/specific-items-manager.vala | 36 |
3 files changed, 40 insertions, 13 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala index bd8b6ad..f46d36b 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -116,10 +116,19 @@ public class PlayerController : GLib.Object public void enable_player_specific_items (string object_path) { + debug ("Player specific item"); player_specific_mgr = new SpecificItemsManager (this, object_path, SpecificItemsManager.category.PLAYER); } + + public int track_specific_count () + { + if (this.track_specific_mgr == null) { + return 0; + } + return this.track_specific_mgr.proxy_items.size; + } private void establish_mpris_connection() { @@ -210,7 +219,7 @@ public class PlayerController : GLib.Object } } } - + private void determine_state() { if(this.mpris_bridge.connected() == true){ diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index bad90ca..9950302 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -326,7 +326,7 @@ bus_method_call (GDBusConnection * connection, gchar* player_object_path; gchar* player_id; g_variant_get (params, "(os)", &player_object_path, &player_id); - g_debug ("object path = %s and id = %s", player_object_path, player_id); + //g_debug ("object path = %s and id = %s", player_object_path, player_id); g_signal_emit (service, signals[TRACK_SPECIFIC_ITEM], 0, @@ -340,7 +340,9 @@ bus_method_call (GDBusConnection * connection, gchar* player_object_path; gchar* player_id; g_variant_get (params, "(os)", &player_object_path, &player_id); - //g_debug ("object path = %s and id = %s", player_object_path, player_id); + g_debug ("PLayer specific item - object path = %s and id = %s", + player_object_path, + player_id); g_signal_emit (service, signals[PLAYER_SPECIFIC_ITEM], 0, diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala index 2755ee8..e3d17e5 100644 --- a/src/specific-items-manager.vala +++ b/src/specific-items-manager.vala @@ -30,7 +30,7 @@ public class SpecificItemsManager : GLib.Object private PlayerController owner {get; set;} private string dbus_path; private Dbusmenu.Client client; - private Gee.ArrayList<Dbusmenu.MenuitemProxy> proxy_items; + public Gee.ArrayList<Dbusmenu.MenuitemProxy> proxy_items {get; construct;} private int of_type; public SpecificItemsManager (PlayerController controller, @@ -38,33 +38,48 @@ public class SpecificItemsManager : GLib.Object category which_type) { this.of_type = which_type; - this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>(); this.owner = controller; this.dbus_path = path; this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); this.client.root_changed.connect (on_root_changed); } + construct{ + this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>(); + } private int figure_out_positioning() { - int specific_item_count = this.proxy_items.size; + int result = 0 ; if (this.of_type == category.TRACK){ - return this.owner.menu_offset + 2 + specific_item_count; + int specific_item_count = this.proxy_items.size; + result = this.owner.menu_offset + 4 + specific_item_count; + } + else if (this.of_type == category.PLAYER){ + int pos = this.owner.menu_offset + 4 + this.owner.track_specific_count(); + pos += this.owner.use_playlists == true ? 1 : 0; + result = pos; } - return (int)this.owner.root_menu.get_children().length(); + debug ("!!!!! Menu pos of type %i is = %i", this.of_type, result); + return result; } - private void on_root_changed (GLib.Object newroot) + private void on_root_changed (GLib.Object? newroot) { + if (newroot == null){ + debug ("root disappeared -remove proxyitems"); + foreach(var p in proxy_items){ + this.owner.root_menu.child_delete (p); + } + this.proxy_items.clear();// = null; + //this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>(); + return; + } + Dbusmenu.Menuitem? root = this.client.get_root(); root.child_added.connect (on_child_added); root.child_removed.connect (on_child_removed); // Fetch what children are there already. - if (root == null){ - debug ("root disappeared -remove proxyitems"); - return; - } GLib.List<weak void*> children = root.get_children().copy(); debug ("on_root_changed - size of children list : %i", @@ -77,6 +92,7 @@ public class SpecificItemsManager : GLib.Object debug ("Proxy item of label = %s added to collection", item.property_get (MENUITEM_PROP_LABEL)); this.owner.root_menu.child_add_position (proxy, pos); + } } |