banshee r3620 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3620 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio
- Date: Mon, 31 Mar 2008 19:25:44 +0100 (BST)
Author: gburt
Date: Mon Mar 31 19:25:44 2008
New Revision: 3620
URL: http://svn.gnome.org/viewvc/banshee?rev=3620&view=rev
Log:
2008-03-31 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Sources/Source.cs: Move SetStatus and
HideStatus methods here from StationSource since they are generally useful.
* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs: Use
Source's SetStatus and HideStatus methods, and move the account button
status code into a static method on LastfmSource.
* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs: Set
the status when not connected.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs Mon Mar 31 19:25:44 2008
@@ -48,6 +48,7 @@
{
private Source parent;
private PropertyStore properties = new PropertyStore ();
+ protected SourceMessage status_message;
private List<SourceMessage> messages = new List<SourceMessage> ();
private List<Source> child_sources = new List<Source> ();
private ReadOnlyCollection<Source> read_only_children;
@@ -208,6 +209,34 @@
#endregion
#region Protected Methods
+
+ protected virtual void SetStatus (string message, bool error)
+ {
+ if (status_message == null) {
+ status_message = new SourceMessage (this);
+ PushMessage (status_message);
+ }
+
+ string status_name = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText (Name));
+
+ status_message.FreezeNotify ();
+ status_message.Text = String.Format (GLib.Markup.EscapeText (message), status_name);
+ status_message.CanClose = !error;
+ status_message.IsSpinning = !error;
+ status_message.SetIconName (error ? "dialog-error" : null);
+ status_message.ClearActions ();
+
+ status_message.ThawNotify ();
+ }
+
+ protected virtual void HideStatus ()
+ {
+ if (status_message != null) {
+ RemoveMessage (status_message);
+ status_message = null;
+ }
+ }
+
protected virtual void PushMessage (SourceMessage message)
{
Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs Mon Mar 31 19:25:44 2008
@@ -304,9 +304,40 @@
}
Name = (Connection.State == ConnectionState.Connected ) ? lastfm : Catalog.GetString ("Last.fm (Disconnected)");
+
+ if (Connection.Connected) {
+ HideStatus ();
+ } else {
+ SetStatus (RadioConnection.MessageFor (Connection.State), Connection.State != ConnectionState.Connecting, Connection.State);
+ }
+
OnUpdated ();
}
+ protected override void SetStatus (string message, bool error)
+ {
+ base.SetStatus (message, error);
+ SetStatus (status_message, this, error, ConnectionState.Connected);
+ }
+
+ private void SetStatus (string message, bool error, ConnectionState state)
+ {
+ base.SetStatus (message, error);
+ SetStatus (status_message, this, error, state);
+ }
+
+ internal static void SetStatus (SourceMessage status_message, LastfmSource lastfm, bool error, ConnectionState state)
+ {
+ status_message.FreezeNotify ();
+ if (error && (state == ConnectionState.NoAccount || state == ConnectionState.InvalidAccount)) {
+ status_message.AddAction (new MessageAction (Catalog.GetString ("Account Settings"),
+ delegate { lastfm.Actions.ShowLoginDialog (); }));
+ status_message.AddAction (new MessageAction (Catalog.GetString ("Join Last.fm"),
+ delegate { lastfm.Account.SignUp (); }));
+ }
+ status_message.ThawNotify ();
+ }
+
public static readonly SchemaEntry<bool> EnabledSchema = new SchemaEntry<bool> (
"plugins.lastfm", "enabled", false, "Extension enabled", "Last.fm extension enabled"
);
Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs Mon Mar 31 19:25:44 2008
@@ -55,7 +55,6 @@
private static string generic_name = Catalog.GetString ("Last.fm Station");
private MemoryTrackListModel track_model;
- private SourceMessage status_message;
private LastfmSource lastfm;
public LastfmSource LastfmSource {
@@ -239,43 +238,16 @@
}
}
- private void SetStatus (string message, bool error)
+ protected override void SetStatus (string message, bool error)
{
- SetStatus (message, error, ConnectionState.Connected);
+ base.SetStatus (message, error);
+ LastfmSource.SetStatus (status_message, lastfm, error, ConnectionState.Connected);
}
private void SetStatus (string message, bool error, ConnectionState state)
{
- if (status_message == null) {
- status_message = new SourceMessage (this);
- PushMessage (status_message);
- }
-
- string status_name = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText (Name));
-
- status_message.FreezeNotify ();
- status_message.Text = String.Format (GLib.Markup.EscapeText (message), status_name);
- status_message.CanClose = !error;
- status_message.IsSpinning = !error;
- status_message.SetIconName (error ? "dialog-error" : null);
- status_message.ClearActions ();
-
- if (error && (state == ConnectionState.NoAccount || state == ConnectionState.InvalidAccount)) {
- status_message.AddAction (new MessageAction (Catalog.GetString ("Account Settings"),
- delegate { lastfm.Actions.ShowLoginDialog (); }));
- status_message.AddAction (new MessageAction (Catalog.GetString ("Join Last.fm"),
- delegate { lastfm.Account.SignUp (); }));
- }
-
- status_message.ThawNotify ();
- }
-
- private void HideStatus ()
- {
- if (status_message != null) {
- RemoveMessage (status_message);
- status_message = null;
- }
+ base.SetStatus (message, error);
+ LastfmSource.SetStatus (status_message, lastfm, error, state);
}
/*public override void ShowPropertiesDialog ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]