aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-06-29 14:56:14 +0200
committerConor Curran <conor.curran@canonical.com>2011-06-29 14:56:14 +0200
commit14bcbdbedbe248b4274ae36287f20c8dddf6276f (patch)
treebb190008c4e429d625c368231a6d931091669be0
parente63dc6451177bc9d4c398849eda13ff880fc69c3 (diff)
downloadayatana-indicator-sound-14bcbdbedbe248b4274ae36287f20c8dddf6276f.tar.gz
ayatana-indicator-sound-14bcbdbedbe248b4274ae36287f20c8dddf6276f.tar.bz2
ayatana-indicator-sound-14bcbdbedbe248b4274ae36287f20c8dddf6276f.zip
proxy items created
-rw-r--r--src/Makefile.am3
-rw-r--r--src/player-controller.vala32
-rw-r--r--src/track-specific-items-manager.vala51
3 files changed, 57 insertions, 29 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index fedf5de..1b01811 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,7 +50,8 @@ glib_marshal_prefix = _sound_service_marshal
music_bridge_VALASOURCES = \
music-player-bridge.vala \
transport-menu-item.vala \
- track-specific-menu-item.vala \
+ track-specific-items-manager.vala \
+ player-specific-items-manager.vala \
metadata-menu-item.vala \
player-controller.vala \
mpris2-interfaces.vala \
diff --git a/src/player-controller.vala b/src/player-controller.vala
index b1c0396..ce1d8c8 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -1,5 +1,4 @@
/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
Copyright 2010 Canonical Ltd.
Authors:
@@ -23,13 +22,12 @@ using Gee;
public class PlayerController : GLib.Object
{
- public const int WIDGET_QUANTITY = 5;
+ public const int WIDGET_QUANTITY = 4;
public static enum widget_order{
SEPARATOR,
METADATA,
TRANSPORT,
- TRACK_SPECIFIC,
PLAYLISTS
}
@@ -43,7 +41,7 @@ public class PlayerController : GLib.Object
public int current_state = state.OFFLINE;
- private Dbusmenu.Menuitem root_menu;
+ public Dbusmenu.Menuitem root_menu;
public string dbus_name { get; set;}
public ArrayList<PlayerItem> custom_items;
public Mpris2Controller mpris_bridge;
@@ -51,7 +49,8 @@ public class PlayerController : GLib.Object
public int menu_offset { get; set;}
public string icon_name { get; set; }
public bool? use_playlists;
- public Client track_specific_client;
+ private SpecificItemsManager track_specific_mgr;
+ private SpecificItemsManager player_specific_mgr;
public PlayerController(Dbusmenu.Menuitem root,
GLib.AppInfo app,
@@ -110,19 +109,14 @@ public class PlayerController : GLib.Object
public void enable_track_specific_items (string object_path)
{
- track_specific_client = new Client (this.dbus_name, object_path);
- track_specific_client.root_changed.connect (on_new_track_specific_root_changed);
- /*TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem;
- menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, true);
- menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true);*/
+ track_specific_mgr = new SpecificItemsManager (this, object_path);
}
- private void on_new_track_specific_root_changed (GLib.Object item)
- {
- debug ("!!!!!!!!!!!!!!!!!! - Root changed for track specific item %s",
- this.app_info.get_name());
+ public void enable_player_specific_items (string object_path)
+ {
+ player_specific_mgr = new SpecificItemsManager (this, object_path);
}
-
+
private void establish_mpris_connection()
{
if(this.current_state != state.READY || this.dbus_name == null ){
@@ -196,10 +190,6 @@ public class PlayerController : GLib.Object
// Transport item
TransportMenuitem transport_item = new TransportMenuitem(this);
this.custom_items.add(transport_item);
-
- // Track Specific item
- TrackSpecificMenuitem track_specific_item = new TrackSpecificMenuitem(this);
- this.custom_items.add(track_specific_item);
// Playlist item
PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this);
@@ -210,10 +200,6 @@ public class PlayerController : GLib.Object
PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem;
root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
}
- else if (this.custom_items.index_of(item) == 3) {
- TrackSpecificMenuitem trackspecific_menuitem = item as TrackSpecificMenuitem;
- root_menu.child_add_position(trackspecific_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));
}
diff --git a/src/track-specific-items-manager.vala b/src/track-specific-items-manager.vala
index 3949727..67b8bbf 100644
--- a/src/track-specific-items-manager.vala
+++ b/src/track-specific-items-manager.vala
@@ -1,6 +1,5 @@
/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
-Copyright 2010 Canonical Ltd.
+Copyright 2011 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
@@ -21,10 +20,52 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
using Dbusmenu;
using Gee;
-public class TrackSpecificMenuitemsManager : GLib.Object
+public class SpecificItemsManager : GLib.Object
{
- public TrackSpecificMenuitemsManager()
+ 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)
{
+ 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);
}
-}
+
+ private void on_root_changed (GLib.Object newroot)
+ {
+ 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.
+ 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) {
+ 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.menu_item,
+ this.owner.menu_offset + 3);
+ }
+ }
+
+ private void on_child_added (GLib.Object child, uint position)
+ {
+ debug ("On child added Specific root node");
+ }
+ private void on_child_removed (GLib.Object child)
+ {
+ debug ("On child removed Specific root node");
+ }
+
+}