Code

Switched pen and pencil toobars to stock GTK+ toolbars
[inkscape.git] / src / event-log.cpp
index d6bc99bea8a34e195cb2c0331413bc0136d5c355..4ee65f3f8417ae9b18c7c295d58b03b4b7b5b04d 100644 (file)
@@ -2,7 +2,7 @@
  * 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
  */
@@ -155,34 +155,7 @@ EventLog::notifyRedoEvent(Event* log)
 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;
 
@@ -235,6 +208,20 @@ EventLog::notifyUndoCommitEvent(Event* log)
     updateUndoVerbs();
 }
 
+void
+EventLog::notifyClearUndoEvent()
+{
+    _clearUndo();    
+    updateUndoVerbs();
+}
+
+void
+EventLog::notifyClearRedoEvent()
+{
+    _clearRedo();
+    updateUndoVerbs();
+}
+
 void 
 EventLog::connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callback_connections)
 {
@@ -324,8 +311,48 @@ EventLog::_getRedoEvent() const
     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++