summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/undo-history.cpp
diff options
context:
space:
mode:
authorgustav_b <gustav_b@users.sourceforge.net>2007-12-07 01:41:04 +0000
committergustav_b <gustav_b@users.sourceforge.net>2007-12-07 01:41:04 +0000
commit1d22b74180777745a27e7ddbd3006c950063cf41 (patch)
treedf270c16e2856da62210ce610e3da52c45fe6c0d /src/ui/dialog/undo-history.cpp
parentFized crashes & odd behaviour when resizing, zooming and rotating feTurbulence (diff)
downloadinkscape-1d22b74180777745a27e7ddbd3006c950063cf41.tar.gz
inkscape-1d22b74180777745a27e7ddbd3006c950063cf41.zip
Rework dialog management. Use singleton behavior for dialogs when
started in floating dialogs mode and use one dialog/desktop behavior when started in dockable dialogs mode. Replace the panels use of the SP_ACTIVE_DESKTOP macro and unify the panels' handling of desktop activation events. (bzr r4188)
Diffstat (limited to 'src/ui/dialog/undo-history.cpp')
-rw-r--r--src/ui/dialog/undo-history.cpp62
1 files changed, 10 insertions, 52 deletions
diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp
index b808e57de..c53583741 100644
--- a/src/ui/dialog/undo-history.cpp
+++ b/src/ui/dialog/undo-history.cpp
@@ -22,6 +22,7 @@
#include "inkscape.h"
#include "ui/icons.h"
#include "verbs.h"
+#include "desktop-handles.h"
#include "undo-history.h"
@@ -95,27 +96,19 @@ CellRendererInt::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
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::getInstance()
{
- if (!_instance)
- _instance = new UndoHistory();
-
- return *_instance;
+ return *new UndoHistory();
}
void
UndoHistory::setDesktop(SPDesktop* desktop)
{
- if (!desktop || !SP_ACTIVE_DOCUMENT) return;
+ Panel::setDesktop(desktop);
- _document = SP_ACTIVE_DOCUMENT;
+ if (!desktop) return;
+
+ _document = sp_desktop_document(desktop);
_event_log = desktop->event_log;
@@ -133,9 +126,8 @@ UndoHistory::setDesktop(SPDesktop* desktop)
UndoHistory::UndoHistory()
: UI::Widget::Panel ("", "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
- _desktop (SP_ACTIVE_DESKTOP),
- _document (SP_ACTIVE_DOCUMENT),
- _event_log (_desktop ? _desktop->event_log : NULL),
+ _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())
{
@@ -181,11 +173,6 @@ UndoHistory::UndoHistory()
_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));
@@ -317,8 +304,7 @@ 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());
}
}
@@ -327,8 +313,7 @@ void
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