summaryrefslogtreecommitdiffstats
path: root/src/event-log.cpp
diff options
context:
space:
mode:
authorgustav_b <gustav_b@users.sourceforge.net>2006-07-09 11:32:23 +0000
committergustav_b <gustav_b@users.sourceforge.net>2006-07-09 11:32:23 +0000
commitc631dfb4add034db59cb477843ca95bcc2986758 (patch)
treec616db1f1e294f6630734af1e237322259c09366 /src/event-log.cpp
parent* packaging/osx-app.sh: Set the svn:executable property. (diff)
downloadinkscape-c631dfb4add034db59cb477843ca95bcc2986758.tar.gz
inkscape-c631dfb4add034db59cb477843ca95bcc2986758.zip
Added descriptions to Undo/Redo commands in the menus
(bzr r1379)
Diffstat (limited to 'src/event-log.cpp')
-rw-r--r--src/event-log.cpp89
1 files changed, 87 insertions, 2 deletions
diff --git a/src/event-log.cpp b/src/event-log.cpp
index 40c8364ac..64a9b19ec 100644
--- a/src/event-log.cpp
+++ b/src/event-log.cpp
@@ -10,14 +10,16 @@
#include <glibmm/i18n.h>
#include "desktop.h"
-
#include "event-log.h"
+#include "inkscape.h"
+#include "util/ucompose.hpp"
namespace Inkscape {
EventLog::EventLog() :
UndoStackObserver(),
_connected (false),
+ _document (NULL),
_event_list_store (Gtk::TreeStore::create(_columns)),
_event_list_selection (NULL),
_event_list_view (NULL),
@@ -39,7 +41,7 @@ void
EventLog::notifyUndoEvent(Event* log)
{
if ( !_notifications_blocked ) {
-
+
// if we're on the first child event...
if ( _curr_event->parent() &&
_curr_event == _curr_event->parent()->children().begin() )
@@ -81,7 +83,9 @@ EventLog::notifyUndoEvent(Event* log)
(*_callback_connections)[CALLB_SELECTION_CHANGE].block(false);
}
+ updateUndoVerbs();
}
+
}
void
@@ -137,7 +141,9 @@ EventLog::notifyRedoEvent(Event* log)
(*_callback_connections)[CALLB_SELECTION_CHANGE].block(false);
}
+ updateUndoVerbs();
}
+
}
void
@@ -219,8 +225,18 @@ EventLog::notifyUndoCommitEvent(Event* log)
(*_callback_connections)[CALLB_SELECTION_CHANGE].block(false);
}
+ updateUndoVerbs();
}
+
+void
+EventLog::setDocument(SPDocument *document)
+{
+ _document = document;
+ updateUndoVerbs();
+}
+
+
void
EventLog::connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callback_connections)
{
@@ -242,7 +258,76 @@ EventLog::connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callbac
_connected = true;
}
+void
+EventLog::updateUndoVerbs()
+{
+ if(_document) {
+
+ if(_getUndoEvent()) {
+ Inkscape::Verb::get(SP_VERB_EDIT_UNDO)->sensitive(_document, true);
+
+ Inkscape::Verb::get(SP_VERB_EDIT_UNDO)->name(_document, String::ucompose("%1 %2",
+ Glib::ustring(_("_Undo")),
+ Glib::ustring((*_getUndoEvent())[_columns.description])));
+ } else {
+ Inkscape::Verb::get(SP_VERB_EDIT_UNDO)->name(_document, _("_Undo"));
+ Inkscape::Verb::get(SP_VERB_EDIT_UNDO)->sensitive(_document, false);
+ }
+
+ if(_getRedoEvent()) {
+ Inkscape::Verb::get(SP_VERB_EDIT_REDO)->sensitive(_document, true);
+ Inkscape::Verb::get(SP_VERB_EDIT_REDO)->name(_document, String::ucompose("%1 %2",
+ Glib::ustring(_("_Redo")),
+ Glib::ustring((*_getRedoEvent())[_columns.description])));
+
+ } else {
+ Inkscape::Verb::get(SP_VERB_EDIT_REDO)->name(_document, _("_Redo"));
+ Inkscape::Verb::get(SP_VERB_EDIT_REDO)->sensitive(_document, false);
+ }
+
+ }
+
+}
+
+
+EventLog::const_iterator
+EventLog::_getUndoEvent() const
+{
+ const_iterator undo_event = (const_iterator)NULL;
+ if( _curr_event != _event_list_store->children().begin() )
+ undo_event = _curr_event;
+ return undo_event;
}
+
+EventLog::const_iterator
+EventLog::_getRedoEvent() const
+{
+ const_iterator redo_event = (const_iterator)NULL;
+
+ if ( _curr_event != _last_event ) {
+
+ if ( !_curr_event->children().empty() )
+ redo_event = _curr_event->children().begin();
+ else {
+ redo_event = _curr_event;
+ ++redo_event;
+
+ if ( redo_event->parent() &&
+ redo_event == redo_event->parent()->children().end() ) {
+
+ redo_event = redo_event->parent();
+ ++redo_event;
+
+ }
+ }
+
+ }
+
+ return redo_event;
+}
+
+}
+
/*
Local Variables:
mode:c++