Author: lluis
Date: 2007-01-11 14:48:05 -0500 (Thu, 11 Jan 2007)
New Revision: 70878
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/GeneratorContext.cs
trunk/stetic/libstetic/ObjectWrapper.cs
trunk/stetic/libstetic/editor/ActionGroupEditor.cs
trunk/stetic/libstetic/undo/ActionDiffAdaptor.cs
trunk/stetic/libstetic/undo/DiffGenerator.cs
trunk/stetic/libstetic/undo/UndoManager.cs
trunk/stetic/libstetic/wrapper/Action.cs
trunk/stetic/libstetic/wrapper/ActionGroup.cs
trunk/stetic/libstetic/wrapper/Container.cs
trunk/stetic/libstetic/wrapper/Widget.cs
trunk/stetic/libsteticui/ActionComponent.cs
trunk/stetic/libsteticui/ActionGroupDesigner.cs
trunk/stetic/libsteticui/ActionGroupEditSession.cs
trunk/stetic/libsteticui/ApplicationBackend.cs
trunk/stetic/libsteticui/CodeGenerator.cs
trunk/stetic/libsteticui/CodeGeneratorInternalClass.cs
trunk/stetic/libsteticui/ComponentEventHandler.cs
trunk/stetic/libsteticui/Makefile.am
trunk/stetic/libsteticui/PaletteBackend.cs
trunk/stetic/libsteticui/Project.cs
trunk/stetic/libsteticui/ProjectBackend.cs
trunk/stetic/libsteticui/PropertyGrid.cs
trunk/stetic/libsteticui/UndoQueue.cs
trunk/stetic/libsteticui/WidgetDesigner.cs
trunk/stetic/stetic/DesignerView.cs
trunk/stetic/stetic/LibraryManagerDialog.cs
trunk/stetic/stetic/Stetic.cs
Log:
* libsteticui/ActionGroupDesigner.cs, libsteticui/WidgetDesigner.cs,
libsteticui/ActionGroupEditSession.cs: Added undo support for the
global action group designer.
* libsteticui/ApplicationBackend.cs: Catch errors when loading a
library to avoid aborting the whole update operation.
* libsteticui/ProjectBackend.cs,
libsteticui/CodeGeneratorInternalClass.cs,
libsteticui/PaletteBackend.cs, libsteticui/PropertyGrid.cs,
libstetic/undo/ActionDiffAdaptor.cs, stetic/Stetic.cs,
stetic/DesignerView.cs: Track api changes.
* libsteticui/CodeGenerator.cs: Include actions in the bind field list.
* libsteticui/ComponentEventHandler.cs, libsteticui/Project.cs: The
component removed event now provides the name of the removed
component, no the component reference. Needed since the component
is already removed, and providing an instance in this case is
problematic.
* libsteticui/ActionComponent.cs: Added property for gettion the group
of an action.
* libsteticui/Makefile.am: Added new file.
* libsteticui/UndoQueue.cs: Generalized the undo manager, so it can be
used for the action group editor.
* libstetic/undo/DiffGenerator.cs: Improved error message.
* libstetic/undo/UndoManager.cs: Make sure the UndoWriter works for
wrappers other than widgets. Don't include disposed or unregistered
wrappers into the undo event.
* libstetic/ObjectWrapper.cs: Factorized some undo properties and
methods into ObjectWrapper.
* libstetic/wrapper/Action.cs: More undo support.
* libstetic/wrapper/Container.cs, libstetic/wrapper/Widget.cs: Removed
some methods and properties now implemented in ObjectWrapper.
* libstetic/wrapper/ActionGroup.cs: ActionGroup is now an ObjectWrapper
subclass. Added better support for Undo.
* libstetic/editor/ActionGroupEditor.cs: Use new new ObjectChanged
event.
* libstetic/GeneratorContext.cs: Made GenerateInstanceExpression
public.
* stetic/LibraryManagerDialog.cs: Fixed warning.
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2007-01-11 19:41:51 UTC (rev 70877)
+++ trunk/stetic/ChangeLog 2007-01-11 19:48:05 UTC (rev 70878)
@@ -1,3 +1,43 @@
+2007-01-11 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * libsteticui/ActionGroupDesigner.cs, libsteticui/WidgetDesigner.cs,
+ libsteticui/ActionGroupEditSession.cs: Added undo support for the
+ global action group designer.
+ * libsteticui/ApplicationBackend.cs: Catch errors when loading a
+ library to avoid aborting the whole update operation.
+ * libsteticui/ProjectBackend.cs,
+ libsteticui/CodeGeneratorInternalClass.cs,
+ libsteticui/PaletteBackend.cs, libsteticui/PropertyGrid.cs,
+ libstetic/undo/ActionDiffAdaptor.cs, stetic/Stetic.cs,
+ stetic/DesignerView.cs: Track api changes.
+ * libsteticui/CodeGenerator.cs: Include actions in the bind field list.
+ * libsteticui/ComponentEventHandler.cs, libsteticui/Project.cs: The
+ component removed event now provides the name of the removed
+ component, no the component reference. Needed since the component
+ is already removed, and providing an instance in this case is
+ problematic.
+ * libsteticui/ActionComponent.cs: Added property for gettion the group
+ of an action.
+ * libsteticui/Makefile.am: Added new file.
+ * libsteticui/UndoQueue.cs: Generalized the undo manager, so it can be
+ used for the action group editor.
+ * libstetic/undo/DiffGenerator.cs: Improved error message.
+ * libstetic/undo/UndoManager.cs: Make sure the UndoWriter works for
+ wrappers other than widgets. Don't include disposed or unregistered
+ wrappers into the undo event.
+ * libstetic/ObjectWrapper.cs: Factorized some undo properties and
+ methods into ObjectWrapper.
+ * libstetic/wrapper/Action.cs: More undo support.
+ * libstetic/wrapper/Container.cs, libstetic/wrapper/Widget.cs: Removed
+ some methods and properties now implemented in ObjectWrapper.
+ * libstetic/wrapper/ActionGroup.cs: ActionGroup is now an ObjectWrapper
+ subclass. Added better support for Undo.
+ * libstetic/editor/ActionGroupEditor.cs: Use new new ObjectChanged
+ event.
+ * libstetic/GeneratorContext.cs: Made GenerateInstanceExpression
+ public.
+ * stetic/LibraryManagerDialog.cs: Fixed warning.
+
2007-01-09 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* libsteticui/CodeGenerator.cs: Don't generate variables for
Modified: trunk/stetic/libstetic/GeneratorContext.cs
===================================================================
--- trunk/stetic/libstetic/GeneratorContext.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libstetic/GeneratorContext.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -48,10 +48,10 @@
return var;
}
- protected virtual CodeExpression GenerateInstanceExpression
(ObjectWrapper wrapper, CodeExpression newObject)
+ public virtual CodeExpression GenerateInstanceExpression
(ObjectWrapper wrapper, CodeExpression newObject)
{
string varName = NewId ();
- CodeVariableDeclarationStatement varDec = new
CodeVariableDeclarationStatement (wrapper.ClassDescriptor.WrappedTypeName,
varName);
+ CodeVariableDeclarationStatement varDec = new
CodeVariableDeclarationStatement (wrapper.WrappedTypeName, varName);
varDec.InitExpression = newObject;
statements.Add (varDec);
return new CodeVariableReferenceExpression (varName);
Modified: trunk/stetic/libstetic/ObjectWrapper.cs
===================================================================
--- trunk/stetic/libstetic/ObjectWrapper.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libstetic/ObjectWrapper.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -24,6 +24,12 @@
bool loading;
IObjectFrontend frontend;
bool disposed;
+
+ // This id is used by the undo methods to identify an object.
+ // This id is not stored, since it's used only while the widget
is being
+ // edited in the designer
+ string undoId = WidgetUtils.GetUndoId ();
+
UndoManager undoManager;
static UndoManager defaultUndoManager = new UndoManager (true);
@@ -45,6 +51,35 @@
internal set { undoManager = value; }
}
+ // Called the get a diff of changes since the last call to
GetUndoDiff().
+ // The returned object can be used to restore the object status
by calling
+ // ApplyUndoRedoDiff. The implementation can use the
UndoManager object to
+ // store status information.
+ public virtual object GetUndoDiff ()
+ {
+ return null;
+ }
+
+ // Called to apply a set of changes to the object. It returns
+ // a set of changes which can be used to reverse the operation.
+ public virtual object ApplyUndoRedoDiff (object diff)
+ {
+ return null;
+ }
+
+ public string UndoId {
+ get { return undoId; }
+ internal set { undoId = value; }
+ }
+
+ public virtual ObjectWrapper FindObjectByUndoId (string id)
+ {
+ if (undoId == id)
+ return this;
+ else
+ return null;
+ }
+
internal virtual UndoManager GetUndoManagerInternal ()
{
return undoManager;
@@ -90,7 +125,8 @@
if (frontend != null)
frontend.Dispose ();
frontend = null;
- wrappers.Remove (GetIndentityObject (wrapped));
+ if (wrapped != null)
+ wrappers.Remove (GetIndentityObject (wrapped));
System.Runtime.Remoting.RemotingServices.Disconnect
(this);
}
@@ -198,9 +234,9 @@
PropertyDescriptor prop =
ClassDescriptor.InitializationProperties [n];
paramters [n] = ctx.GenerateValue
(prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable);
}
- return new CodeObjectCreateExpression
(ClassDescriptor.WrappedTypeName, paramters);
+ return new CodeObjectCreateExpression
(WrappedTypeName, paramters);
} else
- return new CodeObjectCreateExpression
(ClassDescriptor.WrappedTypeName);
+ return new CodeObjectCreateExpression
(WrappedTypeName);
}
protected virtual void GeneratePropertySet (GeneratorContext
ctx, CodeExpression var, PropertyDescriptor prop)
@@ -246,6 +282,10 @@
get { return classDescriptor; }
}
+ public virtual string WrappedTypeName {
+ get { return classDescriptor.WrappedTypeName; }
+ }
+
public void NotifyChanged ()
{
if (UndoManager.CanNotifyChanged (this))
Modified: trunk/stetic/libstetic/editor/ActionGroupEditor.cs
===================================================================
--- trunk/stetic/libstetic/editor/ActionGroupEditor.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libstetic/editor/ActionGroupEditor.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -80,14 +80,14 @@
get { return actionGroup; }
set {
if (actionGroup != null) {
- actionGroup.Changed -= OnGroupChanged;
+ actionGroup.ObjectChanged -=
OnGroupChanged;
actionGroup.ActionAdded -=
OnActionAdded;
actionGroup.ActionRemoved -=
OnActionRemoved;
}
actionGroup = value;
if (actionGroup != null) {
headerLabel.Text = actionGroup.Name;
- actionGroup.Changed += OnGroupChanged;
+ actionGroup.ObjectChanged +=
OnGroupChanged;
actionGroup.ActionAdded +=
OnActionAdded;
actionGroup.ActionRemoved +=
OnActionRemoved;
foreach (Action a in
actionGroup.Actions)
@@ -227,7 +227,7 @@
emptyLabel = null;
}
- void OnGroupChanged (object s, EventArgs args)
+ void OnGroupChanged (object s, ObjectWrapperEventArgs args)
{
headerLabel.Text = actionGroup.Name;
NotifyModified ();
Modified: trunk/stetic/libstetic/undo/ActionDiffAdaptor.cs
===================================================================
--- trunk/stetic/libstetic/undo/ActionDiffAdaptor.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libstetic/undo/ActionDiffAdaptor.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -141,13 +141,14 @@
public object DeserializeChild (XmlElement data)
{
+ ObjectReader or = new ObjectReader (project,
FileFormat.Native);
if (data.LocalName == "action") {
Action ac = new Action ();
- ac.Read (project, data);
+ ac.Read (or, data);
return ac;
} else if (data.LocalName == "action-group") {
ActionGroup ac = new ActionGroup ();
- ac.Read (project, data);
+ ac.Read (or, data);
return ac;
}
throw new NotImplementedException ();
Modified: trunk/stetic/libstetic/undo/DiffGenerator.cs
===================================================================
--- trunk/stetic/libstetic/undo/DiffGenerator.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libstetic/undo/DiffGenerator.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -62,7 +62,7 @@
changes.Add (cdiff);
}
} else {
- throw new InvalidOperationException
("Found an element without ID");
+ throw new InvalidOperationException
("Found an element of type '" + oldChild.GetType () + "' without ID");
}
}
@@ -81,7 +81,7 @@
changes.Add (cdiff);
}
} else
- throw new InvalidOperationException
("Found an element without ID");
+ throw new InvalidOperationException
("Found an element of type '" + newChildElem.GetType () + "' without ID");
lastWidgetId = cid;
}
Modified: trunk/stetic/libstetic/undo/UndoManager.cs
===================================================================
--- trunk/stetic/libstetic/undo/UndoManager.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libstetic/undo/UndoManager.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -36,14 +36,14 @@
elements.Clear ();
doc = new XmlDocument ();
- UndoWriter writer = new UndoWriter (doc,
FileFormat.Native, this);
+ UndoWriter writer = new UndoWriter (doc, this);
writer.WriteObject (wrapper);
}
internal bool CanNotifyChanged (ObjectWrapper wrapper)
{
if (!InAtomicChange) {
- if (UndoCheckpoint != null)
+ if (IsRegistered (wrapper) && UndoCheckpoint !=
null)
UndoCheckpoint (this, new
UndoCheckpointEventArgs (new ObjectWrapper[] { wrapper }));
return true;
} else
@@ -115,7 +115,6 @@
internal bool IsRegistered (ObjectWrapper w)
{
- VerifyManager ();
return elements.ContainsKey (w);
}
@@ -177,7 +176,7 @@
UndoManager undoManager;
bool allowMarkers = true;
- public UndoWriter (XmlDocument doc, FileFormat format,
UndoManager undoManager): base (doc, format)
+ public UndoWriter (XmlDocument doc, UndoManager undoManager):
base (doc, FileFormat.Native)
{
this.undoManager = undoManager;
CreateUndoInfo = true;
@@ -202,12 +201,14 @@
allowMarkers = oldAllow;
if (ww != null) {
- // Register the object, so it is correctly
bound to this xml element
ww.RequiresUndoStatusUpdate = false;
- if (undoManager.IsRegistered (ww))
- undoManager.UnregisterObject (ww);
- undoManager.RegisterObject (ww, elem);
}
+
+ // Register the object, so it is correctly bound to
this xml element
+ if (undoManager.IsRegistered (wrapper))
+ undoManager.UnregisterObject (wrapper);
+ undoManager.RegisterObject (wrapper, elem);
+
return elem;
}
}
@@ -282,6 +283,18 @@
((ObjectWrapper)ChangeEventPending[n]).FireObjectChangedEvent ();
}
+ // Remove from the list the widgets that have
been disposed. It means that
+ // they have been deleted. That change will be
recorded by their parents.
+ // Remove as well wrappers that are not
registered, since there won't be
+ // status information for them.
+ for (int n=0; n<ChangeEventPending.Count; n++) {
+ ObjectWrapper w =
(ObjectWrapper)ChangeEventPending[n];
+ if (w.IsDisposed ||
!undoManager.IsRegistered (w)) {
+ ChangeEventPending.RemoveAt (n);
+ n--;
+ }
+ }
+
ObjectWrapper[] obs = (ObjectWrapper[])
ChangeEventPending.ToArray (typeof(ObjectWrapper));
ChangeEventPending.Clear ();
Count = 0;
Modified: trunk/stetic/libstetic/wrapper/Action.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Action.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libstetic/wrapper/Action.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -4,6 +4,7 @@
using System.Xml;
using System.CodeDom;
using System.Collections;
+using Stetic.Undo;
namespace Stetic.Wrapper
{
@@ -20,9 +21,6 @@
string oldDefaultName;
string nameRoot;
- // This id is used by the undo methods to identify an object.
- string undoId = WidgetUtils.GetUndoId ();
-
public enum ActionType {
Action,
Toggle,
@@ -55,9 +53,15 @@
}
}
- internal string UndoId {
- get { return undoId; }
- set { undoId = value; }
+ public override string WrappedTypeName {
+ get {
+ if (type == ActionType.Action)
+ return "Gtk.Action";
+ else if (type == ActionType.Toggle)
+ return "Gtk.ToggleAction";
+ else
+ return "Gtk.RadioAction";
+ }
}
internal void UpdateNameIndex ()
@@ -171,26 +175,26 @@
{
XmlElement elem = writer.XmlDocument.CreateElement
("action");
elem.SetAttribute ("id", Name);
- if (writer.CreateUndoInfo)
- elem.SetAttribute ("undoId", undoId);
WidgetUtils.GetProps (this, elem);
WidgetUtils.GetSignals (this, elem);
+ if (writer.CreateUndoInfo)
+ elem.SetAttribute ("undoId", UndoId);
return elem;
}
- public void Read (IProject project, XmlElement elem)
+ public override void Read (ObjectReader reader, XmlElement elem)
{
Gtk.Action ac = new Gtk.Action (name, "");
ClassDescriptor klass = Registry.LookupClassByName
("Gtk.Action");
- ObjectWrapper.Bind (project, klass, this, ac, true);
+ ObjectWrapper.Bind (reader.Project, klass, this, ac,
true);
WidgetUtils.ReadMembers (klass, this, ac, elem);
name = nameRoot = oldDefaultName = elem.GetAttribute
("id");
string uid = elem.GetAttribute ("undoId");
if (uid.Length > 0)
- undoId = uid;
+ UndoId = uid;
}
public Action Clone ()
@@ -311,10 +315,45 @@
internal override UndoManager GetUndoManagerInternal ()
{
if (group != null)
- return group.GetUndoManager ();
+ return group.GetUndoManagerInternal ();
else
return base.GetUndoManagerInternal ();
}
+
+ DiffGenerator GetDiffGenerator ()
+ {
+ DiffGenerator gen = new DiffGenerator ();
+ gen.CurrentStatusAdaptor = new ActionDiffAdaptor
(Project);
+ gen.NewStatusAdaptor = new XmlDiffAdaptor ();
+ return gen;
+ }
+
+ public override object GetUndoDiff ()
+ {
+ XmlElement oldElem = UndoManager.GetObjectStatus (this);
+ UndoWriter writer = new UndoWriter
(oldElem.OwnerDocument, UndoManager);
+ XmlElement newElem = Write (writer);
+ ObjectDiff actionsDiff = GetDiffGenerator().GetDiff
(this, oldElem);
+ UndoManager.UpdateObjectStatus (this, newElem);
+ return actionsDiff;
+ }
+
+ public override object ApplyUndoRedoDiff (object diff)
+ {
+ ObjectDiff actionsDiff = (ObjectDiff) diff;
+
+ XmlElement status = UndoManager.GetObjectStatus (this);
+
+ DiffGenerator differ = GetDiffGenerator();
+ differ.ApplyDiff (this, actionsDiff);
+ actionsDiff = differ.GetDiff (this, status);
+
+ UndoWriter writer = new UndoWriter
(status.OwnerDocument, UndoManager);
+ XmlElement newElem = Write (writer);
+ UndoManager.UpdateObjectStatus (this, newElem);
+
+ return actionsDiff;
+ }
}
[Serializable]
Modified: trunk/stetic/libstetic/wrapper/ActionGroup.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ActionGroup.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libstetic/wrapper/ActionGroup.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -7,23 +7,15 @@
namespace Stetic.Wrapper
{
- public sealed class ActionGroup: MarshalByRefObject, IDisposable
+ public sealed class ActionGroup: ObjectWrapper
{
string name;
ActionCollection actions;
- IObjectFrontend frontend;
ObjectWrapper owner;
- // This id is used by the undo methods to identify an object.
- string undoId = WidgetUtils.GetUndoId ();
-
public event ActionEventHandler ActionAdded;
public event ActionEventHandler ActionRemoved;
public event ActionEventHandler ActionChanged;
- public event EventHandler Changed;
- public event SignalEventHandler SignalAdded;
- public event SignalEventHandler SignalRemoved;
- public event SignalChangedEventHandler SignalChanged;
public ActionGroup ()
{
@@ -35,26 +27,13 @@
this.name = name;
}
- public void Dispose ()
+ public override void Dispose ()
{
foreach (Action a in actions)
a.Dispose ();
+ base.Dispose ();
}
- internal string UndoId {
- get { return undoId; }
- set { undoId = value; }
- }
-
- public IObjectFrontend Frontend {
- get { return frontend; }
- set {
- if (frontend != null)
- frontend.Dispose ();
- frontend = value;
- }
- }
-
public ActionCollection Actions {
get { return actions; }
}
@@ -98,33 +77,33 @@
return name;
}
- public XmlElement Write (ObjectWriter writer)
+ public override XmlElement Write (ObjectWriter writer)
{
XmlElement group = writer.XmlDocument.CreateElement
("action-group");
group.SetAttribute ("name", name);
if (writer.CreateUndoInfo)
- group.SetAttribute ("undoId", undoId);
+ group.SetAttribute ("undoId", UndoId);
foreach (Action ac in actions) {
if (ac.Name.Length > 0)
- group.AppendChild (ac.Write (writer));
+ group.AppendChild (writer.WriteObject
(ac));
}
return group;
}
- public void Read (IProject project, XmlElement elem)
+ public override void Read (ObjectReader reader, XmlElement elem)
{
name = elem.GetAttribute ("name");
string uid = elem.GetAttribute ("undoId");
if (uid.Length > 0)
- undoId = uid;
+ UndoId = uid;
foreach (XmlElement child in elem.SelectNodes
("action")) {
Action ac = new Action ();
- ac.Read (project, child);
+ ac.Read (reader, child);
actions.Add (ac);
}
}
- internal CodeExpression GenerateObjectCreation
(GeneratorContext ctx)
+ internal protected override CodeExpression
GenerateObjectCreation (GeneratorContext ctx)
{
return new CodeObjectCreateExpression (
typeof(Gtk.ActionGroup),
@@ -132,26 +111,11 @@
);
}
- internal void GenerateBuildCode (GeneratorContext ctx,
CodeExpression var)
+ internal protected override void GenerateBuildCode
(GeneratorContext ctx, CodeExpression var)
{
foreach (Action action in Actions) {
// Create the action
- string acVar = ctx.NewId ();
- Type atype;
- if (action.Type == Action.ActionType.Action)
- atype = typeof (Gtk.Action);
- else if (action.Type == Action.ActionType.Radio)
- atype = typeof(Gtk.RadioAction);
- else
- atype = typeof(Gtk.ToggleAction);
-
- CodeVariableDeclarationStatement uidec = new
CodeVariableDeclarationStatement (
- atype,
- acVar,
- action.GenerateObjectCreation (ctx)
- );
- CodeExpression acVarExp = new
CodeVariableReferenceExpression (acVar);
- ctx.Statements.Add (uidec);
+ CodeExpression acVarExp =
ctx.GenerateInstanceExpression (action, action.GenerateObjectCreation (ctx));
ctx.GenerateBuildCode (action, acVarExp);
ctx.Statements.Add (
new CodeMethodInvokeExpression (
@@ -169,14 +133,65 @@
this.owner = owner;
}
- internal UndoManager GetUndoManager ()
+ internal override UndoManager GetUndoManagerInternal ()
{
if (owner != null)
return owner.UndoManager;
else
- return null;
+ return base.GetUndoManagerInternal ();
}
+ public override ObjectWrapper FindObjectByUndoId (string id)
+ {
+ ObjectWrapper ow = base.FindObjectByUndoId (id);
+ if (ow != null) return ow;
+
+ foreach (Action ac in Actions) {
+ ow = ac.FindObjectByUndoId (id);
+ if (ow != null)
+ return ow;
+ }
+ return null;
+ }
+
+ DiffGenerator GetDiffGenerator ()
+ {
+ DiffGenerator gen = new DiffGenerator ();
+ gen.CurrentStatusAdaptor = new ActionDiffAdaptor
(Project);
+ XmlDiffAdaptor xad = new XmlDiffAdaptor ();
+ xad.ChildElementName = "action";
+ gen.NewStatusAdaptor = xad;
+ return gen;
+ }
+
+ public override object GetUndoDiff ()
+ {
+ XmlElement oldElem = UndoManager.GetObjectStatus (this);
+ UndoWriter writer = new UndoWriter
(oldElem.OwnerDocument, UndoManager);
+
+ XmlElement newElem = Write (writer);
+ ObjectDiff actionsDiff = GetDiffGenerator().GetDiff
(this, oldElem);
+ UndoManager.UpdateObjectStatus (this, newElem);
+ return actionsDiff;
+ }
+
+ public override object ApplyUndoRedoDiff (object diff)
+ {
+ ObjectDiff actionsDiff = (ObjectDiff) diff;
+
+ XmlElement status = UndoManager.GetObjectStatus (this);
+
+ DiffGenerator differ = GetDiffGenerator();
+ differ.ApplyDiff (this, actionsDiff);
+ actionsDiff = differ.GetDiff (this, status);
+
+ UndoWriter writer = new UndoWriter
(status.OwnerDocument, UndoManager);
+ XmlElement newElem = Write (writer);
+ UndoManager.UpdateObjectStatus (this, newElem);
+
+ return actionsDiff;
+ }
+
internal void NotifyActionAdded (Action ac)
{
ac.SetActionGroup (this);
@@ -207,14 +222,6 @@
ActionRemoved (this, new ActionEventArgs (ac));
}
- void NotifyChanged ()
- {
- if (frontend != null)
- frontend.NotifyChanged ();
- if (Changed != null)
- Changed (this, EventArgs.Empty);
- }
-
void OnActionChanged (object s, ObjectWrapperEventArgs args)
{
NotifyChanged ();
@@ -224,23 +231,17 @@
void OnSignalAdded (object s, SignalEventArgs args)
{
- NotifyChanged ();
- if (SignalAdded != null)
- SignalAdded (this, args);
+ OnSignalAdded (args);
}
void OnSignalRemoved (object s, SignalEventArgs args)
{
- NotifyChanged ();
- if (SignalRemoved != null)
- SignalRemoved (this, args);
+ OnSignalRemoved (args);
}
void OnSignalChanged (object s, SignalChangedEventArgs args)
{
- NotifyChanged ();
- if (SignalChanged != null)
- SignalChanged (this, args);
+ OnSignalChanged (args);
}
}
@@ -277,6 +278,16 @@
}
}
+ internal ObjectWrapper FindObjectByUndoId (string id)
+ {
+ foreach (ActionGroup ag in List) {
+ ObjectWrapper ow = ag.FindObjectByUndoId (id);
+ if (ow != null)
+ return ow;
+ }
+ return null;
+ }
+
DiffGenerator GetDiffGenerator (IProject prj)
{
DiffGenerator gen = new DiffGenerator ();
@@ -342,7 +353,7 @@
void NotifyGroupAdded (ActionGroup grp)
{
grp.SetOwner (owner);
- grp.Changed += OnGroupChanged;
+ grp.ObjectChanged += OnGroupChanged;
if (ActionGroupAdded != null)
ActionGroupAdded (this, new
ActionGroupEventArgs (grp));
}
@@ -350,12 +361,12 @@
void NotifyGroupRemoved (ActionGroup grp)
{
grp.SetOwner (null);
- grp.Changed -= OnGroupChanged;
+ grp.ObjectChanged -= OnGroupChanged;
if (ActionGroupRemoved != null)
ActionGroupRemoved (this, new
ActionGroupEventArgs (grp));
}
- void OnGroupChanged (object s, EventArgs a)
+ void OnGroupChanged (object s, ObjectWrapperEventArgs a)
{
if (ActionGroupChanged != null)
ActionGroupChanged (this, new
ActionGroupEventArgs ((ActionGroup)s));
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -151,7 +151,7 @@
// Write the new status of the object. This is going to
replace the old status in undoManager.
// In the process, register new objects found.
- UndoWriter writer = new UndoWriter
(oldElem.OwnerDocument, FileFormat.Native, UndoManager);
+ UndoWriter writer = new UndoWriter
(oldElem.OwnerDocument, UndoManager);
XmlElement newElem = Write (writer);
// Console.WriteLine ("CURRENT status: ");
@@ -222,7 +222,7 @@
foreach (XmlElement group in status.SelectNodes
("action-group"))
status.RemoveChild (group);
- UndoWriter writer = new UndoWriter
(status.OwnerDocument, FileFormat.Native, UndoManager);
+ UndoWriter writer = new UndoWriter
(status.OwnerDocument, UndoManager);
foreach (ActionGroup actionGroup in
LocalActionGroups)
status.InsertBefore (actionGroup.Write
(writer), status.FirstChild);
}
@@ -1165,48 +1165,27 @@
return null;
}
- public Widget FindChildByUndoId (string id)
+ public override ObjectWrapper FindObjectByUndoId (string id)
{
- if (UndoId == id)
- return this;
- else
- return Widget.Lookup (FindChildByUndoId
((Gtk.Container)Wrapped, id));
- }
-
- Gtk.Widget FindChildByUndoId (Gtk.Container parent, string id)
- {
- foreach (Gtk.Widget w in parent.AllChildren) {
+ ObjectWrapper c = base.FindObjectByUndoId (id);
+ if (c != null)
+ return c;
+
+ foreach (Gtk.Widget w in container.AllChildren) {
Widget ww = Widget.Lookup (w);
if (ww == null)
continue;
- if (ww.UndoId == id)
- return w;
- if (w is Gtk.Container) {
- Gtk.Widget res = FindChildByUndoId
((Gtk.Container)w, id);
- if (res != null)
- return res;
- }
+ ObjectWrapper ow = ww.FindObjectByUndoId (id);
+ if (ow != null)
+ return ow;
}
return null;
}
+
+
public class ContainerChild : Stetic.ObjectWrapper
{
- // This id is used by the undo methods to identify a
child of a container.
- // The id is not stored, since it's used only while the
widget is being
- // edited in the designer
- string undoId;
-
- public ContainerChild ()
- {
- undoId = WidgetUtils.GetUndoId ();
- }
-
- internal string UndoId {
- get { return undoId; }
- set { undoId = value; }
- }
-
internal static void Register ()
{
// FIXME?
Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libstetic/wrapper/Widget.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -10,9 +10,6 @@
{
static DiffGenerator propDiffGenerator;
- // This id is used by the undo methods to identify an object
(even if it's name changes)
- string undoId = WidgetUtils.GetUndoId ();
-
string oldName;
string oldMemberName;
internal bool settingFocus;
@@ -110,11 +107,6 @@
base.Dispose ();
}
- public string UndoId {
- get { return undoId; }
- internal set { undoId = value; }
- }
-
void OnFocusIn (object s, Gtk.FocusInEventArgs a)
{
if (settingFocus)
@@ -396,8 +388,20 @@
set { requiresUndoStatusUpdate = value; }
}
- public virtual object GetUndoDiff ()
+ public override ObjectWrapper FindObjectByUndoId (string id)
{
+ ObjectWrapper c = base.FindObjectByUndoId (id);
+ if (c != null)
+ return c;
+
+ if (actionGroups != null)
+ return actionGroups.FindObjectByUndoId (id);
+ else
+ return null;
+ }
+
+ public override object GetUndoDiff ()
+ {
XmlElement oldElem = UndoManager.GetObjectStatus (this);
XmlElement newElem = WriteProperties (new ObjectWriter
(oldElem.OwnerDocument, FileFormat.Native));
@@ -412,7 +416,7 @@
return new ObjectDiff[] { propsDiff,
actionsDiff };
}
- public virtual object ApplyUndoRedoDiff (object diff)
+ public override object ApplyUndoRedoDiff (object diff)
{
ObjectDiff[] data = (ObjectDiff[]) diff;
@@ -447,7 +451,7 @@
if (reader.Format == FileFormat.Native) {
foreach (XmlElement groupElem in
elem.SelectNodes ("action-group")) {
ActionGroup actionGroup = new
ActionGroup ();
- actionGroup.Read (Project, groupElem);
+ actionGroup.Read (reader, groupElem);
if (actionGroups == null) {
actionGroups = new
ActionGroupCollection ();
actionGroups.SetOwner (this);
@@ -475,7 +479,7 @@
string uid = elem.GetAttribute ("undoId");
if (uid.Length > 0)
- undoId = uid;
+ UndoId = uid;
}
public override XmlElement Write (ObjectWriter writer)
@@ -490,7 +494,7 @@
if (writer.Format == FileFormat.Native) {
XmlElement elem = WidgetUtils.Write (this,
writer.XmlDocument);
if (writer.CreateUndoInfo)
- elem.SetAttribute ("undoId", undoId);
+ elem.SetAttribute ("undoId", UndoId);
return elem;
}
else {
Modified: trunk/stetic/libsteticui/ActionComponent.cs
===================================================================
--- trunk/stetic/libsteticui/ActionComponent.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/ActionComponent.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -41,5 +41,9 @@
return icon;
}
}
+
+ public ActionGroupComponent ActionGroup {
+ get { return (ActionGroupComponent) app.GetComponent
(((Wrapper.Action)backend).ActionGroup, null, null); }
+ }
}
}
Modified: trunk/stetic/libsteticui/ActionGroupDesigner.cs
===================================================================
--- trunk/stetic/libsteticui/ActionGroupDesigner.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libsteticui/ActionGroupDesigner.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -11,25 +11,33 @@
string componentName;
string actionGroupName;
bool autoCommitChanges;
+ WidgetDesigner relatedWidgetDesigner;
public event EventHandler BindField;
public event EventHandler ModifiedChanged;
+ public event EventHandler RootComponentChanged;
public event ComponentSignalEventHandler SignalAdded;
public event ComponentSignalEventHandler SignalChanged;
- internal ActionGroupDesigner (Project project, string
componentName, ActionGroupComponent actionGroup, bool autoCommitChanges): base
(project.App)
+ internal ActionGroupDesigner (Project project, string
componentName, ActionGroupComponent actionGroup, WidgetDesigner
relatedWidgetDesigner, bool autoCommitChanges): base (project.App)
{
this.componentName = componentName;
+ this.relatedWidgetDesigner = relatedWidgetDesigner;
+
if (actionGroup != null)
this.actionGroupName = actionGroup.Name;
this.autoCommitChanges = autoCommitChanges;
this.project = project;
-
+
frontend = new ActionGroupDesignerFrontend (this);
CreateSession ();
}
+ public Component RootComponent {
+ get { return app.GetComponent
(editSession.EditedActionGroup, null, null); }
+ }
+
public bool AllowActionBinding {
get {
return editSession != null &&
editSession.AllowActionBinding;
@@ -40,6 +48,17 @@
}
}
+ public UndoQueue UndoQueue {
+ get {
+ if (relatedWidgetDesigner != null)
+ return relatedWidgetDesigner.UndoQueue;
+ else if (editSession != null)
+ return editSession.UndoQueue;
+ else
+ return UndoQueue.Empty;
+ }
+ }
+
public ActionComponent SelectedAction {
get {
if (editSession == null)
@@ -169,6 +188,9 @@
editSession.RestoreState (sessionData);
base.OnBackendChanged (oldBackend);
+
+ if (RootComponentChanged != null)
+ RootComponentChanged (this, EventArgs.Empty);
}
internal void NotifyBindField ()
Modified: trunk/stetic/libsteticui/ActionGroupEditSession.cs
===================================================================
--- trunk/stetic/libsteticui/ActionGroupEditSession.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libsteticui/ActionGroupEditSession.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -21,6 +21,9 @@
Stetic.Wrapper.ActionGroup group;
Hashtable actionCopyMap = new Hashtable ();
+ UndoRedoManager undoManager;
+ UndoQueue undoQueue;
+
public ActionGroupEditSession (ActionGroupDesignerFrontend
frontend, ProjectBackend project, string containerName, string groupToEdit,
bool autoCommitChanges)
{
this.groupToEdit = groupToEdit;
@@ -35,6 +38,11 @@
throw new InvalidOperationException
("Unknown action group: " + groupToEdit);
Load (group);
groupToolbar = new ActionGroupToolbar
(frontend, groupCopy);
+
+ undoManager = new UndoRedoManager ();
+ undoQueue = new UndoQueue ();
+ undoManager.UndoQueue = undoQueue;
+ undoManager.RootObject = groupCopy;
}
else {
if (!autoCommitChanges)
@@ -48,6 +56,10 @@
project.ProjectReloaded += new EventHandler
(OnProjectReloaded);
}
+ public Wrapper.ActionGroup EditedActionGroup {
+ get { return groupCopy; }
+ }
+
void Load (Stetic.Wrapper.ActionGroup group)
{
if (autoCommitChanges) {
@@ -102,6 +114,15 @@
Modified = false;
}
+ public UndoQueue UndoQueue {
+ get {
+ if (undoQueue != null)
+ return undoQueue;
+ else
+ return UndoQueue.Empty;
+ }
+ }
+
public void CopySelection ()
{
designer.Editor.Copy ();
Modified: trunk/stetic/libsteticui/ApplicationBackend.cs
===================================================================
--- trunk/stetic/libsteticui/ApplicationBackend.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libsteticui/ApplicationBackend.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -161,7 +161,15 @@
}
}
if (alib != null) {
- Registry.RegisterWidgetLibrary (alib);
+ try {
+ Registry.RegisterWidgetLibrary
(alib);
+ } catch (Exception ex) {
+ // Catch errors when loading a
library to avoid aborting
+ // the whole update method.
After all, that's not a fatal
+ // error (some widgets just
won't be shown).
+ // FIXME: return the error
somewhere
+ Console.WriteLine (ex);
+ }
updated = true;
}
}
@@ -457,5 +465,10 @@
{
return CodeGenerator.GetFieldsToBind (wrapper).ToArray
();
}
+
+ internal ObjectWrapper GetPropertyTreeTarget ()
+ {
+ return targetViewerObject as ObjectWrapper;
+ }
}
}
Modified: trunk/stetic/libsteticui/CodeGenerator.cs
===================================================================
--- trunk/stetic/libsteticui/CodeGenerator.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/CodeGenerator.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -295,16 +295,21 @@
memberName = ((Wrapper.Action) wrapper).Name;
if (memberName != null) {
- ObjectBindInfo binfo = new ObjectBindInfo
(wrapper.ClassDescriptor.WrappedTypeName, memberName);
+ ObjectBindInfo binfo = new ObjectBindInfo
(wrapper.WrappedTypeName, memberName);
tobind.Add (binfo);
}
+ Wrapper.ActionGroup agroup = wrapper as
Wrapper.ActionGroup;
+ if (agroup != null) {
+ foreach (Wrapper.Action ac in agroup.Actions)
+ GetFieldsToBind (tobind, ac);
+ }
+
Wrapper.Widget widget = wrapper as Wrapper.Widget;
if (widget != null && widget.IsTopLevel) {
// Generate fields for local actions
foreach (Wrapper.ActionGroup grp in
widget.LocalActionGroups) {
- foreach (Wrapper.Action ac in
grp.Actions)
- GetFieldsToBind (tobind, ac);
+ GetFieldsToBind (tobind, grp);
}
}
@@ -347,8 +352,9 @@
this.type = type;
}
- protected override CodeExpression GenerateInstanceExpression
(ObjectWrapper wrapper, CodeExpression newObject)
+ public override CodeExpression GenerateInstanceExpression
(ObjectWrapper wrapper, CodeExpression newObject)
{
+ string typeName = wrapper.WrappedTypeName;
string memberName = null;
if (wrapper is Wrapper.Widget)
memberName = ((Wrapper.Widget)
wrapper).Wrapped.Name;
@@ -365,7 +371,7 @@
if (ww == null || (!ww.IsTopLevel &&
ww.InternalChildProperty == null && !ww.Unselectable)) {
type.Members.Add (
new CodeMemberField (
-
wrapper.ClassDescriptor.WrappedTypeName,
+ typeName,
memberName
)
);
Modified: trunk/stetic/libsteticui/CodeGeneratorInternalClass.cs
===================================================================
--- trunk/stetic/libsteticui/CodeGeneratorInternalClass.cs 2007-01-11
19:41:51 UTC (rev 70877)
+++ trunk/stetic/libsteticui/CodeGeneratorInternalClass.cs 2007-01-11
19:48:05 UTC (rev 70878)
@@ -181,7 +181,7 @@
string name = widget != null ? widget.Name :
agroup.Name;
string internalClassName = ids.MakeUnique
(CodeIdentifier.MakeValid (name));
- string typeName = widget != null ?
wwidget.ClassDescriptor.WrappedTypeName : "Gtk.ActionGroup";
+ string typeName = widget != null ?
wwidget.WrappedTypeName : "Gtk.ActionGroup";
// Create the build method for the top level
CodeMemberMethod met;
Modified: trunk/stetic/libsteticui/ComponentEventHandler.cs
===================================================================
--- trunk/stetic/libsteticui/ComponentEventHandler.cs 2007-01-11 19:41:51 UTC
(rev 70877)
+++ trunk/stetic/libsteticui/ComponentEventHandler.cs 2007-01-11 19:48:05 UTC
(rev 70878)
@@ -5,6 +5,7 @@
{
public delegate void ComponentEventHandler (object sender,
ComponentEventArgs args);
public delegate void ComponentNameEventHandler (object sender,
ComponentNameEventArgs args);
+ public delegate void ComponentRemovedEventHandler (object sender,
ComponentRemovedEventArgs args);
public class ComponentEventArgs: EventArgs
{
@@ -39,4 +40,24 @@
get { return oldName; }
}
}
+
+ public class ComponentRemovedEventArgs: EventArgs
+ {
+ Project project;
+ string componentName;
+
+ internal ComponentRemovedEventArgs (Project p, string name)
+ {
+ project = p;
+ componentName = name;
+ }
+
+ public Project Project {
+ get { return project; }
+ }
+
+ public string ComponentName {
+ get { return componentName; }
+ }
+ }
}
Modified: trunk/stetic/libsteticui/Makefile.am
===================================================================
--- trunk/stetic/libsteticui/Makefile.am 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/Makefile.am 2007-01-11 19:48:05 UTC (rev
70878)
@@ -18,6 +18,7 @@
ApplicationBackend.cs \
ApplicationBackendController.cs \
Clipboard.cs \
+ ContainerUndoRedoManager.cs \
ContextMenu.cs \
Component.cs \
ComponentEventHandler.cs \
Modified: trunk/stetic/libsteticui/PaletteBackend.cs
===================================================================
--- trunk/stetic/libsteticui/PaletteBackend.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/PaletteBackend.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -280,7 +280,7 @@
group.ActionAdded += OnActionGroupChanged;
group.ActionRemoved += OnActionGroupChanged;
group.ActionChanged += OnActionGroupChanged;
- group.Changed += OnActionGroupChanged;
+ group.ObjectChanged += OnActionGroupChanged;
Fill ();
}
@@ -294,7 +294,7 @@
group.ActionAdded -= OnActionGroupChanged;
group.ActionRemoved -= OnActionGroupChanged;
group.ActionChanged -= OnActionGroupChanged;
- group.Changed -= OnActionGroupChanged;
+ group.ObjectChanged -= OnActionGroupChanged;
}
public void Fill ()
Modified: trunk/stetic/libsteticui/Project.cs
===================================================================
--- trunk/stetic/libsteticui/Project.cs 2007-01-11 19:41:51 UTC (rev 70877)
+++ trunk/stetic/libsteticui/Project.cs 2007-01-11 19:48:05 UTC (rev 70878)
@@ -22,7 +22,7 @@
internal event BackendChangedHandler BackendChanged;
public event ComponentEventHandler ComponentAdded;
- public event ComponentEventHandler ComponentRemoved;
+ public event ComponentRemovedEventHandler ComponentRemoved;
public event ComponentEventHandler SelectionChanged;
public event ComponentNameEventHandler ComponentNameChanged;
@@ -144,14 +144,9 @@
public ActionGroupDesigner CreateActionGroupDesigner
(ActionGroupComponent actionGroup, bool autoCommitChanges)
{
- return new ActionGroupDesigner (this, null,
actionGroup, autoCommitChanges);
+ return new ActionGroupDesigner (this, null,
actionGroup, null, autoCommitChanges);
}
- public ActionGroupDesigner CreateActionGroupDesigner (Component
component, bool autoCommitChanges)
- {
- return new ActionGroupDesigner (this, component.Name,
null, autoCommitChanges);
- }
-
public WidgetComponent AddNewComponent (ComponentType type,
string name)
{
object ob = backend.AddNewWidget (type.Name, name);
@@ -289,9 +284,8 @@
if (topLevel) {
Gtk.Application.Invoke (
delegate {
- Component c = App.GetComponent
(obj, name, typeName);
- if (c != null &&
ComponentRemoved != null)
- ComponentRemoved (this,
new ComponentEventArgs (this, c));
+ if (ComponentRemoved != null)
+ ComponentRemoved (this,
new ComponentRemovedEventArgs (this, name));
}
);
}
Modified: trunk/stetic/libsteticui/ProjectBackend.cs
===================================================================
--- trunk/stetic/libsteticui/ProjectBackend.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/ProjectBackend.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -180,9 +180,11 @@
if (node == null)
throw new ApplicationException
(Catalog.GetString ("Not a Stetic file according to node name."));
+ ObjectReader reader = new ObjectReader (this,
FileFormat.Native);
+
foreach (XmlElement groupElem in
node.SelectNodes ("action-group")) {
Wrapper.ActionGroup actionGroup = new
Wrapper.ActionGroup ();
- actionGroup.Read (this, groupElem);
+ actionGroup.Read (reader, groupElem);
actionGroups.Add (actionGroup);
}
@@ -190,7 +192,6 @@
if (iconsElem != null)
iconFactory.Read (this, iconsElem);
- ObjectReader reader = new ObjectReader (this,
FileFormat.Native);
foreach (XmlElement toplevel in
node.SelectNodes ("widget")) {
Wrapper.Container wrapper =
Stetic.ObjectWrapper.ReadObject (reader, toplevel) as Wrapper.Container;
if (wrapper != null)
@@ -359,8 +360,9 @@
{
XmlDocument doc = new XmlDocument ();
doc.LoadXml (template);
+ ObjectReader or = new ObjectReader (this,
FileFormat.Native);
Stetic.Wrapper.ActionGroup group = new
Stetic.Wrapper.ActionGroup ();
- group.Read (this, doc.DocumentElement);
+ group.Read (or, doc.DocumentElement);
ActionGroups.Add (group);
return group;
}
Modified: trunk/stetic/libsteticui/PropertyGrid.cs
===================================================================
--- trunk/stetic/libsteticui/PropertyGrid.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/PropertyGrid.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -269,7 +269,7 @@
Gtk.Widget w = (Gtk.Widget) ob;
ObjectWrapper wrapper = ObjectWrapper.Lookup (w);
image.Pixbuf = wrapper.ClassDescriptor.Icon;
- label.Text = wrapper.ClassDescriptor.WrappedTypeName;
+ label.Text = wrapper.WrappedTypeName;
}
}
}
Modified: trunk/stetic/libsteticui/UndoQueue.cs
===================================================================
--- trunk/stetic/libsteticui/UndoQueue.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/UndoQueue.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -97,14 +97,15 @@
}
}
+
class ObjectWrapperUndoRedoChange: UndoRedoChange
{
- ContainerUndoRedoManager manager;
+ UndoRedoManager manager;
public string TargetObject;
public object Diff;
public ObjectWrapperUndoRedoChange Next;
- public ObjectWrapperUndoRedoChange (ContainerUndoRedoManager
manager, string targetObject, object diff)
+ public ObjectWrapperUndoRedoChange (UndoRedoManager manager,
string targetObject, object diff)
{
this.manager = manager;
this.TargetObject = targetObject;
@@ -122,19 +123,19 @@
}
}
- class ContainerUndoRedoManager: IDisposable
+ class UndoRedoManager: IDisposable
{
UndoQueue queue;
- Wrapper.Container rootObject;
+ ObjectWrapper rootObject;
bool updating;
UndoManager undoManager = new UndoManager ();
- public ContainerUndoRedoManager ()
+ public UndoRedoManager ()
{
undoManager.UndoCheckpoint += OnUndoCheckpoint;
}
- public Wrapper.Container RootObject {
+ public ObjectWrapper RootObject {
get { return rootObject; }
set {
rootObject = value;
@@ -164,26 +165,23 @@
ObjectWrapperUndoRedoChange firstChange = null;
ObjectWrapperUndoRedoChange lastChange = null;
-// Console.WriteLine ("** UNDO CHECKPOINT: {0} objects",
obs.Length);
+ Console.WriteLine ("** UNDO CHECKPOINT: {0} objects",
obs.Length);
foreach (ObjectWrapper ob in obs) {
- Wrapper.Widget widget = ob as Wrapper.Widget;
- if (widget == null)
- continue;
-
+
// Get the diff for going from the new status
to the old status
- object diff = widget.GetUndoDiff ();
+ object diff = GetDiff (ob);
if (diff == null) // No differences
continue;
-// Console.WriteLine ("ADDCHANGE " + widget + "
uid:" + widget.UndoId);
-// PrintPatch (diff);
+ Console.WriteLine ("ADDCHANGE " + ob + " uid:"
+ ob.UndoId);
+ PrintPatch (diff);
- if (widget.UndoId == null ||
widget.UndoId.Length == 0)
- throw new InvalidOperationException
("Object of type '" + widget.GetType () + "' does not have an undo id.");
+ if (ob.UndoId == null || ob.UndoId.Length == 0)
+ throw new InvalidOperationException
("Object of type '" + ob.GetType () + "' does not have an undo id.");
- ObjectWrapperUndoRedoChange change = new
ObjectWrapperUndoRedoChange (this, widget.UndoId, diff);
+ ObjectWrapperUndoRedoChange change = new
ObjectWrapperUndoRedoChange (this, ob.UndoId, diff);
if (lastChange == null)
lastChange = firstChange = change;
else {
@@ -195,6 +193,11 @@
queue.AddChange (firstChange);
}
+ protected virtual object GetDiff (ObjectWrapper w)
+ {
+ return w.GetUndoDiff ();
+ }
+
public UndoRedoChange ApplyChange (ObjectWrapperUndoRedoChange
first)
{
updating = true;
@@ -221,10 +224,14 @@
ObjectWrapperUndoRedoChange ApplyDiff (string id, object diff)
{
-// Console.WriteLine ("** APPLYING DIFF: uid:" + id);
-// PrintPatch (diff);
+ Console.WriteLine ("** APPLYING DIFF: uid:" + id);
+ PrintPatch (diff);
- Wrapper.Widget ww = rootObject.FindChildByUndoId (id);
+ ObjectWrapper ww = rootObject.FindObjectByUndoId (id);
+ if (ww == null) {
+ Console.WriteLine ("Object with undo id '{0}'
not found", id);
+ return null;
+ }
object reverseDiff = ww.ApplyUndoRedoDiff (diff);
Modified: trunk/stetic/libsteticui/WidgetDesigner.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetDesigner.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/libsteticui/WidgetDesigner.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -57,7 +57,7 @@
// Creates an action group designer for the widget being edited
by this widget designer
public ActionGroupDesigner CreateActionGroupDesigner ()
{
- return new ActionGroupDesigner (editedProject,
componentName, null, true);
+ return new ActionGroupDesigner (editedProject,
componentName, null, this, true);
}
public bool Modified {
Modified: trunk/stetic/stetic/DesignerView.cs
===================================================================
--- trunk/stetic/stetic/DesignerView.cs 2007-01-11 19:41:51 UTC (rev 70877)
+++ trunk/stetic/stetic/DesignerView.cs 2007-01-11 19:48:05 UTC (rev 70878)
@@ -21,7 +21,7 @@
// Actions design tab
- actionbox = project.CreateActionGroupDesigner (widget,
true);
+ actionbox = design.CreateActionGroupDesigner ();
// Designers tab
Modified: trunk/stetic/stetic/LibraryManagerDialog.cs
===================================================================
--- trunk/stetic/stetic/LibraryManagerDialog.cs 2007-01-11 19:41:51 UTC (rev
70877)
+++ trunk/stetic/stetic/LibraryManagerDialog.cs 2007-01-11 19:48:05 UTC (rev
70878)
@@ -7,7 +7,6 @@
{
public class LibraryManagerDialog: IDisposable
{
- [Glade.Widget] Gtk.Button buttonRemove;
[Glade.Widget] Gtk.TreeView libraryList;
[Glade.Widget ("LibraryManagerDialog")] Gtk.Dialog dialog;
Gtk.ListStore store;
Modified: trunk/stetic/stetic/Stetic.cs
===================================================================
--- trunk/stetic/stetic/Stetic.cs 2007-01-11 19:41:51 UTC (rev 70877)
+++ trunk/stetic/stetic/Stetic.cs 2007-01-11 19:48:05 UTC (rev 70878)
@@ -221,9 +221,14 @@
OpenWindow (args.Component);
}
- static void OnWidgetRemoved (object s, ComponentEventArgs args)
+ static void OnWidgetRemoved (object s,
ComponentRemovedEventArgs args)
{
- CloseWindow (args.Component);
+ foreach (Component c in openWindows.Keys) {
+ if (c.Name == args.ComponentName) {
+ CloseWindow (c);
+ return;
+ }
+ }
}
static void OnSelectionChanged (object s, ComponentEventArgs
args)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches