[hyena] [Hyena.Gui] Fix ActionManager toolitem icon sizing



commit 9dd093655d8084bf1fed69fd4e057b8407108cd1
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Aug 31 13:13:10 2010 -0500

    [Hyena.Gui] Fix ActionManager toolitem icon sizing
    
    Before, any custom widgets populated into a toolbar would not inherit
    the size of the toolbar.  For example, in Banshee the Next button (a
    MenuButton) would remain at size = LargeToolbar even if the toolbar size
    had been set to Menu.  Fixes bgo#609265

 Hyena.Gui/Hyena.Gui/ActionManager.cs |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui/ActionManager.cs b/Hyena.Gui/Hyena.Gui/ActionManager.cs
index f1f0ba9..fdb2145 100644
--- a/Hyena.Gui/Hyena.Gui/ActionManager.cs
+++ b/Hyena.Gui/Hyena.Gui/ActionManager.cs
@@ -140,10 +140,28 @@ namespace Hyena.Gui
                 ToolItem container_item = new Hyena.Widgets.GenericToolItem<Widget> (item);
                 container_item.Expand = expand;
                 container_item.Show ();
+                container_item.ToolbarReconfigured += (o, a) => {
+                    SetItemSize (container_item, container_item.IconSize);
+                };
                 toolbar.Insert (container_item, position);
             }
         }
 
+        private void SetItemSize (Gtk.Widget widget, Gtk.IconSize size)
+        {
+            var container = widget as Container;
+            if (container != null) {
+                foreach (var child in container.Children) {
+                    SetItemSize (child, size);
+                }
+            }
+
+            var img = widget as Image;
+            if (img != null) {
+                img.IconSize = (int)size;
+            }
+        }
+
         public uint AddUiFromFileInCurrentAssembly (string ui_file)
         {
             return AddUiFromFile (ui_file, Assembly.GetCallingAssembly ());



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