← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~cjcurran/indicator-sound/ui-bug-fixes into lp:indicator-sound

 

Conor Curran has proposed merging lp:~cjcurran/indicator-sound/ui-bug-fixes into lp:indicator-sound.

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

-- 
https://code.launchpad.net/~cjcurran/indicator-sound/ui-bug-fixes/+merge/31050
Your team ayatana-commits is subscribed to branch lp:indicator-sound.
=== modified file 'src/common-defs.h'
--- src/common-defs.h	2010-07-21 09:56:15 +0000
+++ src/common-defs.h	2010-07-27 14:21:08 +0000
@@ -19,26 +19,29 @@
 
 
 /* constants used for signals on the dbus. This file is shared between client and server implementation */
-#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
-#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
-#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
-#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate"
+#define SIGNAL_SINK_INPUT_WHILE_MUTED 					"SinkInputWhileMuted"
+#define SIGNAL_SINK_VOLUME_UPDATE 							"SinkVolumeUpdate"
+#define SIGNAL_SINK_MUTE_UPDATE 								"SinkMuteUpdate"
+#define SIGNAL_SINK_AVAILABLE_UPDATE 						"SinkAvailableUpdate"
+
+#define DBUSMENU_PROPERTY_EMPTY									-1
 
 /* 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_PLAY_STATE  "x-canonical-transport-play-state"
-
-#define DBUSMENU_METADATA_MENUITEM_TYPE  				"x-canonical-sound-menu-player-metadata-menu-item"
+#define DBUSMENU_SLIDER_MENUITEM_TYPE          	"x-canonical-ido-slider-type"
+
+#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-artist"
 #define DBUSMENU_METADATA_MENUITEM_TITLE  			"x-canonical-sound-menu-player-metadata-title"
 #define DBUSMENU_METADATA_MENUITEM_ALBUM   			"x-canonical-sound-menu-player-metadata-album"
 #define DBUSMENU_METADATA_MENUITEM_ARTURL  			"x-canonical-sound-menu-player-metadata-arturl"
 
-#define DBUSMENU_TITLE_MENUITEM_TYPE          	"x-canonical-sound-menu-player-title-menu-item"
+#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_SCRUB_MENUITEM_TYPE						"x-canonical-sound-menu-player-scrub-menu-item"
+#define DBUSMENU_SCRUB_MENUITEM_TYPE						"x-canonical-sound-menu-player-scrub-type"
 #define DBUSMENU_SCRUB_MENUITEM_DURATION				"x-canonical-sound-menu-player-scrub-time"
 #define DBUSMENU_SCRUB_MENUITEM_POSITION				"x-canonical-sound-menu-player-scrub-position"
 #define DBUSMENU_SCRUB_MENUITEM_PLAY_STATE			"x-canonical-sound-menu-player-scrub-play-state"

=== modified file 'src/metadata-menu-item.vala'
--- src/metadata-menu-item.vala	2010-07-22 17:56:43 +0000
+++ src/metadata-menu-item.vala	2010-07-27 14:21:08 +0000
@@ -26,6 +26,7 @@
 	public MetadataMenuitem()
   {
 		Object(item_type: MENUITEM_TYPE); 	
+		reset(attributes_format());
 	}
 
 	public static HashSet<string> attributes_format()
@@ -37,11 +38,5 @@
     attrs.add(MENUITEM_ARTURL);
 		return attrs;
 	}
-	
-	public bool not_populated()
-	{
-		return (this.property_get(MENUITEM_TITLE) == null && 
-		        this.property_get(MENUITEM_TITLE) == "");
-	}
 		
 }
\ No newline at end of file

=== modified file 'src/metadata-widget.c'
--- src/metadata-widget.c	2010-07-13 11:18:08 +0000
+++ src/metadata-widget.c	2010-07-27 14:21:08 +0000
@@ -199,6 +199,16 @@
 {
 	g_return_if_fail (IS_METADATA_WIDGET (userdata));	
 
+	if(g_value_get_int(value) == DBUSMENU_PROPERTY_EMPTY){
+		g_debug("Metadata widget: property update - reset");
+		gchar* empty = "";
+		GValue new_value = {0};
+  	g_value_init(&new_value, G_TYPE_STRING);		
+		g_value_set_string(&new_value, g_strdup(""));		
+		//g_free(empty);
+		value = &new_value;
+	}
+	
 	MetadataWidget* mitem = METADATA_WIDGET(userdata);
 	MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem);
 	

=== modified file 'src/play-button.c'
--- src/play-button.c	2010-07-22 17:56:43 +0000
+++ src/play-button.c	2010-07-27 14:21:08 +0000
@@ -85,16 +85,6 @@
 
 /// internal helper functions //////////////////////////////////////////////////
 
-/*static double
-_align (double val)
-{
-  double fract = val - (int) val;
-
-  if (fract != 0.5f)
-    return (double) ((int) val + 0.5f);
-  else
-    return val;
-}*/
 
 static inline void
 _blurinner (guchar* pixel,
@@ -464,8 +454,29 @@
 play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update)
 {
 	PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+	gboolean changed  = priv->current_state != update; 
 	priv->current_state = update;
 	g_debug("PlayButton::toggle play state : %i", priv->current_state); 
+
+	if(changed == TRUE){
+		g_debug("Toggle play pause - changed of state detected");
+		cairo_t *cr;
+	
+		cr = gdk_cairo_create (button->window);
+
+		GList* list = g_hash_table_lookup(priv->command_coordinates,
+			                                GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE));
+
+		cairo_rectangle(cr,
+			              GPOINTER_TO_INT(g_list_nth_data(list, 0)),
+			              GPOINTER_TO_INT(g_list_nth_data(list, 1)),
+										GPOINTER_TO_INT(g_list_nth_data(list, 2)),	               	
+										GPOINTER_TO_INT(g_list_nth_data(list, 3)));
+
+		cairo_clip(cr);
+		draw (button, cr);
+		cairo_destroy (cr);
+	}
 }
 
 

=== modified file 'src/player-controller.vala'
--- src/player-controller.vala	2010-07-22 17:56:43 +0000
+++ src/player-controller.vala	2010-07-27 14:21:08 +0000
@@ -56,7 +56,7 @@
 		this.root_menu = root;
 		this.name = format_client_name(client_name.strip());
 		this.custom_items = new ArrayList<PlayerItem>();
-		this.update_state(initial_state);
+		this.current_state = initial_state;
 		this.menu_offset = offset;
 		construct_widgets();
 		establish_mpris_connection();
@@ -67,7 +67,7 @@
 	{
 		debug("update_state - player controller %s : new state %i", this.name, new_state);
 		this.current_state = new_state;
-		//this.update_layout();
+		this.update_layout();
 	}
 	
 	public void activate()
@@ -108,7 +108,7 @@
 		else{
 			this.mpris_adaptor = new MprisController(this);
 		}
-		
+		// TODO refactor
 		if(this.mpris_adaptor.connected() == true){
 			debug("yup I'm connected");
 			this.update_state(state.CONNECTED);
@@ -116,7 +116,6 @@
 		else{
 			this.update_state(state.DISCONNECTED);
 		}
-		this.update_layout();
 	}
 	
 	public void vanish()
@@ -127,21 +126,28 @@
 	}
 
 	public void update_layout()
-	{
-		bool visibility = true;
-		MetadataMenuitem meta_item = this.custom_items[widget_order.METADATA] as MetadataMenuitem;
-		if(this.current_state != state.CONNECTED /*|| 
-		   meta_item.not_populated()*/){
-			visibility = false;
-		}
-		debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string());
-		this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
-		this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
-		this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);		
-		// DEBUG
-		if(visibility == false){
-			warning("Update layout of client %s is setting widgets to invisibile!", this.name);
-		}
+	{		
+		if(this.current_state != state.CONNECTED){
+			this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE,
+			                                                            false);
+			this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE,
+			                                                        false);
+			this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE,
+			                                                           false);		
+			return;			
+		}
+		
+		debug("update layout - metadata %s", this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()).to_string());
+		this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE,
+			                                                        this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()));
+		debug("update layout - scrub %s", this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()).to_string());
+		this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE,
+		                                                        this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()));
+
+
+		this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE,
+		                                                            this.current_state == state.CONNECTED);
+		
 	}
 		
 	private void construct_widgets()

=== modified file 'src/player-item.vala'
--- src/player-item.vala	2010-07-21 09:56:15 +0000
+++ src/player-item.vala	2010-07-27 14:21:08 +0000
@@ -24,7 +24,8 @@
 {
 	public PlayerController owner {get; construct;}
 	public string item_type { get; construct; }
-
+	private const int EMPTY = -1;
+	
 	public PlayerItem(string type)
 	{		
 		Object(item_type: type);
@@ -36,17 +37,16 @@
 
 	public void reset(HashSet<string> attrs){		
 		foreach(string s in attrs){
-			debug("attempting to set prop %s to null", s);
-			this.property_set(s, null);
-			this.property_set_int(s, 0);
+			debug("attempting to set prop %s to EMPTY", s);
+			this.property_set_int(s, EMPTY);
 		}
 	}
 	
 	public void update(HashTable<string, Value?> data, HashSet<string> attributes)
 	{
 		debug("PlayerItem::update()");
-		if(ensure_valid_updates(data, attributes) == false){
-			debug("PlayerItem::Update -> The hashtable update does not contain what we were expecting - just leave it!");
+		if(data == null){
+			debug("PlayerItem::Update -> The hashtable was null - just leave it!");
 			return;
 		}		
 		
@@ -82,19 +82,21 @@
 				this.property_set_bool(property, v.get_boolean());
 			}
 		}
+		if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){
+			this.property_set_bool(MENUITEM_PROP_VISIBLE, true);
+		}
 	}	
-
-	private static bool ensure_valid_updates(HashTable<string, Value?> data, HashSet<string> attributes)
+	
+	public bool populated(HashSet<string> attrs)
 	{
-		if(data == null){
-			return false;
+		foreach(string prop in attrs){
+		  int value_int = property_get_int(prop);
+			debug("populate - prop %s and value %i", prop, value_int);
+			if(property_get_int(prop) != EMPTY){
+				return true;
+			}
 		}
-		/*if(data.size() < attributes.size){
-			warning("update hash was too small for the target");
-			return false;
-		}*/
-		return true;		
+		return false;
 	}
-
 }
 

=== modified file 'src/scrub-menu-item.vala'
--- src/scrub-menu-item.vala	2010-07-21 09:56:15 +0000
+++ src/scrub-menu-item.vala	2010-07-27 14:21:08 +0000
@@ -26,6 +26,7 @@
 	public ScrubMenuitem(PlayerController parent)
 	{
 		Object(item_type: MENUITEM_TYPE, owner: parent);
+		reset(attributes_format());
 	}
 
 	public override void handle_event(string name, GLib.Value input_value, uint timestamp)

=== modified file 'src/scrub-widget.c'
--- src/scrub-widget.c	2010-07-22 17:56:43 +0000
+++ src/scrub-widget.c	2010-07-27 14:21:08 +0000
@@ -149,6 +149,8 @@
 		ido_timeline_pause(priv->time_line);
 		ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar),
 		                                      scrub_widget_format_time(g_value_get_int(value)/1000)); 					
+
+		g_debug("scrub-widget::update progress = %f", scrub_widget_calculate_progress(mitem)*100); 
 																					
 		ido_timeline_set_progress(priv->time_line, scrub_widget_calculate_progress(mitem)*1000);
 		scrub_widget_set_ido_position(mitem, g_value_get_int(value)/1000,
@@ -235,18 +237,26 @@
 static gchar*
 scrub_widget_format_time(gint time)
 {
-	// Assuming its in seconds for now ...
-	gint minutes = time/60;
-	gint seconds = time % 60;
-	gchar* prefix="0";
-	gchar* seconds_prefix="0";
-	if(minutes > 9)
-		prefix="";
-	if(seconds > 9)
-		seconds_prefix="";
-	return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds);	
+// Assuming its in seconds for now ...
+	gchar* prefix = "-";
+	gchar* seconds_prefix = "-";
+
+	if(time != DBUSMENU_PROPERTY_EMPTY){
+		gint minutes = time/60;
+		gint seconds = time % 60;
+		prefix="0";
+		seconds_prefix="0";
+		if(minutes > 9)
+			prefix="";
+		if(seconds > 9)
+			seconds_prefix="";
+		return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds);	
+	}	
+	else{
+		return g_strdup_printf("%s-:%s-", prefix, seconds_prefix);	
+	}
 }
-
+ 
 static void
 scrub_widget_set_ido_position(ScrubWidget* self,
                               gint position,
@@ -289,7 +299,7 @@
 	ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem);
 	if(priv->scrubbing == TRUE)
 	{
-		//g_debug("don't update the slider or timeline, slider is being scrubbed");
+		g_debug("don't update the slider or timeline, slider is being scrubbed");
 		return;
 	}
 	gint position = progress * dbusmenu_menuitem_property_get_int(priv->twin_item, 
@@ -298,12 +308,12 @@
 	ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), left_text); 	
   GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar);
   GtkRange *range = (GtkRange*)slider;
- 	gtk_range_set_value(range, progress * 100);
-
+ 	//gtk_range_set_value(range, progress * 100);
 	/*g_debug("position in seconds %i and in words %s", position, left_text);
 	g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line));
 	g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line));	
 	*/
+	//g_debug("timeline-update - progress = %f", progress);
 	g_free(left_text);
 }
 

=== modified file 'src/transport-widget.c'
--- src/transport-widget.c	2010-07-20 10:24:43 +0000
+++ src/transport-widget.c	2010-07-27 14:21:08 +0000
@@ -152,8 +152,8 @@
 		g_value_init(&value, G_TYPE_INT);
 		g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
 		g_value_set_int(&value, (int)result);	
+		play_button_react_to_button_press(priv->play_button, result);
 		dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
-		play_button_react_to_button_press(priv->play_button, result);
 	}	
 	return TRUE;
 }
@@ -182,11 +182,14 @@
 	g_debug("transport_widget_update_state - with property  %s", property);  
 	TransportWidget* bar = (TransportWidget*)userdata;
 	g_return_if_fail(IS_TRANSPORT_WIDGET(bar));
-	
-	TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
-	int update_value = g_value_get_int(value);
-	g_debug("transport_widget_update_state - with value  %i", update_value);  
-	play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
+
+	if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0)
+	{
+		TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
+		int update_value = g_value_get_int(value);
+		g_debug("transport_widget_update_state - with value  %i", update_value);  
+		play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
+	}
 }
 
  /**


Follow ups