summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79ace60)
raw | patch | inline | side by side (parent: 79ace60)
author | gustav_b <gustav_b@users.sourceforge.net> | |
Sun, 9 Jul 2006 11:32:23 +0000 (11:32 +0000) | ||
committer | gustav_b <gustav_b@users.sourceforge.net> | |
Sun, 9 Jul 2006 11:32:23 +0000 (11:32 +0000) |
12 files changed:
diff --git a/src/document.cpp b/src/document.cpp
index a6b6e4e45ecb5827ac24ec941ae3ce47cc3113d3..69f9128a862e6fc222a494a56f3be51707d4eaa9 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
p->redo = NULL;
p->undoStackObservers.add(p->event_log);
+ p->event_log.setDocument(this);
priv = p;
diff --git a/src/event-log.cpp b/src/event-log.cpp
index 40c8364acabdca5de0597dc265a323414172ef33..64a9b19ec9fe067dc1575229a364f44518fb4456 100644 (file)
--- a/src/event-log.cpp
+++ b/src/event-log.cpp
#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),
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() )
(*_callback_connections)[CALLB_SELECTION_CHANGE].block(false);
}
+ updateUndoVerbs();
}
+
}
void
(*_callback_connections)[CALLB_SELECTION_CHANGE].block(false);
}
+ updateUndoVerbs();
}
+
}
void
(*_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++
diff --git a/src/event-log.h b/src/event-log.h
index 148d6329de0fc812963bc8ee90ad608613810437..16ecfd5558c4d77b66627d6ed92ea624e546c033 100644 (file)
--- a/src/event-log.h
+++ b/src/event-log.h
void setCurrEventParent(iterator event) { _curr_event_parent = event; }
void blockNotifications(bool status=true) { _notifications_blocked = status; }
+ void setDocument(SPDocument *document);
+
/*
* Callback types for TreeView changes.
*/
*/
void connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callback_connections);
+ /*
+ * Updates the sensitivity and names of SP_VERB_EDIT_UNDO and SP_VERB_EDIT_REDO to reflect the
+ * current state.
+ */
+ void updateUndoVerbs();
+
private:
bool _connected; //< connected with dialog
-
+ SPDocument *_document; //< document that is logged
+
const EventModelColumns _columns;
/**
// Map of connections used to temporary block/unblock callbacks in a TreeView
CallbackMap *_callback_connections;
+ 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
+
// noncopyable, nonassignable
EventLog(EventLog const &other);
EventLog& operator=(EventLog const &other);
index 2f884aa1cf0a0126cd95360129392aa916b6f299..71ddf3e247216509297ae421e9d49dfdfba3dc55 100644 (file)
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
* is called.
*/
SPActionEventVector Effect::EffectVerb::vector =
- {{NULL},Effect::EffectVerb::perform, NULL, NULL, NULL};
+ {{NULL}, Effect::EffectVerb::perform, NULL, NULL, NULL, NULL};
} } /* namespace Inkscape, Extension */
diff --git a/src/helper/action.cpp b/src/helper/action.cpp
index 9584c5dae22991cd110563b0a682718cbfdcd7fd..1c8c7ec1532a813769ff6319364e1f5c5e10d6b1 100644 (file)
--- a/src/helper/action.cpp
+++ b/src/helper/action.cpp
#include <string.h>
-
#include "helper/action.h"
static void sp_action_class_init (SPActionClass *klass);
}
}
+
+/**
+ * Change name for all actions that can be taken with the action.
+ */
+void
+sp_action_set_name (SPAction *action, Glib::ustring name)
+{
+ nr_return_if_fail (action != NULL);
+ nr_return_if_fail (SP_IS_ACTION (action));
+
+ NRActiveObject *aobject;
+ g_free(action->name);
+ action->name = g_strdup(name.c_str());
+ aobject = (NRActiveObject *) action;
+ if (aobject->callbacks) {
+ unsigned int i;
+ for (i = 0; i < aobject->callbacks->length; i++) {
+ NRObjectListener *listener;
+ SPActionEventVector *avector;
+ listener = aobject->callbacks->listeners + i;
+ avector = (SPActionEventVector *) listener->vector;
+ if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_name) {
+ avector->set_name (action, name, listener->data);
+ }
+ }
+ }
+}
+
+
+
+
/**
* Return View associated with the action.
*/
diff --git a/src/helper/action.h b/src/helper/action.h
index 1e364643904c9f0f590129d5ff84ffa793fd4e11..4c99e31d859ba372ede843b009efe8f1d214539e 100644 (file)
--- a/src/helper/action.h
+++ b/src/helper/action.h
#include "libnr/nr-object.h"
#include "forward.h"
+#include <glibmm/ustring.h>
//class Inkscape::UI::View::View;
namespace Inkscape {
void (* set_active)(SPAction *action, unsigned active, void *data); /**< Callback for activation change */
void (* set_sensitive)(SPAction *action, unsigned sensitive, void *data); /**< Callback for a change in sensitivity */
void (* set_shortcut)(SPAction *action, unsigned shortcut, void *data); /**< Callback for setting the shortcut for this function */
+ void (* set_name)(SPAction *action, Glib::ustring, void *data); /**< Callback for setting the name for this function */
};
/** All the data that is required to be an action. This
void sp_action_perform(SPAction *action, void *data);
void sp_action_set_active(SPAction *action, unsigned active);
void sp_action_set_sensitive(SPAction *action, unsigned sensitive);
+void sp_action_set_name (SPAction *action, Glib::ustring);
Inkscape::UI::View::View *sp_action_get_view(SPAction *action);
#endif
diff --git a/src/interface.cpp b/src/interface.cpp
index 91a26226fe6a8108521217e74aba69dab53dc309..348e71821acf13b4c6ee2fbf80526a000b460ff7 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
static void sp_ui_menu_item_set_sensitive(SPAction *action,
unsigned int sensitive,
void *data);
+static void sp_ui_menu_item_set_name(SPAction *action,
+ Glib::ustring name,
+ void *data);
SPActionEventVector menu_item_event_vector = {
{NULL},
NULL,
NULL, /* set_active */
sp_ui_menu_item_set_sensitive, /* set_sensitive */
- NULL /* set_shortcut */
+ NULL, /* set_shortcut */
+ sp_ui_menu_item_set_name /* set_name */
};
void
@@ -1317,6 +1321,15 @@ sp_ui_menu_item_set_sensitive(SPAction *action, unsigned int sensitive, void *da
return gtk_widget_set_sensitive(GTK_WIDGET(data), sensitive);
}
+static void
+sp_ui_menu_item_set_name(SPAction *action, Glib::ustring name, void *data)
+{
+ gtk_label_set_markup_with_mnemonic(
+ GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (GTK_BIN (data)->child))->data),
+ name.c_str());
+}
+
+
/*
Local Variables:
mode:c++
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 4f9e4e2881aafdb791a77e0f244b7b9908bbef33..f3dea40c76335b2f62b9bf051a9e7a191a6ce487 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
#include "document.h"
#include "desktop-events.h"
#include "desktop-handles.h"
+#include "event-log.h"
#include "sp-guide.h"
#include "sp-item-group.h"
#include "sp-namedview.h"
if (layer) {
desktop->setCurrentLayer(layer);
}
+
+ // FIXME: find a better place to do this
+ sp_desktop_document(desktop)->getEventLog().updateUndoVerbs();
}
void sp_namedview_document_from_window(SPDesktop *desktop)
index 13f6bff261423f9c26269c2f3a85ba3ee1764720..e1b60f3150f7257b427d9f13efcef66f122c7f75 100644 (file)
EventLog::const_iterator selected = _event_list_selection->get_selected();
/* If no event is selected in the view, find the right one and select it. This happens whenever
- * a branch we're currently in is collapsed.
+ * a branch we're currently in is collapsed.
*/
if (!selected) {
}
}
_event_log->blockNotifications(false);
+ _event_log->updateUndoVerbs();
} else { // An event after the current one has been selected. Redo to the selected event.
}
_event_log->setCurrEvent(selected);
+ _event_log->updateUndoVerbs();
}
}
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 6a595721808d03b8fe80f36871e2935cd6463407..5b740b2158c4149e4bb27ce9eb32481fbd6c93a8 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
return;
}
+
+void
+Verb::name(SPDocument *in_doc, Glib::ustring in_name)
+{
+ if (_actions != NULL) {
+ for (ActionTable::iterator cur_action = _actions->begin();
+ cur_action != _actions->end();
+ cur_action++) {
+ if (in_doc == NULL || (cur_action->first != NULL && cur_action->first->doc() == in_doc)) {
+ sp_action_set_name(cur_action->second, in_name);
+ }
+ }
+ }
+}
+
/** \brief A function to remove the action associated with a view.
\param view Which view's actions should be removed.
\return None
* is called.
*/
SPActionEventVector FileVerb::vector =
- {{NULL},FileVerb::perform, NULL, NULL, NULL};
+ {{NULL},FileVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined edit verb is
* called.
*/
SPActionEventVector EditVerb::vector =
- {{NULL},EditVerb::perform, NULL, NULL, NULL};
+ {{NULL},EditVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined selection
* verb is called
*/
SPActionEventVector SelectionVerb::vector =
- {{NULL},SelectionVerb::perform, NULL, NULL, NULL};
+ {{NULL},SelectionVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined layer
* verb is called
*/
SPActionEventVector LayerVerb::vector =
- {{NULL}, LayerVerb::perform, NULL, NULL, NULL};
+ {{NULL}, LayerVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined object
* editing verb is called
*/
SPActionEventVector ObjectVerb::vector =
- {{NULL},ObjectVerb::perform, NULL, NULL, NULL};
+ {{NULL},ObjectVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined context
* verb is called
*/
SPActionEventVector ContextVerb::vector =
- {{NULL},ContextVerb::perform, NULL, NULL, NULL};
+ {{NULL},ContextVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined zoom verb
* is called
*/
SPActionEventVector ZoomVerb::vector =
- {{NULL},ZoomVerb::perform, NULL, NULL, NULL};
+ {{NULL},ZoomVerb::perform, NULL, NULL, NULL, NULL};
/**
* is called
*/
SPActionEventVector DialogVerb::vector =
- {{NULL},DialogVerb::perform, NULL, NULL, NULL};
+ {{NULL},DialogVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined help verb
* is called
*/
SPActionEventVector HelpVerb::vector =
- {{NULL},HelpVerb::perform, NULL, NULL, NULL};
+ {{NULL},HelpVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined tutorial verb
* is called
*/
SPActionEventVector TutorialVerb::vector =
- {{NULL},TutorialVerb::perform, NULL, NULL, NULL};
+ {{NULL},TutorialVerb::perform, NULL, NULL, NULL, NULL};
/**
* Action vector to define functions called if a staticly defined tutorial verb
* is called
*/
SPActionEventVector TextVerb::vector =
- {{NULL},TextVerb::perform, NULL, NULL, NULL};
+ {{NULL},TextVerb::perform, NULL, NULL, NULL, NULL};
/* *********** Effect Last ********** */
* The vector to attach in the last effect verb.
*/
SPActionEventVector EffectLastVerb::vector =
- {{NULL},EffectLastVerb::perform, NULL, NULL, NULL};
+ {{NULL},EffectLastVerb::perform, NULL, NULL, NULL, NULL};
/** \brief Create an action for a \c EffectLastVerb
\param view Which view the action should be created for
* The vector to attach in the fit canvas verb.
*/
SPActionEventVector FitCanvasVerb::vector =
- {{NULL},FitCanvasVerb::perform, NULL, NULL, NULL};
+ {{NULL},FitCanvasVerb::perform, NULL, NULL, NULL, NULL};
/** \brief Create an action for a \c FitCanvasVerb
\param view Which view the action should be created for
/* Effect */
new EffectLastVerb(SP_VERB_EFFECT_LAST, "EffectLast", N_("Previous Effect"),
- N_("Repeat the last effect with the same settings"), NULL/*"tutorial_tips"*/),
+ N_("Repeat the last effect with the same settings"), NULL),
new EffectLastVerb(SP_VERB_EFFECT_LAST_PREF, "EffectLastPref", N_("Previous Effect Settings..."),
- N_("Repeat the last effect with new settings"), NULL/*"tutorial_tips"*/),
+ N_("Repeat the last effect with new settings"), NULL),
/* Fit Page */
new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION, "FitCanvasToSelection", N_("Fit Page to Selection"),
diff --git a/src/verbs.h b/src/verbs.h
index 8474203f63ec3c9d43deca58f282f1fdbde2e00c..fa232280b6b3ce914fa1e1534299fdf77d6db8c6 100644 (file)
--- a/src/verbs.h
+++ b/src/verbs.h
#include "require-config.h" /* HAVE_GTK_WINDOW_FULLSCREEN */
#include "helper/helper-forward.h"
#include "forward.h"
+#include <glibmm/ustring.h>
/** \brief This anonymous enum is used to provide a list of the Verbs
which are defined staticly in the verb files. There may be
void delete_view (Inkscape::UI::View::View * view);
void sensitive (SPDocument * in_doc = NULL, bool in_sensitive = true);
+ void name (SPDocument * in_doc = NULL, Glib::ustring in_name = "");
// Yes, multiple public, protected and private sections are bad. We'll clean that up later
protected:
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index 42775213a6de3f3ad506066631589ead1825bdcc..f9e854302424db73802be485664a39a258f6c1b7 100644 (file)
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
NULL,
sp_button_action_set_active,
sp_button_action_set_sensitive,
- sp_button_action_set_shortcut
+ sp_button_action_set_shortcut,
+ NULL
};
GtkType