diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-06-09 12:15:39 +0200 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-06-09 12:15:39 +0200 |
commit | 58627767fbd151587a843fd2397f1c293533664a (patch) | |
tree | b3953dd922e99747e8707dcc5dcda55263366d3d /src | |
parent | bf2c6d9d1f7ac8897c76b8917f4feaeff54816d6 (diff) | |
download | ayatana-indicator-sound-58627767fbd151587a843fd2397f1c293533664a.tar.gz ayatana-indicator-sound-58627767fbd151587a843fd2397f1c293533664a.tar.bz2 ayatana-indicator-sound-58627767fbd151587a843fd2397f1c293533664a.zip |
merged the title and metadata at the backend, now for the tricky UI work@
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/common-defs.h | 20 | ||||
-rw-r--r-- | src/indicator-sound.c | 11 | ||||
-rw-r--r-- | src/metadata-menu-item.vala | 38 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 8 | ||||
-rw-r--r-- | src/player-controller.vala | 29 | ||||
-rw-r--r-- | src/title-menu-item.vala | 4 |
7 files changed, 64 insertions, 49 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bafd6be..c546f0f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,8 +18,6 @@ libsoundmenu_la_SOURCES = \ transport-widget.h \ metadata-widget.c \ metadata-widget.h \ - title-widget.c \ - title-widget.h \ volume-widget.c \ volume-widget.h \ voip-input-widget.c \ @@ -49,7 +47,6 @@ music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ metadata-menu-item.vala \ - title-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ mpris2-watcher.vala \ diff --git a/src/common-defs.h b/src/common-defs.h index b118d4b..5f44296 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -67,16 +67,16 @@ typedef enum { #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type" #define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state" -#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" -#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist" -#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title" -#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-xesam:album" -#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-mpris:artUrl" - -#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type" -#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name" -#define DBUSMENU_TITLE_MENUITEM_ICON "x-canonical-sound-menu-player-title-icon" -#define DBUSMENU_TITLE_MENUITEM_RUNNING "x-canonical-sound-menu-player-title-running" +#define DBUSMENU_TRACK_SPECIFIC_MENUITEM_TYPE "x-canonical-sound-menu-player-track-specific-type" + +#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" +#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist" +#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title" +#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-xesam:album" +#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-mpris:artUrl" +#define DBUSMENU_METADATA_MENUITEM_PLAYER_NAME "x-canonical-sound-menu-player-metadata-player-name" +#define DBUSMENU_METADATA_MENUITEM_PLAYER_ICON "x-canonical-sound-menu-player-metadata-player-icon" +#define DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING "x-canonical-sound-menu-player-metadata-player-running" #define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type" #define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-mpris:length" diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 5002463..da5218f 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -94,10 +94,6 @@ static gboolean new_metadata_widget (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -static gboolean new_title_widget (DbusmenuMenuitem * newitem, - DbusmenuMenuitem * parent, - DbusmenuClient * client, - gpointer user_data); // DBUS communication static GDBusNodeInfo *node_info = NULL; @@ -208,9 +204,6 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler (DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); - dbusmenu_client_add_type_handler (DBUSMENU_CLIENT(client), - DBUSMENU_TITLE_MENUITEM_TYPE, - new_title_widget); // Note: Not ideal but all key handling needs to be managed here and then // delegated to the appropriate widget. g_signal_connect (menu, "key-press-event", G_CALLBACK(key_press_cb), io); @@ -369,7 +362,7 @@ new_metadata_widget (DbusmenuMenuitem * newitem, return TRUE; } -static gboolean +/*static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, @@ -391,7 +384,7 @@ new_title_widget(DbusmenuMenuitem * newitem, newitem, menu_title_widget, parent); return TRUE; -} +}*/ static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 741bb9f..599a9c6 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -29,9 +29,9 @@ public class MetadataMenuitem : PlayerItem private static FetchFile fetcher; private string previous_temp_album_art_path; - public MetadataMenuitem() + public MetadataMenuitem (PlayerController parent) { - Object(item_type: MENUITEM_TYPE); + Object(item_type: MENUITEM_TYPE, owner: parent); reset(attributes_format()); } @@ -39,6 +39,9 @@ public class MetadataMenuitem : PlayerItem MetadataMenuitem.clean_album_art_temp_dir(); this.previous_temp_album_art_path = null; this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir(); + this.property_set(MENUITEM_PLAYER_NAME, this.owner.app_info.get_name()); + this.property_set(MENUITEM_PLAYER_ICON, this.owner.icon_name); + this.property_set_bool(MENUITEM_PLAYER_RUNNING, false); } private static void clean_album_art_temp_dir() @@ -135,7 +138,7 @@ public class MetadataMenuitem : PlayerItem PixbufLoader loader = new PixbufLoader (); loader.write (update.data); loader.close (); - Pixbuf icon = loader.get_pixbuf (); + Pixbuf icon = loader.get_pixbuf (); string path = this.album_art_cache_dir.concat("/downloaded-coverart-XXXXXX"); int r = FileUtils.mkstemp(path); if(r != -1){ @@ -152,7 +155,31 @@ public class MetadataMenuitem : PlayerItem e.message); } } + + public override void handle_event (string name, + Variant input_value, + uint timestamp) + { + if(this.owner.current_state == PlayerController.state.OFFLINE) + { + this.owner.instantiate(); + } + else if(this.owner.current_state == PlayerController.state.CONNECTED){ + this.owner.mpris_bridge.expose(); + } + } + public void alter_label (string new_title) + { + if (new_title == null) return; + this.property_set (MENUITEM_PLAYER_NAME, new_title); + } + + public void toggle_active_triangle (bool update) + { + this.property_set_bool (MENUITEM_PLAYER_RUNNING, update); + } + public static HashSet<string> attributes_format() { HashSet<string> attrs = new HashSet<string>(); @@ -160,6 +187,9 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_ARTIST); attrs.add(MENUITEM_ALBUM); attrs.add(MENUITEM_ARTURL); + attrs.add(MENUITEM_PLAYER_NAME); + attrs.add(MENUITEM_PLAYER_ICON); + attrs.add(MENUITEM_PLAYER_RUNNING); return attrs; - } + } } diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 04ceb88..e0d13cf 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -109,8 +109,8 @@ public class Mpris2Controller : GLib.Object } Variant? identity_v = changed_properties.lookup("Identity"); if (identity_v != null){ - TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; - title.alter_label (this.mpris2_root.Identity); + MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem; + md.alter_label (this.mpris2_root.Identity); } } @@ -162,8 +162,8 @@ public class Mpris2Controller : GLib.Object update = determine_play_state (this.player.PlaybackStatus); } if (this.mpris2_root.Identity != null){ - TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; - title.alter_label (this.mpris2_root.Identity); + MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem; + md.alter_label (this.mpris2_root.Identity); } (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state (update); GLib.HashTable<string, Value?>? cleaned_metadata = this.clean_metadata(); diff --git a/src/player-controller.vala b/src/player-controller.vala index 20479d9..1ff8b08 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 @@ -111,10 +110,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(); } @@ -136,8 +135,8 @@ public class PlayerController : GLib.Object 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); + MetadataMenuitem md = this.custom_items[widget_order.METADATA] as MetadataMenuitem; + md.toggle_active_triangle(false); this.mpris_bridge = null; } @@ -172,12 +171,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 +184,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 +198,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{ diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index ac93b89..07294fc 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -43,13 +43,13 @@ public class TitleMenuitem : PlayerItem } else if(this.owner.current_state == PlayerController.state.CONNECTED){ this.owner.mpris_bridge.expose(); - } + } } public void alter_label (string new_title) { if (new_title == null) return; - this.property_set(MENUITEM_NAME, new_title); + this.property_set (MENUITEM_NAME, new_title); } public void toggle_active_triangle(bool update) |