← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~cjcurran/indicator-sound/refactoring_1 into lp:indicator-sound

 

Conor Curran has proposed merging lp:~cjcurran/indicator-sound/refactoring_1 into lp:indicator-sound.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)


Refactors the vala code base making it far more oop. 
-- 
https://code.launchpad.net/~cjcurran/indicator-sound/refactoring_1/+merge/28156
Your team ayatana-commits is subscribed to branch lp:indicator-sound.
=== modified file 'src/Makefile.am'
--- src/Makefile.am	2010-06-17 18:26:03 +0000
+++ src/Makefile.am	2010-06-22 10:44:24 +0000
@@ -56,17 +56,20 @@
 	metadata-menu-item.vala \
 	player-controller.vala \
 	mpris-controller-v2.vala \
-	mpris-controller.vala
+	mpris-controller.vala \
+	player-item.vala
 
 music_bridge_VALAFLAGS = \
   --ccode \
   -H music-player-bridge.h -d . \
   --library music-bridge \
   --vapidir=./ \
+  --vapidir=../vapi/ \
   --thread \
   --pkg gee-1.0 \
   --pkg Indicate-0.2 \
   --pkg Dbusmenu-Glib-0.2 \
+  --pkg common-defs \
 	--pkg dbus-glib-1
  
   $(MAINTAINER_VALAFLAGS)

=== modified file 'src/common-defs.h'
--- src/common-defs.h	2010-06-13 21:27:50 +0000
+++ src/common-defs.h	2010-06-22 10:44:24 +0000
@@ -27,10 +27,10 @@
 /* DBUS Custom Items */
 #define DBUSMENU_SLIDER_MENUITEM_TYPE          	"x-canonical-ido-slider-item"
 #define DBUSMENU_TRANSPORT_MENUITEM_TYPE       	"x-canonical-transport-bar"
-#define DBUSMENU_TRANSPORT_MENUITEM_STATE  		 	"x-canonical-transport-state"
+#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE  		 	"x-canonical-transport-state"
 
 #define DBUSMENU_METADATA_MENUITEM_TYPE  				"x-canonical-metadata-menu-item"
 #define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST  "x-canonical-metadata-text-artist"
-#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE  	"x-canonical-metadata-text-piece"
-#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER  "x-canonical-metadata-text-container"
-#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH  			"x-canonical-metadata-image"
+#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_ARTURL  			"x-canonical-metadata-arturl"

=== modified file 'src/metadata-menu-item.vala'
--- src/metadata-menu-item.vala	2010-06-17 17:02:38 +0000
+++ src/metadata-menu-item.vala	2010-06-22 10:44:24 +0000
@@ -1,40 +1,22 @@
 using Dbusmenu;
 using Gee;
+using DbusmenuMetadata;
 
-public class MetadataMenuitem : Dbusmenu.Menuitem
+public class MetadataMenuitem : PlayerItem
 {
-	/* Not ideal duplicate definition of const - see common-defs/h */
- 	const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item";
- 	const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist";
- 	const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece";
- 	const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container";
-	const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image";
-
 	public MetadataMenuitem()
   {
-		this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE);
-	}
-
-	public 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_PIECE, data.get("title").strip());
-		this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, data.get("album").strip());
-		this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl")));
-	}
-
-	public static string sanitize_image_path(string path)
-	{
-		string result = path.strip();
-		if(result.has_prefix("file:///")){
-			result = result.slice(7, result.len());		                   
-		}
-		debug("Sanitize image path - result = %s", result);
-		return result;
+		this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE);
+	}
+
+	public static HashSet<string> attributes_format()
+	{
+		HashSet<string> attrs = new HashSet<string>();		
+		attrs.add(MENUITEM_TEXT_TITLE);
+    attrs.add(MENUITEM_TEXT_ARTIST);
+    attrs.add(MENUITEM_TEXT_ALBUM);
+    attrs.add(MENUITEM_ARTURL);
+		return attrs;
 	}
 		
-	public override void handle_event(string name, GLib.Value input_value, uint timestamp)
-	{
-		debug("MetadataItem -> handle event caught!");
-	}	
 }
\ No newline at end of file

=== modified file 'src/metadata-widget.c'
--- src/metadata-widget.c	2010-06-17 17:02:38 +0000
+++ src/metadata-widget.c	2010-06-22 10:44:24 +0000
@@ -93,7 +93,7 @@
 	
 	// 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);
@@ -106,13 +106,13 @@
 	
 	// piece
 	GtkWidget* piece;
-	piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE));
+	piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_TITLE));
 	priv->piece_label =  piece;
 
 
 	// container
 	GtkWidget* container;
-	container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER));
+	container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM));
 	priv->container_label = container;
 
 	// Pack in the right order
@@ -171,13 +171,13 @@
 	if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, property) == 0){  
 		gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value));
 	}
-	else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, property) == 0){  
+	else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, property) == 0){  
 		gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value));
 	}	
-	else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, property) == 0){  
+	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 @@
 	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);	

=== modified file 'src/mpris-controller.vala'
--- src/mpris-controller.vala	2010-06-17 15:41:54 +0000
+++ src/mpris-controller.vala	2010-06-22 10:44:24 +0000
@@ -20,7 +20,6 @@
 
 using Gee;
 
-
 public class MprisController : GLib.Object
 {
   private DBus.Connection connection;
@@ -33,7 +32,6 @@
     public int32 endless;
   }
 		
-	
 	public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){
     try {
       this.connection = DBus.Bus.get (DBus.BusType.SESSION);
@@ -43,18 +41,23 @@
 		this.controller = controller;
 		this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface);				
     this.mpris_player.TrackChange += onTrackChange;	
-    this.mpris_player.StatusChange += onStatusChange;		
-		this.controller.update_playing_info(get_track_data());
-	}
-
-	public HashMap<string, string> get_track_data()
-	{
-		return format_metadata(this.mpris_player.GetMetadata());
-	}
+    this.mpris_player.StatusChange += onStatusChange;	
+
+		status st = this.mpris_player.GetStatus();
+		int play_state =  st.playback;
+		debug("GetStatusChange - play state %i", play_state);
+		(this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
+		this.controller.custom_items[this.controller.METADATA].update(this.mpris_player.GetMetadata(),
+		                            MetadataMenuitem.attributes_format());
+		
+	}
+
 
 	private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
 	{
-		this.controller.update_playing_info(format_metadata(ht));
+		debug("onTrackChange");
+		this.controller.custom_items[this.controller.METADATA].update(ht,
+		                            MetadataMenuitem.attributes_format());
 	}
 
 	/**
@@ -76,26 +79,17 @@
 	private void onStatusChange(dynamic DBus.Object mpris_client, status st)
   {
     debug("onStatusChange - signal received");	
-		//ValueArray a = new ValueArray(4);
-		//Value v = new Value(typeof(int32));          
-		//v.set_int(st.playback);
-		//a.append(v);
-		//debug("onStatusChange - play %i", a.get_nth(0).get_int());
-		//int playback = (ValueArray)st.get_nth(0).get_int();
-		//int shuffle = ar.get_nth(1).get_int();
-		//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;                          				
+		status* status = &st;
+		unowned ValueArray ar = (ValueArray)status;
+		
+		int play_state = ar.get_nth(0).get_int();
+		debug("onStatusChange - play state %i", play_state);
+		//HashTable<string, Value?> ht = new HashTable<string, Value?>(str_hash, str_equal);
+		//int* type = &play_state;
+		//Value v = Value(typeof(int*));
+		//v.set_pointer(type);
+		//ht.insert("state", v); 
+		(this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
 	}
 	
 }

=== modified file 'src/player-controller.vala'
--- src/player-controller.vala	2010-06-17 15:41:54 +0000
+++ src/player-controller.vala	2010-06-22 10:44:24 +0000
@@ -23,13 +23,13 @@
 
 public class PlayerController : GLib.Object
 {
-	private const int METADATA = 2;	
+	public const int METADATA = 2;	
 	private const int TRANSPORT = 3;
 	
 	private Dbusmenu.Menuitem root_menu;
 	private string name;
 	private bool is_active;
-	private ArrayList<Dbusmenu.Menuitem> custom_items;	
+	public ArrayList<PlayerItem> custom_items;	
 	private MprisController mpris_adaptor;
 
 	public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active)
@@ -37,7 +37,7 @@
 		this.root_menu = root;
 		this.name = format_client_name(client_name.strip());
 		this.is_active = active;
-		this.custom_items = new ArrayList<Dbusmenu.Menuitem>();
+		this.custom_items = new ArrayList<PlayerItem>();
 		self_construct();
 		
 		// Temporary scenario to handle both v1 and v2 of MPRIS.
@@ -47,12 +47,7 @@
 		else{
 			this.mpris_adaptor = new MprisController(this.name, this);
 		}			
-
-		// TODO subclass dbusmenuMenuitem to something like a playermenuitem 
-		// and use this type to collectively 
-		// control widgets.
-		TransportMenuitem t = (TransportMenuitem)this.custom_items[TRANSPORT];
-		t.set_adaptor(this.mpris_adaptor);
+		this.custom_items[TRANSPORT].set_adaptor(this.mpris_adaptor);
 	}
 
 	public void vanish()
@@ -65,15 +60,10 @@
 	private bool self_construct()
 	{
 		// Separator item
-		Dbusmenu.Menuitem separator_item = new Dbusmenu.Menuitem();
-		separator_item.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR);			
-		this.custom_items.add(separator_item);
+		this.custom_items.add(PlayerItem.new_separator_item());
 
 		// Title item
-		Dbusmenu.Menuitem title_item = new Dbusmenu.Menuitem();
-		title_item.property_set(MENUITEM_PROP_LABEL, this.name);					
-		title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia");			
-		this.custom_items.add(title_item);
+		this.custom_items.add(PlayerItem.new_title_item(this.name));
 
 		// Metadata item
 		MetadataMenuitem metadata_item = new MetadataMenuitem();
@@ -84,18 +74,18 @@
 		this.custom_items.add(transport_item);
 
 		int offset = 2;
-		foreach(Dbusmenu.Menuitem item in this.custom_items){
+		foreach(PlayerItem item in this.custom_items){
 			root_menu.child_add_position(item, offset + this.custom_items.index_of(item));			
 		}
 		return true;
 	}	
 
-	public void update_playing_info(HashMap<string, string> data)
-	{
-		debug("PlayerController - update_playing_info");
-		MetadataMenuitem item = (MetadataMenuitem)this.custom_items[METADATA];		
-		item.update(data);
-	}
+	//public void update_playing_info(HashMap<string, string> data)
+	//{
+	//	debug("PlayerController - update_playing_info");
+	//	MetadataMenuitem item = this.custom_items[METADATA] as MetadataMenuitem;		
+	//	item.update(data, MetadataMenuitem.attributes_format());
+	//}
 
 	private static string format_client_name(string client_name)
 	{

=== added file 'src/player-item.vala'
--- src/player-item.vala	1970-01-01 00:00:00 +0000
+++ src/player-item.vala	2010-06-22 10:44:24 +0000
@@ -0,0 +1,92 @@
+/*
+This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
+Copyright 2010 Canonical Ltd.
+
+Authors:
+    Conor Curran <conor.curran@xxxxxxxxxxxxx>
+
+This program is free software: you can redistribute it and/or modify it 
+under the terms of the GNU General Public License version 3, as published 
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but 
+WITHOUT ANY WARRANTY; without even the implied warranties of 
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
+PURPOSE.  See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along 
+with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using Dbusmenu;
+using Gee;
+
+public class PlayerItem : Dbusmenu.Menuitem
+{
+	public MprisController mpris_adaptor;
+	
+	public PlayerItem()
+	{		
+	}
+
+	public void update(HashTable<string, Value?> data, HashSet<string> attributes)
+	{
+		debug("PlayerItem::update()");
+		foreach(string property in attributes){
+			string[] input_keys = property.split("-");
+			string search_key = input_keys[input_keys.length-1 : input_keys.length][0];
+			debug("search key = %s", search_key);
+			if (data.lookup(search_key).holds (typeof (string))){
+				debug("track data change player item update");
+				this.property_set(property, this.sanitize_string(data.lookup(search_key) as string));
+			}			    
+			else if (data.lookup(search_key).holds (typeof (int))){
+				// Circumvent weird vala bug
+				int* v = (int*)data.lookup(search_key);
+				int r = *v;
+				this.property_set_int(property, r);
+			}
+			else if(data.lookup(search_key).holds (typeof (bool))){
+				bool* b = (bool*)data.lookup(search_key);
+				bool input = *b;
+				this.property_set_bool(property, input);
+			}
+		}
+	}	
+
+	public void set_adaptor(MprisController adaptor)
+	{
+		this.mpris_adaptor = adaptor;		
+	}
+
+
+	public static string sanitize_string(string st)
+	{
+		string result = st.strip();
+		if(result.has_prefix("file:///")){
+			result = result.slice(7, result.len());		                   
+		}
+		debug("Sanitize string - result = %s", result);
+		return result;
+	}
+
+	
+	//----- Custom constructors for player items ----------------//
+	// Title item
+	public static PlayerItem new_title_item(dynamic string name)
+	{
+		PlayerItem item = new PlayerItem();
+		item.property_set(MENUITEM_PROP_LABEL, name);					
+		item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia");			
+		return item;		
+	}
+
+	// Separator item
+	public static PlayerItem new_separator_item()
+	{
+		PlayerItem separator = new PlayerItem();
+		separator.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR);					
+		return separator;
+	}	
+}
+

=== modified file 'src/transport-menu-item.vala'
--- src/transport-menu-item.vala	2010-06-17 15:41:54 +0000
+++ src/transport-menu-item.vala	2010-06-22 10:44:24 +0000
@@ -20,35 +20,32 @@
 
 using Dbusmenu;
 using Gee;
+using DbusmenuTransport;
 
-public class TransportMenuitem : Dbusmenu.Menuitem
+public class TransportMenuitem : PlayerItem
 {
-	/* Not ideal duplicate definition of const - see common-defs/h */
- 	const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar";
- 	const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state";
-	private MprisController mpris_adaptor;
 	
 	public TransportMenuitem()
   {
-		this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE);
-		// Hardcode the set up state until we can get the struct vala bug fixed
-		this.property_set_bool(DBUSMENU_TRANSPORT_MENUITEM_STATE, false);
+		this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE);
 		debug("transport on the vala side");
 	}
 
-	public void set_adaptor(MprisController adaptor)
+	public void change_play_state(int state)
 	{
-		this.mpris_adaptor = adaptor;		
+		this.property_set_int(MENUITEM_PLAY_STATE, state);	
 	}
 	
-	/**
-	 Callback method for the handle_event
-	 * TRUE  => Playing
-	 * FALSE => Paused
-	 **/
 	public override void handle_event(string name, GLib.Value input_value, uint timestamp)
 	{
 		debug("handle_event with bool value %s", input_value.get_boolean().to_string());
 		this.mpris_adaptor.toggle_playback(input_value.get_boolean());
+	}
+
+	public static HashSet<string> attributes_format()
+	{
+		HashSet<string> attrs = new HashSet<string>();		
+		attrs.add(MENUITEM_PLAY_STATE);
+		return attrs;
 	}	
 }
\ No newline at end of file

=== modified file 'src/transport-widget.c'
--- src/transport-widget.c	2010-06-17 17:02:38 +0000
+++ src/transport-widget.c	2010-06-22 10:44:24 +0000
@@ -61,13 +61,15 @@
                                                   		GdkEventButton        *event);
 static gboolean transport_widget_button_release_event (GtkWidget             *menuitem,
                                                     	GdkEventButton        *event);
-
+static void transport_widget_play_clicked (GtkWidget* button,
+                                           TransportWidget* self);
+                                          
 static void transport_widget_property_update(DbusmenuMenuitem* item,
                                        gchar * property, 
                                        GValue * value,
                                        gpointer userdata);
 // utility methods
-static gchar* transport_widget_toggle_play_label(const gchar* state);
+static gchar* transport_widget_toggle_play_label(gint state);
 
 G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
 
@@ -78,7 +80,9 @@
 {
 	GObjectClass 			*gobject_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass    *widget_class = GTK_WIDGET_CLASS (klass);
+	GtkMenuItemClass *menu_item_class =  GTK_MENU_ITEM_CLASS(klass);
 
+	menu_item_class->hide_on_activate = FALSE;
   widget_class->button_press_event = transport_widget_button_press_event;
   widget_class->button_release_event = transport_widget_button_release_event;
 	
@@ -130,19 +134,16 @@
 	GtkWidget *hbox;
 
 	hbox = gtk_hbox_new(TRUE, 2);
-
-	gchar* label = ">";
-	if(dbusmenu_menuitem_property_get_bool(twin_item, DBUSMENU_TRANSPORT_MENUITEM_STATE) == TRUE){
-		label = "||";
-	}
-
-	priv->play_button =	gtk_button_new_with_label(g_strdup(label));
+	gchar* symbol = transport_widget_toggle_play_label(dbusmenu_menuitem_property_get_int(twin_item, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE));
+	priv->play_button =	gtk_button_new_with_label(symbol);
 	gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0);
 
 	priv->hbox = hbox;
 	
 	g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self);
 
+	g_signal_connect(priv->play_button, "clicked", G_CALLBACK(transport_widget_play_clicked), self);
+	                 
 	gtk_container_add (GTK_CONTAINER (self), priv->hbox);
 
   gtk_widget_show_all (priv->hbox);
@@ -166,11 +167,13 @@
                                   	GdkEventButton *event)
 {
 	g_debug("TransportWidget::menu_press_event");
+
 	TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
 
+	gtk_widget_event (priv->hbox, (GdkEvent*)event);
 	gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0;
 
-	gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))));
+	gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label((gint)state));
  	GValue value = {0};
   g_value_init(&value, G_TYPE_BOOLEAN);
 	g_debug("TransportWidget::menu_press_event - going to send value %i", state);
@@ -181,11 +184,21 @@
 	return TRUE;
 }
 
+static void
+transport_widget_play_clicked(GtkWidget* button,
+                              TransportWidget* self)
+{
+	g_debug("Transport_widget_play_clicked");
+}
+                              
 static gboolean
 transport_widget_button_release_event (GtkWidget *menuitem, 
                                   GdkEventButton *event)
 {
 	g_debug("TransportWidget::menu_release_event");
+	TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+	gtk_widget_event (priv->hbox, (GdkEvent*)event);
+	
 	return TRUE;
 }
 
@@ -198,20 +211,20 @@
                                        GValue* value, gpointer userdata)
 {
 	g_debug("transport_widget_update_state - with property  %s", property);  
-	gchar* input = g_strdup(g_value_get_string(value));
-	g_debug("transport_widget_update_state - with value  %s", input);  
+	int update_value = g_value_get_int(value);
+	g_debug("transport_widget_update_state - with value  %i", update_value);  
 
 	TransportWidget* bar = (TransportWidget*)userdata;
 	TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
 	
-	gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_toggle_play_label(property)));
+	gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(update_value));
 }
 
 // will be needed for image swapping
-static gchar* transport_widget_toggle_play_label(const gchar* state)
+static gchar* transport_widget_toggle_play_label(int play_state)
 {
 	gchar* label = ">";
-	if(g_strcmp0(state, ">") == 0){
+	if(play_state == 1){
 		label = "||";
 	}
 	return label;

=== added directory 'vapi'
=== added file 'vapi/common-defs.vapi'
--- vapi/common-defs.vapi	1970-01-01 00:00:00 +0000
+++ vapi/common-defs.vapi	2010-06-22 10:44:24 +0000
@@ -0,0 +1,15 @@
+/* music-bridge.vapi generated by valac, do not modify. */
+[CCode (cheader_filename = "common-defs.h")]
+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;	
+}
+
+[CCode (cheader_filename = "common-defs.h")]
+namespace DbusmenuTransport{
+	public const string MENUITEM_TYPE;
+	public const string MENUITEM_PLAY_STATE;
+}
\ No newline at end of file


Follow ups