banshee r4075 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.ServiceStack src/Core/Banshee.ThickClient/Banshee.Addins.Gui src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea src/Extensions/Banshee.NowPlaying src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying



Author: abock
Date: Mon Jun  2 21:41:03 2008
New Revision: 4075
URL: http://svn.gnome.org/viewvc/banshee?rev=4075&view=rev

Log:
2008-06-02  Aaron Bockover  <abock gnome org>

    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs:
    Added Boyd's panel icon sizing code from Tomboy so we display the best
    icon for a given panel size, only scaling if we're in SVG territory;
    this is so hot I think I'll make my panel like KDE now (BGO #526333)

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.addin.xml:
    Make the Now Playing extension required for now

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs:
    * src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs:
    Set the window hint to notification to prevent compiz from doing strange
    things with the windows when they are mapped/unmapped (BGO #526326)

    * src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs: Do not
    show addins where the category starts with 'required:'

    * src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs:
    Avoid possible NRE (BGO #532215)



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
   trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.addin.xml
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs	Mon Jun  2 21:41:03 2008
@@ -52,7 +52,7 @@
         
         public static string MakeDBusSafeString (string str)
         {
-            return Regex.Replace (str, @"[^A-Za-z0-9]*", String.Empty);
+            return str == null ? String.Empty : Regex.Replace (str, @"[^A-Za-z0-9]*", String.Empty);
         }
         
         public static string MakeObjectPath (IDBusExportable o)

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs	Mon Jun  2 21:41:03 2008
@@ -55,7 +55,8 @@
         private void LoadAddins ()
         {
             foreach (Addin addin in AddinManager.Registry.GetAddins ()) {
-                if (addin.Name != addin.Id) {
+                if (addin.Name != addin.Id && addin.Description != null && 
+                    addin.Description.Category != null && !addin.Description.Category.StartsWith ("required:")) {
                     AppendAddin (addin);
                 }
             }

Modified: trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs	Mon Jun  2 21:41:03 2008
@@ -52,6 +52,7 @@
             BorderWidth = 4;
             AppPaintable = true;
             Resizable = false;
+            TypeHint = Gdk.WindowTypeHint.Notification;
             
             // Position label and linear progress bar
             HBox position_box = new HBox ();

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	Mon Jun  2 21:41:03 2008
@@ -40,11 +40,18 @@
 {
     public class X11NotificationAreaBox : X11NotificationArea, INotificationAreaBox
     {
+        private enum PanelOrientation { 
+            Horizontal, 
+            Vertical 
+        }
+    
         private EventBox event_box;
+        private Image icon;
         
         private TrackInfoPopup popup;
         private bool can_show_popup = false;
         private bool cursor_over_trayicon = false;
+        private int panel_size;
         
         public event EventHandler Disconnected;
         public event EventHandler Activated;
@@ -57,8 +64,12 @@
         public X11NotificationAreaBox () : base (Catalog.GetString ("Banshee"))
         {
             event_box = new EventBox ();
-            event_box.Add (Image.NewFromIconName (Banshee.ServiceStack.Application.IconName, IconSize.LargeToolbar));
             Add (event_box);
+            icon = new Image ();
+            
+            // Load a 16x16-sized icon to ensure we don't end up with a 1x1 pixel.
+            panel_size = 16;
+            event_box.Add (icon);
             
             event_box.ButtonPressEvent += OnButtonPressEvent;
             event_box.EnterNotifyEvent += OnEnterNotifyEvent;
@@ -103,6 +114,78 @@
             return on_bottom;
         }
         
+#region Panel Icon Sizing
+
+        // This code has been shamelessly ripped off from 
+        // Tomboy, the wonderful life organizer!
+        
+        private void ConfigureIconSize ()
+        {   
+            // For some reason, the first time we ask for the allocation,
+            // it's a 1x1 pixel.  Prevent against this by returning a
+            // reasonable default.  Setting the icon causes OnSizeAllocated
+            // to be called again anyhow. (--Boyd)
+            int icon_size = panel_size;
+            if (icon_size < 16) {
+                icon_size = 16;
+            }
+            
+            // Control specifically which icon is used at the smaller sizes
+            // so that no scaling occurs. See bug #403500 for more info (--Boyd)
+            if (icon_size <= 21) {
+                icon_size = 16;
+            } else if (icon_size <= 31) {
+                icon_size = 22;
+            } else if (icon_size <= 47) {
+                icon_size = 32;
+            }
+            
+            icon.IconName = Banshee.ServiceStack.Application.IconName;
+            icon.PixelSize = icon_size;
+        }
+
+        private PanelOrientation GetPanelOrientation ()
+        {
+            // Determine whether the tray is inside a horizontal or vertical
+            // panel so the size of the icon can adjust correctly.
+        
+            if (ParentWindow == null) {
+                return PanelOrientation.Horizontal;
+            }
+
+            Gdk.Window top_level_window = ParentWindow.Toplevel;
+
+            Gdk.Rectangle rect = top_level_window.FrameExtents;
+            if (rect.Width < rect.Height) {
+                return PanelOrientation.Vertical;
+            }
+            
+            return PanelOrientation.Horizontal;
+        }
+
+        protected override void OnSizeAllocated (Gdk.Rectangle rect)
+        {
+            base.OnSizeAllocated (rect);
+
+            if (GetPanelOrientation () == PanelOrientation.Horizontal) {
+                if (panel_size == Allocation.Height) {
+                    return;
+                }
+                
+                panel_size = Allocation.Height;
+            } else {
+                if (panel_size == Allocation.Width) {
+                    return;
+                }
+                
+                panel_size = Allocation.Width;
+            }
+
+            ConfigureIconSize ();
+        }
+        
+#endregion
+        
         private void HidePopup () 
         {
             if (popup == null) {

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.addin.xml
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.addin.xml	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.addin.xml	Mon Jun  2 21:41:03 2008
@@ -1,11 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!-- 
+    We do not want users to disable this extension for
+    1.0, though it should be possible in the future.
+-->
 <Addin 
     id="Banshee.NowPlaying"
     version="1.0"
     compatVersion="1.0"
     copyright="Â 2008 Novell Inc. Licensed under the MIT X11 license."
     name="Now Playing"
-    category="User Interface"
+    category="required:User Interface"
     description="Provides a source that displays embedded video and provides fullscreen video playback and controls."
     author="Aaron Bockover"
     url="http://banshee-project.org/";

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	Mon Jun  2 21:41:03 2008
@@ -107,6 +107,10 @@
             Decorated = false;
             TransientFor = null;
             
+            // FIXME: Not really correct, but prevents Compiz from 
+            // doing strange things with the window
+            TypeHint = Gdk.WindowTypeHint.Notification;
+            
             Gdk.Screen screen = Screen;
             int monitor = screen.GetMonitorAtWindow (parent.GdkWindow);
             Gdk.Rectangle bounds = screen.GetMonitorGeometry (monitor);



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