aboutsummaryrefslogtreecommitdiff
path: root/src/player-controller.vala
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-06-15 08:48:54 +0200
committerConor Curran <conor.curran@canonical.com>2011-06-15 08:48:54 +0200
commit1677228ec606dd8d2e7eadccfff77a1703fdb727 (patch)
tree09e435494c9fd603bf502f3f88e26d25a667cbd3 /src/player-controller.vala
parentbf2c6d9d1f7ac8897c76b8917f4feaeff54816d6 (diff)
parentd72fb000fdf8c8a65abb214d1e6e67c7d31b4dbb (diff)
downloadayatana-indicator-sound-1677228ec606dd8d2e7eadccfff77a1703fdb727.tar.gz
ayatana-indicator-sound-1677228ec606dd8d2e7eadccfff77a1703fdb727.tar.bz2
ayatana-indicator-sound-1677228ec606dd8d2e7eadccfff77a1703fdb727.zip
merge metadata widget and title widget
Diffstat (limited to 'src/player-controller.vala')
-rw-r--r--src/player-controller.vala40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 20479d9..002af65 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -23,11 +23,10 @@ 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,
- TITLE,
METADATA,
TRANSPORT,
PLAYLISTS
@@ -71,6 +70,7 @@ public class PlayerController : GLib.Object
this.construct_widgets();
this.establish_mpris_connection();
this.update_layout();
+ debug ("New player controller for %s with icon name %s", this.app_info.get_name(), this.icon_name);
}
public void update_state(state new_state)
@@ -111,10 +111,10 @@ public class PlayerController : GLib.Object
if(this.current_state != state.READY || this.dbus_name == null ){
debug("establish_mpris_connection - Not ready to connect");
return;
- }
+ }
debug ( " establish mpris connection - use playlists value = %s ",
this.use_playlists.to_string() );
-
+
this.mpris_bridge = new Mpris2Controller(this);
this.determine_state();
}
@@ -135,26 +135,26 @@ public class PlayerController : GLib.Object
update_state(PlayerController.state.OFFLINE);
TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem;
transport.change_play_state (Transport.State.PAUSED);
- this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
- TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
- title.toggle_active_triangle(false);
+ this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.relevant_attributes_for_ui());
+ MetadataMenuitem md = this.custom_items[widget_order.METADATA] as MetadataMenuitem;
+ md.toggle_active_triangle (false);
this.mpris_bridge = null;
}
public void update_layout()
{
PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem;
+ MetadataMenuitem metadata_menuitem = this.custom_items[widget_order.METADATA] as MetadataMenuitem;
if(this.current_state != state.CONNECTED){
- this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE,
- false);
+ // TODO
+ metadata_menuitem.should_collapse (true);
playlists_menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE,
false );
this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE,
this.app_info.get_id() == "banshee.desktop");
return;
}
- this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE,
- this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()));
+ metadata_menuitem.should_collapse (!this.custom_items[widget_order.METADATA].populated (MetadataMenuitem.relevant_attributes_for_ui()) );
if (this.app_info.get_id() == "banshee.desktop"){
TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem;
transport.handle_cached_action();
@@ -172,12 +172,8 @@ public class PlayerController : GLib.Object
// Separator item
this.custom_items.add(new PlayerItem(CLIENT_TYPES_SEPARATOR));
- // Title item
- TitleMenuitem title_menu_item = new TitleMenuitem(this);
- this.custom_items.add(title_menu_item);
-
// Metadata item
- MetadataMenuitem metadata_item = new MetadataMenuitem();
+ MetadataMenuitem metadata_item = new MetadataMenuitem(this);
this.custom_items.add(metadata_item);
// Transport item
@@ -189,12 +185,12 @@ public class PlayerController : GLib.Object
this.custom_items.add(playlist_menuitem);
foreach(PlayerItem item in this.custom_items){
- if (this.custom_items.index_of(item) != 4) {
- root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
+ if (this.custom_items.index_of(item) == 3) {
+ 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{
- PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem;
- root_menu.child_add_position(playlists_menuitem.root_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));
}
}
}
@@ -203,8 +199,8 @@ public class PlayerController : GLib.Object
{
if(this.mpris_bridge.connected() == true){
this.update_state(state.CONNECTED);
- TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem;
- title.toggle_active_triangle(true);
+ MetadataMenuitem md = this.custom_items[widget_order.METADATA] as MetadataMenuitem;
+ md.toggle_active_triangle(true);
this.mpris_bridge.initial_update();
}
else{