[banshee] [ThickClient] Make TrackInfoDisplay more customizable
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [ThickClient] Make TrackInfoDisplay more customizable
- Date: Fri, 14 May 2010 22:43:12 +0000 (UTC)
commit 325eede13719947a2d9ba20c9192bc75734d9ef2
Author: Gabriel Burt <gabriel burt gmail com>
Date: Fri May 14 14:22:38 2010 -0700
[ThickClient] Make TrackInfoDisplay more customizable
So we can change the default/missing icon to 'audiobook' for the
Audiobook BookView.
.../Banshee.Gui.Widgets/CoverArtDisplay.cs | 4 +-
.../Banshee.Gui.Widgets/TrackInfoDisplay.cs | 68 +++++++++++++-------
2 files changed, 46 insertions(+), 26 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs
index c12a204..a557f09 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs
@@ -55,7 +55,6 @@ namespace Banshee.Gui.Widgets
public override void Dispose ()
{
- Console.WriteLine ("Disposing idle artwork");
var disposable = idle_album as IDisposable;
if (disposable != null) {
disposable.Dispose ();
@@ -64,7 +63,6 @@ namespace Banshee.Gui.Widgets
base.Dispose ();
}
-
protected override int ArtworkSizeRequest {
get { return Allocation.Width; }
}
@@ -80,7 +78,7 @@ namespace Banshee.Gui.Widgets
protected override void RenderIdle (Cairo.Context cr)
{
idle_album = idle_album ?? PixbufImageSurface.Create (Banshee.Gui.IconThemeUtils.LoadIcon (
- ArtworkSizeRequest, "media-optical"), true);
+ ArtworkSizeRequest, MissingAudioIconName), true);
ArtworkRenderer.RenderThumbnail (cr, idle_album, false, Allocation.X, Allocation.Y,
ArtworkSizeRequest, ArtworkSizeRequest,
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
index eb419ec..d51c207 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
@@ -65,22 +65,22 @@ namespace Banshee.Gui.Widgets
get { return incoming_image; }
}
+ protected string MissingAudioIconName { get; set; }
+ protected string MissingVideoIconName { get; set; }
+
private ImageSurface missing_audio_image;
protected ImageSurface MissingAudioImage {
get { return missing_audio_image ?? (missing_audio_image
- = PixbufImageSurface.Create (IconThemeUtils.LoadIcon (MissingIconSizeRequest, "audio-x-generic"), true)); }
+ = PixbufImageSurface.Create (IconThemeUtils.LoadIcon (MissingIconSizeRequest, MissingAudioIconName), true)); }
}
private ImageSurface missing_video_image;
protected ImageSurface MissingVideoImage {
get { return missing_video_image ?? (missing_video_image
- = PixbufImageSurface.Create (IconThemeUtils.LoadIcon (MissingIconSizeRequest, "video-x-generic"), true)); }
+ = PixbufImageSurface.Create (IconThemeUtils.LoadIcon (MissingIconSizeRequest, MissingVideoIconName), true)); }
}
- private Cairo.Color background_color;
- protected virtual Cairo.Color BackgroundColor {
- get { return background_color; }
- }
+ protected virtual Cairo.Color BackgroundColor { get; set; }
private Cairo.Color text_color;
protected virtual Cairo.Color TextColor {
@@ -111,20 +111,40 @@ namespace Banshee.Gui.Widgets
public TrackInfoDisplay ()
{
+ MissingAudioIconName = "audio-x-generic";
+ MissingAudioIconName = "video-x-generic";
stage.Iteration += OnStageIteration;
if (ServiceManager.Contains<ArtworkManager> ()) {
artwork_manager = ServiceManager.Get<ArtworkManager> ();
}
- ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
- PlayerEvent.StartOfStream |
- PlayerEvent.TrackInfoUpdated |
- PlayerEvent.StateChange);
+ Connected = true;
WidgetFlags |= WidgetFlags.NoWindow;
}
+ private bool connected;
+ public bool Connected {
+ get { return connected; }
+ set {
+ if (value == connected)
+ return;
+
+ if (ServiceManager.PlayerEngine != null) {
+ connected = value;
+ if (value) {
+ ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
+ PlayerEvent.StartOfStream |
+ PlayerEvent.TrackInfoUpdated |
+ PlayerEvent.StateChange);
+ } else {
+ ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ }
+ }
+ }
+ }
+
public static Widget GetEditable (TrackInfoDisplay display)
{
return CoverArtEditor.For (display,
@@ -140,9 +160,7 @@ namespace Banshee.Gui.Widgets
GLib.Source.Remove (idle_timeout_id);
}
- if (ServiceManager.PlayerEngine != null) {
- ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
- }
+ Connected = false;
stage.Iteration -= OnStageIteration;
stage = null;
@@ -182,7 +200,7 @@ namespace Banshee.Gui.Widgets
base.OnStyleSet (previous);
text_color = CairoExtensions.GdkColorToCairoColor (Style.Foreground (StateType.Normal));
- background_color = CairoExtensions.GdkColorToCairoColor (Style.Background (StateType.Normal));
+ BackgroundColor = CairoExtensions.GdkColorToCairoColor (Style.Background (StateType.Normal));
text_light_color = Hyena.Gui.Theming.GtkTheme.GetCairoTextMidColor (this);
ResetMissingImages ();
@@ -422,7 +440,18 @@ namespace Banshee.Gui.Widgets
private void LoadImage (TrackInfo track, bool force)
{
- string artwork_id = track.ArtworkId;
+ LoadImage (track.MediaAttributes, track.ArtworkId, force);
+
+ if (track == current_track) {
+ if (current_image != null && current_image != incoming_image && !IsMissingImage (current_image)) {
+ ((IDisposable)current_image).Dispose ();
+ }
+ current_image = incoming_image;
+ }
+ }
+
+ protected void LoadImage (TrackMediaAttributes attr, string artwork_id, bool force)
+ {
if (current_artwork_id != artwork_id || force) {
current_artwork_id = artwork_id;
if (incoming_image != null && current_image != incoming_image && !IsMissingImage (incoming_image)) {
@@ -432,14 +461,7 @@ namespace Banshee.Gui.Widgets
}
if (incoming_image == null) {
- incoming_image = MissingImage (track.HasAttribute (TrackMediaAttributes.VideoStream));
- }
-
- if (track == current_track) {
- if (current_image != null && current_image != incoming_image && !IsMissingImage (current_image)) {
- ((IDisposable)current_image).Dispose ();
- }
- current_image = incoming_image;
+ incoming_image = MissingImage ((attr & TrackMediaAttributes.VideoStream) != 0);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]