aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-21 16:25:16 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-21 16:25:16 +0100
commit7be2c7248a0b29ea74e8e36db405d5974995a57b (patch)
tree694e0fc9fa91ff83d842508f9e1b830a5e66b75b
parent87445b8921774ec705b4bb62429a5f69be941737 (diff)
downloadayatana-indicator-sound-7be2c7248a0b29ea74e8e36db405d5974995a57b.tar.gz
ayatana-indicator-sound-7be2c7248a0b29ea74e8e36db405d5974995a57b.tar.bz2
ayatana-indicator-sound-7be2c7248a0b29ea74e8e36db405d5974995a57b.zip
going for generic property updates
-rw-r--r--src/common-defs.h2
-rw-r--r--src/metadata-menu-item.vala48
-rw-r--r--src/metadata-widget.c6
-rw-r--r--src/mpris-controller.vala13
-rw-r--r--src/player-controller.vala2
-rw-r--r--src/player-item.vala16
-rw-r--r--vapi/common-defs.vapi12
7 files changed, 46 insertions, 53 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index d35c672..1e53e07 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -33,4 +33,4 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist"
#define DBUSMENU_METADATA_MENUITEM_TEXT_TITLE "x-canonical-metadata-text-title"
#define DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM "x-canonical-metadata-text-album"
-#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image"
+#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-metadata-image"
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 2b865f7..5464074 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -1,22 +1,21 @@
using Dbusmenu;
using Gee;
-using CommonDefs;
+using DbusmenuMetadata;
public class MetadataMenuitem : PlayerItem
{
public MetadataMenuitem()
{
- this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE);
-
+ this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE);
}
- public override void update(HashMap<string, string> data)
- {
- this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip());
- this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, data.get("title").strip());
- this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, data.get("album").strip());
- this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl")));
- }
+ //public override void update(HashMap<string, string> data)
+ //{
+ // this.property_set(MENUITEM_TEXT_ARTIST, data.get("artist").strip());
+ // this.property_set(MENUITEM_TEXT_TITLE, data.get("title").strip());
+ // this.property_set(MENUITEM_TEXT_ALBUM, data.get("album").strip());
+ // this.property_set(MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl")));
+ //}
public static string sanitize_image_path(string path)
{
@@ -27,21 +26,26 @@ public class MetadataMenuitem : PlayerItem
debug("Sanitize image path - result = %s", result);
return result;
}
-
- public override void handle_event(string name, GLib.Value input_value, uint timestamp)
+
+ public static HashMap<string, Type> attributes_format()
{
- debug("MetadataItem -> handle event caught!");
- }
+ HashMap<string,Type> results = new HashMap<string, Type>();
+ results.set(MENUITEM_TEXT_TITLE, typeof(string));
+ results.set(MENUITEM_TEXT_ARTIST, typeof(string));
+ results.set(MENUITEM_TEXT_ALBUM, typeof(string));
+ results.set(MENUITEM_TEXT_ARTURL, typeof(string));
+ return results;
+ }
+
- public static HashMap<string, Type> attributes()
+ public static HashMap<string, string> format_updates(HashMap<string, Value?> data)
{
- HashMap<string, Type> result = new HashMap<string, Type>();
- result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, typeof(string));
- result.set(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, typeof(string));
- result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, typeof(string));
- result.set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, typeof(string));
+ HashMap<string,string> results = new HashMap<string, string>();
- return result;
+ results.set(MENUITEM_TEXT_TITLE, (string)data.lookup("title").strip());
+ results.set(MENUITEM_TEXT_ARTIST, (string)data.lookup("artist").strip());
+ results.set(MENUITEM_TEXT_ALBUM, (string)data.lookup("album").strip(), typeof(string));
+ results.set(MENUITEM_TEXT_ARTURL, sanitize_image_path((string)data.lookup("arturl").strip()), typeof(string));
+ return results;
}
-
} \ No newline at end of file
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index b2ca255..66e8cac 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -93,7 +93,7 @@ metadata_widget_init (MetadataWidget *self)
// image
priv->album_art = gtk_image_new();
- priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH));
+ priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL));
update_album_art(self);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0);
GtkWidget* vbox = gtk_vbox_new(TRUE, 0);
@@ -177,7 +177,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value));
}
- else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){
+ else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){
if(priv->image_path != NULL){
g_free(priv->image_path);
}
@@ -194,7 +194,7 @@ static void update_album_art(MetadataWidget* self){
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
GdkPixbuf* pixbuf;
pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL);
- pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60,GDK_INTERP_BILINEAR);
+ pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR);
g_debug("attempting to set the image with path %s", priv->image_path);
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf);
g_object_unref(pixbuf);
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index cd1d2db..98473ad 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -54,7 +54,7 @@ public class MprisController : GLib.Object
private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
{
- this.controller.update_playing_info(format_metadata(ht));
+ this.controller.update_playing_info(MetadataMenuitem.format_updates(ht));
}
/**
@@ -85,16 +85,5 @@ public class MprisController : GLib.Object
//int repeat = ar.get_nth(2).get_int();
//int endless = ar.get_nth(3).get_int();
}
-
- private static HashMap<string, string> format_metadata(HashTable<string,Value?> data)
- {
- HashMap<string,string> results = new HashMap<string, string>();
- debug("format_metadata - title = %s", (string)data.lookup("title"));
- results.set("title", (string)data.lookup("title"));
- results.set("artist", (string)data.lookup("artist"));
- results.set("album", (string)data.lookup("album"));
- results.set("arturl", (string)data.lookup("arturl"));
- return results;
- }
}
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 22a200e..ef1e130 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -84,7 +84,7 @@ public class PlayerController : GLib.Object
public void update_playing_info(HashMap<string, string> data)
{
debug("PlayerController - update_playing_info");
- MetadataMenuitem item = (MetadataMenuitem)this.custom_items[METADATA];
+ MetadataMenuitem item = this.custom_items[METADATA] as MetadataMenuitem;
item.update(data);
}
diff --git a/src/player-item.vala b/src/player-item.vala
index aa35b33..10dedc2 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -26,15 +26,17 @@ public class PlayerItem : Dbusmenu.Menuitem
public MprisController mpris_adaptor;
public PlayerItem()
- {
+ {
}
- public virtual void update(HashMap<string, Value?> data)
+ public void update(HashMap<string, Value?> data, Type type)
{
debug("PlayerItem::update()");
- //foreach(var key in this.attributes().keys){
- // this.attributes.get(key);
- //}
+ HashMap<string, Type> attributes = type.attributes_format();
+ foreach(var property in data){
+ //property.value as attributes.get(property.key)
+ //this.property_set(property.key, );
+ }
}
public void set_adaptor(MprisController adaptor)
@@ -58,8 +60,6 @@ public class PlayerItem : Dbusmenu.Menuitem
PlayerItem separator = new PlayerItem();
separator.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR);
return separator;
- }
-
-
+ }
}
diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi
index 8f374d0..ce77929 100644
--- a/vapi/common-defs.vapi
+++ b/vapi/common-defs.vapi
@@ -1,9 +1,9 @@
/* music-bridge.vapi generated by valac, do not modify. */
[CCode (cheader_filename = "common-defs.h")]
-namespace CommonDefs{
- public const string DBUSMENU_METADATA_MENUITEM_TYPE;
- public const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST;
- public const string DBUSMENU_METADATA_MENUITEM_TEXT_TITLE;
- public const string DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM;
- public const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH;
+namespace DbusmenuMetadata{
+ public const string MENUITEM_TYPE;
+ public const string MENUITEM_TEXT_ARTIST;
+ public const string MENUITEM_TEXT_TITLE;
+ public const string MENUITEM_TEXT_ALBUM;
+ public const string MENUITEM_ARTURL;
} \ No newline at end of file