summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e64dcdb)
raw | patch | inline | side by side (parent: e64dcdb)
author | gustav_b <gustav_b@users.sourceforge.net> | |
Thu, 29 Mar 2007 23:02:20 +0000 (23:02 +0000) | ||
committer | gustav_b <gustav_b@users.sourceforge.net> | |
Thu, 29 Mar 2007 23:02:20 +0000 (23:02 +0000) |
index 85d7aed13242d58f4706c892a18c7ec6e1562aee..03e4796bd4526be23a3448d42f471d3dd8de3a88 100644 (file)
this->_unlock();
}
+void
+CompositeUndoStackObserver::notifyClearUndoEvent()
+{
+ this->_lock();
+ for(UndoObserverRecordList::iterator i = this->_active.begin(); i != _active.end(); ++i) {
+ if (!i->to_remove) {
+ i->issueClearUndo();
+ }
+ }
+ this->_unlock();
+}
+
+void
+CompositeUndoStackObserver::notifyClearRedoEvent()
+{
+ this->_lock();
+ for(UndoObserverRecordList::iterator i = this->_active.begin(); i != _active.end(); ++i) {
+ if (!i->to_remove) {
+ i->issueClearRedo();
+ }
+ }
+ this->_unlock();
+}
+
bool
CompositeUndoStackObserver::_remove_one(UndoObserverRecordList& list, UndoStackObserver& o)
{
index 7e45ccae4f01e24087184f040118fd8d85cd9945..e24561ace61ca5467887c77fea9b2f2227ea4258 100644 (file)
this->_observer.notifyUndoCommitEvent(log);
}
+ /**
+ * Issue a clear undo event to the UndoStackObserver
+ * that is associated with this
+ * UndoStackObserverRecord.
+ */
+ void issueClearUndo()
+ {
+ this->_observer.notifyClearUndoEvent();
+ }
+
+ /**
+ * Issue a clear redo event to the UndoStackObserver
+ * that is associated with this
+ * UndoStackObserverRecord.
+ */
+ void issueClearRedo()
+ {
+ this->_observer.notifyClearRedoEvent();
+ }
+
private:
UndoStackObserver& _observer;
};
*/
void notifyUndoCommitEvent(Event* log);
+ virtual void notifyClearUndoEvent();
+ virtual void notifyClearRedoEvent();
+
private:
// Remove an observer from a given list
bool _remove_one(UndoObserverRecordList& list, UndoStackObserver& rec);
index 7035e89feb1fb7450b2cabc7915ecaa2eb9d30fd..98e6c69a66206b98beb0e1205b050bc47e54de92 100644 (file)
//g_message("notifyUndoCommitEvent (sp_document_maybe_done) called; log=%p\n", log->event);
}
+void
+ConsoleOutputUndoObserver::notifyClearUndoEvent()
+{
+ //g_message("notifyClearUndoEvent (sp_document_clear_undo) called);
+}
+
+void
+ConsoleOutputUndoObserver::notifyClearRedoEvent()
+{
+ //g_message("notifyClearRedoEvent (sp_document_clear_redo) called);
+}
+
}
/*
index 32149c15dc012b13b83d5d68e2897938826a11ee..b6fec7f326b634f7ccca712b34f2afb775241043 100644 (file)
void notifyUndoEvent(Event* log);
void notifyRedoEvent(Event* log);
void notifyUndoCommitEvent(Event* log);
+ void notifyClearUndoEvent();
+ void notifyClearRedoEvent();
};
}
diff --git a/src/document-undo.cpp b/src/document-undo.cpp
index 47d56ca662bb0f0d088d758f4a1fff1d529dd85f..f37b53f89c5d89c228d78dd5b9eb67c61aa3aeff 100644 (file)
--- a/src/document-undo.cpp
+++ b/src/document-undo.cpp
g_warning ("Incomplete undo transaction:");
priv.partial = sp_repr_coalesce_log(priv.partial, log);
sp_repr_debug_print_log(priv.partial);
- priv.undo = g_slist_prepend(priv.undo, new Inkscape::Event(priv.partial));
+ Inkscape::Event *event = new Inkscape::Event(priv.partial);
+ priv.undo = g_slist_prepend(priv.undo, event);
+ priv.undoStackObservers.notifyUndoCommitEvent(event);
priv.partial = NULL;
}
}
void
sp_document_clear_undo (SPDocument *doc)
{
+ if (doc->priv->undo)
+ doc->priv->undoStackObservers.notifyClearUndoEvent();
+
while (doc->priv->undo) {
GSList *current;
void
sp_document_clear_redo (SPDocument *doc)
{
+ if (doc->priv->redo)
+ doc->priv->undoStackObservers.notifyClearRedoEvent();
+
while (doc->priv->redo) {
GSList *current;
diff --git a/src/event-log.cpp b/src/event-log.cpp
index d6bc99bea8a34e195cb2c0331413bc0136d5c355..4ee65f3f8417ae9b18c7c295d58b03b4b7b5b04d 100644 (file)
--- a/src/event-log.cpp
+++ b/src/event-log.cpp
* Author:
* Gustav Broberg <broberg@kth.se>
*
- * Copyright (c) 2006 Authors
+ * Copyright (c) 2006, 2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
void
EventLog::notifyUndoCommitEvent(Event* log)
{
- // If we're not at the last event in list then erase the previously undone events
- if ( _last_event != _curr_event ) {
-
- _last_event = _curr_event;
-
- if ( !_last_event->children().empty() ) {
- _last_event = _last_event->children().begin();
- } else {
- ++_last_event;
- }
-
- while ( _last_event != _event_list_store->children().end() ) {
-
- if (_last_event->parent()) {
- while ( _last_event != _last_event->parent()->children().end() ) {
- _last_event = _event_list_store->erase(_last_event);
- }
- _last_event = _last_event->parent();
-
- (*_last_event)[_columns.child_count] = _last_event->children().size() + 1;
-
- ++_last_event;
- } else {
- _last_event = _event_list_store->erase(_last_event);
- }
-
- }
- }
+ _clearRedo();
const unsigned int event_type = log->type;
updateUndoVerbs();
}
+void
+EventLog::notifyClearUndoEvent()
+{
+ _clearUndo();
+ updateUndoVerbs();
+}
+
+void
+EventLog::notifyClearRedoEvent()
+{
+ _clearRedo();
+ updateUndoVerbs();
+}
+
void
EventLog::connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callback_connections)
{
return redo_event;
}
+void
+EventLog::_clearUndo()
+{
+ // TODO: Implement when needed
+}
+
+void
+EventLog::_clearRedo()
+{
+ if ( _last_event != _curr_event ) {
+
+ _last_event = _curr_event;
+
+ if ( !_last_event->children().empty() ) {
+ _last_event = _last_event->children().begin();
+ } else {
+ ++_last_event;
+ }
+
+ while ( _last_event != _event_list_store->children().end() ) {
+
+ if (_last_event->parent()) {
+ while ( _last_event != _last_event->parent()->children().end() ) {
+ _last_event = _event_list_store->erase(_last_event);
+ }
+ _last_event = _last_event->parent();
+
+ (*_last_event)[_columns.child_count] = _last_event->children().size() + 1;
+
+ ++_last_event;
+ } else {
+ _last_event = _event_list_store->erase(_last_event);
+ }
+
+ }
+
+ }
}
+} // namespace Inkscape
+
+
/*
Local Variables:
mode:c++
diff --git a/src/event-log.h b/src/event-log.h
index 02cfa4b9a2560ecd5d245b970e78be8570932e73..a618f0467e0a1b7e84fce9dba1c08231b0649075 100644 (file)
--- a/src/event-log.h
+++ b/src/event-log.h
* Author:
* Gustav Broberg <broberg@kth.se>
*
- * Copyright (c) 2006 Authors
+ * Copyright (c) 2006, 2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
void notifyUndoEvent(Event *log);
void notifyRedoEvent(Event *log);
void notifyUndoCommitEvent(Event *log);
+ void notifyClearUndoEvent();
+ void notifyClearRedoEvent();
/**
* Accessor functions
const EventModelColumns _columns;
- /**
- * Helper functions for initialization
- */
-
Glib::RefPtr<Gtk::TreeStore> _event_list_store;
Glib::RefPtr<Gtk::TreeSelection> _event_list_selection;
Gtk::TreeView *_event_list_view;
// Map of connections used to temporary block/unblock callbacks in a TreeView
CallbackMap *_callback_connections;
+ /**
+ * Helper functions
+ */
+
const_iterator _getUndoEvent() const; //< returns the current undoable event or NULL if none
const_iterator _getRedoEvent() const; //< returns the current redoable event or NULL if none
+ void _clearUndo(); //< erase all previously commited events
+ void _clearRedo(); //< erase all previously undone events
+
// noncopyable, nonassignable
EventLog(EventLog const &other);
EventLog& operator=(EventLog const &other);
index dbda2b9809e04f867224b3efaa16c5fe6415af53..5bf405f7f290f210d3695c2e1d0d155b2ac80ea4 100644 (file)
* \param log Pointer to an Event describing the committed events.
*/
virtual void notifyUndoCommitEvent(Event* log) = 0;
+
+ /**
+ * Triggered when the undo log is cleared.
+ */
+ virtual void notifyClearUndoEvent() = 0;
+
+ /**
+ * Triggered when the redo log is cleared.
+ */
+ virtual void notifyClearRedoEvent() = 0;
+
};
}