"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Pinta.Core/Classes/DocumentWorkspaceHistory.cs" between
pinta-1.7.tar.gz and pinta-1.7.1.tar.gz

About: Pinta is a powerful image drawing and editing program (modeled after Paint.NET).

DocumentWorkspaceHistory.cs  (pinta-1.7):DocumentWorkspaceHistory.cs  (pinta-1.7.1)
skipping to change at line 38 skipping to change at line 38
using System.Collections.Generic; using System.Collections.Generic;
using Gtk; using Gtk;
namespace Pinta.Core namespace Pinta.Core
{ {
public class DocumentWorkspaceHistory public class DocumentWorkspaceHistory
{ {
private Document document; private Document document;
List<BaseHistoryItem> history = new List<BaseHistoryItem> (); List<BaseHistoryItem> history = new List<BaseHistoryItem> ();
int historyPointer = -1; int historyPointer = -1;
int cleanPointer = -1;
internal DocumentWorkspaceHistory (Document document) internal DocumentWorkspaceHistory (Document document)
{ {
this.document = document; this.document = document;
ListStore = new ListStore (typeof (BaseHistoryItem)); ListStore = new ListStore (typeof (BaseHistoryItem));
} }
public Gtk.ListStore ListStore { get; private set; } public Gtk.ListStore ListStore { get; private set; }
public int Pointer { public int Pointer {
skipping to change at line 83 skipping to change at line 84
} else if (item.State == HistoryItemState.Undo) { } else if (item.State == HistoryItemState.Undo) {
break; break;
} }
} }
//Add new undo to ListStore //Add new undo to ListStore
newItem.Id = ListStore.AppendValues (newItem); newItem.Id = ListStore.AppendValues (newItem);
history.Add (newItem); history.Add (newItem);
historyPointer = history.Count - 1; historyPointer = history.Count - 1;
if (newItem.CausesDirty) if (newItem.CausesDirty)
document.IsDirty = true; document.IsDirty = true;
if (history.Count > 1) { if (history.Count > 1) {
PintaCore.Actions.Edit.Undo.Sensitive = true; PintaCore.Actions.Edit.Undo.Sensitive = true;
CanUndo = true; CanUndo = true;
} }
PintaCore.Actions.Edit.Redo.Sensitive = false; PintaCore.Actions.Edit.Redo.Sensitive = false;
CanRedo = false; CanRedo = false;
skipping to change at line 105 skipping to change at line 105
} }
public void Undo () public void Undo ()
{ {
if (historyPointer < 0) { if (historyPointer < 0) {
throw new InvalidOperationException ("Undo stack is empty"); throw new InvalidOperationException ("Undo stack is empty");
} else { } else {
BaseHistoryItem item = history[historyPointer]; BaseHistoryItem item = history[historyPointer];
item.Undo (); item.Undo ();
item.State = HistoryItemState.Redo; item.State = HistoryItemState.Redo;
if (item.CausesDirty)
document.IsDirty = true;
ListStore.SetValue (item.Id, 0, item); ListStore.SetValue (item.Id, 0, item);
history[historyPointer] = item; history[historyPointer] = item;
historyPointer--; historyPointer--;
} }
if (historyPointer == 0) { if (historyPointer == cleanPointer)
document.IsDirty = false; document.IsDirty = false;
if (historyPointer == 0) {
PintaCore.Actions.Edit.Undo.Sensitive = false; PintaCore.Actions.Edit.Undo.Sensitive = false;
CanUndo = false; CanUndo = false;
} }
PintaCore.Actions.Edit.Redo.Sensitive = true; PintaCore.Actions.Edit.Redo.Sensitive = true;
CanRedo = true; CanRedo = true;
PintaCore.History.OnActionUndone (); PintaCore.History.OnActionUndone ();
} }
public void Redo () public void Redo ()
skipping to change at line 138 skipping to change at line 143
item.Redo (); item.Redo ();
item.State = HistoryItemState.Undo; item.State = HistoryItemState.Undo;
ListStore.SetValue (item.Id, 0, item); ListStore.SetValue (item.Id, 0, item);
history[historyPointer] = item; history[historyPointer] = item;
if (historyPointer == history.Count - 1) { if (historyPointer == history.Count - 1) {
PintaCore.Actions.Edit.Redo.Sensitive = false; PintaCore.Actions.Edit.Redo.Sensitive = false;
CanRedo = false; CanRedo = false;
} }
if (item.CausesDirty) if (historyPointer == cleanPointer)
document.IsDirty = false;
else if (item.CausesDirty)
document.IsDirty = true; document.IsDirty = true;
if (history.Count > 1) { if (history.Count > 1) {
PintaCore.Actions.Edit.Undo.Sensitive = true; PintaCore.Actions.Edit.Undo.Sensitive = true;
CanUndo = true; CanUndo = true;
} }
PintaCore.History.OnActionRedone (); PintaCore.History.OnActionRedone ();
} }
/// <summary>
/// Mark the document as being clean at the current point in the history
stack.
/// This might be used after e.g. saving the document to disk.
/// The document's IsDirty property is also set to false.
/// </summary>
public void SetClean()
{
cleanPointer = historyPointer;
document.IsDirty = false;
}
public void Clear () public void Clear ()
{ {
history.ForEach (delegate(BaseHistoryItem item) { item.Di spose (); } ); history.ForEach (delegate(BaseHistoryItem item) { item.Di spose (); } );
history.Clear(); history.Clear();
ListStore.Clear (); ListStore.Clear ();
historyPointer = -1; historyPointer = -1;
cleanPointer = -1;
document.IsDirty = false; document.IsDirty = false;
PintaCore.Actions.Edit.Redo.Sensitive = false; PintaCore.Actions.Edit.Redo.Sensitive = false;
PintaCore.Actions.Edit.Undo.Sensitive = false; PintaCore.Actions.Edit.Undo.Sensitive = false;
CanRedo = false; CanRedo = false;
CanUndo = false; CanUndo = false;
} }
public bool CanRedo { get; private set; } public bool CanRedo { get; private set; }
 End of changes. 8 change blocks. 
3 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)