banshee r4437 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Preferences.Gui src/Core/Banshee.Widgets/Banshee.Widgets src/Dap/Banshee.Dap/Banshee.Dap



Author: gburt
Date: Wed Aug 27 23:15:10 2008
New Revision: 4437
URL: http://svn.gnome.org/viewvc/banshee?rev=4437&view=rev

Log:
2008-08-26  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Widgets/Banshee.Widgets/RatingActionProxy.cs:
	* src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs: Make work
	with Toolbars as well, so we can have custom toolbar widgets connected to
	Gtk.Actions.



Added:
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DescriptionLabel.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/PodcastGroupSource.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs
   trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/RatingActionProxy.cs

Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Preferences.Gui/DescriptionLabel.cs
==============================================================================

Modified: trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/CustomActionProxy.cs	Wed Aug 27 23:15:10 2008
@@ -82,8 +82,8 @@
             if (uninitialized_actions.ContainsKey (args.Action.Name)) {
                 ActionMenuPath path = uninitialized_actions[args.Action.Name];
 
-                MenuItem item = (path.AfterMenuItem != null)
-                    ? ui.GetWidget (String.Format ("{0}/{1}", path.MenuPath, path.AfterMenuItem)) as MenuItem
+                Widget item = (path.AfterMenuItem != null)
+                    ? ui.GetWidget (String.Format ("{0}/{1}", path.MenuPath, path.AfterMenuItem))
                     : null;
 
                 InsertProxy (args.Action, ui.GetWidget (path.MenuPath), item);
@@ -94,15 +94,41 @@
             }
         }
 
-        protected virtual void InsertProxy (Gtk.Action menuAction, Widget menu, MenuItem afterItem)
+        protected virtual void InsertProxy (Gtk.Action menuAction, Widget parent, Widget afterItem)
         {
-            Menu parent_menu = ((menu is MenuItem) ? (menu as MenuItem).Submenu : menu) as Menu;
-            int position = (afterItem != null) ? Array.IndexOf (parent_menu.Children, afterItem) + 1 : 0;
-            Widget item = GetNewItem ();
-            parent_menu.Insert (item, position);
-            action.ConnectProxy (item);
+            int position = 0;
+            Widget item = null;
+            if (parent is MenuItem || parent is Menu) {
+                Menu parent_menu = ((parent is MenuItem) ? (parent as MenuItem).Submenu : parent) as Menu;
+                position = (afterItem != null) ? Array.IndexOf (parent_menu.Children, afterItem as MenuItem) + 1 : 0;
+                item = GetNewMenuItem ();
+                if (item != null) {
+                    parent_menu.Insert (item, position);
+                }
+            } else if (parent is Toolbar) {
+                ToolItem after_item = afterItem as ToolItem;
+                if (after_item != null) {
+                    position = (parent as Toolbar).GetItemIndex (after_item);
+                    ToolItem tool_item = GetNewToolItem ();
+                    if (tool_item != null) {
+                        (parent as Toolbar).Insert (tool_item, position);
+                        item = tool_item;
+                    }
+                }
+            }
+
+            if (item != null) {
+                action.ConnectProxy (item);
+            }
         }
 
-        protected abstract ComplexMenuItem GetNewItem ();
+        protected virtual ComplexMenuItem GetNewMenuItem ()
+        {
+            return null;
+        }
+        
+        protected virtual ToolItem GetNewToolItem () {
+            return null;
+        }
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/RatingActionProxy.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/RatingActionProxy.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/RatingActionProxy.cs	Wed Aug 27 23:15:10 2008
@@ -49,7 +49,7 @@
         //    base.InsertProxy (menuAction, menu, afterItem);
         //}
 
-        protected override ComplexMenuItem GetNewItem ()
+        protected override ComplexMenuItem GetNewMenuItem ()
         {
             RatingMenuItem item = new RatingMenuItem ();
             item.RatingEntry.Changing += HandleChanging;

Added: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/PodcastGroupSource.cs
==============================================================================



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