Code

Add a zoom correction option to preferences (used when zooming to 1:1 etc. to display...
[inkscape.git] / src / ui / dialog / undo-history.cpp
index b808e57dee7076d7bcdba25d20f26b418eafef88..f2f51a780094239aea95b29abef5494ef168279a 100644 (file)
@@ -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,15 +126,14 @@ 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())
 {
     if ( !_document || !_event_log || !_columns ) return;
 
-    set_size_request(300, 200);
+    set_size_request(300, 95);
 
     _getContents()->pack_start(_scrolled_window);
     _scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -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