aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-08-09 21:41:22 +0100
committerConor Curran <conor.curran@canonical.com>2011-08-09 21:41:22 +0100
commit8594ebfd7953488650107625622cba9f343c051f (patch)
tree16eb17edfb7366edd73da53af63a050e336819aa
parent4300a124d6959f8bfad9393530de587fefe828be (diff)
downloadayatana-indicator-sound-8594ebfd7953488650107625622cba9f343c051f.tar.gz
ayatana-indicator-sound-8594ebfd7953488650107625622cba9f343c051f.tar.bz2
ayatana-indicator-sound-8594ebfd7953488650107625622cba9f343c051f.zip
track specific almost in place
-rw-r--r--src/player-controller.vala11
-rw-r--r--src/sound-service.c4
-rw-r--r--src/specific-items-manager.vala32
3 files changed, 37 insertions, 10 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala
index ce1d8c8..bd8b6ad 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -109,12 +109,16 @@ public class PlayerController : GLib.Object
public void enable_track_specific_items (string object_path)
{
- track_specific_mgr = new SpecificItemsManager (this, object_path);
+ track_specific_mgr = new SpecificItemsManager (this,
+ object_path,
+ SpecificItemsManager.category.TRACK);
}
public void enable_player_specific_items (string object_path)
{
- player_specific_mgr = new SpecificItemsManager (this, object_path);
+ player_specific_mgr = new SpecificItemsManager (this,
+ object_path,
+ SpecificItemsManager.category.PLAYER);
}
private void establish_mpris_connection()
@@ -201,7 +205,8 @@ public class PlayerController : GLib.Object
root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
}
else{
- root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
+ root_menu.child_add_position (item,
+ this.menu_offset + this.custom_items.index_of(item));
}
}
}
diff --git a/src/sound-service.c b/src/sound-service.c
index da9b94e..a9ca56c 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- close_pulse_activites();
- g_main_loop_quit(mainloop);
+ /*close_pulse_activites();
+ g_main_loop_quit(mainloop);*/
}
return;
}
diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala
index 3fa7663..2755ee8 100644
--- a/src/specific-items-manager.vala
+++ b/src/specific-items-manager.vala
@@ -22,13 +22,22 @@ using Gee;
public class SpecificItemsManager : GLib.Object
{
+ public static enum category{
+ TRACK,
+ PLAYER
+ }
+
private PlayerController owner {get; set;}
private string dbus_path;
private Dbusmenu.Client client;
private Gee.ArrayList<Dbusmenu.MenuitemProxy> proxy_items;
-
- public SpecificItemsManager (PlayerController controller, string path)
+ private int of_type;
+
+ public SpecificItemsManager (PlayerController controller,
+ string path,
+ category which_type)
{
+ this.of_type = which_type;
this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>();
this.owner = controller;
this.dbus_path = path;
@@ -36,25 +45,38 @@ public class SpecificItemsManager : GLib.Object
this.client.root_changed.connect (on_root_changed);
}
+ private int figure_out_positioning()
+ {
+ int specific_item_count = this.proxy_items.size;
+ if (this.of_type == category.TRACK){
+ return this.owner.menu_offset + 2 + specific_item_count;
+ }
+ return (int)this.owner.root_menu.get_children().length();
+ }
+
private void on_root_changed (GLib.Object newroot)
{
- Dbusmenu.Menuitem root = this.client.get_root();
+ 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",
(int)children.length());
foreach (void* child in children) {
+ int pos = figure_out_positioning();
unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child;
Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item);
proxy_items.add (proxy);
debug ("Proxy item of label = %s added to collection",
item.property_get (MENUITEM_PROP_LABEL));
- this.owner.root_menu.child_add_position (proxy,
- this.owner.menu_offset + 3);
+ this.owner.root_menu.child_add_position (proxy, pos);
}
}