diff --git a/src/desktop.cpp b/src/desktop.cpp
index 7d99043421fb2272c7bdd05221481cf7c1206d2b..5590633b8bf9cecbbf920df0245f977ec88739d0 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
* MenTaLguY <mental@rydia.net>
* bulia byak <buliabyak@users.sf.net>
* Ralf Stephan <ralf@ark.in-berlin.de>
+ * John Bintz <jcoswell@coswellproductions.org>
+ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
+ * Copyright (C) 2006-2007 Johan Engelen
+ * Copyright (C) 2006 John Bintz
* Copyright (C) 2004 MenTaLguY
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
#endif
#include <glibmm/i18n.h>
+#include <sigc++/functors/mem_fun.h>
#include "macros.h"
#include "inkscape-private.h"
#include "xml/repr.h"
#include "message-context.h"
#include "layer-manager.h"
-
-#ifdef WITH_INKBOARD
-#include "jabber_whiteboard/session-manager.h"
-#endif
+#include "event-log.h"
namespace Inkscape { namespace XML { class Node; }}
static void _layer_hierarchy_changed(SPObject *top, SPObject *bottom, SPDesktop *desktop);
static void _reconstruction_start(SPDesktop * desktop);
static void _reconstruction_finish(SPDesktop * desktop);
-static void _namedview_modified (SPNamedView *nv, guint flags, SPDesktop *desktop);
+static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop);
static void _update_snap_distances (SPDesktop *desktop);
/**
is_fullscreen = false;
gr_item = NULL;
- gr_point_num = 0;
+ gr_point_type = 0;
+ gr_point_i = 0;
gr_fill_or_stroke = true;
_layer_hierarchy = NULL;
SP_CANVAS_ARENA (drawing)->arena->delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0); // default is 1 px
- // Start always in normal mode
- SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_NORMAL;
- canvas->rendermode = RENDERMODE_NORMAL; // canvas needs that for choosing the best buffer size
+ if (prefs_get_int_attribute("options.startmode", "outline", 0)) {
+ // Start in outline mode
+ setDisplayModeOutline();
+ } else {
+ // Start in normal mode, default
+ setDisplayModeNormal();
+ }
grid = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
guides = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
_doc2dt[5] = sp_document_height (document);
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
- g_signal_connect (G_OBJECT (namedview), "modified", G_CALLBACK (_namedview_modified), this);
-
+ _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (sp_document_root (document)),
SP_CANVAS_ARENA (drawing)->arena,
/* Ugly hack */
_namedview_modified (namedview, SP_OBJECT_MODIFIED_FLAG, this);
- /* Construct SessionManager
- *
- * SessionManager construction needs to be done after document connection
- */
-#ifdef WITH_INKBOARD
- _whiteboard_session_manager = new Inkscape::Whiteboard::SessionManager(this);
-#endif
-
/* Set up notification of rebuilding the document, this allows
for saving object related settings in the document. */
_reconstruction_start_connection =
_reconstruction_finish_connection =
document->connectReconstructionFinish(sigc::bind(sigc::ptr_fun(_reconstruction_finish), this));
_reconstruction_old_layer_id = NULL;
-
+
+ _commit_connection = document->connectCommit(sigc::mem_fun(*this, &SPDesktop::updateNow));
+
// ?
// sp_active_desktop_set (desktop);
_inkscape = INKSCAPE;
_deactivate_connection.disconnect();
_sel_modified_connection.disconnect();
_sel_changed_connection.disconnect();
+ _modified_connection.disconnect();
+ _commit_connection.disconnect();
+ _reconstruction_start_connection.disconnect();
+ _reconstruction_finish_connection.disconnect();
+
+ g_signal_handlers_disconnect_by_func(G_OBJECT (acetate), (gpointer) G_CALLBACK(sp_desktop_root_handler), this);
+ g_signal_handlers_disconnect_by_func(G_OBJECT (main), (gpointer) G_CALLBACK(sp_desktop_root_handler), this);
+ g_signal_handlers_disconnect_by_func(G_OBJECT (drawing), (gpointer) G_CALLBACK(_arena_handler), this);
while (event_context) {
SPEventContext *ec = event_context;
drawing = NULL;
}
-#ifdef WITH_INKBOARD
- if (_whiteboard_session_manager) {
- delete _whiteboard_session_manager;
- }
-#endif
-
delete _guides_message_context;
_guides_message_context = NULL;
- sp_signal_disconnect_by_data (G_OBJECT (namedview), this);
-
g_list_free (zooms_past);
g_list_free (zooms_future);
}
void SPDesktop::setDisplayModeNormal()
{
+ prefs_set_int_attribute("options.outlinemode", "value", 0);
SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_NORMAL;
canvas->rendermode = RENDERMODE_NORMAL; // canvas needs that for choosing the best buffer size
+ displayMode = RENDERMODE_NORMAL;
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw
+ _widget->setTitle(SP_DOCUMENT_NAME(sp_desktop_document(this)));
}
void SPDesktop::setDisplayModeOutline()
{
+ prefs_set_int_attribute("options.outlinemode", "value", 1);
SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_OUTLINE;
canvas->rendermode = RENDERMODE_OUTLINE; // canvas needs that for choosing the best buffer size
+ displayMode = RENDERMODE_OUTLINE;
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw
+ _widget->setTitle(SP_DOCUMENT_NAME(sp_desktop_document(this)));
+}
+
+void SPDesktop::displayModeToggle()
+{
+ if (prefs_get_int_attribute("options.outlinemode", "value", prefs_get_int_attribute("options.startmode", "outline", 0)))
+ setDisplayModeNormal();
+ else
+ setDisplayModeOutline();
}
/**
inkscape_subselection_changed (this);
}
+void
+SPDesktop::updateNow()
+{
+ sp_canvas_update_now(canvas);
+}
+
+void
+SPDesktop::enableInteraction()
+{
+ _widget->enableInteraction();
+}
+
+void SPDesktop::disableInteraction()
+{
+ _widget->disableInteraction();
+}
+
//----------------------------------------------------------------------
// Callback implementations. The virtual ones are connected by the view.
}
}
+void
+SPDesktop::updateCanvasNow()
+{
+ _widget->requestCanvasUpdateAndWait();
+}
+
/**
* Associate document with desktop.
*/
+/// \todo fixme: refactor SPDesktop::init to use setDocument
void
SPDesktop::setDocument (SPDocument *doc)
{
_layer_hierarchy->connectChanged(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this));
_layer_hierarchy->setTop(SP_DOCUMENT_ROOT(doc));
+ /* setup EventLog */
+ event_log = new Inkscape::EventLog(doc);
+ doc->addUndoObserver(*event_log);
+
+ _commit_connection.disconnect();
+ _commit_connection = doc->connectCommit(sigc::mem_fun(*this, &SPDesktop::updateNow));
+
/// \todo fixme: This condition exists to make sure the code
/// inside is called only once on initialization. But there
/// are surely more safe methods to accomplish this.
NRArenaItem *ai;
namedview = sp_document_namedview (doc, NULL);
- g_signal_connect (G_OBJECT (namedview), "modified", G_CALLBACK (_namedview_modified), this);
+ _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
number = namedview->getViewCount();
ai = sp_item_invoke_show (SP_ITEM (sp_document_root (doc)),
* Namedview_modified callback.
*/
static void
-_namedview_modified (SPNamedView *nv, guint flags, SPDesktop *desktop)
+_namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop)
{
+ SPNamedView *nv=SP_NAMEDVIEW(obj);
+
if (flags & SP_OBJECT_MODIFIED_FLAG) {
/* Recalculate snap distances */
SP_RGBA32_G_U(nv->pagecolor) +
SP_RGBA32_B_U(nv->pagecolor)) >= 384) {
// the background color is light or transparent, use black outline
- SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = 0xff;
+ SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "onlight", 0xff);
} else { // use white outline
- SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = 0xffffffff;
+ SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "ondark", 0xffffffff);
}
}
}
nv.snap_manager.grid.setDistance(sp_convert_distance_full(nv.gridtolerance,
*nv.gridtoleranceunit,
px));
+ nv.snap_manager.axonomgrid.setDistance(sp_convert_distance_full(nv.gridtolerance,
+ *nv.gridtoleranceunit,
+ px));
nv.snap_manager.guide.setDistance(sp_convert_distance_full(nv.guidetolerance,
*nv.guidetoleranceunit,
px));