[Goodies-commits] r7754 - in xfmpc/trunk: . src

Mike Massonnet mmassonnet at xfce.org
Wed Jul 22 12:45:25 CEST 2009


Author: mmassonnet
Date: 2009-07-22 10:45:25 +0000 (Wed, 22 Jul 2009)
New Revision: 7754

Modified:
   xfmpc/trunk/ChangeLog
   xfmpc/trunk/src/interface.vala
   xfmpc/trunk/src/main-window.vala
   xfmpc/trunk/src/playlist.vala
Log:
Fixed inconsistent title/sub-title and current song

Modified: xfmpc/trunk/ChangeLog
===================================================================
--- xfmpc/trunk/ChangeLog	2009-07-22 08:37:00 UTC (rev 7753)
+++ xfmpc/trunk/ChangeLog	2009-07-22 10:45:25 UTC (rev 7754)
@@ -1,3 +1,21 @@
+2009-07-21	Mike Massonnet <mmassonnet at xfce.org>
+
+Fixed inconsistent title/sub-title and current song
+
+- In Xfmpc.Interface, renamed the public function clean to reset which must
+only be called to reinit/reset the widget to 0, useful when the client gets
+disconnected.
+- Still in Xfmpc.Interface, fixed numerous title/subtitle inconsistencies. On
+update_title, get_title always returned a value != null, therefore now it sets
+an appropriate title given MPD is currently playing, stopped or disconnected.
+On callback stopped, set pp button to play and call update_title instead of
+reset.
+- In Xfmpc.MainWindow rename interface to @interface as it is a Vala keyword
+and use new renamed function reset instead of clean.
+- In Xfmpc.Playlist, a new callback on pp-changed (the current song is unknown
+when MPD is stopped and the client is started) and moved the select_row call
+inside the refresh_current_song function.
+
 2009-07-20	Mike Massonnet <mmassonnet at xfce.org>
 
 Small fixes with Xfmpc.Statusbar

Modified: xfmpc/trunk/src/interface.vala
===================================================================
--- xfmpc/trunk/src/interface.vala	2009-07-22 08:37:00 UTC (rev 7753)
+++ xfmpc/trunk/src/interface.vala	2009-07-22 10:45:25 UTC (rev 7754)
@@ -199,28 +199,36 @@
 			this.progress_bar.set_fraction ((fraction <= 1.0) ? fraction : 1.0);
 		}
 
-		public void clean () {
+		public void reset () {
 			set_pp (false);
 			set_time (0, 0);
 			set_volume (0);
-			set_title (_("Not connected"));
-			set_subtitle (Config.PACKAGE_STRING);
+			update_title ();
 		}
 
 		public void update_title () {
-			if (this.mpdclient.get_title () != null) {
+			if (this.mpdclient.is_playing ()) {
 				set_title (this.mpdclient.get_title ());
-
-  	  	  		/* subtitle "by \"artist\" from \"album\" (year)" */
-				GLib.StringBuilder text = new GLib.StringBuilder ();
-				text.append_printf (_("by \"%s\" from \"%s\" (%s)"),
-				     	    	    this.mpdclient.get_artist (),
-				     	    	    this.mpdclient.get_album (),
-				     	    	    this.mpdclient.get_date ());
-
-  	  	  		/* text = xfmpc_interface_get_subtitle (interface); to avoid "n/a" values, so far I don't care */
-				set_subtitle (text.str);
+				/*
+				// write private function in case it is wished to avoid the
+				// "n/a" values, but no big deal IMO
+				text = get_subtitle (interface);
+				 */
+				/* TRANSLATORS: subtitle "by \"artist\" from \"album\" (year)" */
+				string text = _("by \"%s\" from \"%s\" (%s)").printf (
+						this.mpdclient.get_artist (),
+						this.mpdclient.get_album (),
+						this.mpdclient.get_date ());
+				set_subtitle (text);
 			}
+			else if (this.mpdclient.is_stopped ()) {
+				set_title (_("Stopped"));
+				set_subtitle (Config.PACKAGE_STRING);
+			}
+			else if (!this.mpdclient.is_connected ()) {
+				set_title (_("Not connected"));
+				set_subtitle (Config.PACKAGE_STRING);
+			}
 		}
 
 		private void cb_song_changed () {
@@ -229,7 +237,6 @@
 
 		private void cb_pp_changed (bool is_playing) {
 			set_pp (is_playing);
-
 			cb_song_changed ();
 		}
 
@@ -246,7 +253,8 @@
 		}
 
 		private void cb_stopped () {
-			clean ();
+			set_pp (false);
+			update_title ();
 		}
 
 		private void cb_mpdclient_previous () {

Modified: xfmpc/trunk/src/main-window.vala
===================================================================
--- xfmpc/trunk/src/main-window.vala	2009-07-22 08:37:00 UTC (rev 7753)
+++ xfmpc/trunk/src/main-window.vala	2009-07-22 10:45:25 UTC (rev 7754)
@@ -26,7 +26,7 @@
 		private unowned Xfmpc.Mpdclient mpdclient;
 		private unowned Xfmpc.Preferences preferences;
 
-		private Xfmpc.Interface interface;
+		private Xfmpc.Interface @interface;
 		private Xfmpc.ExtendedInterface extended_interface;
 
 		private Gtk.VBox vbox;
@@ -83,8 +83,8 @@
 				stick ();
 
   	  	  	/* Interface */
-			this.interface = new Xfmpc.Interface ();
-			this.vbox.pack_start (this.interface, false, false, 4);
+			this. at interface = new Xfmpc.Interface ();
+			this.vbox.pack_start (this. at interface, false, false, 4);
 
   	  	  	/* Separator */
 			var separator = new Gtk.HSeparator ();
@@ -127,13 +127,13 @@
 			if (this.mpdclient.is_connected ()) {
 				this.mpdclient.update_status ();
 			} else {
-				this.interface.clean ();
+				this. at interface.reset ();
 				this.mpdclient.reload ();
 				if (this.statusbar != null)
 					this.statusbar.text = "";
 				this.mpdclient.connect ();
 				if (this.mpdclient.is_connected ())
-					this.interface.update_title ();
+					this. at interface.update_title ();
 			}
 
 			return true;
@@ -191,7 +191,7 @@
 		}
 
 		private void action_pp () {
-			this.interface.pp_clicked ();
+			this. at interface.pp_clicked ();
 		}
 
 		private void action_stop () {
@@ -203,7 +203,7 @@
 		}
 
 		private void action_volume () {
-			this.interface.popup_volume ();
+			this. at interface.popup_volume ();
 		}
 
 		private void action_statusbar (Action action) {

Modified: xfmpc/trunk/src/playlist.vala
===================================================================
--- xfmpc/trunk/src/playlist.vala	2009-07-22 08:37:00 UTC (rev 7753)
+++ xfmpc/trunk/src/playlist.vala	2009-07-22 10:45:25 UTC (rev 7754)
@@ -121,6 +121,7 @@
 			pack_start (this.filter_entry, false, false, 0);
 
 			/* Signals */
+			this.mpdclient.pp_changed.connect (cb_pp_changed);
 			this.mpdclient.song_changed.connect (cb_song_changed);
 			this.mpdclient.playlist_changed.connect (cb_playlist_changed);
 
@@ -217,11 +218,18 @@
 			return true;
 		}
 
+		private void cb_pp_changed (bool is_playing) {
+			/* This callback is needed cause there is an unknown state of the current
+			 * song when MPD is stopped and you run the client. When the client then
+			 * starts to play, the song-changed signal is not send and the current song
+			 * is kept on the first entry of te playlist. On another hand it also
+			 * refocus the current song in the playlist between play/pause which can be
+			 * nice ;-) */
+			refresh_current_song ();
+		}
+
 		private void cb_song_changed () {
 			refresh_current_song ();
-
-			if (filter_entry.get_text () == "" && this.autocenter)
-				select_row (this.current);
 		}
 
 		private void cb_playlist_changed () {
@@ -237,9 +245,6 @@
 			}
 
 			refresh_current_song ();
-
-			if (filter_entry.get_text () != "" && this.autocenter)
-				select_row (this.current);
 		}
 
 		private void cb_row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
@@ -375,6 +380,9 @@
 			path = new Gtk.TreePath.from_indices (this.current, -1);
 			if (this.store.get_iter (out iter, path))
 				this.store.set (iter, Columns.COLUMN_WEIGHT, Pango.Weight.BOLD, -1);
+
+			if (filter_entry.get_text () == "" && this.autocenter)
+				select_row (this.current);
 		}
 
 		public void select_row (int i) {




More information about the Goodies-commits mailing list