banshee r3277 - in trunk/banshee: . old-code/Core/Banshee.Base/Notifications src/Core/Banshee.Services/Banshee.MediaEngine src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Extensions/Banshee.NotificationArea src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea src/Extensions/Banshee.NotificationArea/Notifications src/Extensions/Banshee.NotificationArea/Resources



Author: abock
Date: Tue Feb 19 22:45:56 2008
New Revision: 3277
URL: http://svn.gnome.org/viewvc/banshee?rev=3277&view=rev

Log:
2008-02-19  Aaron Bockover  <abock gnome org>
    
    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs:
    Ported notification bubbles. Hawt. 4 u snorp lol.

    * src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs:
    Added constant VolumeDelta and SkipDelta public fields

    * src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs:
    Don't use the redundant string parameter version of ServiceManager.Get

    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs:
    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/INotificationAreaBox.cs:
    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs:
    Added a Widget property for the notifications to use

    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationArea.cs:
    Ignore some other crappy warnings



Added:
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Notifications/
      - copied from r3275, /trunk/banshee/old-code/Core/Banshee.Base/Notifications/
Removed:
   trunk/banshee/old-code/Core/Banshee.Base/Notifications/
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
   trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea.mdp
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/INotificationAreaBox.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationArea.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Makefile.am
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Resources/Banshee.NotificationArea.addin.xml

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngine.cs	Tue Feb 19 22:45:56 2008
@@ -38,6 +38,9 @@
 {
     public abstract class PlayerEngine
     {
+        public const int VolumeDelta = 10;
+        public const int SkipDelta = 10;
+    
         public event PlayerEngineStateHandler StateChanged;
         public event PlayerEngineEventHandler EventChanged;
         

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs	Tue Feb 19 22:45:56 2008
@@ -50,7 +50,7 @@
 
         public ColumnCellAlbum () : base (null, true)
         {
-            artwork_manager = ServiceManager.Get<ArtworkManager> ("ArtworkManager");
+            artwork_manager = ServiceManager.Get<ArtworkManager> ();
         }
     
         public override void Render (CellContext context, StateType state, double cellWidth, double cellHeight)

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp	Tue Feb 19 22:45:56 2008
@@ -10,7 +10,6 @@
   <Contents>
     <File name="Resources/browser-album-cover.png" subtype="Code" buildaction="EmbedAsResource" />
     <File name="Banshee.Collection.Gui/TrackListView.cs" subtype="Code" buildaction="Compile" />
-    <File name="Banshee.Collection.Gui/CompositeTrackListView.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Collection.Gui/ColumnCellAlbum.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Collection.Gui/ArtworkManager.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Collection.Gui/ArtistListView.cs" subtype="Code" buildaction="Compile" />
@@ -91,6 +90,9 @@
     <File name="Banshee.Gui.Widgets/ConnectedMessageBar.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Sources.Gui/SourceIconResolver.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Gui/BaseClientWindow.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Sources.Gui/CompositeTrackSourceContents.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Sources.Gui/ISourceContents.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Sources.Gui/ObjectListSourceContents.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="False" refto="Hyena.Gui" />

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am	Tue Feb 19 22:45:56 2008
@@ -72,8 +72,8 @@
 	Banshee.SmartPlaylist.Gui/Editor.cs \
 	Banshee.Sources.Gui/CellEditEntry.cs \
 	Banshee.Sources.Gui/CompositeTrackSourceContents.cs \
-	Banshee.Sources.Gui/ObjectListSourceContents.cs \
 	Banshee.Sources.Gui/ISourceContents.cs \
+	Banshee.Sources.Gui/ObjectListSourceContents.cs \
 	Banshee.Sources.Gui/SourceIconResolver.cs \
 	Banshee.Sources.Gui/SourceRowRenderer.cs \
 	Banshee.Sources.Gui/SourceView.cs \

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea.mdp	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea.mdp	Tue Feb 19 22:45:56 2008
@@ -15,6 +15,8 @@
     <File name="Banshee.NotificationArea/X11NotificationAreaBox.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.NotificationArea/INotificationAreaBox.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.NotificationArea/GtkNotificationAreaBox.cs" subtype="Code" buildaction="Compile" />
+    <File name="Notifications/Notification.cs" subtype="Code" buildaction="Compile" />
+    <File name="Notifications/Notifications.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs	Tue Feb 19 22:45:56 2008
@@ -48,6 +48,10 @@
             remove { base.PopupMenu -= value; }
         }
         
+        public Widget Widget {
+            get { return null; }
+        }
+        
         public GtkNotificationAreaBox ()
         {
             IconName = "music-player-banshee";

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/INotificationAreaBox.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/INotificationAreaBox.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/INotificationAreaBox.cs	Tue Feb 19 22:45:56 2008
@@ -38,5 +38,7 @@
         event PopupMenuHandler PopupMenuEvent;
         
         void PositionMenu (Menu menu, out int x, out int y, out bool push_in);
+        
+        Widget Widget { get; }
     }
 }

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs	Tue Feb 19 22:45:56 2008
@@ -2,10 +2,11 @@
 // NotificationAreaService.cs
 //
 // Authors:
-//   Sebastian DrÃge <slomo circular-chaos org>
 //   Aaron Bockover <abockover novell com>
+//   Sebastian DrÃge <slomo circular-chaos org>
+//   Alexander Hixon <hixon alexander mediati org>
 //
-// Copyright (C) 2005-2007 Novell, Inc.
+// Copyright (C) 2005-2008 Novell, Inc.
 // Copyright (C) 2006-2007 Sebastian DrÃge
 //
 // Permission is hereby granted, free of charge, to any person obtaining
@@ -32,12 +33,16 @@
 using Gtk;
 using Mono.Unix;
 
-//using Notifications;
+using Notifications;
 
+using Banshee.Collection;
+using Banshee.Collection.Database;
 using Banshee.ServiceStack;
 using Banshee.Configuration;
 using Banshee.Gui;
+using Banshee.Collection.Gui;
 using Banshee.MediaEngine;
+using Banshee.Widgets;
 
 namespace Banshee.NotificationArea 
 {
@@ -46,13 +51,18 @@
         private INotificationAreaBox notif_area;
         private GtkElementsService elements_service;
         private InterfaceActionService interface_action_service;
+        private ArtworkManager artwork_manager_service;
     
         private Menu menu;
-		//private RatingMenuItem rating_menu_item;
+		private RatingMenuItem rating_menu_item;
         private BansheeActionGroup actions;
         private uint ui_manager_id;
         
-        private bool show_notifications = true;
+        private bool show_notifications;
+        private string notify_last_title;
+        private string notify_last_artist;
+        private TrackInfo current_track;
+        private Notification current_nf;
     
         public NotificationAreaService ()
         {
@@ -114,7 +124,20 @@
             menu = (Menu)interface_action_service.UIManager.GetWidget("/NotificationAreaIconMenu");
             menu.Show ();
             
+            for (int i = 0; i < menu.Children.Length; i++) {
+                if (menu.Children[i].Name == "Next") {
+                    rating_menu_item = new RatingMenuItem ();
+                    rating_menu_item.Activated += OnItemRatingActivated;
+                    ToggleRatingMenuSensitive ();
+                    menu.Insert (rating_menu_item, i + 2);
+                    break;
+                }
+            }
+
             ServiceManager.PlayerEngine.EventChanged += OnPlayerEngineEventChanged;
+            
+            // Forcefully load this
+            show_notifications = ShowNotifications;
         }
         
         public void Dispose ()
@@ -203,15 +226,19 @@
         {
             try {
                 if (NotifyOnCloseSchema.Get ()) {
-                    /*Gdk.Pixbuf image = Branding.ApplicationLogo.ScaleSimple(42, 42, Gdk.InterpType.Bilinear);
-                    Notification nf = new Notification(
-                        Catalog.GetString("Still Running"), 
-                        Catalog.GetString("Banshee was closed to the notification area. " + 
+                    Gdk.Pixbuf image = IconThemeUtils.LoadIcon (48, "music-player-banshee");
+                    if (image != null) {
+                        image = image.ScaleSimple (42, 42, Gdk.InterpType.Bilinear);
+                    }
+                    
+                    Notification nf = new Notification (
+                        Catalog.GetString ("Still Running"), 
+                        Catalog.GetString ("Banshee was closed to the notification area. " + 
                             "Use the <i>Quit</i> option to end your session."),
-                        image, event_box);
+                        image, notif_area.Widget);
                     nf.Urgency = Urgency.Low;
                     nf.Timeout = 4500;
-                    nf.Show();*/
+                    nf.Show ();
                     
                     NotifyOnCloseSchema.Set (false);
                 }
@@ -228,41 +255,95 @@
         
         private void OnPlayerEngineEventChanged (object o, PlayerEngineEventArgs args) 
         {
-            /*switch (args.Event) {
+            switch (args.Event) {
                 case PlayerEngineEvent.Iterate:
-                    if(PlayerEngineCore.CurrentTrack != null) {
-                        popup.Duration = (uint)PlayerEngineCore.CurrentTrack.Duration.TotalSeconds;
-                        popup.Position = PlayerEngineCore.Position;
-
-                        if (current_track != PlayerEngineCore.CurrentTrack) {
-                            current_track = PlayerEngineCore.CurrentTrack;
-                            ShowNotification();
-                        }
-                    } else {
-                        popup.Duration = 0;
-                        popup.Position = 0;
+                    if (current_track != ServiceManager.PlayerEngine.CurrentTrack) {
+                        current_track = ServiceManager.PlayerEngine.CurrentTrack;
+                        ShowTrackNotification ();
                     }
                     break;
                 case PlayerEngineEvent.StartOfStream:
                 case PlayerEngineEvent.TrackInfoUpdated:
-                    ToggleRatingMenuSensitive();
-                    FillPopup();
-                    ShowNotification();
+                    ToggleRatingMenuSensitive ();
+                    ShowTrackNotification ();
                     break;
                 case PlayerEngineEvent.EndOfStream:
-                    // only hide the popup when we don't play again after 250ms
-                    GLib.Timeout.Add(250, delegate {
-                        if (PlayerEngineCore.CurrentState != PlayerEngineState.Playing) {
-                            ToggleRatingMenuSensitive();
-                            popup.Duration = 0;
-                            popup.Position = 0;
-                            can_show_popup = false;
-                            popup.Hide();
-                         }
-                         return false;
-                    });
+                    current_track = null;
+                    ToggleRatingMenuSensitive ();
                     break;
-            }*/
+            }
+        }
+        
+        private void OnItemRatingActivated (object o, EventArgs args)
+        {
+            if (ServiceManager.PlayerEngine.CurrentTrack != null) {
+                ServiceManager.PlayerEngine.CurrentTrack.Rating = rating_menu_item.Value;
+                ServiceManager.PlayerEngine.CurrentTrack.Save ();
+                ServiceManager.PlayerEngine.TrackInfoUpdated ();
+            }
+        }
+        
+        private void ToggleRatingMenuSensitive () 
+        {
+            if (ServiceManager.PlayerEngine.CurrentTrack is LibraryTrackInfo) {
+                rating_menu_item.Reset ((int)ServiceManager.PlayerEngine.CurrentTrack.Rating);
+                rating_menu_item.Show ();
+            } else {
+                rating_menu_item.Hide ();
+            }
+        }
+        
+        private void ShowTrackNotification ()
+        {
+            // This has to happen before the next if, otherwise the last_* members aren't set correctly.
+            if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle 
+                && notify_last_artist == current_track.DisplayArtistName)) {
+                return;
+            }
+            
+            notify_last_title = current_track.DisplayTrackTitle;
+            notify_last_artist = current_track.DisplayArtistName;
+
+            if (!show_notifications || elements_service.PrimaryWindow.HasToplevelFocus) {
+                return;
+            }
+            
+            string message = String.Format ("{0}\n<i>{1}</i>", 
+                GLib.Markup.EscapeText (current_track.DisplayTrackTitle),
+                GLib.Markup.EscapeText (current_track.DisplayArtistName));
+            
+            if (artwork_manager_service == null) {
+                artwork_manager_service = ServiceManager.Get<ArtworkManager> ();
+            }
+            
+            Gdk.Pixbuf image = null;
+            
+            if (artwork_manager_service != null) {
+                image = artwork_manager_service.LookupScale (current_track.ArtistAlbumId, 42);
+            }
+            
+            if (image == null) {
+                image = IconThemeUtils.LoadIcon (48, "audio-x-generic");
+                if (image != null) {
+                    image.ScaleSimple (42, 42, Gdk.InterpType.Bilinear);
+                }
+            }
+            
+            try {
+                if (current_nf != null) {
+                    current_nf.Close ();
+                }
+                
+                Notification nf = new Notification (Catalog.GetString ("Now Playing"), 
+                    message, image, notif_area.Widget);
+                nf.Urgency = Urgency.Low;
+                nf.Timeout = 4500;
+                nf.Show ();
+                
+                current_nf = nf;
+            } catch (Exception e) {
+                Hyena.Log.Warning (Catalog.GetString ("Cannot show notification"), e.Message);
+            }
         }
         
         public bool ShowNotifications {
@@ -296,28 +377,28 @@
             get { return "NotificationAreaService"; }
         }
         
-        public static readonly SchemaEntry<bool> EnabledSchema = new SchemaEntry<bool>(
+        public static readonly SchemaEntry<bool> EnabledSchema = new SchemaEntry<bool> (
             "plugins.notification_area", "enabled",
             true,
             "Plugin enabled",
             "Notification area plugin enabled"
         );
                 
-        public static readonly SchemaEntry<bool> ShowNotificationsSchema = new SchemaEntry<bool>(
+        public static readonly SchemaEntry<bool> ShowNotificationsSchema = new SchemaEntry<bool> (
             "plugins.notification_area", "show_notifications",
             true,
             "Show notifications",
             "Show track information notifications when track starts playing"
         );
                 
-        public static readonly SchemaEntry<bool> NotifyOnCloseSchema = new SchemaEntry<bool>(
+        public static readonly SchemaEntry<bool> NotifyOnCloseSchema = new SchemaEntry<bool> (
             "plugins.notification_area", "notify_on_close",
             true,
             "Show a notification when closing main window",
             "When the main window is closed, show a notification stating this has happened."
         );
                 
-        public static readonly SchemaEntry<bool> QuitOnCloseSchema = new SchemaEntry<bool>(
+        public static readonly SchemaEntry<bool> QuitOnCloseSchema = new SchemaEntry<bool> (
             "plugins.notification_area", "quit_on_close",
             false,
             "Quit on close",

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationArea.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationArea.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationArea.cs	Tue Feb 19 22:45:56 2008
@@ -40,7 +40,7 @@
 using Gtk;
 using Gdk;
 
-#pragma warning disable 0169
+#pragma warning disable 0169, 0414
 
 public class X11NotificationArea : Plug
 {
@@ -513,5 +513,5 @@
 	}
 }
 
-#pragma warning restore 0169
+#pragma warning restore 0169, 0414
 

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs	Tue Feb 19 22:45:56 2008
@@ -3,8 +3,10 @@
 //
 // Author:
 //   Aaron Bockover <abockover novell com>
+//   Sebastian DrÃge <slomo circular-chaos org>
+//   Alexander Hixon <hixon alexander mediati org>
 //
-// Copyright (C) 2008 Novell, Inc.
+// Copyright (C) 2005-2008 Novell, Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,6 +32,7 @@
 using Mono.Unix;
 using Gtk;
 
+using Banshee.MediaEngine;
 using Banshee.ServiceStack;
 using Banshee.Gui;
 
@@ -44,6 +47,10 @@
         public event EventHandler Activated;
         public event PopupMenuHandler PopupMenuEvent;
         
+        public Widget Widget {
+            get { return event_box; }
+        }
+        
         public X11NotificationAreaBox () : base (Catalog.GetString ("Banshee"))
         {
             event_box = new EventBox ();
@@ -53,9 +60,9 @@
             Add (event_box);
             
             event_box.ButtonPressEvent += OnButtonPressEvent;
-            //event_box.EnterNotifyEvent += OnEnterNotifyEvent;
-            //event_box.LeaveNotifyEvent += OnLeaveNotifyEvent;
-            //event_box.ScrollEvent += OnMouseScroll;
+            event_box.EnterNotifyEvent += OnEnterNotifyEvent;
+            event_box.LeaveNotifyEvent += OnLeaveNotifyEvent;
+            event_box.ScrollEvent += OnMouseScroll;
             
             ShowAll ();
         }
@@ -110,6 +117,95 @@
             }
         }
         
+        private void OnMouseScroll (object o, ScrollEventArgs args)
+        {
+            switch (args.Event.Direction) {
+                case Gdk.ScrollDirection.Up:
+                    if ((args.Event.State & Gdk.ModifierType.ControlMask) != 0) {
+                        ServiceManager.PlayerEngine.Volume += (ushort)PlayerEngine.VolumeDelta;
+                    } else if((args.Event.State & Gdk.ModifierType.ShiftMask) != 0) {
+                        ServiceManager.PlayerEngine.Position += PlayerEngine.SkipDelta;
+                    } else {
+                        ServiceManager.PlaybackController.Next ();
+                    }
+                    break;
+                    
+                case Gdk.ScrollDirection.Down:
+                    if ((args.Event.State & Gdk.ModifierType.ControlMask) != 0) {
+                        if (ServiceManager.PlayerEngine.Volume < (ushort)PlayerEngine.VolumeDelta) {
+                            ServiceManager.PlayerEngine.Volume = 0;
+                        } else {
+                            ServiceManager.PlayerEngine.Volume -= (ushort)PlayerEngine.VolumeDelta;
+                        }
+                    } else if((args.Event.State & Gdk.ModifierType.ShiftMask) != 0) {
+                        ServiceManager.PlayerEngine.Position -= PlayerEngine.SkipDelta;
+                    } else {
+                        ServiceManager.PlaybackController.Previous ();
+                    }
+                    break;
+            }
+        }
+        
+        private void OnEnterNotifyEvent(object o, EnterNotifyEventArgs args) 
+        {
+            /*cursor_over_trayicon = true;
+            if(can_show_popup) {
+                // only show the popup when the cursor is still over the
+                // tray icon after 500ms
+                GLib.Timeout.Add(500, delegate {
+                    if ((cursor_over_trayicon) && (can_show_popup)) {
+                        ShowPopup();
+                    }
+                    return false;
+                });
+            }*/
+        }
+        
+        private void OnLeaveNotifyEvent(object o, LeaveNotifyEventArgs args) 
+        {
+            // cursor_over_trayicon = false;
+            // HidePopup();
+        }
+        
+        private void OnPlayerEngineEventChanged (object o, PlayerEngineEventArgs args) 
+        {
+            /*switch (args.Event) {
+                case PlayerEngineEvent.Iterate:
+                    if(PlayerEngineCore.CurrentTrack != null) {
+                        popup.Duration = (uint)PlayerEngineCore.CurrentTrack.Duration.TotalSeconds;
+                        popup.Position = PlayerEngineCore.Position;
+
+                        if (current_track != PlayerEngineCore.CurrentTrack) {
+                            current_track = PlayerEngineCore.CurrentTrack;
+                            ShowNotification();
+                        }
+                    } else {
+                        popup.Duration = 0;
+                        popup.Position = 0;
+                    }
+                    break;
+                case PlayerEngineEvent.StartOfStream:
+                case PlayerEngineEvent.TrackInfoUpdated:
+                    ToggleRatingMenuSensitive();
+                    FillPopup();
+                    ShowNotification();
+                    break;
+                case PlayerEngineEvent.EndOfStream:
+                    // only hide the popup when we don't play again after 250ms
+                    GLib.Timeout.Add(250, delegate {
+                        if (PlayerEngineCore.CurrentState != PlayerEngineState.Playing) {
+                            ToggleRatingMenuSensitive();
+                            popup.Duration = 0;
+                            popup.Position = 0;
+                            can_show_popup = false;
+                            popup.Hide();
+                         }
+                         return false;
+                    });
+                    break;
+            }*/
+        }
+        
         protected virtual void OnActivated ()
         {
             EventHandler handler = Activated;
@@ -142,150 +238,7 @@
         private TrackInfoPopup popup;
         private bool can_show_popup = false;
         private bool cursor_over_trayicon = false;
-        private bool show_notifications = false;
-        private TrackInfo current_track = null;
-        private string notify_last_title = null;
-        private string notify_last_artist = null;
-
-        private static readonly uint SkipDelta = 10;
-        private static readonly int VolumeDelta = 10;
-        
-        protected override void PluginInitialize()
-        {
-        }
-        
-        protected override void InterfaceInitialize() 
-        {
 
-            
-            popup = new TrackInfoPopup();
-            PlayerEngineCore.EventChanged += OnPlayerEngineEventChanged;
-
-            // When we're already playing fill the TrackInfoPopup with the current track
-            if (PlayerEngineCore.CurrentState == PlayerEngineState.Playing) {
-                FillPopup();
-            }
-
-            // Forcefully load this value
-            show_notifications = ShowNotifications;
-            elements_service.MainWindow.KeyPressEvent += OnKeyPressEvent;
-        }
-
-        protected override void PluginDispose() 
-        {
-
-        }
-
-        public override Gtk.Widget GetConfigurationWidget()
-        {            
-            return new NotificationAreaIconConfigPage(this);
-        }
-
-        private void ShowNotification()
-        {
-            // This has to happen before the next if, otherwise the last_* members aren't set correctly.
-            if(current_track == null || (notify_last_title == current_track.DisplayTrackTitle 
-                && notify_last_artist == current_track.DisplayArtistName)) {
-                return;
-            }
-            
-            notify_last_title = current_track.DisplayTrackTitle;
-            notify_last_artist = current_track.DisplayArtistName;
-
-            if(cursor_over_trayicon || !show_notifications || elements_service.MainWindow.HasToplevelFocus) {
-                return;
-            }
-            
-            string message = String.Format("{0}\n<i>{1}</i>", 
-                GLib.Markup.EscapeText(current_track.DisplayTrackTitle),
-                GLib.Markup.EscapeText(current_track.DisplayArtistName));
-            
-            Gdk.Pixbuf image = null;
-            
-            try {
-                if(current_track.CoverArtFileName != null) {
-                    image = new Gdk.Pixbuf(current_track.CoverArtFileName);
-                } 
-            } catch {
-            }
-            
-            if(image == null) {
-                image = Branding.DefaultCoverArt;
-            }
-            
-            image = image.ScaleSimple(42, 42, Gdk.InterpType.Bilinear);
-            
-            try {
-                Notification nf = new Notification(Catalog.GetString("Now Playing"), message, image, event_box);
-                nf.Urgency = Urgency.Low;
-                nf.Timeout = 4500;
-                nf.Show();
-            } catch(Exception e) {
-                LogCore.Instance.PushError(Catalog.GetString("Cannot show notification"), e.Message, false);
-            }
-        }
-
-        [GLib.ConnectBefore]
-        private void OnKeyPressEvent(object o, KeyPressEventArgs args)
-        {
-            bool handled = false;
-            
-            if (args.Event.Key == Gdk.Key.w && (args.Event.State & Gdk.ModifierType.ControlMask) != 0) {
-                handled = true;
-                ShowHideMainWindow();
-            }
-            
-            args.RetVal = handled;
-        }
-
-        
-
-        private void OnItemRatingActivated(object o, EventArgs args)
-        {
-            if(PlayerEngineCore.CurrentTrack != null) {
-                PlayerEngineCore.CurrentTrack.Rating = (uint)rating_menu_item.Value;
-                PlayerEngineCore.TrackInfoUpdated();
-            }
-        }
-        
-        private void ToggleRatingMenuSensitive() 
-        {
-            if(PlayerEngineCore.CurrentTrack != null && (SourceManager.ActiveSource is LibrarySource || 
-                SourceManager.ActiveSource is PlaylistSource ||
-                SourceManager.ActiveSource is SmartPlaylistSource)) {
-                rating_menu_item.Reset((int)PlayerEngineCore.CurrentTrack.Rating);
-                rating_menu_item.Show();
-            } else {
-                rating_menu_item.Hide();
-            }
-        }
-
-        private void OnMouseScroll(object o, ScrollEventArgs args) 
-        {
-            switch(args.Event.Direction) {
-                case Gdk.ScrollDirection.Up:
-                    if((args.Event.State & Gdk.ModifierType.ControlMask) != 0) {
-                        PlayerEngineCore.Volume += (ushort)VolumeDelta;
-                    } else if((args.Event.State & Gdk.ModifierType.ShiftMask) != 0) {
-                        PlayerEngineCore.Position += SkipDelta;
-                    } else {
-                        Globals.ActionManager["NextAction"].Activate();
-                    }
-                    break;
-                case Gdk.ScrollDirection.Down:
-                    if((args.Event.State & Gdk.ModifierType.ControlMask) != 0) {
-                        if (PlayerEngineCore.Volume < (ushort)VolumeDelta)
-                            PlayerEngineCore.Volume = 0;
-                        else
-                            PlayerEngineCore.Volume -= (ushort)VolumeDelta;
-                    } else if((args.Event.State & Gdk.ModifierType.ShiftMask) != 0) {
-                        PlayerEngineCore.Position -= SkipDelta;
-                    } else {
-                        Globals.ActionManager["PreviousAction"].Activate();
-                    }
-                    break;
-            }
-        }
 
         private void HidePopup() 
         {
@@ -315,29 +268,6 @@
             
             popup.Move(x, y);
         }
-        
-        private void OnEnterNotifyEvent(object o, EnterNotifyEventArgs args) 
-        {
-            cursor_over_trayicon = true;
-            if(can_show_popup) {
-                // only show the popup when the cursor is still over the
-                // tray icon after 500ms
-                GLib.Timeout.Add(500, delegate {
-                    if ((cursor_over_trayicon) && (can_show_popup)) {
-                        ShowPopup();
-                    }
-                    return false;
-                });
-            }
-        }
-        
-        private void OnLeaveNotifyEvent(object o, LeaveNotifyEventArgs args) 
-        {
-            cursor_over_trayicon = false;
-            HidePopup();
-        }
-
-
 
         private void FillPopup() 
         {
@@ -354,7 +284,25 @@
                 PositionPopup();
             }
         }
+        
+        /*
+                protected override void InterfaceInitialize() 
+        {
 
+            
+            popup = new TrackInfoPopup();
+            PlayerEngineCore.EventChanged += OnPlayerEngineEventChanged;
+
+            // When we're already playing fill the TrackInfoPopup with the current track
+            if (PlayerEngineCore.CurrentState == PlayerEngineState.Playing) {
+                FillPopup();
+            }
+
+            // Forcefully load this value
+            show_notifications = ShowNotifications;
+            elements_service.MainWindow.KeyPressEvent += OnKeyPressEvent;
+        }
+        
         */
     }
 }

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Makefile.am	Tue Feb 19 22:45:56 2008
@@ -7,7 +7,9 @@
 	Banshee.NotificationArea/INotificationAreaBox.cs \
 	Banshee.NotificationArea/NotificationAreaService.cs \
 	Banshee.NotificationArea/X11NotificationArea.cs \
-	Banshee.NotificationArea/X11NotificationAreaBox.cs 
+	Banshee.NotificationArea/X11NotificationAreaBox.cs \
+	Notifications/Notification.cs \
+	Notifications/Notifications.cs 
 
 RESOURCES =  \
 	Resources/Banshee.NotificationArea.addin.xml \

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Resources/Banshee.NotificationArea.addin.xml
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Resources/Banshee.NotificationArea.addin.xml	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Resources/Banshee.NotificationArea.addin.xml	Tue Feb 19 22:45:56 2008
@@ -7,7 +7,7 @@
     name="Notification Area Icon"
     category="User Interface"
     description="Displays an icon in the notification area and allows Banshee to be controlled through it."
-    author="Aaron Bockover, Sebastian DrÃge, Gabriel Burt, Ruben Vermeersch"
+    author="Aaron Bockover, Sebastian DrÃge, Alexander Hixon, Gabriel Burt, Ruben Vermeersch"
     url="http://banshee-project.org/";
     defaultEnabled="true">
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]