Author: lluis
Date: 2006-04-03 08:17:10 -0400 (Mon, 03 Apr 2006)
New Revision: 58938

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/CustomWidget.cs
   trunk/stetic/libstetic/TypedPropertyDescriptor.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
   trunk/stetic/libstetic/wrapper/objects.xml
   trunk/stetic/libsteticui/ContextMenu.cs
   trunk/stetic/libsteticui/ProjectView.cs
   trunk/stetic/libsteticui/WidgetTreeCombo.cs
   trunk/stetic/stetic/Stetic.cs
Log:
2006-04-03  Lluis Sanchez Gual  <[EMAIL PROTECTED]> 

        * libsteticui/WidgetTreeCombo.cs: Don't show children
          for widgets which don't allow children.
        * libsteticui/ProjectView.cs: Allow deleting top level
          widgets from the project view.
        * libsteticui/ContextMenu.cs: Don't allow deleting or
          cutting top level widgets.
        * libstetic/CustomWidget.cs: Use EventBox as base class.
          A gdk window is required to make child widgets selectable.
        * libstetic/wrapper/Container.cs: Minor change in focus
          handling. Don't allow deleting the only placeholder of a 
          top level container.
        * libstetic/wrapper/Widget.cs: Avoid handling the FocusIn
          event fired by an internal Select call.
        * libstetic/wrapper/objects.xml: Removed some read-only
          properties.
        * libstetic/TypedPropertyDescriptor.cs: Provide defaults only
          for primitive type properties.
        * stetic/Stetic.cs: When deleting a top level widget, hide the
          corresponding tab.



Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2006-04-03 12:15:13 UTC (rev 58937)
+++ trunk/stetic/ChangeLog      2006-04-03 12:17:10 UTC (rev 58938)
@@ -1,3 +1,25 @@
+2006-04-03  Lluis Sanchez Gual  <[EMAIL PROTECTED]> 
+
+       * libsteticui/WidgetTreeCombo.cs: Don't show children
+         for widgets which don't allow children.
+       * libsteticui/ProjectView.cs: Allow deleting top level
+         widgets from the project view.
+       * libsteticui/ContextMenu.cs: Don't allow deleting or
+         cutting top level widgets.
+       * libstetic/CustomWidget.cs: Use EventBox as base class.
+         A gdk window is required to make child widgets selectable.
+       * libstetic/wrapper/Container.cs: Minor change in focus
+         handling. Don't allow deleting the only placeholder of a 
+         top level container.
+       * libstetic/wrapper/Widget.cs: Avoid handling the FocusIn
+         event fired by an internal Select call.
+       * libstetic/wrapper/objects.xml: Removed some read-only
+         properties.
+       * libstetic/TypedPropertyDescriptor.cs: Provide defaults only
+         for primitive type properties.
+       * stetic/Stetic.cs: When deleting a top level widget, hide the
+         corresponding tab.
+
 2006-03-31  Lluis Sanchez Gual  <[EMAIL PROTECTED]> 
 
        * libsteticui/PropertyTree.cs: Changed the way instance

Modified: trunk/stetic/libstetic/CustomWidget.cs
===================================================================
--- trunk/stetic/libstetic/CustomWidget.cs      2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libstetic/CustomWidget.cs      2006-04-03 12:17:10 UTC (rev 
58938)
@@ -6,28 +6,18 @@
        // This widget is used at design-time to represent a Gtk.Bin container.
        // Gtk.Bin is the base class for custom widgets.
        
-       public class CustomWidget: Gtk.Bin
+       public class CustomWidget: Gtk.EventBox
        {
-               Gtk.Widget child;
-               
-               protected override void OnSizeRequested (ref Gtk.Requisition 
req)
+               public CustomWidget ()
                {
-                       if (child != null)
-                               req = child.SizeRequest ();
+                       this.VisibleWindow = false;
+                       this.Events |= Gdk.EventMask.ButtonPressMask;
                }
                
-               protected override void OnSizeAllocated (Gdk.Rectangle 
allocation)
+               protected override bool OnButtonPressEvent (Gdk.EventButton ev)
                {
-                       base.OnSizeAllocated (allocation);
-                       if (child != null)
-                               child.Allocation = allocation;
+                       // Avoid forwarding event to parent widget
+                       return true;
                }
-               
-               protected override void OnAdded (Gtk.Widget widget)
-               {
-                       base.OnAdded (widget);
-                       child = widget;
-               }
        }
-       
 }

Modified: trunk/stetic/libstetic/TypedPropertyDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/TypedPropertyDescriptor.cs   2006-04-03 12:15:13 UTC 
(rev 58937)
+++ trunk/stetic/libstetic/TypedPropertyDescriptor.cs   2006-04-03 12:17:10 UTC 
(rev 58938)
@@ -58,7 +58,7 @@
                                maximum = pspec.Maximum;
                                label = pspec.Nick;
                                if (!elem.HasAttribute ("ignore-default"))
-                                       hasDefault = true;
+                                       hasDefault = Type.GetTypeCode 
(PropertyType) != TypeCode.Object || PropertyType.IsEnum;
                        } else {
                                label = propertyInfo.Name;
                                gladeOverride = true;
@@ -91,7 +91,7 @@
                                description = pspec.Blurb;
                                minimum = pspec.Minimum;
                                maximum = pspec.Maximum;
-                               hasDefault = true;
+                               hasDefault = Type.GetTypeCode (PropertyType) != 
TypeCode.Object || PropertyType.IsEnum;
                        } else
                                label = propertyInfo.Name;
                }

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2006-04-03 12:17:10 UTC (rev 
58938)
@@ -558,20 +558,23 @@
 
                        Gtk.Window win = GetParentWindow ();
                        
-                       if (selection != null) {
+                       if (selection != null)
                                selection.Destroyed -= SelectionDestroyed;
-                               // Remove the focus from the window. In this 
way we ensure
-                               // that the current selected widget will lose 
the focus,
-                               // even if the new selection is not focusable.
-                               if (win != null)
-                                       win.Focus = null;
-                       }
+                       
                        if (handles != null)
                                handles.Dispose ();
                                
                        selection = widget;
-                       if (win != null && widget != null && widget.CanFocus)
-                               win.Focus = widget;
+                       if (win != null) {
+                               if (widget != null && widget.CanFocus)
+                                       win.Focus = widget;
+                               else {
+                                       // Remove the focus from the window. In 
this way we ensure
+                                       // that the current selected widget 
will lose the focus,
+                                       // even if the new selection is not 
focusable.
+                                       win.Focus = null;
+                               }
+                       }
                                
                        if (selection != null)
                                selection.Destroyed += SelectionDestroyed;
@@ -656,8 +659,12 @@
                public virtual void Delete (Stetic.Placeholder ph)
                {
                        if (AllowPlaceholders) {
+                               // Don't allow deleting the only placeholder of 
a top level container
+                               if (IsTopLevel && container.Children.Length == 
1)
+                                       return;
                                container.Remove (ph);
                                ph.Destroy ();
+                               // If there aren't more placeholders in this 
container, just delete the container
                                if (container.Children.Length == 0)
                                        Delete ();
                        }

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2006-04-03 12:17:10 UTC (rev 
58938)
@@ -8,6 +8,7 @@
        public class Widget : Object {
        
                string oldName;
+               bool settingFocus;
                SignalCollection signals;
                bool hexpandable, vexpandable;
 
@@ -41,7 +42,7 @@
 
                        if (!(Wrapped is Gtk.Window))
                                Wrapped.ShowAll ();
-
+                       
                        Wrapped.PopupMenu += PopupMenu;
                        Wrapped.FocusInEvent += OnFocusIn;
                        InterceptClicks (Wrapped);
@@ -52,6 +53,9 @@
                
                void OnFocusIn (object s, Gtk.FocusInEventArgs a)
                {
+                       if (settingFocus)
+                               return;
+
                        if (!Unselectable)
                                Select ();
                        else if (ParentWrapper != null)
@@ -159,10 +163,17 @@
 
                public virtual void Select ()
                {
+                       // Select() will bring the focus to this widget.
+                       // This flags avoids calling Select() again
+                       // when the focusIn event is received.
+                       settingFocus = true;
+                       
                        if (ParentWrapper != null)
                                ParentWrapper.Select (this);
                        else if (this is Stetic.Wrapper.Container)
                                ((Container)this).Select (this);
+                               
+                       settingFocus = false;
                }
 
                public void Delete ()

Modified: trunk/stetic/libstetic/wrapper/objects.xml
===================================================================
--- trunk/stetic/libstetic/wrapper/objects.xml  2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libstetic/wrapper/objects.xml  2006-04-03 12:17:10 UTC (rev 
58938)
@@ -209,8 +209,6 @@
        <itemgroups>
            <itemgroup label="Pane Properties">
                <property name="Position" />
-               <property name="MinPosition" />
-               <property name="MaxPosition" />
                <property name="BorderWidth" />
            </itemgroup>
        </itemgroups>

Modified: trunk/stetic/libsteticui/ContextMenu.cs
===================================================================
--- trunk/stetic/libsteticui/ContextMenu.cs     2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libsteticui/ContextMenu.cs     2006-04-03 12:17:10 UTC (rev 
58938)
@@ -68,7 +68,7 @@
                        MenuItem item;
 
                        item = new ImageMenuItem (Gtk.Stock.Cut, null);
-                       if (occupied && !isInternal)
+                       if (occupied && !isInternal && parentWrapper != null)
                                item.Activated += DoCut;
                        else
                                item.Sensitive = false;
@@ -88,12 +88,11 @@
                                item.Sensitive = false;
                        Add (item);
 
-                       item = new ImageMenuItem (Gtk.Stock.Delete, null);
-                       if (!isInternal)
+                       if (!isInternal && parentWrapper != null) {
+                               item = new ImageMenuItem (Gtk.Stock.Delete, 
null);
                                item.Activated += DoDelete;
-                       else
-                               item.Sensitive = false;
-                       Add (item);
+                               Add (item);
+                       }
 
                        if (top) {
                                for (; parentWrapper != null; parentWrapper = 
parentWrapper.ParentWrapper) {

Modified: trunk/stetic/libsteticui/ProjectView.cs
===================================================================
--- trunk/stetic/libsteticui/ProjectView.cs     2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libsteticui/ProjectView.cs     2006-04-03 12:17:10 UTC (rev 
58938)
@@ -113,6 +113,15 @@
 
                        if (selection != null) {
                                Menu m = new ContextMenu (selection);
+                               if (selection.IsTopLevel) {
+                                       // Allow deleting top levels from the 
project view
+                                       ImageMenuItem item = new ImageMenuItem 
(Gtk.Stock.Delete, null);
+                                       item.Activated += delegate (object obj, 
EventArgs args) {
+                                               selection.Delete ();
+                                       };
+                                       item.Show ();
+                                       m.Add (item);
+                               }
                                m.Popup ();
                                return true;
                        } else

Modified: trunk/stetic/libsteticui/WidgetTreeCombo.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetTreeCombo.cs 2006-04-03 12:15:13 UTC (rev 
58937)
+++ trunk/stetic/libsteticui/WidgetTreeCombo.cs 2006-04-03 12:17:10 UTC (rev 
58938)
@@ -102,7 +102,7 @@
                        menu.Append (item);
                        
                        Gtk.Container cc = widget as Gtk.Container;
-                       if (cc != null) {
+                       if (cc != null && 
wrapper.ClassDescriptor.AllowChildren) {
                                foreach (Gtk.Widget child in cc.Children)
                                        FillCombo (menu, child, level + 1);
                        }

Modified: trunk/stetic/stetic/Stetic.cs
===================================================================
--- trunk/stetic/stetic/Stetic.cs       2006-04-03 12:15:13 UTC (rev 58937)
+++ trunk/stetic/stetic/Stetic.cs       2006-04-03 12:17:10 UTC (rev 58938)
@@ -91,6 +91,7 @@
                {
                        Project = new Project ();
                        Project.WidgetAdded += OnWidgetAdded;
+                       Project.WidgetRemoved += OnWidgetRemoved;
                        Project.SelectionChanged += OnSelectionChanged;
 
                        Palette = new Stetic.Palette (Project);
@@ -170,6 +171,13 @@
                        }
                }
                
+               static void OnWidgetRemoved (object s, Wrapper.WidgetEventArgs 
args)
+               {
+                       if (args.Widget.IsTopLevel) {
+                               CloseWindow (args.Widget.Wrapped as 
Gtk.Container);
+                       }
+               }
+               
                static void OnSelectionChanged (object s, 
Wrapper.WidgetEventArgs args)
                {
                        Stetic.Wrapper.Container wc = args.Widget as 
Stetic.Wrapper.Container;
@@ -214,6 +222,7 @@
                                
                                b.Clicked += delegate (object s, EventArgs a) {
                                        box.Hide ();
+                                       WidgetNotebook.QueueResize ();
                                };
                                
                                tabLabel.PackStart (b, false, false, 3);
@@ -224,5 +233,14 @@
                                openWindows [widget] = box;
                        }
                }
+               
+               static void CloseWindow (Gtk.Container widget)
+               {
+                       Gtk.Widget page = (Gtk.Widget) openWindows [widget];
+                       if (page != null) {
+                               WidgetNotebook.Remove (page);
+                               openWindows.Remove (widget);
+                       }
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to