index 344c446e09991908b4bf4fa3ee885e7e3041df1f..f2f51a780094239aea95b29abef5494ef168279a 100644 (file)
#include "inkscape.h"
#include "ui/icons.h"
#include "verbs.h"
+#include "desktop-handles.h"
#include "undo-history.h"
const CellRendererInt::Filter& CellRendererInt::no_filter = CellRendererInt::NoFilter();
-static UndoHistory *_instance = 0;
-
-/* local desktop event handlers */
-static void on_document_replaced(SPDesktop* desktop, SPDocument*);
-static void on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, void*);
-static void on_deactivate_desktop(Inkscape::Application*, SPDesktop* desktop, void*);
-
-UndoHistory*
-UndoHistory::create(Behavior::BehaviorFactory behavior_factory)
+UndoHistory& UndoHistory::getInstance()
{
- if (_instance) return _instance;
- _instance = new UndoHistory(behavior_factory);
- return _instance;
+ return *new UndoHistory();
}
void
UndoHistory::setDesktop(SPDesktop* desktop)
{
- if (!desktop || !SP_ACTIVE_DOCUMENT) return;
+ Panel::setDesktop(desktop);
+
+ if (!desktop) return;
- _document = SP_ACTIVE_DOCUMENT;
+ _document = sp_desktop_document(desktop);
_event_log = desktop->event_log;
_callback_connections[EventLog::CALLB_SELECTION_CHANGE].block(false);
}
-UndoHistory::UndoHistory(Behavior::BehaviorFactory behavior_factory)
- : Dialog (behavior_factory, "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
- _desktop (SP_ACTIVE_DESKTOP),
- _document (SP_ACTIVE_DOCUMENT),
- _event_log (_desktop ? _desktop->event_log : NULL),
+UndoHistory::UndoHistory()
+ : UI::Widget::Panel ("", "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
+ _document (sp_desktop_document(getDesktop())),
+ _event_log (getDesktop() ? getDesktop()->event_log : NULL),
_columns (_event_log ? &_event_log->getColumns() : NULL),
_event_list_selection (_event_list_view.get_selection())
{
- if( !_document || !_event_log || !_columns ) return;
+ if ( !_document || !_event_log || !_columns ) return;
- set_size_request(300, 200);
+ set_size_request(300, 95);
- get_vbox()->pack_start(_scrolled_window);
+ _getContents()->pack_start(_scrolled_window);
_scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
_event_list_store = _event_log->getEventListStore();
_scrolled_window.add(_event_list_view);
- // connect desktop event callbacks
- _document_replaced_connection = _desktop->connectDocumentReplaced(sigc::ptr_fun(on_document_replaced));
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(on_activate_desktop), 0);
- g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(on_deactivate_desktop), 0);
-
// connect EventLog callbacks
_callback_connections[EventLog::CALLB_SELECTION_CHANGE] =
_event_list_selection->signal_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::UndoHistory::_onListSelectionChange));
void
UndoHistory::_onExpandEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &/*path*/)
{
- if ( iter == _event_list_selection->get_selected() )
- {
+ if ( iter == _event_list_selection->get_selected() ) {
_event_list_selection->select(_event_log->getCurrEvent());
}
}
UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &/*path*/)
{
// Collapsing a branch we're currently in is equal to stepping to the last event in that branch
- if ( iter == _event_log->getCurrEvent() )
- {
+ if ( iter == _event_log->getCurrEvent() ) {
EventLog::const_iterator curr_event_parent = _event_log->getCurrEvent();
EventLog::const_iterator curr_event = curr_event_parent->children().begin();
EventLog::const_iterator last = curr_event_parent->children().end();
@@ -349,33 +334,6 @@ UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::T
const CellRendererInt::Filter& UndoHistory::greater_than_1 = UndoHistory::GreaterThan(1);
-static void
-on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, void*)
-{
- if (!_instance) return;
-
- _instance->_document_replaced_connection =
- SP_ACTIVE_DESKTOP->connectDocumentReplaced(sigc::ptr_fun(on_document_replaced));
-
- _instance->setDesktop(desktop);
-}
-
-static void
-on_deactivate_desktop(Inkscape::Application*, SPDesktop* /*desktop*/, void*)
-{
- if (!_instance) return;
-
- _instance->_document_replaced_connection.disconnect();
-}
-
-static void
-on_document_replaced(SPDesktop* desktop, SPDocument*)
-{
- if (!_instance) return;
-
- _instance->setDesktop(desktop);
-}
-
} // namespace Dialog
} // namespace UI
} // namespace Inkscape