From 16bdc89ecb9aa7e31d7efd8b34b0a632d4440f5e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 4 Mar 2011 14:30:17 +0000 Subject: iconthemepath work in progress --- src/playlists-menu-item.vala | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/playlists-menu-item.vala') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index f4d7233..4ed6cf4 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -47,6 +47,12 @@ public class PlaylistsMenuitem : PlayerItem Dbusmenu.Menuitem menuitem = new Menuitem(); menuitem.property_set (MENUITEM_PROP_LABEL, detail.name); + + var icon_file = File.new_for_path (detail.icon_path); + if (icon_file.query_exists () == true) { + menuitem.property_set (MENUITEM_PROP_ICON_NAME, + icon_file.get_basename () ); + } menuitem.property_set (MENUITEM_PROP_ICON_NAME, detail.icon_path); menuitem.property_set (MENUITEM_PATH, (string)detail.path); menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true); -- cgit v1.2.3 From fb651cca574070250f95dca42c888f97be5989f2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 4 Mar 2011 16:32:31 +0000 Subject: debug trace --- src/playlists-menu-item.vala | 1 + 1 file changed, 1 insertion(+) (limited to 'src/playlists-menu-item.vala') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 4ed6cf4..9b1f724 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -50,6 +50,7 @@ public class PlaylistsMenuitem : PlayerItem var icon_file = File.new_for_path (detail.icon_path); if (icon_file.query_exists () == true) { + debug ("icon name = %s", icon_file.get_basename ()); menuitem.property_set (MENUITEM_PROP_ICON_NAME, icon_file.get_basename () ); } -- cgit v1.2.3 From bc33d0a5ef7a294804719273811cdd2878bddbe9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Mar 2011 18:58:36 +0000 Subject: now uses the correct basename minus the extension for the icon name property --- src/playlists-menu-item.vala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/playlists-menu-item.vala') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 9b1f724..78fb6dc 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -49,10 +49,14 @@ public class PlaylistsMenuitem : PlayerItem menuitem.property_set (MENUITEM_PROP_LABEL, detail.name); var icon_file = File.new_for_path (detail.icon_path); - if (icon_file.query_exists () == true) { - debug ("icon name = %s", icon_file.get_basename ()); + + if (icon_file.get_basename () != null) { + debug ("icon name = %s", icon_file.get_basename().split(".")[0]); menuitem.property_set (MENUITEM_PROP_ICON_NAME, - icon_file.get_basename () ); + icon_file.get_basename().split(".")[0]); + } + // TODO: Make sure to set a stock playlist image + else{ } menuitem.property_set (MENUITEM_PROP_ICON_NAME, detail.icon_path); menuitem.property_set (MENUITEM_PATH, (string)detail.path); -- cgit v1.2.3 From 8ded632700c7331b9e4e1f9f1b19ae9bade2eced Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Mar 2011 19:36:20 +0000 Subject: tidied --- src/playlists-menu-item.vala | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/playlists-menu-item.vala') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 78fb6dc..2b820e5 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -47,18 +47,13 @@ public class PlaylistsMenuitem : PlayerItem Dbusmenu.Menuitem menuitem = new Menuitem(); menuitem.property_set (MENUITEM_PROP_LABEL, detail.name); - - var icon_file = File.new_for_path (detail.icon_path); - - if (icon_file.get_basename () != null) { - debug ("icon name = %s", icon_file.get_basename().split(".")[0]); - menuitem.property_set (MENUITEM_PROP_ICON_NAME, - icon_file.get_basename().split(".")[0]); + var result = this.parse_icon_path (detail.icon_path); + if (result != null) { + menuitem.property_set (MENUITEM_PROP_ICON_NAME, result); } // TODO: Make sure to set a stock playlist image else{ } - menuitem.property_set (MENUITEM_PROP_ICON_NAME, detail.icon_path); menuitem.property_set (MENUITEM_PATH, (string)detail.path); menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true); menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true); @@ -88,12 +83,25 @@ public class PlaylistsMenuitem : PlayerItem } } + private string? parse_icon_path (string path) + { + var icon_file = File.new_for_path (path); + + if (icon_file.get_basename() == null)return null; + + debug ("icon name = %s", icon_file.get_basename().split(".")[0]); + return icon_file.get_basename().split(".")[0]; + } + public void update_individual_playlist (PlaylistDetails new_detail) { foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){ if (new_detail.path == item.property_get (MENUITEM_PATH)){ item.property_set (MENUITEM_PROP_LABEL, new_detail.name); - item.property_set (MENUITEM_PROP_ICON_NAME, new_detail.icon_path); + var result = this.parse_icon_path (new_detail.icon_path); + if (result != null) { + item.property_set (MENUITEM_PROP_ICON_NAME, result); + } } } // If its active make sure the name is updated on the root item. -- cgit v1.2.3 From bd007a90262f90081c1be04947e949191cb7e1c6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 11 Mar 2011 11:43:09 +0000 Subject: players who do not export icon names will have iconless playlists menuitems --- src/playlists-menu-item.vala | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/playlists-menu-item.vala') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 2b820e5..9dcb686 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -48,12 +48,11 @@ public class PlaylistsMenuitem : PlayerItem Dbusmenu.Menuitem menuitem = new Menuitem(); menuitem.property_set (MENUITEM_PROP_LABEL, detail.name); var result = this.parse_icon_path (detail.icon_path); + if (result != null) { - menuitem.property_set (MENUITEM_PROP_ICON_NAME, result); - } - // TODO: Make sure to set a stock playlist image - else{ + menuitem.property_set (MENUITEM_PROP_ICON_NAME, result); } + menuitem.property_set (MENUITEM_PATH, (string)detail.path); menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true); menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true); @@ -85,11 +84,9 @@ public class PlaylistsMenuitem : PlayerItem private string? parse_icon_path (string path) { + if (path == "")return null; var icon_file = File.new_for_path (path); - - if (icon_file.get_basename() == null)return null; - - debug ("icon name = %s", icon_file.get_basename().split(".")[0]); + if (icon_file.get_path() == null)return null; return icon_file.get_basename().split(".")[0]; } -- cgit v1.2.3 From 6b0f3ffcaf55d151d87f8dc60d16388b8f4557a2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 11 Mar 2011 15:16:09 +0000 Subject: applied Mikkel's suggestions --- src/playlists-menu-item.vala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/playlists-menu-item.vala') diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 9dcb686..b3fd7c6 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -84,10 +84,7 @@ public class PlaylistsMenuitem : PlayerItem private string? parse_icon_path (string path) { - if (path == "")return null; - var icon_file = File.new_for_path (path); - if (icon_file.get_path() == null)return null; - return icon_file.get_basename().split(".")[0]; + return ( path == "" ? null : Path.get_basename(path).split(".")[0] ); } public void update_individual_playlist (PlaylistDetails new_detail) -- cgit v1.2.3