Author: lluis
Date: 2007-07-20 13:45:02 -0400 (Fri, 20 Jul 2007)
New Revision: 82377

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libsteticui/Component.cs
   trunk/stetic/libsteticui/ProjectBackend.cs
   trunk/stetic/libsteticui/WidgetComponent.cs
   trunk/stetic/libsteticui/WidgetDesigner.cs
   trunk/stetic/libsteticui/WidgetEditSession.cs
Log:
* libsteticui/ProjectBackend.cs: Make DeleteSelection work for
  placeholders.
* libsteticui/WidgetEditSession.cs, libsteticui/Component.cs,
  libsteticui/WidgetDesigner.cs, libsteticui/WidgetComponent.cs:
  Moved all clipboard checking properties to WidgetDesigner.

Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2007-07-20 17:43:39 UTC (rev 82376)
+++ trunk/stetic/ChangeLog      2007-07-20 17:45:02 UTC (rev 82377)
@@ -1,3 +1,11 @@
+2007-07-20  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
+       * libsteticui/ProjectBackend.cs: Make DeleteSelection work for
+         placeholders.
+       * libsteticui/WidgetEditSession.cs, libsteticui/Component.cs,
+         libsteticui/WidgetDesigner.cs, libsteticui/WidgetComponent.cs:
+         Moved all clipboard checking properties to WidgetDesigner.
+
 2007-07-16  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
        * libsteticui/Project.cs: Fixes on ActionGroup management.

Modified: trunk/stetic/libsteticui/Component.cs
===================================================================
--- trunk/stetic/libsteticui/Component.cs       2007-07-20 17:43:39 UTC (rev 
82376)
+++ trunk/stetic/libsteticui/Component.cs       2007-07-20 17:45:02 UTC (rev 
82377)
@@ -9,10 +9,6 @@
                protected string name;
                protected ComponentType type;
                protected string typeName;
-               bool gotClipboardStatus;
-               protected bool canCut;
-               protected bool canCopy;
-               protected bool canPaste;
                protected object backend;
                protected Application app;
                
@@ -63,19 +59,6 @@
                                Changed (this, EventArgs.Empty);
                }
                
-               void GetClipboardStatus ()
-               {
-                       if (gotClipboardStatus)
-                               return;
-
-                       gotClipboardStatus = true;
-                       OnGetClipboardStatus ();
-               }
-               
-               protected virtual void OnGetClipboardStatus ()
-               {
-               }
-
                public virtual string Name {
                        get { return name; }
                        set { name = value; }
@@ -87,27 +70,6 @@
                        }
                }
                
-               public bool CanCut {
-                       get {
-                               GetClipboardStatus ();
-                               return canCut;
-                       }
-               }
-               
-               public bool CanCopy {
-                       get {
-                               GetClipboardStatus ();
-                               return canCopy;
-                       }
-               }
-               
-               public bool CanPaste {
-                       get {
-                               GetClipboardStatus ();
-                               return canPaste;
-                       }
-               }
-               
                public virtual bool GeneratePublic {
                        get { return true; }
                        set {}

Modified: trunk/stetic/libsteticui/ProjectBackend.cs
===================================================================
--- trunk/stetic/libsteticui/ProjectBackend.cs  2007-07-20 17:43:39 UTC (rev 
82376)
+++ trunk/stetic/libsteticui/ProjectBackend.cs  2007-07-20 17:45:02 UTC (rev 
82377)
@@ -531,6 +531,14 @@
                        Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (Selection);
                        if (wrapper != null)
                                wrapper.Delete ();
+                       else {
+                               Placeholder ph = Selection as Placeholder;
+                               if (ph != null) {
+                                       Stetic.Wrapper.Container wc = 
Stetic.Wrapper.Container.LookupParent (ph);
+                                       if (wc != null)
+                                               wc.Delete (ph);
+                               }
+                       }
                }
                
                internal WidgetEditSession CreateWidgetDesignerSession 
(WidgetDesignerFrontend frontend, string windowName, Stetic.ProjectBackend 
editingBackend, bool autoCommitChanges)

Modified: trunk/stetic/libsteticui/WidgetComponent.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetComponent.cs 2007-07-20 17:43:39 UTC (rev 
82376)
+++ trunk/stetic/libsteticui/WidgetComponent.cs 2007-07-20 17:45:02 UTC (rev 
82377)
@@ -52,12 +52,6 @@
                        return (Component[]) children.ToArray 
(typeof(Component));
                }
                
-               protected override void OnGetClipboardStatus ()
-               {
-                       if (app != null)
-                               app.Backend.GetClipboardOperations (backend, 
out canCut, out canCopy, out canPaste);
-               }
-               
                void UpdateComponentInfo ()
                {
                        if (app == null)

Modified: trunk/stetic/libsteticui/WidgetDesigner.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetDesigner.cs  2007-07-20 17:43:39 UTC (rev 
82376)
+++ trunk/stetic/libsteticui/WidgetDesigner.cs  2007-07-20 17:45:02 UTC (rev 
82377)
@@ -21,6 +21,8 @@
                bool autoCommitChanges;
                bool disposed;
                
+               bool canCut, canCopy, canPaste, canDelete;
+               
                public event EventHandler BindField;
                public event EventHandler ModifiedChanged;
                public event EventHandler Changed;
@@ -161,18 +163,6 @@
                        }
                }
                
-               public bool CanCopySelection {
-                       get { return Selection != null ? Selection.CanCopy : 
false; }
-               }
-               
-               public bool CanCutSelection {
-                       get { return Selection != null ? Selection.CanCut : 
false; }
-               }
-               
-               public bool CanPasteToSelection {
-                       get { return Selection != null ? Selection.CanPaste : 
false; }
-               }
-               
                public void CopySelection ()
                {
                        if (session != null)
@@ -197,6 +187,22 @@
                                session.EditingBackend.DeleteSelection ();
                }
                
+               public bool CanDeleteSelection {
+                       get { return canDelete; }
+               }
+               
+               public bool CanCutSelection {
+                       get { return canCut; }
+               }
+               
+               public bool CanCopySelection {
+                       get { return canCopy; }
+               }
+               
+               public bool CanPasteToSelection {
+                       get { return canPaste; }
+               }
+               
                public UndoQueue UndoQueue {
                        get {
                                if (session != null)
@@ -348,8 +354,13 @@
                                Changed (this, EventArgs.Empty);
                }
                
-               internal void NotifySelectionChanged (object ob)
+               internal void NotifySelectionChanged (object ob, bool canCut, 
bool canCopy, bool canPaste, bool canDelete)
                {
+                       this.canCut = canCut;
+                       this.canCopy = canCopy;
+                       this.canPaste = canPaste;
+                       this.canDelete = canDelete;
+                       
                        if (ob != null)
                                selection = app.GetComponent (ob, null, null);
                        else
@@ -391,10 +402,10 @@
                        );
                }
                
-               internal void NotifySelectionChanged (object ob)
+               internal void NotifySelectionChanged (object ob, bool canCut, 
bool canCopy, bool canPaste, bool canDelete)
                {
                        Gtk.Application.Invoke (
-                               delegate { if (!disposed) 
designer.NotifySelectionChanged (ob); }
+                               delegate { if (!disposed) 
designer.NotifySelectionChanged (ob, canCut, canCopy, canPaste, canDelete); }
                        );
                }
 

Modified: trunk/stetic/libsteticui/WidgetEditSession.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetEditSession.cs       2007-07-20 17:43:39 UTC 
(rev 82376)
+++ trunk/stetic/libsteticui/WidgetEditSession.cs       2007-07-20 17:45:02 UTC 
(rev 82377)
@@ -359,8 +359,26 @@
                
                void OnSelectionChanged (object ob, EventArgs a)
                {
-                       if (frontend != null)
-                               frontend.NotifySelectionChanged 
(Component.GetSafeReference (ObjectWrapper.Lookup (widget.Selection)));
+                       if (frontend != null) {
+                               bool canCut, canCopy, canPaste, canDelete;
+                               ObjectWrapper obj = ObjectWrapper.Lookup 
(widget.Selection);
+                               Stetic.Wrapper.Widget wrapper = obj as 
Stetic.Wrapper.Widget;
+                               if (wrapper != null) {
+                                       canCut = wrapper.InternalChildProperty 
== null && !wrapper.IsTopLevel;
+                                       canCopy = !wrapper.IsTopLevel;
+                                       canPaste = false;
+                                       canDelete = canCut;
+                               }
+                               else if (widget.Selection is Placeholder) {
+                                       canCut = canCopy = false;
+                                       canPaste = canDelete = true;
+                               }
+                               else {
+                                       canCut = canCopy = canPaste = canDelete 
= false;
+                               }
+                               
+                               frontend.NotifySelectionChanged 
(Component.GetSafeReference (obj), canCut, canCopy, canPaste, canDelete);
+                       }
                }
                
                public object SaveState ()

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

Reply via email to