From 58627767fbd151587a843fd2397f1c293533664a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 9 Jun 2011 12:15:39 +0200 Subject: merged the title and metadata at the backend, now for the tricky UI work@ --- src/metadata-menu-item.vala | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'src/metadata-menu-item.vala') 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 attributes_format() { HashSet attrs = new HashSet(); @@ -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; - } + } } -- cgit v1.2.3 From a406685399b46b4b2a62b8e580ce7beec2f875f4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 9 Jun 2011 17:39:03 +0200 Subject: image is appearing inthe gutter hurray --- src/metadata-menu-item.vala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 599a9c6..1d50d38 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -18,6 +18,7 @@ with this program. If not, see . */ using Gee; +using Dbusmenu; using DbusmenuMetadata; using Gdk; @@ -32,16 +33,17 @@ public class MetadataMenuitem : PlayerItem public MetadataMenuitem (PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - reset(attributes_format()); + //reset(attributes_format()); } construct{ 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); + debug ("JUST ABOUT TO ATTEMPT PLAYER NAME SETTING %s", this.owner.app_info.get_name()); + 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() -- cgit v1.2.3 From e0761ddf73f224b880adea3f226463eb7a996ec6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 10 Jun 2011 11:38:54 +0200 Subject: label appearing dynamic resizing partially working --- src/metadata-menu-item.vala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 1d50d38..5d32314 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -182,6 +182,21 @@ public class MetadataMenuitem : PlayerItem this.property_set_bool (MENUITEM_PLAYER_RUNNING, update); } + public void collapse() + { + this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, true); + } + + public void expand() + { + this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, false); + } + + public void populated() + { + //this.property_get (MENUITEM_TITLE + } + public static HashSet attributes_format() { HashSet attrs = new HashSet(); -- cgit v1.2.3 From edd58e6f87bd80a4e37eac90b42b03528aba44ee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 10 Jun 2011 16:39:31 +0200 Subject: arrow should be showing --- src/metadata-menu-item.vala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 5d32314..5f3ef8b 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -38,12 +38,13 @@ public class MetadataMenuitem : PlayerItem construct{ MetadataMenuitem.clean_album_art_temp_dir(); - this.previous_temp_album_art_path = null; + this.previous_temp_album_art_path = null; this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir(); debug ("JUST ABOUT TO ATTEMPT PLAYER NAME SETTING %s", this.owner.app_info.get_name()); - 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); + 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); + this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, true); } private static void clean_album_art_temp_dir() -- cgit v1.2.3 From ec14b8310dd5b02ed749c2cfade5c1a45ef00bac Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 13 Jun 2011 12:04:15 +0200 Subject: number of bugs fixed, more to come --- src/metadata-menu-item.vala | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 5f3ef8b..8d7b55d 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -183,19 +183,9 @@ public class MetadataMenuitem : PlayerItem this.property_set_bool (MENUITEM_PLAYER_RUNNING, update); } - public void collapse() + public void should_collapse(bool collapse) { - this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, true); - } - - public void expand() - { - this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, false); - } - - public void populated() - { - //this.property_get (MENUITEM_TITLE + this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, collapse); } public static HashSet attributes_format() @@ -210,4 +200,14 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_PLAYER_RUNNING); return attrs; } + + public static HashSet relevant_attributes_for_ui() + { + HashSet attrs = new HashSet(); + attrs.add(MENUITEM_TITLE); + attrs.add(MENUITEM_ARTIST); + attrs.add(MENUITEM_ALBUM); + attrs.add(MENUITEM_ARTURL); + return attrs; + } } -- cgit v1.2.3 From ed942a6e5eb61a366a87b7346999ef5c146fc7fb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 13 Jun 2011 17:02:41 +0200 Subject: arrow drawing properly --- src/metadata-menu-item.vala | 1 + 1 file changed, 1 insertion(+) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 8d7b55d..de02aec 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -180,6 +180,7 @@ public class MetadataMenuitem : PlayerItem public void toggle_active_triangle (bool update) { + debug ("toggle active triangle"); this.property_set_bool (MENUITEM_PLAYER_RUNNING, update); } -- cgit v1.2.3 From 95fdfeacc7b13034ca71aac2fe2e42fef17de253 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 14 Jun 2011 13:17:25 +0200 Subject: spacing fixed --- src/metadata-menu-item.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index de02aec..dccf478 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -33,7 +33,6 @@ public class MetadataMenuitem : PlayerItem public MetadataMenuitem (PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - //reset(attributes_format()); } construct{ @@ -45,6 +44,7 @@ public class MetadataMenuitem : PlayerItem this.property_set (MENUITEM_PLAYER_ICON, this.owner.icon_name); this.property_set_bool (MENUITEM_PLAYER_RUNNING, false); this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, true); + reset (relevant_attributes_for_ui()); } private static void clean_album_art_temp_dir() -- cgit v1.2.3 From 2e0dd336905735dc75d3ab7e676ef60af76ae746 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 14 Jun 2011 18:24:46 +0200 Subject: caught most of the little bugs I could find@ --- src/metadata-menu-item.vala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/metadata-menu-item.vala') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index dccf478..995d248 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -104,10 +104,16 @@ public class MetadataMenuitem : PlayerItem public void fetch_art(string uri, string prop) { File art_file = File.new_for_uri(uri); - if(art_file.is_native() == true){ + if (art_file.is_native() == true){ + if (art_file.query_exists() == false){ + // Can't load the image, set prop to empty and return. + this.property_set_int ( prop, EMPTY ); + return; + } string path; try{ - path = Filename.from_uri ( uri.strip() ); + path = Filename.from_uri ( uri.strip() ); + debug ("Populating the artwork field with %s", uri.strip()); this.property_set ( prop, path ); } catch(ConvertError e){ @@ -150,7 +156,7 @@ public class MetadataMenuitem : PlayerItem if(this.previous_temp_album_art_path != null){ FileUtils.remove(this.previous_temp_album_art_path); } - this.previous_temp_album_art_path = path; + this.previous_temp_album_art_path = path; } } catch(GLib.Error e){ -- cgit v1.2.3