summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-11-26 01:17:02 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-11-26 01:17:02 +0000
commitbed3cc55fe40330718204c540b328d95407b00fa (patch)
treee4269aab0a32957163935ec6b828b25d00613d68 /src
parentAdd CMake file to find LCMS2 (diff)
parentUpdate to trunk r13766 (diff)
downloadinkscape-bed3cc55fe40330718204c540b328d95407b00fa.tar.gz
inkscape-bed3cc55fe40330718204c540b328d95407b00fa.zip
Merge inkscape-cppify branch
(bzr r13767)
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile_insert2
-rw-r--r--src/box3d.cpp2
-rw-r--r--src/conn-avoid-ref.cpp4
-rw-r--r--src/desktop.cpp59
-rw-r--r--src/desktop.h1
-rw-r--r--src/document-private.h2
-rw-r--r--src/document-undo.cpp7
-rw-r--r--src/document-undo.h2
-rw-r--r--src/document.cpp35
-rw-r--r--src/document.h1
-rw-r--r--src/extension/dbus/application-interface.cpp4
-rw-r--r--src/extension/dbus/dbus-init.cpp10
-rw-r--r--src/extension/dbus/document-interface.cpp2
-rw-r--r--src/extension/effect.cpp10
-rw-r--r--src/extension/error-file.cpp3
-rw-r--r--src/extension/extension.cpp2
-rw-r--r--src/extension/implementation/script.cpp2
-rw-r--r--src/extension/init.cpp2
-rw-r--r--src/extension/internal/cdr-input.cpp2
-rw-r--r--src/extension/internal/filter/filter-file.cpp2
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp2
-rw-r--r--src/extension/system.cpp2
-rw-r--r--src/file.cpp4
-rw-r--r--src/graphlayout.cpp2
-rw-r--r--src/helper/stock-items.cpp4
-rw-r--r--src/inkscape-private.h67
-rw-r--r--src/inkscape.cpp953
-rw-r--r--src/inkscape.h272
-rw-r--r--src/inkview.cpp7
-rw-r--r--src/io/resource.cpp2
-rw-r--r--src/line-geometry.cpp4
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/live_effects/lpe-bspline.cpp1
-rw-r--r--src/live_effects/parameter/text.cpp2
-rw-r--r--src/main-cmdlineact.cpp2
-rw-r--r--src/main.cpp20
-rw-r--r--src/persp3d.cpp8
-rw-r--r--src/preferences.cpp8
-rw-r--r--src/selection-chemistry.cpp4
-rw-r--r--src/selection.cpp6
-rw-r--r--src/shortcuts.cpp4
-rw-r--r--src/sp-item.cpp6
-rw-r--r--src/test-helpers.h6
-rw-r--r--src/ui/CMakeLists.txt4
-rw-r--r--src/ui/clipboard.cpp2
-rw-r--r--src/ui/dialog-events.cpp9
-rw-r--r--src/ui/dialog-events.h12
-rw-r--r--src/ui/dialog/align-and-distribute.cpp16
-rw-r--r--src/ui/dialog/align-and-distribute.h3
-rw-r--r--src/ui/dialog/clonetiler.cpp36
-rw-r--r--src/ui/dialog/clonetiler.h5
-rw-r--r--src/ui/dialog/desktop-tracker.cpp17
-rw-r--r--src/ui/dialog/desktop-tracker.h4
-rw-r--r--src/ui/dialog/dialog.cpp38
-rw-r--r--src/ui/dialog/dialog.h1
-rw-r--r--src/ui/dialog/document-metadata.cpp4
-rw-r--r--src/ui/dialog/document-metadata.h5
-rw-r--r--src/ui/dialog/document-properties.cpp4
-rw-r--r--src/ui/dialog/document-properties.h4
-rw-r--r--src/ui/dialog/export.cpp4
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp7
-rw-r--r--src/ui/dialog/fill-and-stroke.h3
-rw-r--r--src/ui/dialog/grid-arrange-tab.cpp13
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp2
-rw-r--r--src/ui/dialog/panel-dialog.h33
-rw-r--r--src/ui/dialog/swatches.cpp2
-rw-r--r--src/ui/dialog/symbols.cpp10
-rw-r--r--src/ui/dialog/template-load-tab.cpp2
-rw-r--r--src/ui/dialog/transformation.cpp14
-rw-r--r--src/ui/dialog/transformation.h3
-rw-r--r--src/ui/interface.cpp12
-rw-r--r--src/ui/tools-switch.cpp4
-rw-r--r--src/ui/tools/connector-tool.cpp2
-rw-r--r--src/ui/view/view.cpp8
-rw-r--r--src/ui/widget/dock.cpp5
-rw-r--r--src/ui/widget/imageicon.cpp5
-rw-r--r--src/ui/widget/object-composite-settings.cpp21
-rw-r--r--src/ui/widget/object-composite-settings.h4
-rw-r--r--src/ui/widget/panel.cpp6
-rw-r--r--src/ui/widget/panel.h9
-rw-r--r--src/vanishing-point.cpp22
-rw-r--r--src/verbs.cpp20
-rw-r--r--src/widgets/box3d-toolbar.cpp4
-rw-r--r--src/widgets/desktop-widget.cpp10
-rw-r--r--src/widgets/gradient-vector.cpp53
-rw-r--r--src/widgets/icon.cpp6
-rw-r--r--src/widgets/select-toolbar.cpp2
-rw-r--r--src/widgets/sp-widget.cpp97
-rw-r--r--src/widgets/sp-widget.h13
-rw-r--r--src/widgets/stroke-marker-selector.cpp2
92 files changed, 983 insertions, 1124 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3d863a7fa..680d3bae5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -336,7 +336,6 @@ set(inkscape_SRC
icon-size.h
id-clash.h
# ige-mac-menu.h
- inkscape-private.h
inkscape-version.h
inkscape.h
interface.h
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 107acdf31..488ab52c5 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -63,7 +63,7 @@ ink_common_sources += \
helper/pixbuf-ops.h \
icon-size.h \
id-clash.cpp id-clash.h \
- inkscape.cpp inkscape.h inkscape-private.h \
+ inkscape.cpp inkscape.h \
isinf.h \
knot.cpp knot.h \
knot-enums.h \
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 3c0cbb675..93622be4c 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -401,7 +401,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta
snap_pts[3] = diag2.closest_to (pt);
}
- gdouble const zoom = inkscape_active_desktop()->current_zoom();
+ gdouble const zoom = INKSCAPE.active_desktop()->current_zoom();
// determine the distances to all potential snapping points
double snap_dists[MAX_POINT_COUNT];
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index cb72f65dc..cbc8faf7c 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -87,7 +87,7 @@ void SPAvoidRef::setAvoid(char const *value)
void SPAvoidRef::handleSettingChange(void)
{
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
if (desktop == NULL) {
return;
}
@@ -277,7 +277,7 @@ static std::vector<Geom::Point> approxItemWithPoints(SPItem const *item, const G
}
static Avoid::Polygon avoid_item_poly(SPItem const *item)
{
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
g_assert(desktop != NULL);
double spacing = desktop->namedview->connector_spacing;
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 74dea3ca1..288ca1fbf 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -56,7 +56,6 @@
#include "event-log.h"
#include "helper/action-context.h"
#include "ui/interface.h"
-#include "inkscape-private.h"
#include "layer-fns.h"
#include "layer-manager.h"
#include "layer-model.h"
@@ -94,28 +93,28 @@ static void _reconstruction_finish(SPDesktop * desktop);
static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop);
SPDesktop::SPDesktop() :
- _dlg_mgr( 0 ),
- namedview( 0 ),
- canvas( 0 ),
- layers( 0 ),
- selection( 0 ),
- event_context( 0 ),
- layer_manager( 0 ),
- event_log( 0 ),
- temporary_item_list( 0 ),
- snapindicator( 0 ),
- acetate( 0 ),
- main( 0 ),
- gridgroup( 0 ),
- guides( 0 ),
- drawing( 0 ),
- sketch( 0 ),
- controls( 0 ),
- tempgroup ( 0 ),
- table( 0 ),
- page( 0 ),
- page_border( 0 ),
- current( 0 ),
+ _dlg_mgr( NULL ),
+ namedview( NULL ),
+ canvas( NULL ),
+ layers( NULL ),
+ selection( NULL ),
+ event_context( NULL ),
+ layer_manager( NULL ),
+ event_log( NULL ),
+ temporary_item_list( NULL ),
+ snapindicator( NULL ),
+ acetate( NULL ),
+ main( NULL ),
+ gridgroup( NULL ),
+ guides( NULL ),
+ drawing( NULL ),
+ sketch( NULL ),
+ controls( NULL ),
+ tempgroup ( NULL ),
+ table( NULL ),
+ page( NULL ),
+ page_border( NULL ),
+ current( NULL ),
_focusMode(false),
dkey( 0 ),
number( 0 ),
@@ -124,16 +123,15 @@ SPDesktop::SPDesktop() :
waiting_cursor( false ),
showing_dialogs ( false ),
guides_active( false ),
- gr_item( 0 ),
+ gr_item( NULL ),
gr_point_type( POINT_LG_BEGIN ),
gr_point_i( 0 ),
gr_fill_or_stroke( Inkscape::FOR_FILL ),
_reconstruction_old_layer_id(), // an id attribute is not allowed to be the empty string
_display_mode(Inkscape::RENDERMODE_NORMAL),
_display_color_mode(Inkscape::COLORMODE_NORMAL),
- _widget( 0 ),
- _inkscape( 0 ),
- _guides_message_context( 0 ),
+ _widget( NULL ),
+ _guides_message_context( NULL ),
_active( false ),
_w2d(),
_d2w(),
@@ -299,7 +297,6 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
// ?
// sp_active_desktop_set (desktop);
- _inkscape = INKSCAPE;
_activate_connection = _activate_signal.connect(
sigc::bind(
@@ -385,10 +382,6 @@ void SPDesktop::destroy()
layer_manager = NULL;
}
- if (_inkscape) {
- _inkscape = NULL;
- }
-
if (drawing) {
doc()->getRoot()->invoke_hide(dkey);
g_object_unref(drawing);
@@ -1431,7 +1424,7 @@ void
SPDesktop::emitToolSubselectionChanged(gpointer data)
{
_tool_subselection_changed.emit(data);
- inkscape_subselection_changed (this);
+ INKSCAPE.subselection_changed (this);
}
void SPDesktop::updateNow()
diff --git a/src/desktop.h b/src/desktop.h
index 509f8a396..496cc30eb 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -424,7 +424,6 @@ public:
private:
Inkscape::UI::View::EditWidgetInterface *_widget;
- InkscapeApplication *_inkscape;
Inkscape::MessageContext *_guides_message_context;
bool _active;
Geom::Affine _w2d;
diff --git a/src/document-private.h b/src/document-private.h
index 8e28b288b..a5033b3c2 100644
--- a/src/document-private.h
+++ b/src/document-private.h
@@ -75,6 +75,8 @@ struct SPDocumentPrivate {
Inkscape::ConsoleOutputUndoObserver console_output_undo_observer;
bool seeking;
+ sigc::connection selChangeConnection;
+ sigc::connection desktopActivatedConnection;
};
#endif // SEEN_SP_DOCUMENT_PRIVATE_H
diff --git a/src/document-undo.cpp b/src/document-undo.cpp
index 15d5d2c70..d4015bafb 100644
--- a/src/document-undo.cpp
+++ b/src/document-undo.cpp
@@ -99,9 +99,8 @@ void Inkscape::DocumentUndo::done(SPDocument *doc, const unsigned int event_type
maybeDone(doc, NULL, event_type, event_description);
}
-void Inkscape::DocumentUndo::resetKey( InkscapeApplication * /*inkscape*/, SPDesktop * /*desktop*/, GObject *base )
+void Inkscape::DocumentUndo::resetKey( SPDocument *doc )
{
- SPDocument *doc = reinterpret_cast<SPDocument *>(base);
doc->actionkey.clear();
}
@@ -259,7 +258,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc)
doc->priv->seeking = false;
if (ret)
- inkscape_external_change();
+ INKSCAPE.external_change();
return ret;
}
@@ -304,7 +303,7 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc)
doc->priv->seeking = false;
if (ret)
- inkscape_external_change();
+ INKSCAPE.external_change();
return ret;
}
diff --git a/src/document-undo.h b/src/document-undo.h
index 17b3de252..85b44d562 100644
--- a/src/document-undo.h
+++ b/src/document-undo.h
@@ -41,7 +41,7 @@ public:
static void maybeDone(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring const &event_description);
- static void resetKey(InkscapeApplication *inkscape, SPDesktop *desktop, GObject *base);
+ static void resetKey(SPDocument *doc);
static void cancel(SPDocument *document);
diff --git a/src/document.cpp b/src/document.cpp
index e24af8fa8..2625ef8fc 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -50,7 +50,7 @@
#include "document-private.h"
#include "document-undo.h"
#include "id-clash.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "inkscape-version.h"
#include "libavoid/router.h"
#include "persp3d.h"
@@ -154,6 +154,14 @@ SPDocument::~SPDocument() {
router = NULL;
}
+ if (oldSignalsConnected) {
+ priv->selChangeConnection.disconnect();
+ priv->desktopActivatedConnection.disconnect();
+ } else {
+ _selection_changed_connection.disconnect();
+ _desktop_activated_connection.disconnect();
+ }
+
if (priv) {
if (priv->partial) {
sp_repr_free_log(priv->partial);
@@ -208,17 +216,8 @@ SPDocument::~SPDocument() {
rerouting_handler_id = 0;
}
- if (oldSignalsConnected) {
- g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE),
- reinterpret_cast<gpointer>(DocumentUndo::resetKey),
- static_cast<gpointer>(this));
- } else {
- _selection_changed_connection.disconnect();
- _desktop_activated_connection.disconnect();
- }
-
if (keepalive) {
- inkscape_unref();
+ inkscape_unref(INKSCAPE);
keepalive = FALSE;
}
@@ -447,7 +446,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc,
rdf_set_defaults( document );
if (keepalive) {
- inkscape_ref();
+ inkscape_ref(INKSCAPE);
}
// Check if the document already has a perspective (e.g., when opening an existing
@@ -462,10 +461,14 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc,
DocumentUndo::setUndoSensitive(document, true);
// reset undo key when selection changes, so that same-key actions on different objects are not coalesced
- g_signal_connect(G_OBJECT(INKSCAPE), "change_selection",
- G_CALLBACK(DocumentUndo::resetKey), document);
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop",
- G_CALLBACK(DocumentUndo::resetKey), document);
+ document->priv->selChangeConnection = INKSCAPE.signal_selection_changed.connect(
+ sigc::hide(sigc::bind(
+ sigc::ptr_fun(&DocumentUndo::resetKey), document)
+ ));
+ document->priv->desktopActivatedConnection = INKSCAPE.signal_activate_desktop.connect(
+ sigc::hide(sigc::bind(
+ sigc::ptr_fun(&DocumentUndo::resetKey), document)
+ ));
document->oldSignalsConnected = true;
return document;
diff --git a/src/document.h b/src/document.h
index 065c5f323..a8b79eb9e 100644
--- a/src/document.h
+++ b/src/document.h
@@ -38,7 +38,6 @@ class SPGroup;
class SPRoot;
namespace Inkscape {
- struct Application;
class Selection;
class UndoStackObserver;
class EventLog;
diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp
index c0bc19d90..292832a4b 100644
--- a/src/extension/dbus/application-interface.cpp
+++ b/src/extension/dbus/application-interface.cpp
@@ -49,7 +49,7 @@ application_interface_init (ApplicationInterface *app_interface)
static bool
ensure_desktop_valid(GError **error)
{
- if (!inkscape_use_gui()) {
+ if (!INKSCAPE.use_gui()) {
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires a GUI");
return false;
}
@@ -59,7 +59,7 @@ ensure_desktop_valid(GError **error)
static bool
ensure_desktop_not_present(GError **error)
{
- if (inkscape_use_gui()) {
+ if (INKSCAPE.use_gui()) {
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires non-GUI (command line) mode");
return false;
}
diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp
index 19b48e10d..43830762c 100644
--- a/src/extension/dbus/dbus-init.cpp
+++ b/src/extension/dbus/dbus-init.cpp
@@ -153,23 +153,23 @@ gchar *
init_document (void)
{
// This is for command-line use only
- g_assert(!inkscape_use_gui());
+ g_assert(!INKSCAPE.use_gui());
// Create a blank document and get its selection model etc in an ActionContext
SPDocument *doc = SPDocument::createNewDoc(NULL, 1, TRUE);
- inkscape_add_document(doc);
- return dbus_register_document(inkscape_action_context_for_document(doc));
+ INKSCAPE.add_document(doc);
+ return dbus_register_document(INKSCAPE.action_context_for_document(doc));
}
gchar *
init_active_document()
{
- SPDocument *doc = inkscape_active_document();
+ SPDocument *doc = INKSCAPE.active_document();
if (!doc) {
return NULL;
}
- return dbus_register_document(inkscape_active_action_context());
+ return dbus_register_document(INKSCAPE.active_action_context());
}
gchar *
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index e3452f4ce..bd5f826d3 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -156,7 +156,7 @@ get_name_from_object (SPObject * obj)
void
desktop_ensure_active (SPDesktop* desk) {
if (desk != SP_ACTIVE_DESKTOP)
- inkscape_activate_desktop (desk);
+ INKSCAPE.activate_desktop (desk);
return;
}
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index 3c8ee5844..c8f3b2ff9 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -9,7 +9,7 @@
*/
#include "prefdialog.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "helper/action.h"
#include "ui/view/view.h"
#include "desktop-handles.h"
@@ -89,11 +89,13 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation *
} // children of "inkscape-extension"
} // if we have an XML file
- if (INKSCAPE != NULL && inkscape_use_gui()) {
+ // \TODO this gets called from the Inkscape::Application constructor, where it initializes the menus.
+ // But in the constructor, our object isn't quite there yet!
+ if (Inkscape::Application::exists() && INKSCAPE.use_gui()) {
if (_effects_list == NULL)
- _effects_list = find_menu(inkscape_get_menus(INKSCAPE), EFFECTS_LIST);
+ _effects_list = find_menu(INKSCAPE.get_menus(), EFFECTS_LIST);
if (_filters_list == NULL)
- _filters_list = find_menu(inkscape_get_menus(INKSCAPE), FILTERS_LIST);
+ _filters_list = find_menu(INKSCAPE.get_menus(), FILTERS_LIST);
}
if ((_effects_list != NULL || _filters_list != NULL)) {
diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp
index f60af870f..db354c0ce 100644
--- a/src/extension/error-file.cpp
+++ b/src/extension/error-file.cpp
@@ -48,9 +48,10 @@ ErrorFileNotice::ErrorFileNotice (void) :
)
{
+ // \FIXME change this
/* This is some filler text, needs to change before relase */
Glib::ustring dialog_text(_("<span weight=\"bold\" size=\"larger\">One or more extensions failed to load</span>\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: "));
- gchar * ext_error_file = profile_path(EXTENSION_ERROR_LOG_FILENAME);
+ gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME);
dialog_text += ext_error_file;
g_free(ext_error_file);
set_message(dialog_text, true);
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 6a22eb585..3d0f49a20 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -667,7 +667,7 @@ Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc,
void
Extension::error_file_open (void)
{
- gchar * ext_error_file = profile_path(EXTENSION_ERROR_LOG_FILENAME);
+ gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME);
gchar * filename = g_filename_from_utf8( ext_error_file, -1, NULL, NULL, NULL );
error_file.open(filename);
if (!error_file.is_open()) {
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 99c882a01..e6ac13cdc 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -1051,7 +1051,7 @@ int Script::execute (const std::list<std::string> &in_command,
Glib::ustring stderr_data = fileerr.string();
if (stderr_data.length() != 0 &&
- inkscape_use_gui()
+ INKSCAPE.use_gui()
) {
checkStderr(stderr_data, Gtk::MESSAGE_INFO,
_("Inkscape has received additional data from the script executed. "
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 912d58a13..c16a5a899 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -243,7 +243,7 @@ init()
/* Load search path for extensions */
if (Inkscape::Extension::Extension::search_path.size() == 0)
{
- Inkscape::Extension::Extension::search_path.push_back(profile_path("extensions"));
+ Inkscape::Extension::Extension::search_path.push_back(Inkscape::Application::profile_path("extensions"));
Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR));
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index 3a3e2b58e..fb58887c9 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -263,7 +263,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// If only one page is present, import that one without bothering user
if (tmpSVGOutput.size() > 1) {
CdrImportDialog *dlg = 0;
- if (inkscape_use_gui()) {
+ if (INKSCAPE.use_gui()) {
dlg = new CdrImportDialog(tmpSVGOutput);
if (!dlg->showDialog()) {
delete dlg;
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp
index 48e64f089..b1993057d 100644
--- a/src/extension/internal/filter/filter-file.cpp
+++ b/src/extension/internal/filter/filter-file.cpp
@@ -29,7 +29,7 @@ namespace Filter {
void Filter::filters_all_files(void)
{
- gchar *filtersProfilePath = profile_path("filters");
+ gchar *filtersProfilePath = Inkscape::Application::profile_path("filters");
filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled"));
filters_load_dir(filtersProfilePath, _("Personal"));
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index c8a7feabf..defb15754 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -720,7 +720,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
}
PdfImportDialog *dlg = NULL;
- if (inkscape_use_gui()) {
+ if (INKSCAPE.use_gui()) {
dlg = new PdfImportDialog(pdf_doc, uri);
if (!dlg->showDialog()) {
_cancelled = true;
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 9f9bf2651..25815e64f 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -263,7 +263,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// If only one page is present, import that one without bothering user
if (tmpSVGOutput.size() > 1) {
VsdImportDialog *dlg = 0;
- if (inkscape_use_gui()) {
+ if (INKSCAPE.use_gui()) {
dlg = new VsdImportDialog(tmpSVGOutput);
if (!dlg->showDialog()) {
delete dlg;
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index 5225f11ee..6a95717f2 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -121,7 +121,7 @@ SPDocument *open(Extension *key, gchar const *filename)
}
if (last_chance_svg) {
- if ( inkscape_use_gui() ) {
+ if ( INKSCAPE.use_gui() ) {
sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG."));
} else {
g_warning("%s", _("Format autodetect failed. The file is being opened as SVG."));
diff --git a/src/file.cpp b/src/file.cpp
index 307944001..2afb932b8 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -177,7 +177,7 @@ SPDesktop *sp_file_new(const std::string &templ)
Glib::ustring sp_file_default_template_uri()
{
std::list<gchar *> sources;
- sources.push_back( profile_path("templates") ); // first try user's local dir
+ sources.push_back( Inkscape::Application::profile_path("templates") ); // first try user's local dir
sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir
std::list<gchar const*> baseNames;
gchar const* localized = _("default.svg");
@@ -316,7 +316,7 @@ bool sp_file_open(const Glib::ustring &uri,
sp_file_add_recent( doc->getURI() );
}
- if ( inkscape_use_gui() ) {
+ if ( INKSCAPE.use_gui() ) {
// Perform a fixup pass for hrefs.
if ( Inkscape::ResourceManager::getManager().fixupBrokenLinks(doc) ) {
Glib::ustring msg = _("Broken links have been changed to point to existing files.");
diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp
index 18159cb41..43b424f46 100644
--- a/src/graphlayout.cpp
+++ b/src/graphlayout.cpp
@@ -117,7 +117,7 @@ void graphlayout(GSList const *const items) {
// add the connector spacing to the size of node bounding boxes
// so that connectors can always be routed between shapes
- SPDesktop* desktop = inkscape_active_desktop();
+ SPDesktop* desktop = INKSCAPE.active_desktop();
double spacing = 0;
if(desktop) spacing = desktop->namedview->connector_spacing+0.1;
diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp
index 582dcd2a8..17c4c53a7 100644
--- a/src/helper/stock-items.cpp
+++ b/src/helper/stock-items.cpp
@@ -195,7 +195,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock)
gchar * base = g_strndup(e, a);
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
SPDocument *doc = sp_desktop_document(desktop);
SPDefs *defs = doc->getDefs();
if (!defs) {
@@ -265,7 +265,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock)
else {
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
SPDocument *doc = sp_desktop_document(desktop);
SPObject *object = doc->getObjectById(urn);
diff --git a/src/inkscape-private.h b/src/inkscape-private.h
deleted file mode 100644
index d28ed223e..000000000
--- a/src/inkscape-private.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef SEEN_INKSCAPE_PRIVATE_H
-#define SEEN_INKSCAPE_PRIVATE_H
-
-/*
- * Some forward declarations
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * Copyright (C) 1999-2002 Lauris Kaplinski
- * Copyright (C) 2001-2002 Ximian, Inc.
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-#include <glib-object.h>
-
-#define SP_TYPE_INKSCAPE (inkscape_get_type ())
-#define SP_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape))
-#define SP_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_INKSCAPE, InkscapeClass))
-#define SP_IS_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_INKSCAPE))
-#define SP_IS_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE))
-
-#include "inkscape.h"
-
-struct SPColor;
-namespace Inkscape { class Selection; }
-
-GType inkscape_get_type (void);
-
-void inkscape_ref (void);
-void inkscape_unref (void);
-
-guint inkscape_mapalt();
-void inkscape_mapalt(guint);
-
-guint inkscape_trackalt();
-void inkscape_trackalt(guint);
-
-/*
- * These are meant solely for desktop, document etc. implementations
- */
-
-void inkscape_selection_modified (Inkscape::Selection *selection, guint flags);
-void inkscape_selection_changed (Inkscape::Selection * selection);
-void inkscape_selection_set (Inkscape::Selection * selection);
-void inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext);
-void inkscape_add_desktop (SPDesktop * desktop);
-void inkscape_remove_desktop (SPDesktop * desktop);
-void inkscape_activate_desktop (SPDesktop * desktop);
-void inkscape_reactivate_desktop (SPDesktop * desktop);
-
-void inkscape_set_color (SPColor *color, float opacity);
-
-#endif // SEEN_INKSCAPE_PRIVATE_H
-
-
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 36a802e5f..94c3722cb 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -1,13 +1,15 @@
/**
* @file
- * Legacy interface to main application.
+ * Interface to main application.
*/
/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Liam P. White <inkscapebrony@gmail.com>
*
- * Copyright (C) 1999-2005 authors
- * g++ port Copyright (C) 2003 Nathan Hurst
+ * Copyright (C) 1999-2014 authors
+ * c++ port Copyright (C) 2003 Nathan Hurst
+ * c++ification Copyright (C) 2014 Liam P. White
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -50,240 +52,174 @@
#include <gtk/gtk.h>
#include <signal.h>
#include <string>
+
#include "desktop.h"
#include "desktop-handles.h"
#include "device-manager.h"
#include "document.h"
-#include "ui/tools/tool-base.h"
#include "extension/db.h"
#include "extension/init.h"
#include "extension/output.h"
#include "extension/system.h"
-#include "inkscape-private.h"
+#include "helper/action-context.h"
+#include "helper/sp-marshal.h"
+#include "inkscape.h"
#include "io/sys.h"
#include "layer-model.h"
#include "message-stack.h"
#include "preferences.h"
#include "resource-manager.h"
#include "selection.h"
+#include "ui/tools/tool-base.h"
#include "ui/dialog/debug.h"
#include "xml/repr.h"
-#include "helper/action-context.h"
-#include "helper/sp-marshal.h"
-
-static InkscapeApplication *inkscape = NULL;
/* Backbones of configuration xml data */
#include "menus-skeleton.h"
-enum {
- MODIFY_SELECTION, // global: one of selections modified
- CHANGE_SELECTION, // global: one of selections changed
- CHANGE_SUBSELECTION, // global: one of subselections (text selection, gradient handle, etc) changed
- SET_SELECTION, // global: one of selections set
- SET_EVENTCONTEXT, // tool switched
- ACTIVATE_DESKTOP, // some desktop got focus
- DEACTIVATE_DESKTOP, // some desktop lost focus
- SHUTDOWN_SIGNAL, // inkscape is quitting
- DIALOGS_HIDE, // user pressed F12
- DIALOGS_UNHIDE, // user pressed F12
- EXTERNAL_CHANGE, // a document was changed by some external means (undo or XML editor); this
- // may not be reflected by a selection change and thus needs a separate signal
- LAST_SIGNAL
-};
+// Inkscape::Application static members
+Inkscape::Application * Inkscape::Application::_S_inst = NULL;
+bool Inkscape::Application::_crashIsHappening = false;
-#define DESKTOP_IS_ACTIVE(d) (inkscape->desktops && ((d) == inkscape->desktops->data))
+#define DESKTOP_IS_ACTIVE(d) (!INKSCAPE._desktops->empty() && ((d) == INKSCAPE._desktops->front()))
+static void (* segv_handler) (int) = SIG_DFL;
+static void (* abrt_handler) (int) = SIG_DFL;
+static void (* fpe_handler) (int) = SIG_DFL;
+static void (* ill_handler) (int) = SIG_DFL;
+#ifndef WIN32
+static void (* bus_handler) (int) = SIG_DFL;
+#endif
-/*################################
-# FORWARD DECLARATIONS
-################################*/
+#define INKSCAPE_PROFILE_DIR "inkscape"
+#define INKSCAPE_PROFILE_DIR_047DEV "Inkscape"
+#define INKSCAPE_LEGACY_PROFILE_DIR ".inkscape"
+#define MENUS_FILE "menus.xml"
-static void inkscape_dispose (GObject *object);
+#define SP_INDENT 8
-static void inkscape_activate_desktop_private (InkscapeApplication *inkscape, SPDesktop *desktop);
-static void inkscape_deactivate_desktop_private (InkscapeApplication *inkscape, SPDesktop *desktop);
+#ifdef WIN32
+typedef int uid_t;
+#define getuid() 0
+#endif
+
+/** C++ification TODO list
+ * - _S_inst should NOT need to be assigned inside the constructor, but if it isn't the Filters+Extensions menus break.
+ * - Application::_deskops has to be a pointer because of a signal bug somewhere else. Basically, it will attempt to access a deleted object in sp_ui_close_all(),
+ * but if it's a pointer we can stop and return NULL in Application::active_desktop()
+ * - These functions are calling Application::create for no good reason I can determine:
+ *
+ * Inkscape::UI::Dialog::SVGPreview::SVGPreview()
+ * src/ui/dialog/filedialogimpl-gtkmm.cpp:542:9
+ * void Inkscape::UI::Widget::ImageIcon::init()
+ * src/ui/widget/imageicon.cpp:93:9
+ */
-class AppSelectionModel {
- Inkscape::LayerModel _layer_model;
- Inkscape::Selection *_selection;
+class InkErrorHandler : public Inkscape::ErrorReporter {
public:
- AppSelectionModel(SPDocument *doc) {
- _layer_model.setDocument(doc);
- // TODO: is this really how we should manage the lifetime of the selection?
- // I just copied this from the initialization of the Selection in SPDesktop.
- // When and how is it actually released?
- _selection = Inkscape::GC::release(new Inkscape::Selection(&_layer_model, NULL));
+ InkErrorHandler(bool useGui) : Inkscape::ErrorReporter(),
+ _useGui(useGui)
+ {}
+ virtual ~InkErrorHandler() {}
+
+ virtual void handleError( Glib::ustring const& primary, Glib::ustring const& secondary ) const
+ {
+ if (_useGui) {
+ Gtk::MessageDialog err(primary, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
+ err.set_secondary_text(secondary);
+ err.run();
+ } else {
+ g_message("%s", primary.data());
+ g_message("%s", secondary.data());
+ }
}
- Inkscape::Selection *getSelection() const { return _selection; }
+private:
+ bool _useGui;
};
-struct InkscapeApplication {
- GObject object;
- Inkscape::XML::Document *menus;
- std::map<SPDocument *, int> document_set;
- std::map<SPDocument *, AppSelectionModel *> selection_models;
- GSList *desktops;
- gchar *argv0;
- gboolean dialogs_toggle;
- gboolean use_gui; // may want to consider a virtual function
- // for overriding things like the warning dlg's
- guint mapalt;
- guint trackalt;
-};
+void inkscape_ref(Inkscape::Application & in)
+{
+ in.refCount++;
+}
-struct InkscapeApplicationClass {
- GObjectClass object_class;
-
- /* Signals */
- void (* change_selection) (InkscapeApplication * inkscape, Inkscape::Selection * selection);
- void (* change_subselection) (InkscapeApplication * inkscape, SPDesktop *desktop);
- void (* modify_selection) (InkscapeApplication * inkscape, Inkscape::Selection * selection, guint flags);
- void (* set_selection) (InkscapeApplication * inkscape, Inkscape::Selection * selection);
- void (* set_eventcontext) (InkscapeApplication * inkscape, Inkscape::UI::Tools::ToolBase * eventcontext);
- void (* activate_desktop) (InkscapeApplication * inkscape, SPDesktop * desktop);
- void (* deactivate_desktop) (InkscapeApplication * inkscape, SPDesktop * desktop);
- void (* destroy_document) (InkscapeApplication *inkscape, SPDocument *doc);
- void (* color_set) (InkscapeApplication *inkscape, SPColor *color, double opacity);
- void (* shut_down) (InkscapeApplication *inkscape);
- void (* dialogs_hide) (InkscapeApplication *inkscape);
- void (* dialogs_unhide) (InkscapeApplication *inkscape);
- void (* external_change) (InkscapeApplication *inkscape);
-};
+void inkscape_unref(Inkscape::Application & in)
+{
+ in.refCount--;
-static guint inkscape_signals[LAST_SIGNAL] = {0};
+ if (&in == Inkscape::Application::_S_inst) {
+ if (in.refCount <= 0) {
+ delete Inkscape::Application::_S_inst;
+ }
+ } else {
+ g_error("Attempt to unref an Application (=%p) not the current instance (=%p) (maybe it's already been destroyed?)",
+ &in, Inkscape::Application::_S_inst);
+ }
+}
-static void (* segv_handler) (int) = SIG_DFL;
-static void (* abrt_handler) (int) = SIG_DFL;
-static void (* fpe_handler) (int) = SIG_DFL;
-static void (* ill_handler) (int) = SIG_DFL;
-#ifndef WIN32
-static void (* bus_handler) (int) = SIG_DFL;
-#endif
+// Callback passed to g_timeout_add_seconds()
+// gets the current instance and calls autosave()
+int inkscape_autosave(gpointer) {
+ g_assert(Inkscape::Application::exists());
+ return INKSCAPE.autosave();
+}
-#define INKSCAPE_PROFILE_DIR "inkscape"
-#define INKSCAPE_PROFILE_DIR_047DEV "Inkscape"
-#define INKSCAPE_LEGACY_PROFILE_DIR ".inkscape"
-#define MENUS_FILE "menus.xml"
+namespace Inkscape {
+
+/**
+ * Defined only for debugging purposes. If we are certain the bugs are gone we can remove this
+ * and the references in inkscape_ref and inkscape_unref.
+ */
+Application*
+Application::operator &() const
+{
+ return const_cast<Application*>(this);
+}
+/**
+ * Creates a new Inkscape::Application global object.
+ */
+void
+Application::create(const char *argv0, bool use_gui)
+{
+ if (!Application::exists()) {
+ new Application(argv0, use_gui);
+ } else {
+ g_assert_not_reached();
+ }
+}
-G_DEFINE_TYPE(InkscapeApplication, inkscape, G_TYPE_OBJECT);
/**
- * Initializes the inkscape class, registering all of its signal handlers
- * and virtual functions
+ * Checks whether the current Inkscape::Application global object exists.
*/
-static void
-inkscape_class_init (InkscapeApplicationClass * klass)
+bool
+Application::exists()
{
- GObjectClass * object_class = G_OBJECT_CLASS(klass);
-
- inkscape_signals[MODIFY_SELECTION] = g_signal_new ("modify_selection",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, modify_selection),
- NULL, NULL,
- sp_marshal_VOID__POINTER_UINT,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER, G_TYPE_UINT);
- inkscape_signals[CHANGE_SELECTION] = g_signal_new ("change_selection",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, change_selection),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- inkscape_signals[CHANGE_SUBSELECTION] = g_signal_new ("change_subselection",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, change_subselection),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- inkscape_signals[SET_SELECTION] = g_signal_new ("set_selection",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, set_selection),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- inkscape_signals[SET_EVENTCONTEXT] = g_signal_new ("set_eventcontext",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, set_eventcontext),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- inkscape_signals[ACTIVATE_DESKTOP] = g_signal_new ("activate_desktop",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, activate_desktop),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- inkscape_signals[DEACTIVATE_DESKTOP] = g_signal_new ("deactivate_desktop",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, deactivate_desktop),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- inkscape_signals[SHUTDOWN_SIGNAL] = g_signal_new ("shut_down",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, shut_down),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- inkscape_signals[DIALOGS_HIDE] = g_signal_new ("dialogs_hide",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, dialogs_hide),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- inkscape_signals[DIALOGS_UNHIDE] = g_signal_new ("dialogs_unhide",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, dialogs_unhide),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- inkscape_signals[EXTERNAL_CHANGE] = g_signal_new ("external_change",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (InkscapeApplicationClass, external_change),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- object_class->dispose = inkscape_dispose;
-
- klass->activate_desktop = inkscape_activate_desktop_private;
- klass->deactivate_desktop = inkscape_deactivate_desktop_private;
+ return Application::_S_inst != NULL;
}
-#ifdef WIN32
-typedef int uid_t;
-#define getuid() 0
-#endif
+/**
+ * Returns the current Inkscape::Application global object.
+ * \pre Application::_S_inst != NULL
+ */
+Application&
+Application::instance()
+{
+ if (!exists()) {
+ g_error("Inkscape::Application does not yet exist.");
+ }
+ return *Application::_S_inst;
+}
/**
* static gint inkscape_autosave(gpointer);
*
- * Callback passed to g_timeout_add_seconds()
* Responsible for autosaving all open documents
*/
-static gint inkscape_autosave(gpointer)
+int Application::autosave()
{
- if (inkscape->document_set.empty()) { // nothing to autosave
+ if (_document_set.empty()) { // nothing to autosave
return TRUE;
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -302,7 +238,7 @@ static gint inkscape_autosave(gpointer)
}
GDir *autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL);
- if( !autosave_dir_ptr ){
+ if (!autosave_dir_ptr) {
// Try to create the autosave directory if it doesn't exist
if (g_mkdir(autosave_dir.c_str(), 0755)) {
// the creation failed
@@ -333,8 +269,8 @@ static gint inkscape_autosave(gpointer)
gint docnum = 0;
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Autosaving documents..."));
- for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
- iter != inkscape->document_set.end();
+ for (std::map<SPDocument*,int>::iterator iter = _document_set.begin();
+ iter != _document_set.end();
++iter) {
SPDocument *doc = iter->first;
@@ -342,7 +278,6 @@ static gint inkscape_autosave(gpointer)
++docnum;
Inkscape::XML::Node *repr = doc->getReprRoot();
- // g_debug("Document %d: \"%s\" %s", docnum, doc ? doc->getName() : "(null)", doc ? (doc->isModifiedSinceSave() ? "(dirty)" : "(clean)") : "(null)");
if (doc->isModifiedSinceSave()) {
gchar *oldest_autosave = 0;
@@ -373,8 +308,6 @@ static gint inkscape_autosave(gpointer)
}
}
- // g_debug("%d previous autosaves exists. Max = %d", count, autosave_max);
-
// Have we reached the limit for number of autosaves?
if ( count >= autosave_max ){
// Remove the oldest file
@@ -396,8 +329,6 @@ static gint inkscape_autosave(gpointer)
g_free(baseName);
baseName = 0;
- // g_debug("Filename: %s", full_path);
-
// Try to save the file
FILE *file = Inkscape::IO::fopen_utf8name(full_path, "w");
gchar *errortext = 0;
@@ -435,7 +366,7 @@ static gint inkscape_autosave(gpointer)
return TRUE;
}
-void inkscape_autosave_init()
+void Application::autosave_init()
{
static guint32 autosave_timeout_id = 0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -446,139 +377,149 @@ void inkscape_autosave_init()
autosave_timeout_id = 0;
}
- // g_debug("options.autosave.enable = %d", prefs->getBool("/options/autosave/enable", true));
// Is autosave enabled?
if (!prefs->getBool("/options/autosave/enable", true)){
autosave_timeout_id = 0;
} else {
// Turn on autosave
guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60;
- // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10));
autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL);
}
}
-
-static void
-inkscape_init (InkscapeApplication * object)
+void Application::argv0(char const* argv)
{
- if (!inkscape) {
- inkscape = (InkscapeApplication *) object;
- } else {
- g_assert_not_reached ();
- }
-
- new (&inkscape->document_set) std::map<SPDocument *, int>();
- new (&inkscape->selection_models) std::map<SPDocument *, AppSelectionModel *>();
-
- inkscape->menus = NULL;
- inkscape->desktops = NULL;
- inkscape->dialogs_toggle = TRUE;
- inkscape->mapalt = GDK_MOD1_MASK;
- inkscape->trackalt = FALSE;
+ _argv0 = g_strdup(argv);
}
-static void
-inkscape_dispose (GObject *object)
+/* \brief Constructor for the application.
+ * Creates a new Inkscape::Application.
+ *
+ * \pre Application::_S_inst == NULL
+ */
+
+Application::Application(const char* argv, bool use_gui) :
+ _menus(NULL),
+ _desktops(NULL),
+ refCount(1),
+ _dialogs_toggle(TRUE),
+ _mapalt(GDK_MOD1_MASK),
+ _trackalt(FALSE),
+ _use_gui(use_gui)
{
- InkscapeApplication *inkscape = (InkscapeApplication *) object;
+ /* fixme: load application defaults */
- g_assert (!inkscape->desktops);
+ segv_handler = signal (SIGSEGV, Application::crash_handler);
+ abrt_handler = signal (SIGABRT, Application::crash_handler);
+ fpe_handler = signal (SIGFPE, Application::crash_handler);
+ ill_handler = signal (SIGILL, Application::crash_handler);
+#ifndef WIN32
+ bus_handler = signal (SIGBUS, Application::crash_handler);
+#endif
- Inkscape::Preferences::unload();
+ _argv0 = g_strdup(argv);
- if (inkscape->menus) {
- /* fixme: This is not the best place */
- Inkscape::GC::release(inkscape->menus);
- inkscape->menus = NULL;
- }
+ // \TODO: this belongs to Application::init but if it isn't here
+ // then the Filters and Extensions menus don't work.
+ _S_inst = this;
- inkscape->selection_models.~map();
- inkscape->document_set.~map();
+ /* Load the preferences and menus */
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ InkErrorHandler* handler = new InkErrorHandler(use_gui);
+ prefs->setErrorHandler(handler);
+ {
+ Glib::ustring msg;
+ Glib::ustring secondary;
+ if (prefs->getLastError( msg, secondary )) {
+ handler->handleError(msg, secondary);
+ }
+ }
- G_OBJECT_CLASS (inkscape_parent_class)->dispose (object);
+ if (use_gui) {
+ load_menus();
+ Inkscape::DeviceManager::getManager().loadConfig();
+ }
+ Inkscape::ResourceManager::getManager();
- gtk_main_quit ();
-}
+ /* set language for user interface according setting in preferences */
+ Glib::ustring ui_language = prefs->getString("/ui/language");
+ if(!ui_language.empty())
+ {
+ setenv("LANGUAGE", ui_language, 1);
+ }
+ /* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON.
+ * Use only if use_gui is enabled
+ */
+#ifdef WIN32
+#define DEFAULT_LOG_REDIRECT true
+#else
+#define DEFAULT_LOG_REDIRECT false
+#endif
-void
-inkscape_ref (void)
-{
- if (inkscape)
- g_object_ref (G_OBJECT (inkscape));
-}
+ if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT))
+ {
+ Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages();
+ }
+ /* Check for global remapping of Alt key */
+ if (use_gui)
+ {
+ mapalt(guint(prefs->getInt("/options/mapalt/value", 0)));
+ trackalt(guint(prefs->getInt("/options/trackalt/value", 0)));
+ }
-void
-inkscape_unref (void)
-{
- if (inkscape)
- g_object_unref (G_OBJECT (inkscape));
-}
+ /* Initialize the extensions */
+ Inkscape::Extension::init();
-/* returns the mask of the keyboard modifier to map to Alt, zero if no mapping */
-/* Needs to be a guint because gdktypes.h does not define a 'no-modifier' value */
-guint
-inkscape_mapalt() {
- return inkscape->mapalt;
+ autosave_init();
}
-/* Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default */
-void inkscape_mapalt(guint maskvalue)
+Application::~Application()
{
- if(maskvalue<2 || maskvalue> 5 ){ /* MOD5 is the highest defined in gdktypes.h */
- inkscape->mapalt=0;
- }else{
- inkscape->mapalt=(GDK_MOD1_MASK << (maskvalue-1));
+ if (_desktops) {
+ g_error("FATAL: desktops still in list on application destruction!");
}
-}
-guint
-inkscape_trackalt() {
- return inkscape->trackalt;
-}
-
-void inkscape_trackalt(guint trackvalue)
-{
- inkscape->trackalt = trackvalue;
-}
+ Inkscape::Preferences::unload();
+ if (_menus) {
+ Inkscape::GC::release(_menus);
+ _menus = NULL;
+ }
-static void
-inkscape_activate_desktop_private (InkscapeApplication */*inkscape*/, SPDesktop *desktop)
-{
- desktop->set_active (true);
-}
+ if (_argv0) {
+ g_free(_argv0);
+ _argv0 = NULL;
+ }
+ _S_inst = NULL; // this will probably break things
-static void
-inkscape_deactivate_desktop_private (InkscapeApplication */*inkscape*/, SPDesktop *desktop)
-{
- desktop->set_active (false);
+ refCount = 0;
+ gtk_main_quit ();
}
-
-/* fixme: This is EVIL, and belongs to main after all */
-
-#define SP_INDENT 8
-
-
-static bool crashIsHappening = false;
-
-bool inkscapeIsCrashing()
+/** Sets the keyboard modifer to map to Alt.
+ *
+ * Zero switches off mapping, as does '1', which is the default.
+ */
+void Application::mapalt(guint maskvalue)
{
- return crashIsHappening;
+ if ( maskvalue < 2 || maskvalue > 5 ) { // MOD5 is the highest defined in gdktypes.h
+ _mapalt = 0;
+ } else {
+ _mapalt = (GDK_MOD1_MASK << (maskvalue-1));
+ }
}
-static void
-inkscape_crash_handler (int /*signum*/)
+void
+Application::crash_handler (int /*signum*/)
{
using Inkscape::Debug::SimpleEvent;
using Inkscape::Debug::EventTracker;
using Inkscape::Debug::Logger;
- static gint recursion = FALSE;
+ static bool recursion = false;
/*
* reset all signal handlers: any further crashes should just be allowed
@@ -596,9 +537,9 @@ inkscape_crash_handler (int /*signum*/)
if (recursion) {
abort ();
}
- recursion = TRUE;
+ recursion = true;
- crashIsHappening = true;
+ _crashIsHappening = true;
EventTracker<SimpleEvent<Inkscape::Debug::Event::CORE> > tracker("crash");
tracker.set<SimpleEvent<> >("emergency-save");
@@ -612,11 +553,11 @@ inkscape_crash_handler (int /*signum*/)
gint count = 0;
gchar *curdir = g_get_current_dir(); // This one needs to be freed explicitly
- gchar *inkscapedir = g_path_get_dirname(INKSCAPE->argv0); // Needs to be freed
+ gchar *inkscapedir = g_path_get_dirname(INKSCAPE._argv0); // Needs to be freed
GSList *savednames = NULL;
GSList *failednames = NULL;
- for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
- iter != inkscape->document_set.end();
+ for (std::map<SPDocument*,int>::iterator iter = INKSCAPE._document_set.begin(), e = INKSCAPE._document_set.end();
+ iter != e;
++iter) {
SPDocument *doc = iter->first;
Inkscape::XML::Node *repr;
@@ -757,7 +698,7 @@ inkscape_crash_handler (int /*signum*/)
}
*(b + pos) = '\0';
- if ( inkscape_get_instance() && inkscape_use_gui() ) {
+ if ( exists() && instance().use_gui() ) {
GtkWidget *msgbox = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", b);
gtk_dialog_run (GTK_DIALOG (msgbox));
gtk_widget_destroy (msgbox);
@@ -774,132 +715,19 @@ inkscape_crash_handler (int /*signum*/)
/* on exit, allow restored signal handler to take over and crash us */
}
-
-class InkErrorHandler : public Inkscape::ErrorReporter {
-public:
- InkErrorHandler(bool useGui) : Inkscape::ErrorReporter(),
- _useGui(useGui)
- {}
- virtual ~InkErrorHandler() {}
-
- virtual void handleError( Glib::ustring const& primary, Glib::ustring const& secondary ) const
- {
- if (_useGui) {
- Gtk::MessageDialog err(primary, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
- err.set_secondary_text(secondary);
- err.run();
- } else {
- g_message("%s", primary.data());
- g_message("%s", secondary.data());
- }
- }
-
-private:
- bool _useGui;
-};
-
-void
-inkscape_application_init (const gchar *argv0, gboolean use_gui)
-{
- inkscape = (InkscapeApplication *)g_object_new (SP_TYPE_INKSCAPE, NULL);
- /* fixme: load application defaults */
-
- segv_handler = signal (SIGSEGV, inkscape_crash_handler);
- abrt_handler = signal (SIGABRT, inkscape_crash_handler);
- fpe_handler = signal (SIGFPE, inkscape_crash_handler);
- ill_handler = signal (SIGILL, inkscape_crash_handler);
-#ifndef WIN32
- bus_handler = signal (SIGBUS, inkscape_crash_handler);
-#endif
-
- inkscape->use_gui = use_gui;
- inkscape->argv0 = g_strdup(argv0);
-
- /* Load the preferences and menus */
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- InkErrorHandler* handler = new InkErrorHandler(use_gui);
- prefs->setErrorHandler(handler);
- {
- Glib::ustring msg;
- Glib::ustring secondary;
- if (prefs->getLastError( msg, secondary )) {
- handler->handleError(msg, secondary);
- }
- }
-
- if (use_gui) {
- inkscape_load_menus(inkscape);
- Inkscape::DeviceManager::getManager().loadConfig();
- }
- Inkscape::ResourceManager::getManager();
-
- /* set language for user interface according setting in preferences */
- Glib::ustring ui_language = prefs->getString("/ui/language");
- if(!ui_language.empty())
- {
- setenv("LANGUAGE", ui_language, 1);
- }
-
- /* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON.
- * Use only if use_gui is enabled
- */
-#ifdef WIN32
-#define DEFAULT_LOG_REDIRECT true
-#else
-#define DEFAULT_LOG_REDIRECT false
-#endif
-
- if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT))
- {
- Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages();
- }
-
- /* Check for global remapping of Alt key */
- if (use_gui)
- {
- inkscape_mapalt(guint(prefs->getInt("/options/mapalt/value", 0)));
- inkscape_trackalt(guint(prefs->getInt("/options/trackalt/value", 0)));
- }
-
- /* Initialize the extensions */
- Inkscape::Extension::init();
-
- inkscape_autosave_init();
-
- return;
-}
-
-/**
- * Returns the current InkscapeApplication global object
- */
-InkscapeApplication *
-inkscape_get_instance()
-{
- return inkscape;
-}
-
-gboolean inkscape_use_gui()
-{
- return inkscape_get_instance()->use_gui;
-}
-
/**
* Menus management
*
*/
-bool inkscape_load_menus( InkscapeApplication * inkscape )
+bool Application::load_menus()
{
gchar *fn = profile_path(MENUS_FILE);
gchar *menus_xml = 0;
gsize len = 0;
- if ( inkscape != inkscape_get_instance() ) {
- g_warning("BAD BAD BAD THINGS");
- }
-
if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) {
// load the menus_xml file
- inkscape->menus = sp_repr_read_mem(menus_xml, len, NULL);
+ _menus = sp_repr_read_mem(menus_xml, len, NULL);
g_free(menus_xml);
menus_xml = 0;
@@ -907,146 +735,157 @@ bool inkscape_load_menus( InkscapeApplication * inkscape )
g_free(fn);
fn = 0;
- if ( !inkscape->menus ) {
- inkscape->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL);
+ if ( !_menus ) {
+ _menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL);
}
- return (inkscape->menus != NULL);
+ return (_menus != 0);
}
void
-inkscape_selection_modified (Inkscape::Selection *selection, guint flags)
+Application::selection_modified (Inkscape::Selection *selection, guint flags)
{
g_return_if_fail (selection != NULL);
if (DESKTOP_IS_ACTIVE (selection->desktop())) {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[MODIFY_SELECTION], 0, selection, flags);
+ signal_selection_modified.emit(selection, flags);
}
}
void
-inkscape_selection_changed (Inkscape::Selection * selection)
+Application::selection_changed (Inkscape::Selection * selection)
{
g_return_if_fail (selection != NULL);
-
+
if (DESKTOP_IS_ACTIVE (selection->desktop())) {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection);
+ signal_selection_changed.emit(selection);
}
}
void
-inkscape_subselection_changed (SPDesktop *desktop)
+Application::subselection_changed (SPDesktop *desktop)
{
g_return_if_fail (desktop != NULL);
if (DESKTOP_IS_ACTIVE (desktop)) {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SUBSELECTION], 0, desktop);
+ signal_subselection_changed.emit(desktop);
}
}
void
-inkscape_selection_set (Inkscape::Selection * selection)
+Application::selection_set (Inkscape::Selection * selection)
{
g_return_if_fail (selection != NULL);
if (DESKTOP_IS_ACTIVE (selection->desktop())) {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, selection);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection);
+ signal_selection_set.emit(selection);
+ signal_selection_changed.emit(selection);
}
}
void
-inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext)
+Application::eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext)
{
g_return_if_fail (eventcontext != NULL);
g_return_if_fail (SP_IS_EVENT_CONTEXT (eventcontext));
if (DESKTOP_IS_ACTIVE (eventcontext->desktop)) {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, eventcontext);
+ signal_eventcontext_set.emit(eventcontext);
}
}
void
-inkscape_add_desktop (SPDesktop * desktop)
+Application::add_desktop (SPDesktop * desktop)
{
g_return_if_fail (desktop != NULL);
- g_return_if_fail (inkscape != NULL);
+ if (_desktops == NULL) {
+ _desktops = new std::vector<SPDesktop*>;
+ }
- g_assert (!g_slist_find (inkscape->desktops, desktop));
+ if (std::find(_desktops->begin(), _desktops->end(), desktop) != _desktops->end()) {
+ g_error("Attempted to add desktop already in list.");
+ }
- inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop);
+ _desktops->insert(_desktops->begin(), desktop);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext());
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop));
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop));
+ signal_activate_desktop.emit(desktop);
+ signal_eventcontext_set.emit(desktop->getEventContext());
+ signal_selection_set.emit(sp_desktop_selection(desktop));
+ signal_selection_changed.emit(sp_desktop_selection(desktop));
}
void
-inkscape_remove_desktop (SPDesktop * desktop)
+Application::remove_desktop (SPDesktop * desktop)
{
g_return_if_fail (desktop != NULL);
- g_return_if_fail (inkscape != NULL);
- g_assert (g_slist_find (inkscape->desktops, desktop));
+ if (std::find (_desktops->begin(), _desktops->end(), desktop) == _desktops->end() ) {
+ g_error("Attempted to remove desktop not in list.");
+ }
if (DESKTOP_IS_ACTIVE (desktop)) {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, desktop);
- if (inkscape->desktops->next != NULL) {
- SPDesktop * new_desktop = static_cast<SPDesktop *>(inkscape->desktops->next->data);
- inkscape->desktops = g_slist_remove (inkscape->desktops, new_desktop);
- inkscape->desktops = g_slist_prepend (inkscape->desktops, new_desktop);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, new_desktop);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, new_desktop->getEventContext());
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (new_desktop));
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (new_desktop));
+ signal_deactivate_desktop.emit(desktop);
+ if (_desktops->size() > 1) {
+ SPDesktop * new_desktop = *(++_desktops->begin());
+ _desktops->erase(std::find(_desktops->begin(), _desktops->end(), new_desktop));
+ _desktops->insert(_desktops->begin(), new_desktop);
+
+ signal_activate_desktop.emit(new_desktop);
+ signal_eventcontext_set.emit(new_desktop->getEventContext());
+ signal_selection_set.emit(sp_desktop_selection(new_desktop));
+ signal_selection_changed.emit(sp_desktop_selection(new_desktop));
} else {
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL);
+ signal_eventcontext_set.emit(NULL);
if (sp_desktop_selection(desktop))
sp_desktop_selection(desktop)->clear();
}
}
- inkscape->desktops = g_slist_remove (inkscape->desktops, desktop);
+ _desktops->erase(std::find(_desktops->begin(), _desktops->end(), desktop));
// if this was the last desktop, shut down the program
- if (inkscape->desktops == NULL) {
- inkscape_exit (inkscape);
+ if (_desktops->empty()) {
+ this->exit();
+ delete _desktops;
+ _desktops = NULL;
}
}
void
-inkscape_activate_desktop (SPDesktop * desktop)
+Application::activate_desktop (SPDesktop * desktop)
{
g_return_if_fail (desktop != NULL);
- g_return_if_fail (inkscape != NULL);
if (DESKTOP_IS_ACTIVE (desktop)) {
return;
}
- g_assert (g_slist_find (inkscape->desktops, desktop));
+ std::vector<SPDesktop*>::iterator i;
+
+ if ((i = std::find (_desktops->begin(), _desktops->end(), desktop)) == _desktops->end()) {
+ g_error("Tried to activate desktop not added to list.");
+ }
- SPDesktop *current = static_cast<SPDesktop *>(inkscape->desktops->data);
+ SPDesktop *current = _desktops->front();
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current);
+ signal_deactivate_desktop.emit(current);
- inkscape->desktops = g_slist_remove (inkscape->desktops, desktop);
- inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop);
+ _desktops->erase (i);
+ _desktops->insert (_desktops->begin(), desktop);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop);
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext());
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop));
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop));
+ signal_activate_desktop.emit(desktop);
+ signal_eventcontext_set.emit(desktop->getEventContext());
+ signal_selection_set(sp_desktop_selection(desktop));
+ signal_selection_changed(sp_desktop_selection(desktop));
}
@@ -1054,65 +893,62 @@ inkscape_activate_desktop (SPDesktop * desktop)
* Resends ACTIVATE_DESKTOP for current desktop; needed when a new desktop has got its window that dialogs will transientize to
*/
void
-inkscape_reactivate_desktop (SPDesktop * desktop)
+Application::reactivate_desktop (SPDesktop * desktop)
{
g_return_if_fail (desktop != NULL);
- g_return_if_fail (inkscape != NULL);
- if (DESKTOP_IS_ACTIVE (desktop))
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop);
+ if (DESKTOP_IS_ACTIVE (desktop)) {
+ signal_activate_desktop.emit(desktop);
+ }
}
SPDesktop *
-inkscape_find_desktop_by_dkey (unsigned int dkey)
+Application::find_desktop_by_dkey (unsigned int dkey)
{
- for (GSList *r = inkscape->desktops; r; r = r->next) {
- if ((static_cast<SPDesktop *>(r->data))->dkey == dkey){
- return (static_cast<SPDesktop *>(r->data));
+ for (std::vector<SPDesktop*>::iterator r = _desktops->begin(), e = _desktops->end(); r != e; ++r) {
+ if ((*r)->dkey == dkey){
+ return *r;
}
}
return NULL;
}
-
-
-static unsigned int
-inkscape_maximum_dkey()
+unsigned int
+Application::maximum_dkey()
{
unsigned int dkey = 0;
- for (GSList *r = inkscape->desktops; r; r = r->next) {
- if ((static_cast<SPDesktop *>(r->data))->dkey > dkey){
- dkey = (static_cast<SPDesktop *>(r->data))->dkey;
+ for (std::vector<SPDesktop*>::iterator r = _desktops->begin(), e = _desktops->end(); r != e; ++r) {
+ if ((*r)->dkey > dkey){
+ dkey = (*r)->dkey;
}
}
-
return dkey;
}
-static SPDesktop *
-inkscape_next_desktop ()
+SPDesktop *
+Application::next_desktop ()
{
SPDesktop *d = NULL;
- unsigned int dkey_current = (static_cast<SPDesktop *>(inkscape->desktops->data))->dkey;
+ unsigned int dkey_current = (_desktops->front())->dkey;
- if (dkey_current < inkscape_maximum_dkey()) {
+ if (dkey_current < maximum_dkey()) {
// find next existing
- for (unsigned int i = dkey_current + 1; i <= inkscape_maximum_dkey(); i++) {
- d = inkscape_find_desktop_by_dkey (i);
+ for (unsigned int i = dkey_current + 1; i <= maximum_dkey(); ++i) {
+ d = find_desktop_by_dkey (i);
if (d) {
break;
}
}
} else {
// find first existing
- for (unsigned int i = 0; i <= inkscape_maximum_dkey(); i++) {
- d = inkscape_find_desktop_by_dkey (i);
+ for (unsigned int i = 0; i <= maximum_dkey(); ++i) {
+ d = find_desktop_by_dkey (i);
if (d) {
break;
}
@@ -1120,22 +956,21 @@ inkscape_next_desktop ()
}
g_assert (d);
-
return d;
}
-static SPDesktop *
-inkscape_prev_desktop ()
+SPDesktop *
+Application::prev_desktop ()
{
SPDesktop *d = NULL;
- unsigned int dkey_current = (static_cast<SPDesktop *>(inkscape->desktops->data))->dkey;
+ unsigned int dkey_current = (_desktops->front())->dkey;
if (dkey_current > 0) {
// find prev existing
- for (signed int i = dkey_current - 1; i >= 0; i--) {
- d = inkscape_find_desktop_by_dkey (i);
+ for (signed int i = dkey_current - 1; i >= 0; --i) {
+ d = find_desktop_by_dkey (i);
if (d) {
break;
}
@@ -1143,81 +978,74 @@ inkscape_prev_desktop ()
}
if (!d) {
// find last existing
- d = inkscape_find_desktop_by_dkey (inkscape_maximum_dkey());
+ d = find_desktop_by_dkey (maximum_dkey());
}
g_assert (d);
-
return d;
}
void
-inkscape_switch_desktops_next ()
+Application::switch_desktops_next ()
{
- inkscape_next_desktop()->presentWindow();
+ next_desktop()->presentWindow();
}
-
-
void
-inkscape_switch_desktops_prev ()
+Application::switch_desktops_prev()
{
- inkscape_prev_desktop()->presentWindow();
+ prev_desktop()->presentWindow();
}
-
-
void
-inkscape_dialogs_hide ()
+Application::dialogs_hide()
{
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0);
- inkscape->dialogs_toggle = FALSE;
+ signal_dialogs_hide.emit();
+ _dialogs_toggle = false;
}
void
-inkscape_dialogs_unhide ()
+Application::dialogs_unhide()
{
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0);
- inkscape->dialogs_toggle = TRUE;
+ signal_dialogs_unhide.emit();
+ _dialogs_toggle = true;
}
void
-inkscape_dialogs_toggle ()
+Application::dialogs_toggle()
{
- if (inkscape->dialogs_toggle) {
- inkscape_dialogs_hide ();
+ if (_dialogs_toggle) {
+ dialogs_hide();
} else {
- inkscape_dialogs_unhide ();
+ dialogs_unhide();
}
}
void
-inkscape_external_change ()
+Application::external_change()
{
- g_return_if_fail (inkscape != NULL);
-
- g_signal_emit (G_OBJECT (inkscape), inkscape_signals[EXTERNAL_CHANGE], 0);
+ signal_external_change.emit();
}
/**
* fixme: These need probably signals too
*/
void
-inkscape_add_document (SPDocument *document)
+Application::add_document (SPDocument *document)
{
g_return_if_fail (document != NULL);
// try to insert the pair into the list
- if (!(inkscape->document_set.insert(std::make_pair(document, 1)).second)) {
+ if (!(_document_set.insert(std::make_pair(document, 1)).second)) {
//insert failed, this key (document) is already in the list
- for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
- iter != inkscape->document_set.end();
+ for (std::map<SPDocument*,int>::iterator iter = _document_set.begin();
+ iter != _document_set.end();
++iter) {
if (iter->first == document) {
// found this document in list, increase its count
@@ -1227,10 +1055,10 @@ inkscape_add_document (SPDocument *document)
} else {
// insert succeeded, this document is new. Do we need to create a
// selection model for it, i.e. are we running without a desktop?
- if (!inkscape->use_gui) {
+ if (!_use_gui) {
// Create layer model and selection model so we can run some verbs without a GUI
- g_assert(inkscape->selection_models.find(document) == inkscape->selection_models.end());
- inkscape->selection_models[document] = new AppSelectionModel(document);
+ g_assert(_selection_models.find(document) == _selection_models.end());
+ _selection_models[document] = new AppSelectionModel(document);
}
}
}
@@ -1238,24 +1066,24 @@ inkscape_add_document (SPDocument *document)
// returns true if this was last reference to this document, so you can delete it
bool
-inkscape_remove_document (SPDocument *document)
+Application::remove_document (SPDocument *document)
{
g_return_val_if_fail (document != NULL, false);
- for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
- iter != inkscape->document_set.end();
+ for (std::map<SPDocument *,int>::iterator iter = _document_set.begin();
+ iter != _document_set.end();
++iter) {
if (iter->first == document) {
// found this document in list, decrease its count
iter->second --;
if (iter->second < 1) {
// this was the last one, remove the pair from list
- inkscape->document_set.erase (iter);
+ _document_set.erase (iter);
// also remove the selection model
- std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = inkscape->selection_models.find(document);
- if (sel_iter != inkscape->selection_models.end()) {
- inkscape->selection_models.erase(sel_iter);
+ std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = _selection_models.find(document);
+ if (sel_iter != _selection_models.end()) {
+ _selection_models.erase(sel_iter);
}
return true;
@@ -1269,37 +1097,38 @@ inkscape_remove_document (SPDocument *document)
}
SPDesktop *
-inkscape_active_desktop (void)
+Application::active_desktop()
{
- if (inkscape->desktops == NULL) {
+ if (!_desktops || _desktops->empty()) {
return NULL;
}
- return static_cast<SPDesktop *>(inkscape->desktops->data);
+ return _desktops->front();
}
SPDocument *
-inkscape_active_document (void)
+Application::active_document()
{
if (SP_ACTIVE_DESKTOP) {
return sp_desktop_document (SP_ACTIVE_DESKTOP);
- } else if (!inkscape->document_set.empty()) {
+ } else if (!_document_set.empty()) {
// If called from the command line there will be no desktop
// So 'fall back' to take the first listed document in the Inkscape instance
- return inkscape->document_set.begin()->first;
+ return _document_set.begin()->first;
}
return NULL;
}
-bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop) {
+bool
+Application::sole_desktop_for_document(SPDesktop const &desktop) {
SPDocument const* document = desktop.doc();
if (!document) {
return false;
}
- for ( GSList *iter = inkscape->desktops ; iter ; iter = iter->next ) {
- SPDesktop *other_desktop=static_cast<SPDesktop *>(iter->data);
- SPDocument *other_document=other_desktop->doc();
+ for ( std::vector<SPDesktop*>::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e; ++iter ) {
+ SPDesktop *other_desktop = *iter;
+ SPDocument *other_document = other_desktop->doc();
if ( other_document == document && other_desktop != &desktop ) {
return false;
}
@@ -1308,7 +1137,7 @@ bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop) {
}
Inkscape::UI::Tools::ToolBase *
-inkscape_active_event_context (void)
+Application::active_event_context (void)
{
if (SP_ACTIVE_DESKTOP) {
return SP_ACTIVE_DESKTOP->getEventContext();
@@ -1318,34 +1147,36 @@ inkscape_active_event_context (void)
}
Inkscape::ActionContext
-inkscape_active_action_context()
+Application::active_action_context()
{
if (SP_ACTIVE_DESKTOP) {
return Inkscape::ActionContext(SP_ACTIVE_DESKTOP);
}
- SPDocument *doc = inkscape_active_document();
+ SPDocument *doc = active_document();
if (!doc) {
return Inkscape::ActionContext();
}
- return inkscape_action_context_for_document(doc);
+ return action_context_for_document(doc);
}
Inkscape::ActionContext
-inkscape_action_context_for_document(SPDocument *doc)
+Application::action_context_for_document(SPDocument *doc)
{
// If there are desktops, check them first to see if the document is bound to one of them
- for (GSList *iter = inkscape->desktops ; iter ; iter = iter->next) {
- SPDesktop *desktop=static_cast<SPDesktop *>(iter->data);
- if (desktop->doc() == doc) {
- return Inkscape::ActionContext(desktop);
+ if (_desktops != NULL) {
+ for (std::vector<SPDesktop*>::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e ; ++iter) {
+ SPDesktop *desktop = *iter;
+ if (desktop->doc() == doc) {
+ return Inkscape::ActionContext(desktop);
+ }
}
}
// Document is not associated with any desktops - maybe we're in command-line mode
- std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = inkscape->selection_models.find(doc);
- if (sel_iter == inkscape->selection_models.end()) {
+ std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = _selection_models.find(doc);
+ if (sel_iter == _selection_models.end()) {
return Inkscape::ActionContext();
}
return Inkscape::ActionContext(sel_iter->second->getSelection());
@@ -1357,10 +1188,10 @@ inkscape_action_context_for_document(SPDocument *doc)
#####################*/
void
-inkscape_refresh_display (InkscapeApplication *inkscape)
+Application::refresh_display ()
{
- for (GSList *l = inkscape->desktops; l != NULL; l = l->next) {
- (static_cast<Inkscape::UI::View::View*>(l->data))->requestRedraw();
+ for (std::vector<SPDesktop*>::iterator l = _desktops->begin(), e = _desktops->end(); l != e; ++l) {
+ (*l)->requestRedraw();
}
}
@@ -1370,26 +1201,26 @@ inkscape_refresh_display (InkscapeApplication *inkscape)
* saves the preferences if appropriate, and quits.
*/
void
-inkscape_exit (InkscapeApplication */*inkscape*/)
+Application::exit ()
{
- g_assert (INKSCAPE);
-
//emit shutdown signal so that dialogs could remember layout
- g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0);
+ signal_shut_down.emit();
Inkscape::Preferences::unload();
gtk_main_quit ();
}
char *
-homedir_path(const char *filename)
+Application::homedir_path(const char *filename)
{
static const gchar *homedir = NULL;
if (!homedir) {
homedir = g_get_home_dir();
}
if (!homedir) {
- homedir = g_path_get_dirname(INKSCAPE->argv0);
+ if (Application::exists()) {
+ homedir = g_path_get_dirname(Application::instance()._argv0);
+ }
}
return g_build_filename(homedir, filename, NULL);
}
@@ -1400,7 +1231,7 @@ homedir_path(const char *filename)
* file should be located.
*/
gchar *
-profile_path(const char *filename)
+Application::profile_path(const char *filename)
{
static const gchar *prefdir = NULL;
@@ -1512,21 +1343,21 @@ profile_path(const char *filename)
}
Inkscape::XML::Node *
-inkscape_get_menus (InkscapeApplication * inkscape)
+Application::get_menus()
{
- Inkscape::XML::Node *repr = inkscape->menus->root();
+ Inkscape::XML::Node *repr = _menus->root();
g_assert (!(strcmp (repr->name(), "inkscape")));
return repr->firstChild();
}
void
-inkscape_get_all_desktops(std::list< SPDesktop* >& listbuf)
+Application::get_all_desktops(std::list< SPDesktop* >& listbuf)
{
- for(GSList* l = inkscape->desktops; l != NULL; l = l->next) {
- listbuf.push_back(static_cast< SPDesktop* >(l->data));
- }
+ listbuf.insert(listbuf.end(), _desktops->begin(), _desktops->end());
}
+} // namespace Inkscape
+
/*
Local Variables:
mode:c++
diff --git a/src/inkscape.h b/src/inkscape.h
index 3a9b85fc9..fe424377c 100644
--- a/src/inkscape.h
+++ b/src/inkscape.h
@@ -6,116 +6,220 @@
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Liam P. White <inkscapebrony@gmail.com>
*
- * Copyright (C) 1999-2003 Authors
+ * Copyright (C) 1999-2014 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <list>
+#include <map>
+#include <vector>
#include <glib.h>
+#include <glib-object.h>
+#include <sigc++/signal.h>
+#include "layer-model.h"
+#include "selection.h"
class SPDesktop;
class SPDocument;
+struct SPColor;
namespace Inkscape {
+
+class Application;
namespace UI {
namespace Tools {
class ToolBase;
-}
-}
-}
-
-struct InkscapeApplication;
-
-namespace Inkscape {
- class ActionContext;
- namespace XML {
- class Node;
- struct Document;
- }
-}
-
-#define INKSCAPE inkscape_get_instance()
-
-void inkscape_autosave_init();
-
-void inkscape_application_init (const gchar *argv0, gboolean use_gui);
-
-bool inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton, unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml, const gchar *e_notsp, const gchar *warn);
-
-/* Menus */
-bool inkscape_load_menus (InkscapeApplication * inkscape);
-bool inkscape_save_menus (InkscapeApplication * inkscape);
-Inkscape::XML::Node *inkscape_get_menus (InkscapeApplication * inkscape);
-
-InkscapeApplication *inkscape_get_instance();
-gboolean inkscape_use_gui();
-
-bool inkscapeIsCrashing();
+} // namespace Tools
+} // namespace UI
-SPDesktop * inkscape_find_desktop_by_dkey (unsigned int dkey);
+class ActionContext;
-#define SP_ACTIVE_EVENTCONTEXT inkscape_active_event_context ()
-Inkscape::UI::Tools::ToolBase * inkscape_active_event_context (void);
+namespace XML {
+class Node;
+struct Document;
+} // namespace XML
-#define SP_ACTIVE_DOCUMENT inkscape_active_document ()
-SPDocument * inkscape_active_document (void);
+} // namespace Inkscape
-#define SP_ACTIVE_DESKTOP inkscape_active_desktop ()
-SPDesktop * inkscape_active_desktop (void);
+void inkscape_ref (Inkscape::Application & in);
+void inkscape_unref(Inkscape::Application & in);
-// Use this function to get selection model etc for a document, if possible!
-// The "active" alternative below has all the horrible static cling of a singleton.
-Inkscape::ActionContext
-inkscape_action_context_for_document(SPDocument *doc);
+#define INKSCAPE (Inkscape::Application::instance())
+#define SP_ACTIVE_EVENTCONTEXT (INKSCAPE.active_event_context())
+#define SP_ACTIVE_DOCUMENT (INKSCAPE.active_document())
+#define SP_ACTIVE_DESKTOP (INKSCAPE.active_desktop())
-// More horrible static cling... sorry about this. Should really replace all of
-// the static stuff with a single instance of some kind of engine class holding
-// all the document / non-GUI stuff, and an optional GUI class that behaves a
-// bit like SPDesktop does currently. Then it will be easier to write good code
-// that doesn't just expect a GUI all the time (like lots of the app currently
-// does).
-// Also, while the "active" document / desktop concepts are convenient, they
-// appear to have been abused somewhat, further increasing static cling.
-Inkscape::ActionContext inkscape_active_action_context();
+class AppSelectionModel {
+ Inkscape::LayerModel _layer_model;
+ Inkscape::Selection *_selection;
-bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop);
+public:
+ AppSelectionModel(SPDocument *doc) {
+ _layer_model.setDocument(doc);
+ // TODO: is this really how we should manage the lifetime of the selection?
+ // I just copied this from the initialization of the Selection in SPDesktop.
+ // When and how is it actually released?
+ _selection = Inkscape::GC::release(new Inkscape::Selection(&_layer_model, NULL));
+ }
-gchar *homedir_path(const char *filename);
-gchar *profile_path(const char *filename);
+ Inkscape::Selection *getSelection() const { return _selection; }
+};
-/* Inkscape desktop stuff */
-void inkscape_activate_desktop (SPDesktop * desktop);
-void inkscape_switch_desktops_next ();
-void inkscape_switch_desktops_prev ();
-void inkscape_get_all_desktops (std::list< SPDesktop* >& listbuf);
-
-void inkscape_dialogs_hide ();
-void inkscape_dialogs_unhide ();
-void inkscape_dialogs_toggle ();
-
-void inkscape_external_change ();
-void inkscape_subselection_changed (SPDesktop *desktop);
-
-/* Moved document add/remove functions into public inkscape.h as they are used
- (rightly or wrongly) by console-mode functions */
-void inkscape_add_document (SPDocument *document);
-bool inkscape_remove_document (SPDocument *document);
-
-/*
- * fixme: This has to be rethought
- */
-
-void inkscape_refresh_display (InkscapeApplication *inkscape);
-
-/*
- * fixme: This also
- */
+namespace Inkscape {
-void inkscape_exit (InkscapeApplication *inkscape);
+class Application {
+public:
+ static Application& instance();
+ static bool exists();
+ static void create(const char* argv0, bool use_gui);
+
+ // returns the mask of the keyboard modifier to map to Alt, zero if no mapping
+ // Needs to be a guint because gdktypes.h does not define a 'no-modifier' value
+ guint mapalt() const { return _mapalt; }
+
+ // Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default
+ void mapalt(guint maskvalue);
+
+ guint trackalt() const { return _trackalt; }
+ void trackalt(guint trackvalue) { _trackalt = trackvalue; }
+
+ bool use_gui() const { return _use_gui; }
+ void use_gui(gboolean guival) { _use_gui = guival; }
+
+ char const* argv0() const { return _argv0; }
+ void argv0(char const *);
+
+ // no setter for this -- only we can control this variable
+ static bool isCrashing() { return _crashIsHappening; }
+
+ // useful functions
+ void autosave_init();
+ void application_init (const gchar *argv0, gboolean use_gui);
+ void load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton,
+ unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml,
+ const gchar *e_notsp, const gchar *warn);
+
+ bool load_menus();
+ bool save_menus();
+ Inkscape::XML::Node * get_menus();
+
+ Inkscape::UI::Tools::ToolBase * active_event_context();
+ SPDocument * active_document();
+ SPDesktop * active_desktop();
+
+ // Use this function to get selection model etc for a document
+ Inkscape::ActionContext action_context_for_document(SPDocument *doc);
+ Inkscape::ActionContext active_action_context();
+
+ bool sole_desktop_for_document(SPDesktop const &desktop);
+
+ // Inkscape desktop stuff
+ void add_desktop(SPDesktop * desktop);
+ void remove_desktop(SPDesktop* desktop);
+ void activate_desktop (SPDesktop * desktop);
+ void switch_desktops_next ();
+ void switch_desktops_prev ();
+ void get_all_desktops (std::list< SPDesktop* >& listbuf);
+ void reactivate_desktop (SPDesktop * desktop);
+ SPDesktop * find_desktop_by_dkey (unsigned int dkey);
+ unsigned int maximum_dkey();
+ SPDesktop * next_desktop ();
+ SPDesktop * prev_desktop ();
+
+ void dialogs_hide ();
+ void dialogs_unhide ();
+ void dialogs_toggle ();
+
+ void external_change ();
+ void selection_modified (Inkscape::Selection *selection, guint flags);
+ void selection_changed (Inkscape::Selection * selection);
+ void subselection_changed (SPDesktop *desktop);
+ void selection_set (Inkscape::Selection * selection);
+
+ void eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext);
+
+ // Moved document add/remove functions into public inkscape.h as they are used
+ // (rightly or wrongly) by console-mode functions
+ void add_document (SPDocument *document);
+ bool remove_document (SPDocument *document);
+
+ static char *homedir_path(const char *filename);
+ static char *profile_path(const char *filename);
+
+ // fixme: This has to be rethought
+ void refresh_display ();
+
+ // fixme: This also
+ void exit ();
+
+ static void crash_handler(int signum);
+
+ int autosave();
+
+ // nobody should be accessing our reference count, so it's made private.
+ friend void ::inkscape_ref (Application & in);
+ friend void ::inkscape_unref(Application & in);
+
+ // signals
+
+ // one of selections changed
+ sigc::signal<void, Inkscape::Selection *> signal_selection_changed;
+ // one of subselections (text selection, gradient handle, etc) changed
+ sigc::signal<void, SPDesktop *> signal_subselection_changed;
+ // one of selections modified
+ sigc::signal<void, Inkscape::Selection *, guint /*flags*/> signal_selection_modified;
+ // one of selections set
+ sigc::signal<void, Inkscape::Selection *> signal_selection_set;
+ // tool switched
+ sigc::signal<void, Inkscape::UI::Tools::ToolBase * /*eventcontext*/> signal_eventcontext_set;
+ // some desktop got focus
+ sigc::signal<void, SPDesktop *> signal_activate_desktop;
+ // some desktop lost focus
+ sigc::signal<void, SPDesktop *> signal_deactivate_desktop;
+
+ // these are orphaned signals (nothing emits them and nothing connects to them)
+ sigc::signal<void, SPDocument *> signal_destroy_document;
+ sigc::signal<void, SPColor *, double /*opacity*/> signal_color_set;
+
+ // inkscape is quitting
+ sigc::signal<void> signal_shut_down;
+ // user pressed F12
+ sigc::signal<void> signal_dialogs_hide;
+ // user pressed F12
+ sigc::signal<void> signal_dialogs_unhide;
+ // a document was changed by some external means (undo or XML editor); this
+ // may not be reflected by a selection change and thus needs a separate signal
+ sigc::signal<void> signal_external_change;
+
+private:
+ static Inkscape::Application * _S_inst;
+
+ Application(const char* argv0, bool use_gui);
+ ~Application();
+
+ Application(Application const&); // no copy
+ Application& operator=(Application const&); // no assign
+ Application* operator&() const; // no pointer access
+
+ Inkscape::XML::Document * _menus;
+ std::map<SPDocument *, int> _document_set;
+ std::map<SPDocument *, AppSelectionModel *> _selection_models;
+ std::vector<SPDesktop *> * _desktops;
+
+ unsigned refCount;
+ bool _dialogs_toggle;
+ guint _mapalt;
+ guint _trackalt;
+ char * _argv0;
+ static bool _crashIsHappening;
+ bool _use_gui;
+};
+
+} // namespace Inkscape
#endif
diff --git a/src/inkview.cpp b/src/inkview.cpp
index 2969bb140..0b7b4d35c 100644
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
@@ -60,9 +60,7 @@
#include "io/inkjar.h"
#endif
-#include "inkscape-private.h"
-
-InkscapeApplication *inkscape;
+#include "inkscape.h"
#include <iostream>
@@ -232,7 +230,8 @@ main (int argc, const char **argv)
ss.view = NULL;
ss.fullscreen = false;
- inkscape = (InkscapeApplication *)g_object_new (SP_TYPE_INKSCAPE, NULL);
+ Inkscape::Application::create(argv[0], true);
+ //Inkscape::Application &inkscape = Inkscape::Application::instance();
// starting at where the commandline options stopped parsing because
// we want all the files to be in the list
diff --git a/src/io/resource.cpp b/src/io/resource.cpp
index ac1c5f06b..501eab03b 100644
--- a/src/io/resource.cpp
+++ b/src/io/resource.cpp
@@ -73,7 +73,7 @@ Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
case TEMPLATES: name = "templates"; break;
default: return get_path(SYSTEM, type, filename);
}
- path = profile_path(name);
+ path = Inkscape::Application::profile_path(name);
} break;
}
diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp
index 566af8840..fe279ae19 100644
--- a/src/line-geometry.cpp
+++ b/src/line-geometry.cpp
@@ -201,7 +201,7 @@ boost::optional<Geom::Point> Line::intersection_with_viewbox (SPDesktop *desktop
void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba)
{
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
SPCanvasItem * canvas_pt = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRL,
"size", size,
"filled", 1,
@@ -214,7 +214,7 @@ void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba)
void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba)
{
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
SPCtrlLine *line = ControlManager::getManager().createControlLine(sp_desktop_controls(desktop), p1, p2);
line->setRgba32(rgba);
sp_canvas_item_show(line);
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index e49a15dd0..39420134b 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -476,7 +476,7 @@ void
Effect::doAcceptPathPreparations(SPLPEItem *lpeitem)
{
// switch to pen context
- SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop?
+ SPDesktop *desktop = INKSCAPE.active_desktop(); // TODO: Is there a better method to find the item's desktop?
if (!tools_isactive(desktop, TOOLS_FREEHAND_PEN)) {
tools_switch(desktop, TOOLS_FREEHAND_PEN);
}
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index c5390a0c9..2bed90139 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -367,6 +367,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue)
{
using Geom::X;
using Geom::Y;
+
if (curve->get_segment_count() < 1)
return;
// Make copy of old path as it is changed during processing
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index 956a001ad..03b37b51c 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -32,7 +32,7 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip,
value(default_value),
defvalue(default_value)
{
- SPDesktop *desktop = inkscape_active_desktop(); // FIXME: we shouldn't use this!
+ SPDesktop *desktop = INKSCAPE.active_desktop(); // FIXME: we shouldn't use this!
canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), "");
sp_canvastext_set_text (canvas_text, default_value.c_str());
sp_canvastext_set_coords (canvas_text, 0, 0);
diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp
index 6af616e34..216953f4f 100644
--- a/src/main-cmdlineact.cpp
+++ b/src/main-cmdlineact.cpp
@@ -82,7 +82,7 @@ CmdLineAction::doList (ActionContext const & context) {
bool
CmdLineAction::idle (void) {
std::list<SPDesktop *> desktops;
- inkscape_get_all_desktops(desktops);
+ INKSCAPE.get_all_desktops(desktops);
// We're going to assume one desktop per document, because no one
// should have had time to make more at this point.
diff --git a/src/main.cpp b/src/main.cpp
index 12ddb76e6..06c0d4873 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -74,7 +74,7 @@
#include "svg/svg-color.h"
#include "svg/stringstream.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "inkscape-version.h"
#include "sp-namedview.h"
@@ -933,9 +933,9 @@ guint get_group0_keyval(GdkEventKey const* event);
static void
snooper(GdkEvent *event, gpointer /*data*/) {
- if (inkscape_mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */
+ if (INKSCAPE.mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */
{
- GdkModifierType mapping=(GdkModifierType)inkscape_mapalt();
+ GdkModifierType mapping=(GdkModifierType)INKSCAPE.mapalt();
switch (event->type) {
case GDK_MOTION_NOTIFY:
if(event->motion.state & mapping) {
@@ -957,7 +957,7 @@ snooper(GdkEvent *event, gpointer /*data*/) {
}
}
- if (inkscape_trackalt()) {
+ if (INKSCAPE.trackalt()) {
// MacOS X with X11 has some problem with the default
// xmodmapping. A ~/.xmodmap solution does not work reliably due
// to the way we package our executable in a .app that can launch
@@ -1042,7 +1042,7 @@ sp_main_gui(int argc, char const **argv)
}
// Add our icon directory to the search path for icon theme lookups.
- gchar *usericondir = profile_path("icons");
+ gchar *usericondir = Inkscape::Application::profile_path("icons");
gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), usericondir);
gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_PIXMAPDIR);
g_free(usericondir);
@@ -1059,7 +1059,7 @@ sp_main_gui(int argc, char const **argv)
gboolean create_new = TRUE;
/// \todo FIXME BROKEN - non-UTF-8 sneaks in here.
- inkscape_application_init(argv[0], true);
+ Inkscape::Application::create(argv[0], true);
while (fl) {
if (sp_file_open((gchar *)fl->data,NULL)) {
@@ -1125,14 +1125,14 @@ static int sp_process_file_list(GSList *fl)
retVal++;
} else {
- inkscape_add_document(doc);
+ INKSCAPE.add_document(doc);
if (sp_vacuum_defs) {
doc->vacuumDocument();
}
// Execute command-line actions (selections and verbs) using our local models
- bool has_performed_actions = Inkscape::CmdLineAction::doList(inkscape_active_action_context());
+ bool has_performed_actions = Inkscape::CmdLineAction::doList(INKSCAPE.active_action_context());
#ifdef WITH_DBUS
// If we've been asked to listen for D-Bus messages, enter a main loop here
@@ -1221,7 +1221,7 @@ static int sp_process_file_list(GSList *fl)
do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id);
}
- inkscape_remove_document(doc);
+ INKSCAPE.remove_document(doc);
delete doc;
}
@@ -1335,7 +1335,7 @@ int sp_main_console(int argc, char const **argv)
exit(0);
}
- inkscape_application_init(argv[0], false);
+ Inkscape::Application::create(argv[0], false);
if (sp_shell) {
int retVal = sp_main_shell(argv[0]); // Run as interactive shell
diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index b10e5f23b..7abfd0782 100644
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
@@ -140,7 +140,7 @@ void Persp3D::set(unsigned key, gchar const *value) {
}
// FIXME: Is this the right place for resetting the draggers?
- Inkscape::UI::Tools::ToolBase *ec = inkscape_active_event_context();
+ Inkscape::UI::Tools::ToolBase *ec = INKSCAPE.active_event_context();
if (SP_IS_BOX3D_CONTEXT(ec)) {
Inkscape::UI::Tools::Box3dTool *bc = SP_BOX3D_CONTEXT(ec);
bc->_vpdrag->updateDraggers();
@@ -289,7 +289,7 @@ persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo) {
persp3d_update_box_reprs (persp);
persp->updateRepr(SP_OBJECT_WRITE_EXT);
if (set_undo) {
- DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+ DocumentUndo::done(sp_desktop_document(INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX,
_("Toggle vanishing point"));
}
}
@@ -300,7 +300,7 @@ persp3d_toggle_VPs (std::list<Persp3D *> p, Proj::Axis axis) {
for (std::list<Persp3D *>::iterator i = p.begin(); i != p.end(); ++i) {
persp3d_toggle_VP((*i), axis, false);
}
- DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+ DocumentUndo::done(sp_desktop_document(INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX,
_("Toggle multiple vanishing points"));
}
@@ -527,7 +527,7 @@ persp3d_print_all_selected() {
g_print ("\n======================================\n");
g_print ("Selected perspectives and their boxes:\n");
- std::list<Persp3D *> sel_persps = sp_desktop_selection(inkscape_active_desktop())->perspList();
+ std::list<Persp3D *> sel_persps = sp_desktop_selection(INKSCAPE.active_desktop())->perspList();
for (std::list<Persp3D *>::iterator j = sel_persps.begin(); j != sel_persps.end(); ++j) {
Persp3D *persp = SP_PERSP3D(*j);
diff --git a/src/preferences.cpp b/src/preferences.cpp
index d0c3783b5..e5a5fe7f0 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -91,11 +91,13 @@ Preferences::Preferences() :
_hasError(false)
{
// profile_path essentailly returns the argument prefixed by the profile directory.
- gchar *path = profile_path(NULL);
+ // \TODO this is kinda hackish, but the alternative (strrchr) is worse
+
+ gchar *path = Inkscape::Application::profile_path(NULL);
_prefs_dir = path;
g_free(path);
- path = profile_path(_prefs_basename.c_str());
+ path = Inkscape::Application::profile_path(_prefs_basename.c_str());
_prefs_filename = path;
g_free(path);
@@ -155,7 +157,7 @@ void Preferences::_load()
// create some subdirectories for user stuff
char const *user_dirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
for (int i=0; user_dirs[i]; ++i) {
- char *dir = profile_path(user_dirs[i]);
+ char *dir = Inkscape::Application::profile_path(user_dirs[i]);
g_mkdir(dir, 0755);
g_free(dir);
}
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index ba491f535..d9c61544b 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -99,7 +99,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "display/curve.h"
#include "display/canvas-bpath.h"
#include "display/cairo-utils.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "path-chemistry.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/multi-path-manipulator.h"
@@ -3625,7 +3625,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
directory = g_path_get_dirname( document->getURI() );
}
if (directory == NULL) {
- directory = homedir_path(NULL);
+ directory = INKSCAPE.homedir_path(NULL);
}
gchar *filepath = g_build_filename(directory, basename, NULL);
g_free(directory);
diff --git a/src/selection.cpp b/src/selection.cpp
index 17b7253f2..81139d044 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -20,7 +20,7 @@
# include <config.h>
#endif
#include "macros.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "document.h"
#include "layer-model.h"
#include "selection.h"
@@ -89,7 +89,7 @@ Selection::_emit_modified(Selection *selection)
}
void Selection::_emitModified(guint flags) {
- inkscape_selection_modified(this, flags);
+ INKSCAPE.selection_modified(this, flags);
_modified_signal.emit(this, flags);
}
@@ -104,7 +104,7 @@ void Selection::_emitChanged(bool persist_selection_context/* = false */) {
_releaseContext(_selection_context);
}
- inkscape_selection_changed(this);
+ INKSCAPE.selection_changed(this);
_changed_signal.emit(this);
}
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index 1e43c98c6..e72c16de0 100644
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
@@ -211,7 +211,7 @@ Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename)
void sp_shortcut_get_file_names(std::vector<Glib::ustring> *names, std::vector<Glib::ustring> *paths) {
std::list<gchar *> sources;
- sources.push_back( profile_path("keys") );
+ sources.push_back( Inkscape::Application::profile_path("keys") );
sources.push_back( g_strdup(INKSCAPE_KEYSDIR) );
// loop through possible keyboard shortcut file locations.
@@ -229,7 +229,7 @@ void sp_shortcut_get_file_names(std::vector<Glib::ustring> *names, std::vector<G
gchar *filename = 0;
while ((filename = (gchar *) g_dir_read_name(directory)) != NULL) {
gchar* lower = g_ascii_strdown(filename, -1);
- if (!strcmp(dirname, profile_path("keys")) &&
+ if (!strcmp(dirname, Inkscape::Application::profile_path("keys")) &&
!strcmp(lower, "default.xml")) {
// Dont add the users custom keys file
continue;
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 73347fc4e..f836b0316 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -1006,7 +1006,7 @@ void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscap
clips_and_masks.push_back(clip_ref->getObject());
clips_and_masks.push_back(mask_ref->getObject());
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
for (std::list<SPObject const *>::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); ++o) {
if (*o) {
// obj is a group object, the children are the actual clippers
@@ -1607,7 +1607,7 @@ Geom::Affine SPItem::i2doc_affine() const
Geom::Affine SPItem::i2dt_affine() const
{
Geom::Affine ret;
- SPDesktop const *desktop = inkscape_active_desktop();
+ SPDesktop const *desktop = INKSCAPE.active_desktop();
if ( desktop ) {
ret = i2doc_affine() * desktop->doc2dt();
} else {
@@ -1625,7 +1625,7 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt)
if (parent) {
dt2p = static_cast<SPItem *>(parent)->i2dt_affine().inverse();
} else {
- SPDesktop *dt = inkscape_active_desktop();
+ SPDesktop *dt = INKSCAPE.active_desktop();
dt2p = dt->dt2doc();
}
diff --git a/src/test-helpers.h b/src/test-helpers.h
index 001356e65..d30449ebb 100644
--- a/src/test-helpers.h
+++ b/src/test-helpers.h
@@ -5,7 +5,7 @@
#include <cxxtest/TestSuite.h>
#include "document.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
// Dummy functions to keep linker happy
@@ -28,10 +28,10 @@ T* createSuiteAndDocument( void (*fun)(T*&) )
#endif
Inkscape::GC::init();
- if ( !inkscape_get_instance() )
+ if ( !Inkscape::Application::exists() )
{
// Create the global inkscape object.
- static_cast<void>(g_object_new(inkscape_get_type(), NULL));
+ Inkscape::Application::create("", false);
}
SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true );
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index e5c605889..98a5a224c 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -4,8 +4,8 @@ set(ui_SRC
control-manager.cpp
dialog-events.cpp
draw-anchor.cpp
- interface.cpp
- object-edit.cpp
+ interface.cpp
+ object-edit.cpp
previewholder.cpp
shape-editor.cpp
tools-switch.cpp
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 153ed9830..7c82fb230 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -331,7 +331,7 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const*
// Set a default style in <use> rather than <symbol> so it can be changed.
use->setAttribute("style", style );
- Inkscape::XML::Node *nv_repr = sp_desktop_namedview(inkscape_active_desktop())->getRepr();
+ Inkscape::XML::Node *nv_repr = sp_desktop_namedview(SP_ACTIVE_DESKTOP)->getRepr();
gdouble scale_units = Inkscape::Util::Quantity::convert(1, nv_repr->attribute("inkscape:document-units"), "px");
gchar *transform_str = sp_svg_transform_write(Geom::Scale(scale_units, scale_units));
use->setAttribute("transform", transform_str);
diff --git a/src/ui/dialog-events.cpp b/src/ui/dialog-events.cpp
index 6bd93bbc3..5bc8088a1 100644
--- a/src/ui/dialog-events.cpp
+++ b/src/ui/dialog-events.cpp
@@ -6,7 +6,7 @@
* bulia byak <bulia@dr.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
- * Copyright (C) 2003-2007 Authors
+ * Copyright (C) 2003-2014 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -25,7 +25,7 @@
#include "macros.h"
#include <gtk/gtk.h>
#include "desktop.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "preferences.h"
#include "ui/tools/tool-base.h"
@@ -183,12 +183,11 @@ void sp_transientize(GtkWidget *dialog)
void on_transientize (SPDesktop *desktop, win_data *wd )
{
- sp_transientize_callback (0, desktop, wd);
+ sp_transientize_callback (desktop, wd);
}
void
-sp_transientize_callback ( InkscapeApplication * /*inkscape*/,
- SPDesktop *desktop, win_data *wd )
+sp_transientize_callback ( SPDesktop *desktop, win_data *wd )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint transient_policy = prefs->getIntLimited( "/options/transientpolicy/value", 1, 0, 2);
diff --git a/src/ui/dialog-events.h b/src/ui/dialog-events.h
index b33eb3f38..b4a5d7c35 100644
--- a/src/ui/dialog-events.h
+++ b/src/ui/dialog-events.h
@@ -4,7 +4,7 @@
/* Authors:
* bulia byak <bulia@dr.com>
*
- * Copyright (C) 2003 authors
+ * Copyright (C) 2003-2014 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -28,8 +28,6 @@ class Entry;
}
class SPDesktop;
-
-struct InkscapeApplication;
typedef struct {
GtkWidget *win;
@@ -53,14 +51,14 @@ void sp_transientize ( GtkWidget *win );
void on_transientize ( SPDesktop *desktop,
win_data *wd );
-void sp_transientize_callback ( InkscapeApplication *inkscape,
- SPDesktop *desktop,
+void sp_transientize_callback ( SPDesktop *desktop,
win_data *wd );
void on_dialog_hide (GtkWidget *w);
void on_dialog_unhide (GtkWidget *w);
-gboolean sp_dialog_hide (GObject *object, gpointer data);
-gboolean sp_dialog_unhide (GObject *object, gpointer data);
+
+//gboolean sp_dialog_hide (GObject *object, gpointer data);
+//gboolean sp_dialog_unhide (GObject *object, gpointer data);
#endif
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 431da7ad1..c538968d6 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -829,14 +829,14 @@ private :
-static void on_tool_changed(InkscapeApplication */*inkscape*/, Inkscape::UI::Tools::ToolBase */*context*/, AlignAndDistribute *daad)
+static void on_tool_changed(AlignAndDistribute *daad)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop && desktop->getEventContext())
daad->setMode(tools_active(desktop) == TOOLS_NODES);
}
-static void on_selection_changed(InkscapeApplication */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad)
+static void on_selection_changed(AlignAndDistribute *daad)
{
daad->randomize_bbox = Geom::OptRect();
}
@@ -1044,10 +1044,10 @@ AlignAndDistribute::AlignAndDistribute()
contents->pack_start(_nodesFrame, true, true);
//Connect to the global tool change signal
- g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this);
+ _toolChangeConn = INKSCAPE.signal_eventcontext_set.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)));
// Connect to the global selection change, to invalidate cached randomize_bbox
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
+ _selChangeConn = INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)));
randomize_bbox = Geom::OptRect();
_desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) );
@@ -1055,18 +1055,18 @@ AlignAndDistribute::AlignAndDistribute()
show_all_children();
- on_tool_changed (NULL, NULL, this); // set current mode
+ on_tool_changed (this); // set current mode
}
AlignAndDistribute::~AlignAndDistribute()
{
- sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this);
-
for (std::list<Action *>::iterator it = _actionList.begin();
it != _actionList.end(); ++it) {
delete *it;
}
+ _toolChangeConn.disconnect();
+ _selChangeConn.disconnect();
_desktopChangeConn.disconnect();
_deskTrack.disconnect();
}
@@ -1075,7 +1075,7 @@ void AlignAndDistribute::setTargetDesktop(SPDesktop *desktop)
{
if (_desktop != desktop) {
_desktop = desktop;
- on_tool_changed (NULL, NULL, this);
+ on_tool_changed (this);
}
}
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index dfd84535b..eecc30ff8 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -127,7 +127,8 @@ protected:
SPDesktop *_desktop;
DesktopTracker _deskTrack;
sigc::connection _desktopChangeConn;
-
+ sigc::connection _toolChangeConn;
+ sigc::connection _selChangeConn;
private:
AlignAndDistribute(AlignAndDistribute const &d);
AlignAndDistribute& operator=(AlignAndDistribute const &d);
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index 7a776a9b8..37881d4ae 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -76,15 +76,12 @@ static gdouble trace_zoom;
static SPDocument *trace_doc = NULL;
-CloneTiler::CloneTiler (void) :
+CloneTiler::CloneTiler () :
UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER),
dlg(NULL),
desktop(NULL),
deskTrack(),
- table_row_labels(NULL),
- selectChangedConn(),
- subselChangedConn(),
- selectModifiedConn()
+ table_row_labels(NULL)
{
Gtk::Box *contents = _getContents();
contents->set_spacing(0);
@@ -1273,12 +1270,13 @@ CloneTiler::CloneTiler (void) :
// connect to global selection changed signal (so we can change desktops) and
// external_change (so we're not fooled by undo)
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg);
- g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg);
- g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE));
+ selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg));
+ externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg));
+
+ g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this);
// update now
- clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
+ clonetiler_change_selection (sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
}
{
@@ -1350,7 +1348,7 @@ void CloneTiler::on_picker_color_changed(guint rgba)
is_updating = false;
}
-void CloneTiler::clonetiler_change_selection(InkscapeApplication * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
+void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg)
{
GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles"));
GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status"));
@@ -1379,16 +1377,18 @@ void CloneTiler::clonetiler_change_selection(InkscapeApplication * /*inkscape*/,
}
}
-void CloneTiler::clonetiler_external_change(InkscapeApplication * /*inkscape*/, GtkWidget *dlg)
+void CloneTiler::clonetiler_external_change(GtkWidget *dlg)
{
- clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
+ clonetiler_change_selection (sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
}
-void CloneTiler::clonetiler_disconnect_gsignal(GObject *widget, gpointer source)
+void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source)
{
- if (source && G_IS_OBJECT(source)) {
- sp_signal_disconnect_by_data (source, widget);
- }
+ g_return_if_fail(source != NULL);
+
+ CloneTiler* dlg = reinterpret_cast<CloneTiler*>(source);
+ dlg->selectChangedConn.disconnect();
+ dlg->externChangedConn.disconnect();
}
Geom::Affine CloneTiler::clonetiler_get_transform(
@@ -2169,7 +2169,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
}
g_slist_free (to_delete);
- clonetiler_change_selection (NULL, selection, dlg);
+ clonetiler_change_selection (selection, dlg);
if (do_undo) {
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
@@ -2643,7 +2643,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
clonetiler_trace_finish ();
}
- clonetiler_change_selection (NULL, selection, dlg);
+ clonetiler_change_selection (selection, dlg);
desktop->clearWaitingCursor();
diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h
index 70da86338..e5f5638b2 100644
--- a/src/ui/dialog/clonetiler.h
+++ b/src/ui/dialog/clonetiler.h
@@ -57,8 +57,8 @@ protected:
static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/);
static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg);
static void clonetiler_unclump(GtkWidget */*widget*/, void *);
- static void clonetiler_change_selection(InkscapeApplication * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg);
- static void clonetiler_external_change(InkscapeApplication * /*inkscape*/, GtkWidget *dlg);
+ static void clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg);
+ static void clonetiler_external_change(GtkWidget *dlg);
static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source);
static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg);
static guint clonetiler_number_of_clones(SPObject *obj);
@@ -129,6 +129,7 @@ private:
sigc::connection desktopChangeConn;
sigc::connection selectChangedConn;
+ sigc::connection externChangedConn;
sigc::connection subselChangedConn;
sigc::connection selectModifiedConn;
sigc::connection color_changed_connection;
diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp
index 3ed998252..0659de67b 100644
--- a/src/ui/dialog/desktop-tracker.cpp
+++ b/src/ui/dialog/desktop-tracker.cpp
@@ -22,7 +22,6 @@ DesktopTracker::DesktopTracker() :
desktop(0),
widget(0),
hierID(0),
- inkID(0),
trackActive(false),
desktopChangedSig()
{
@@ -41,7 +40,10 @@ void DesktopTracker::connect(GtkWidget *widget)
// Use C/gobject callbacks to avoid gtkmm rewrap-during-destruct issues:
hierID = g_signal_connect( G_OBJECT(widget), "hierarchy-changed", G_CALLBACK(hierarchyChangeCB), this );
- inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this );
+ inkID = INKSCAPE.signal_activate_desktop.connect(
+ sigc::bind(
+ sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this)
+ );
GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET);
if (wdgt && !base) {
@@ -60,11 +62,8 @@ void DesktopTracker::disconnect()
}
hierID = 0;
}
- if (inkID) {
- if (INKSCAPE) {
- g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID);
- }
- inkID = 0;
+ if (inkID.connected()) {
+ inkID.disconnect();
}
}
@@ -94,12 +93,12 @@ sigc::connection DesktopTracker::connectDesktopChanged( const sigc::slot<void, S
return desktopChangedSig.connect(slot);
}
-gboolean DesktopTracker::activateDesktopCB(InkscapeApplication */*inkscape*/, SPDesktop *desktop, DesktopTracker *self )
+void DesktopTracker::activateDesktopCB(SPDesktop *desktop, DesktopTracker *self )
{
if (self && self->trackActive) {
self->setDesktop(desktop);
}
- return FALSE;
+ //return FALSE;
}
bool DesktopTracker::hierarchyChangeCB(GtkWidget * /*widget*/, GtkWidget* /*prev*/, DesktopTracker *self)
diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h
index 7b944ddfa..8cb205a35 100644
--- a/src/ui/dialog/desktop-tracker.h
+++ b/src/ui/dialog/desktop-tracker.h
@@ -36,7 +36,7 @@ public:
sigc::connection connectDesktopChanged( const sigc::slot<void, SPDesktop*> & slot );
private:
- static gboolean activateDesktopCB(InkscapeApplication *inkscape, SPDesktop *desktop, DesktopTracker *self );
+ static void activateDesktopCB(SPDesktop *desktop, DesktopTracker *self );
static bool hierarchyChangeCB(GtkWidget *widget, GtkWidget* prev, DesktopTracker *self);
void handleHierarchyChange();
@@ -46,7 +46,7 @@ private:
SPDesktop *desktop;
GtkWidget *widget;
gulong hierID;
- gulong inkID;
+ sigc::connection inkID;
bool trackActive;
sigc::signal<void, SPDesktop*> desktopChangedSig;
};
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 213965a18..6dabcfb6b 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -41,12 +41,6 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
-void sp_retransientize(InkscapeApplication */*inkscape*/, SPDesktop *desktop, gpointer dlgPtr)
-{
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onDesktopActivated (desktop);
-}
-
gboolean sp_retransientize_again(gpointer dlgPtr)
{
Dialog *dlg = static_cast<Dialog *>(dlgPtr);
@@ -54,30 +48,6 @@ gboolean sp_retransientize_again(gpointer dlgPtr)
return FALSE; // so that it is only called once
}
-void sp_dialog_shutdown(GObject * /*object*/, gpointer dlgPtr)
-{
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onShutdown();
-}
-
-
-static void hideCallback(GObject * /*object*/, gpointer dlgPtr)
-{
- g_return_if_fail( dlgPtr != NULL );
-
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onHideF12();
-}
-
-static void unhideCallback(GObject * /*object*/, gpointer dlgPtr)
-{
- g_return_if_fail( dlgPtr != NULL );
-
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onShowF12();
-}
-
-
//=====================================================================
Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num,
@@ -103,10 +73,10 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat
_behavior = behavior_factory(*this);
_desktop = SP_ACTIVE_DESKTOP;
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_dialog_shutdown), (void *)this);
+ INKSCAPE.signal_activate_desktop.connect(sigc::mem_fun(*this, &Dialog::onDesktopActivated));
+ INKSCAPE.signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dialog::onHideF12));
+ INKSCAPE.signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dialog::onShowF12));
+ INKSCAPE.signal_shut_down.connect(sigc::mem_fun(*this, &Dialog::onShutdown));
Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent));
Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress));
diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h
index ccff43a56..9c7efd47b 100644
--- a/src/ui/dialog/dialog.h
+++ b/src/ui/dialog/dialog.h
@@ -30,7 +30,6 @@ namespace Dialog {
enum BehaviorType { FLOATING, DOCK };
-void sp_retransientize(InkscapeApplication *inkscape, SPDesktop *desktop, gpointer dlgPtr);
gboolean sp_retransientize_again(gpointer dlgPtr);
void sp_dialog_shutdown(GObject *object, gpointer dlgPtr);
diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp
index 77ea175d9..820d5a8bb 100644
--- a/src/ui/dialog/document-metadata.cpp
+++ b/src/ui/dialog/document-metadata.cpp
@@ -223,7 +223,7 @@ DocumentMetadata::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *)
}
void
-DocumentMetadata::_handleActivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+DocumentMetadata::_handleActivateDesktop(SPDesktop *desktop)
{
Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
repr->addListener(&_repr_events, this);
@@ -231,7 +231,7 @@ DocumentMetadata::_handleActivateDesktop(InkscapeApplication *, SPDesktop *deskt
}
void
-DocumentMetadata::_handleDeactivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+DocumentMetadata::_handleDeactivateDesktop(SPDesktop *desktop)
{
Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
repr->removeListenerByData(this);
diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h
index 77084bc3d..cde5d92fd 100644
--- a/src/ui/dialog/document-metadata.h
+++ b/src/ui/dialog/document-metadata.h
@@ -28,6 +28,7 @@
# include <gtkmm/table.h>
#endif
+#include "inkscape.h"
#include "ui/widget/licensor.h"
#include "ui/widget/registry.h"
@@ -56,8 +57,8 @@ protected:
void init();
void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
- void _handleActivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
- void _handleDeactivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
+ void _handleActivateDesktop(SPDesktop *desktop);
+ void _handleDeactivateDesktop(SPDesktop *desktop);
Gtk::Notebook _notebook;
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index f7701655c..13ee8a6c6 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1599,7 +1599,7 @@ void DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument
update();
}
-void DocumentProperties::_handleActivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+void DocumentProperties::_handleActivateDesktop(SPDesktop *desktop)
{
Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
repr->addListener(&_repr_events, this);
@@ -1608,7 +1608,7 @@ void DocumentProperties::_handleActivateDesktop(InkscapeApplication *, SPDesktop
update();
}
-void DocumentProperties::_handleDeactivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+void DocumentProperties::_handleDeactivateDesktop(SPDesktop *desktop)
{
Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
repr->removeListenerByData(this);
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index ee7e88b18..b1f90b4b7 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -94,8 +94,8 @@ protected:
void save_default_metadata();
void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
- void _handleActivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
- void _handleDeactivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
+ void _handleActivateDesktop(SPDesktop *desktop);
+ void _handleDeactivateDesktop(SPDesktop *desktop);
Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer;
Gtk::Notebook _notebook;
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 37022a186..1ebd1fc7c 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -51,7 +51,7 @@
#include "ui/widget/unit-menu.h"
#include "util/units.h"
#include "helper/window.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "document.h"
#include "document-undo.h"
#include "desktop-handles.h"
@@ -588,7 +588,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust
}
if (directory.empty()) {
- directory = homedir_path(NULL);
+ directory = INKSCAPE.homedir_path(NULL);
}
Glib::ustring filename = Glib::build_filename(directory, id+".png");
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 5d330f7f0..17cf835cd 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -577,8 +577,9 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType)
SVGPreview::SVGPreview()
{
- if (!INKSCAPE)
- inkscape_application_init("", false);
+ // \FIXME Why?!!??
+ if (!Inkscape::Application::exists())
+ Inkscape::Application::create("", false);
document = NULL;
viewerGtk = NULL;
set_size_request(150, 150);
@@ -1083,7 +1084,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl
}
// allow easy access to the user's own templates folder
- gchar *templates = profile_path("templates");
+ gchar *templates = Inkscape::Application::profile_path("templates");
if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) &&
Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) {
add_shortcut_folder(templates);
diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h
index 35c98ef9c..f2a6bf39d 100644
--- a/src/ui/dialog/fill-and-stroke.h
+++ b/src/ui/dialog/fill-and-stroke.h
@@ -41,8 +41,7 @@ public:
virtual void setDesktop(SPDesktop *desktop);
- void selectionChanged(InkscapeApplication *inkscape,
- Inkscape::Selection *selection);
+ //void selectionChanged(Inkscape::Selection *selection);
void showPageFill();
void showPageStrokePaint();
diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp
index 1417b39fa..2ff647a74 100644
--- a/src/ui/dialog/grid-arrange-tab.cpp
+++ b/src/ui/dialog/grid-arrange-tab.cpp
@@ -567,17 +567,6 @@ void GridArrangeTab::updateSelection()
}
-
-/*##########################
-## Experimental
-##########################*/
-
-static void updateSelectionCallback(InkscapeApplication */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg)
-{
- dlg->updateSelection();
-}
-
-
//#########################################################################
//## C O N S T R U C T O R / D E S T R U C T O R
//#########################################################################
@@ -605,7 +594,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
{
// Selection Change signal
- g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this);
+ INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)));
}
Gtk::Box *contents = this;
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 1fd8aa9be..ed4b16008 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1913,7 +1913,7 @@ void InkscapePreferences::initPageSystem()
_page_system.add_group_header( _("System info"));
- _sys_user_config.set_text((char const *)profile_path(""));
+ _sys_user_config.set_text((char const *)Inkscape::Application::profile_path(""));
_sys_user_config.set_editable(false);
_page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true);
diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h
index b4a355083..39110f47a 100644
--- a/src/ui/dialog/panel-dialog.h
+++ b/src/ui/dialog/panel-dialog.h
@@ -49,19 +49,10 @@ public:
virtual UI::Widget::Panel &getPanel() { return _panel; }
protected:
- static void handle_deactivate_desktop(InkscapeApplication *application, SPDesktop *desktop, void *data) {
- g_return_if_fail(data != NULL);
- static_cast<PanelDialogBase *>(data)->_propagateDesktopDeactivated(application, desktop);
- }
-
- static void _handle_activate_desktop(InkscapeApplication *application, SPDesktop *desktop, void *data) {
- g_return_if_fail(data != NULL);
- static_cast<PanelDialogBase *>(data)->_propagateDesktopActivated(application, desktop);
- }
inline virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document);
- inline virtual void _propagateDesktopActivated(InkscapeApplication *, SPDesktop *);
- inline virtual void _propagateDesktopDeactivated(InkscapeApplication *, SPDesktop *);
+ inline virtual void _propagateDesktopActivated(SPDesktop *);
+ inline virtual void _propagateDesktopDeactivated(SPDesktop *);
UI::Widget::Panel &_panel;
sigc::connection _document_replaced_connection;
@@ -134,17 +125,17 @@ void PanelDialogBase::_propagateDocumentReplaced(SPDesktop *desktop, SPDocument
_panel.signalDocumentReplaced().emit(desktop, document);
}
-void PanelDialogBase::_propagateDesktopActivated(InkscapeApplication *application, SPDesktop *desktop)
+void PanelDialogBase::_propagateDesktopActivated(SPDesktop *desktop)
{
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialogBase::_propagateDocumentReplaced));
- _panel.signalActivateDesktop().emit(application, desktop);
+ _panel.signalActivateDesktop().emit(desktop);
}
-void PanelDialogBase::_propagateDesktopDeactivated(InkscapeApplication *application, SPDesktop *desktop)
+void PanelDialogBase::_propagateDesktopDeactivated(SPDesktop *desktop)
{
_document_replaced_connection.disconnect();
- _panel.signalDeactiveDesktop().emit(application, desktop);
+ _panel.signalDeactiveDesktop().emit(desktop);
}
@@ -162,7 +153,7 @@ PanelDialog<B>::PanelDialog(Widget::Panel &panel, char const *prefs_path, int co
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- _propagateDesktopActivated(INKSCAPE, desktop);
+ _propagateDesktopActivated(desktop);
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced));
@@ -211,7 +202,7 @@ PanelDialog<Behavior::FloatingBehavior>::PanelDialog(UI::Widget::Panel &panel, c
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- _propagateDesktopActivated(INKSCAPE, desktop);
+ _propagateDesktopActivated(desktop);
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced));
@@ -247,8 +238,12 @@ PanelDialog<Behavior::FloatingBehavior> *PanelDialog<Behavior::FloatingBehavior>
new PanelDialog<Behavior::FloatingBehavior>(panel, panel.getPrefsPath(),
panel.getVerb(), panel.getApplyLabel());
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(_handle_activate_desktop), instance);
- g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(handle_deactivate_desktop), instance);
+ INKSCAPE.signal_activate_desktop.connect(
+ sigc::mem_fun(*instance, &PanelDialog<Behavior::FloatingBehavior>::_propagateDesktopActivated)
+ );
+ INKSCAPE.signal_deactivate_desktop.connect(
+ sigc::mem_fun(*instance, &PanelDialog<Behavior::FloatingBehavior>::_propagateDesktopDeactivated)
+ );
return instance;
}
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index a3cfeeba8..187e31233 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -527,7 +527,7 @@ static void loadEmUp()
beenHere = true;
std::list<gchar *> sources;
- sources.push_back( profile_path("palettes") );
+ sources.push_back( Inkscape::Application::profile_path("palettes") );
sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
sources.push_back( g_strdup(CREATE_PALETTESDIR) );
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index a17a03861..c9d9bb36c 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -287,7 +287,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
++row;
/**********************************************************/
- currentDesktop = inkscape_active_desktop();
+ currentDesktop = INKSCAPE.active_desktop();
currentDocument = sp_desktop_document(currentDesktop);
previewDocument = symbols_preview_doc(); /* Template to render symbols in */
@@ -585,13 +585,15 @@ void SymbolsDialog::get_symbols() {
std::list<Glib::ustring> directories;
+// \TODO optimize this
+
if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) &&
Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) {
directories.push_back( INKSCAPE_SYMBOLSDIR );
}
- if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
- Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
- directories.push_back( profile_path("symbols") );
+ if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
+ Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
+ directories.push_back( Inkscape::Application::profile_path("symbols") );
}
std::list<Glib::ustring>::iterator it;
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index 13cb01eef..fca1f7b30 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -194,7 +194,7 @@ void TemplateLoadTab::_refreshTemplatesList()
void TemplateLoadTab::_loadTemplates()
{
// user's local dir
- _getTemplatesFromDir(profile_path("templates") + _loading_path);
+ _getTemplatesFromDir(Inkscape::Application::profile_path("templates") + _loading_path);
// system templates dir
_getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path);
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 6dbcf4a05..2c6692777 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -47,16 +47,13 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
-static void on_selection_changed(InkscapeApplication */*inkscape*/, Inkscape::Selection *selection, Transformation *daad)
+static void on_selection_changed(Inkscape::Selection *selection, Transformation *daad)
{
int page = daad->getCurrentPage();
daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection);
}
-static void on_selection_modified( InkscapeApplication */*inkscape*/,
- Inkscape::Selection *selection,
- guint /*flags*/,
- Transformation *daad )
+static void on_selection_modified(Inkscape::Selection *selection, Transformation *daad)
{
int page = daad->getCurrentPage();
daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection);
@@ -159,8 +156,8 @@ Transformation::Transformation()
}
// Connect to the global selection changed & modified signals
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
- g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this);
+ _selChangeConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&on_selection_changed), this));
+ _selModifyConn = INKSCAPE.signal_selection_modified.connect(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)));
_desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) );
_deskTrack.connect(GTK_WIDGET(gobj()));
@@ -170,7 +167,8 @@ Transformation::Transformation()
Transformation::~Transformation()
{
- sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this);
+ _selModifyConn.disconnect();
+ _selChangeConn.disconnect();
_desktopChangeConn.disconnect();
_deskTrack.disconnect();
}
diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h
index 1d24a0c94..89aa95d90 100644
--- a/src/ui/dialog/transformation.h
+++ b/src/ui/dialog/transformation.h
@@ -232,6 +232,9 @@ private:
Gtk::Button *applyButton;
Gtk::Button *resetButton;
Gtk::Button *cancelButton;
+
+ sigc::connection _selChangeConn;
+ sigc::connection _selModifyConn;
};
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 7830a8de1..7abbb5934 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -29,7 +29,7 @@
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "extension/db.h"
#include "extension/effect.h"
#include "extension/input.h"
@@ -270,7 +270,7 @@ sp_create_window(SPViewWidget *vw, bool editable)
// needed because the first ACTIVATE_DESKTOP was sent when there was no window yet
if ( SP_IS_DESKTOP_WIDGET(vw) ) {
- inkscape_reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop);
+ INKSCAPE.reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop);
}
}
@@ -318,7 +318,7 @@ sp_ui_close_view(GtkWidget */*widget*/)
// If closing the last document, open a new document so Inkscape doesn't quit.
std::list<SPDesktop *> desktops;
- inkscape_get_all_desktops(desktops);
+ INKSCAPE.get_all_desktops(desktops);
if (desktops.size() == 1) {
Glib::ustring templateUri = sp_file_default_template_uri();
SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true );
@@ -921,7 +921,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I
GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view)
{
GtkWidget *mbar = gtk_menu_bar_new();
- sp_ui_build_dyn_menus(inkscape_get_menus(INKSCAPE), mbar, view);
+ sp_ui_build_dyn_menus(INKSCAPE.get_menus(), mbar, view);
return mbar;
}
@@ -2117,13 +2117,13 @@ void ContextMenu::ImageEdit(void)
void ContextMenu::ImageTraceBitmap(void)
{
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
_desktop->_dlg_mgr->showDialog("Trace");
}
void ContextMenu::ImageTracePixelArt(void)
{
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
_desktop->_dlg_mgr->showDialog("PixelArt");
}
diff --git a/src/ui/tools-switch.cpp b/src/ui/tools-switch.cpp
index 47b9d2832..07d68471f 100644
--- a/src/ui/tools-switch.cpp
+++ b/src/ui/tools-switch.cpp
@@ -16,7 +16,7 @@
#include <cstring>
#include <string>
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "desktop.h"
#include "desktop-handles.h"
#include <glibmm/i18n.h>
@@ -159,7 +159,7 @@ tools_switch(SPDesktop *dt, int num)
/* fixme: This is really ugly hack. We should bind and unbind class methods */
/* First 4 tools use guides, first is undefined but we don't care */
dt->activate_guides(num < 5);
- inkscape_eventcontext_set(dt->getEventContext());
+ INKSCAPE.eventcontext_set(dt->getEventContext());
}
void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p)
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 7b5c84c16..776bc9c89 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -1304,7 +1304,7 @@ bool cc_item_is_connector(SPItem *item)
void cc_selection_set_avoid(bool const set_avoid)
{
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
if (desktop == NULL) {
return;
}
diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp
index 72548e213..47e2a1e0d 100644
--- a/src/ui/view/view.cpp
+++ b/src/ui/view/view.cpp
@@ -20,7 +20,7 @@
#include "message-stack.h"
#include "message-context.h"
#include "verbs.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
namespace Inkscape {
namespace UI {
@@ -85,7 +85,7 @@ void View::_close() {
if (_doc) {
_document_uri_set_connection.disconnect();
_document_resized_connection.disconnect();
- if (inkscape_remove_document(_doc)) {
+ if (INKSCAPE.remove_document(_doc)) {
// this was the last view of this document, so delete it
delete _doc;
}
@@ -111,13 +111,13 @@ void View::setDocument(SPDocument *doc) {
if (_doc) {
_document_uri_set_connection.disconnect();
_document_resized_connection.disconnect();
- if (inkscape_remove_document(_doc)) {
+ if (INKSCAPE.remove_document(_doc)) {
// this was the last view of this document, so delete it
delete _doc;
}
}
- inkscape_add_document(doc);
+ INKSCAPE.add_document(doc);
_doc = doc;
_document_uri_set_connection =
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index 52e9ea605..c5e14d4f0 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -119,8 +119,9 @@ Dock::Dock(Gtk::Orientation orientation)
gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this);
+
+ INKSCAPE.signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dock::hide));
+ INKSCAPE.signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dock::show));
g_signal_connect(_paned->gobj(), "button-press-event", G_CALLBACK(_on_paned_button_event), (void *)this);
g_signal_connect(_paned->gobj(), "button-release-event", G_CALLBACK(_on_paned_button_event), (void *)this);
diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp
index 22abd04ba..df261b69a 100644
--- a/src/ui/widget/imageicon.cpp
+++ b/src/ui/widget/imageicon.cpp
@@ -88,8 +88,9 @@ ImageIcon::~ImageIcon()
*/
void ImageIcon::init()
{
- if (!INKSCAPE)
- inkscape_application_init("",false);
+ // \FIXME Why?
+ if (!Inkscape::Application::exists())
+ Inkscape::Application::create("", false);
document = NULL;
viewerGtkmm = NULL;
//set_size_request(150,150);
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index e4cd76345..a377bf118 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -39,26 +39,6 @@ namespace Inkscape {
namespace UI {
namespace Widget {
-/*void ObjectCompositeSettings::_on_desktop_activate(
- InkscapeApplication *application,
- SPDesktop *desktop,
- ObjectCompositeSettings *w
-) {
- if (w->_subject) {
- w->_subject->setDesktop(desktop);
- }
-}
-
-void ObjectCompositeSettings::_on_desktop_deactivate(
- InkscapeApplication *application,
- SPDesktop *desktop,
- ObjectCompositeSettings *w
-) {
- if (w->_subject) {
- w->_subject->setDesktop(NULL);
- }
-}*/
-
ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags)
: _verb_code(verb_code),
_blur_tag(Glib::ustring(history_prefix) + ":blur"),
@@ -102,7 +82,6 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co
ObjectCompositeSettings::~ObjectCompositeSettings() {
setSubject(NULL);
- g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _desktop_activated);
}
void ObjectCompositeSettings::setSubject(StyleSubject *subject) {
diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h
index e375bf24a..5a723a2fd 100644
--- a/src/ui/widget/object-composite-settings.h
+++ b/src/ui/widget/object-composite-settings.h
@@ -66,8 +66,8 @@ private:
gulong _desktop_activated;
sigc::connection _subject_changed;
- static void _on_desktop_activate(InkscapeApplication *application, SPDesktop *desktop, ObjectCompositeSettings *w);
- static void _on_desktop_deactivate(InkscapeApplication *application, SPDesktop *desktop, ObjectCompositeSettings *w);
+ static void _on_desktop_activate(SPDesktop *desktop, ObjectCompositeSettings *w);
+ static void _on_desktop_deactivate(SPDesktop *desktop, ObjectCompositeSettings *w);
void _subjectChanged();
void _blendBlurValueChanged();
void _opacityValueChanged();
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index 0abd81b16..c96eac838 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -293,7 +293,7 @@ void Panel::_init()
signalResponse().connect(sigc::mem_fun(*this, &Panel::_handleResponse));
- signalActivateDesktop().connect(sigc::hide<0>(sigc::mem_fun(*this, &Panel::setDesktop)));
+ signalActivateDesktop().connect(sigc::mem_fun(*this, &Panel::setDesktop));
show_all_children();
@@ -643,13 +643,13 @@ Panel::signalDocumentReplaced()
return _signal_document_replaced;
}
-sigc::signal<void, InkscapeApplication *, SPDesktop *> &
+sigc::signal<void, SPDesktop *> &
Panel::signalActivateDesktop()
{
return _signal_activate_desktop;
}
-sigc::signal<void, InkscapeApplication *, SPDesktop *> &
+sigc::signal<void, SPDesktop *> &
Panel::signalDeactiveDesktop()
{
return _signal_deactive_desktop;
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 177314797..5680cac30 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -48,6 +48,7 @@ namespace Gtk {
struct InkscapeApplication;
namespace Inkscape {
+
class Selection;
namespace UI {
@@ -116,8 +117,8 @@ public:
void setResponseSensitive(int response_id, bool setting);
virtual sigc::signal<void, SPDesktop *, SPDocument *> &signalDocumentReplaced();
- virtual sigc::signal<void, InkscapeApplication *, SPDesktop *> &signalActivateDesktop();
- virtual sigc::signal<void, InkscapeApplication *, SPDesktop *> &signalDeactiveDesktop();
+ virtual sigc::signal<void, SPDesktop *> &signalActivateDesktop();
+ virtual sigc::signal<void, SPDesktop *> &signalDeactiveDesktop();
protected:
/**
@@ -147,8 +148,8 @@ protected:
sigc::signal<void, int> _signal_response;
sigc::signal<void> _signal_present;
sigc::signal<void, SPDesktop *, SPDocument *> _signal_document_replaced;
- sigc::signal<void, InkscapeApplication *, SPDesktop *> _signal_activate_desktop;
- sigc::signal<void, InkscapeApplication *, SPDesktop *> _signal_deactive_desktop;
+ sigc::signal<void, SPDesktop *> _signal_activate_desktop;
+ sigc::signal<void, SPDesktop *> _signal_deactive_desktop;
private:
void _init();
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index 13dd03ee3..de42007aa 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -94,7 +94,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
Geom::Point p = ppointer;
// FIXME: take from prefs
- double snap_dist = SNAP_DIST / inkscape_active_desktop()->current_zoom();
+ double snap_dist = SNAP_DIST / INKSCAPE.active_desktop()->current_zoom();
/*
* We use dragging_started to indicate if we have already checked for the need to split Draggers up.
@@ -110,7 +110,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
for (std::set<VanishingPoint*, less_ptr>::iterator vp = sel_vps.begin(); vp != sel_vps.end(); ++vp) {
// for each VP that has selected boxes:
Persp3D *old_persp = (*vp)->get_perspective();
- sel_boxes = (*vp)->selectedBoxes(sp_desktop_selection(inkscape_active_desktop()));
+ sel_boxes = (*vp)->selectedBoxes(sp_desktop_selection(INKSCAPE.active_desktop()));
// we create a new perspective ...
Persp3D *new_persp = persp3d_create_xml_element (dragger->parent->document, old_persp->perspective_impl);
@@ -129,7 +129,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
}
// FIXME: Do we need to create a new dragger as well?
dragger->updateZOrders ();
- DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+ DocumentUndo::done(sp_desktop_document (INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX,
_("Split vanishing points"));
return;
}
@@ -174,7 +174,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
// deleted according to changes in the svg representation, not based on any user input
// as is currently the case.
- DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+ DocumentUndo::done(sp_desktop_document (INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX,
_("Merge vanishing points"));
return;
@@ -182,7 +182,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
}
// We didn't snap to another dragger, so we'll try a regular snap
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = INKSCAPE.active_desktop();
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE));
@@ -277,7 +277,7 @@ VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp)
if (vp.is_finite()) {
// create the knot
- this->knot = new SPKnot(inkscape_active_desktop(), NULL);
+ this->knot = new SPKnot(INKSCAPE.active_desktop(), NULL);
this->knot->setMode(SP_KNOT_MODE_XOR);
this->knot->setFill(VP_KNOT_COLOR_NORMAL, VP_KNOT_COLOR_NORMAL, VP_KNOT_COLOR_NORMAL);
this->knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
@@ -394,7 +394,7 @@ VPDragger::VPsOfSelectedBoxes() {
std::set<VanishingPoint*, less_ptr> sel_vps;
VanishingPoint *vp;
// FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference.
- Inkscape::Selection *sel = sp_desktop_selection(inkscape_active_desktop());
+ Inkscape::Selection *sel = sp_desktop_selection(INKSCAPE.active_desktop());
for (GSList const* i = sel->itemList(); i != NULL; i = i->next) {
SPItem *item = static_cast<SPItem *>(i->data);
SPBox3D *box = dynamic_cast<SPBox3D *>(item);
@@ -488,7 +488,7 @@ VPDragger::printVPs() {
VPDrag::VPDrag (SPDocument *document)
{
this->document = document;
- this->selection = sp_desktop_selection(inkscape_active_desktop());
+ this->selection = sp_desktop_selection(INKSCAPE.active_desktop());
this->draggers = NULL;
this->lines = NULL;
@@ -635,7 +635,7 @@ VPDrag::updateBoxHandles ()
return;
}
- Inkscape::UI::Tools::ToolBase *ec = inkscape_active_event_context();
+ Inkscape::UI::Tools::ToolBase *ec = INKSCAPE.active_event_context();
g_assert (ec != NULL);
if (ec->shape_editor != NULL) {
ec->shape_editor->update_knotholder();
@@ -708,7 +708,7 @@ void VPDrag::drawLinesForFace(const SPBox3D *box, Proj::Axis axis) //, guint cor
// draw perspective lines for infinite VPs
boost::optional<Geom::Point> pt1, pt2, pt3, pt4;
Persp3D *persp = box3d_get_perspective(box);
- SPDesktop *desktop = inkscape_active_desktop (); // FIXME: Store the desktop in VPDrag
+ SPDesktop *desktop = INKSCAPE.active_desktop (); // FIXME: Store the desktop in VPDrag
Box3D::PerspectiveLine pl (corner1, axis, persp);
pt1 = pl.intersection_with_viewbox(desktop);
@@ -782,7 +782,7 @@ VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1)
void VPDrag::addLine(Geom::Point const &p1, Geom::Point const &p2, Inkscape::CtrlLineType type)
{
- SPCtrlLine *line = ControlManager::getManager().createControlLine(sp_desktop_controls(inkscape_active_desktop()), p1, p2, type);
+ SPCtrlLine *line = ControlManager::getManager().createControlLine(sp_desktop_controls(INKSCAPE.active_desktop()), p1, p2, type);
sp_canvas_item_show(line);
this->lines = g_slist_append(this->lines, line);
}
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 33810fba2..bafb6f89b 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -52,7 +52,7 @@
#include "helper/action.h"
#include "helper/action-context.h"
#include "help.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "ui/interface.h"
#include "layer-fns.h"
#include "layer-manager.h"
@@ -906,10 +906,10 @@ void FileVerb::perform(SPAction *action, void *data)
// sp_file_export_to_ocal(*parent);
// break;
case SP_VERB_FILE_NEXT_DESKTOP:
- inkscape_switch_desktops_next();
+ INKSCAPE.switch_desktops_next();
break;
case SP_VERB_FILE_PREV_DESKTOP:
- inkscape_switch_desktops_prev();
+ INKSCAPE.switch_desktops_prev();
break;
case SP_VERB_FILE_CLOSE_VIEW:
sp_ui_close_view(NULL);
@@ -1203,11 +1203,11 @@ void SelectionVerb::perform(SPAction *action, void *data)
SelectionHelper::reverse(dt);
break;
case SP_VERB_SELECTION_TRACE:
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
dt->_dlg_mgr->showDialog("Trace");
break;
case SP_VERB_SELECTION_PIXEL_ART:
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
dt->_dlg_mgr->showDialog("PixelArt");
break;
case SP_VERB_SELECTION_CREATE_BITMAP:
@@ -1221,7 +1221,7 @@ void SelectionVerb::perform(SPAction *action, void *data)
sp_selected_path_break_apart(dt);
break;
case SP_VERB_SELECTION_ARRANGE:
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
dt->_dlg_mgr->showDialog("TileDialog"); //FIXME: denis: What's this string (to be changed)
break;
default:
@@ -2006,7 +2006,7 @@ void ZoomVerb::perform(SPAction *action, void *data)
dt->toggleColorProfAdjust();
break;
case SP_VERB_VIEW_ICON_PREVIEW:
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
dt->_dlg_mgr->showDialog("IconPreviewPanel");
break;
@@ -2025,7 +2025,7 @@ void DialogVerb::perform(SPAction *action, void *data)
{
if (reinterpret_cast<std::size_t>(data) != SP_VERB_DIALOG_TOGGLE) {
// unhide all when opening a new dialog
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
}
g_return_if_fail(ensure_desktop_valid(action));
@@ -2088,7 +2088,7 @@ void DialogVerb::perform(SPAction *action, void *data)
dt->_dlg_mgr->showDialog("UndoHistory");
break;
case SP_VERB_DIALOG_TOGGLE:
- inkscape_dialogs_toggle();
+ INKSCAPE.dialogs_toggle();
break;
case SP_VERB_DIALOG_CLONETILER:
//clonetiler_dialog();
@@ -2166,7 +2166,7 @@ void HelpVerb::perform(SPAction *action, void *data)
*/
case SP_VERB_HELP_MEMORY:
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
dt->_dlg_mgr->showDialog("Memory");
break;
default:
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index 02d102a11..e0fa591f4 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -195,7 +195,7 @@ static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObj
sp_repr_synthesize_events(persp_repr, &box3d_persp_tb_repr_events, tbl);
}
- inkscape_active_document()->setCurrentPersp3D(persp3d_get_from_repr(persp_repr));
+ SP_ACTIVE_DOCUMENT->setCurrentPersp3D(persp3d_get_from_repr(persp_repr));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setString("/tools/shapes/3dbox/persp", persp_repr->attribute("id"));
@@ -255,7 +255,7 @@ static void box3d_angle_z_value_changed(GtkAdjustment *adj, GObject *dataKludge)
static void box3d_vp_state_changed( GtkToggleAction *act, GtkAction * /*box3d_angle*/, Proj::Axis axis )
{
// TODO: Take all selected perspectives into account
- std::list<Persp3D *> sel_persps = sp_desktop_selection(inkscape_active_desktop())->perspList();
+ std::list<Persp3D *> sel_persps = sp_desktop_selection(INKSCAPE.active_desktop())->perspList();
if (sel_persps.empty()) {
// this can happen when the document is created; we silently ignore it
return;
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 2aab68812..989b060c9 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -45,7 +45,7 @@
#include "helper/action-context.h"
#include "util/units.h"
#include "ui/widget/unit-tracker.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "ui/interface.h"
#include "macros.h"
#include "preferences.h"
@@ -795,7 +795,7 @@ static void sp_desktop_widget_dispose(GObject *object)
dtw->layer_selector->setDesktop(NULL);
dtw->layer_selector->unreference();
- inkscape_remove_desktop (dtw->desktop); // clears selection too
+ INKSCAPE.remove_desktop (dtw->desktop); // clears selection too
dtw->modified_connection.disconnect();
dtw->desktop->destroy();
Inkscape::GC::release (dtw->desktop);
@@ -1091,7 +1091,7 @@ SPDesktopWidget::shutdown()
{
g_assert(desktop != NULL);
- if (inkscape_is_sole_desktop_for_document(*desktop)) {
+ if (INKSCAPE.sole_desktop_for_document(*desktop)) {
SPDocument *doc = desktop->doc();
if (doc->isModifiedSinceSave()) {
GtkWidget *dialog;
@@ -1672,7 +1672,7 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview)
dtw->desktop = new SPDesktop();
dtw->stub = new SPDesktopWidget::WidgetStub (dtw);
dtw->desktop->init (namedview, dtw->canvas, dtw->stub);
- inkscape_add_desktop (dtw->desktop);
+ INKSCAPE.add_desktop (dtw->desktop);
// Add the shape geometry to libavoid for autorouting connectors.
// This needs desktop set for its spacing preferences.
@@ -1818,7 +1818,7 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
}
}
- inkscape_activate_desktop (desktop);
+ INKSCAPE.activate_desktop (desktop);
return false;
}
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 6607c90d2..d2c46ffec 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -1012,13 +1012,28 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop)
sp_transientize(dlg);
wd.win = dlg;
wd.stop = 0;
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_transientize_callback), &wd);
- g_signal_connect(G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg);
- g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg);
- g_signal_connect(G_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg);
- g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg);
- g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(sp_dialog_hide), dlg );
- g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(sp_dialog_unhide), dlg );
+
+ GObject *obj = G_OBJECT(dlg);
+ sigc::connection *conn = NULL;
+
+ conn = new sigc::connection(INKSCAPE.signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd)));
+ g_object_set_data(obj, "desktop-activate-connection", conn);
+
+ g_signal_connect(obj, "event", G_CALLBACK(sp_dialog_event_handler), dlg);
+ g_signal_connect(obj, "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg);
+ g_signal_connect(obj, "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg);
+
+ conn = new sigc::connection(INKSCAPE.signal_shut_down.connect(
+ sigc::hide_return(
+ sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL)
+ )));
+ g_object_set_data(obj, "shutdown-connection", conn);
+
+ conn = new sigc::connection(INKSCAPE.signal_dialogs_hide.connect(sigc::bind(sigc::ptr_fun(&gtk_widget_hide), dlg)));
+ g_object_set_data(obj, "dialog-hide-connection", conn);
+
+ conn = new sigc::connection(INKSCAPE.signal_dialogs_unhide.connect(sigc::bind(sigc::ptr_fun(&gtk_widget_show), dlg)));
+ g_object_set_data(obj, "dialog-unhide-connection", conn);
gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD);
@@ -1141,7 +1156,29 @@ static void sp_gradient_vector_dialog_destroy(GtkWidget * /*object*/, gpointer /
static void sp_gradient_vector_dialog_destroy(GtkObject * /*object*/, gpointer /*data*/)
#endif
{
- sp_signal_disconnect_by_data(INKSCAPE, dlg);
+ GObject *obj = G_OBJECT(dlg);
+ assert(obj != NULL);
+
+ sigc::connection *conn = static_cast<sigc::connection *>(g_object_get_data(obj, "desktop-activate-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
+ conn = static_cast<sigc::connection *>(g_object_get_data(obj, "shutdown-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
+ conn = static_cast<sigc::connection *>(g_object_get_data(obj, "dialog-hide-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
+ conn = static_cast<sigc::connection *>(g_object_get_data(obj, "dialog-unhide-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
wd.win = dlg = NULL;
wd.stop = 0;
}
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index a6e53d638..afc4fcfb0 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -1261,7 +1261,7 @@ std::list<gchar*> &IconImpl::icons_svg_paths()
static bool initialized = false;
if (!initialized) {
// Fall back from user prefs dir into system locations.
- gchar *userdir = profile_path("icons");
+ gchar *userdir = Inkscape::Application::profile_path("icons");
sources.push_back(g_build_filename(userdir,"icons.svg", NULL));
sources.push_back(g_build_filename(INKSCAPE_PIXMAPDIR, "icons.svg", NULL));
g_free(userdir);
@@ -1572,7 +1572,7 @@ void IconImpl::addPreRender( GtkIconSize lsize, gchar const *name )
}
gboolean IconImpl::prerenderTask(gpointer /*data*/) {
- if ( inkscapeIsCrashing() ) {
+ if ( Inkscape::Application::isCrashing() ) {
// stop
} else if (!pendingRenders.empty()) {
bool workDone = false;
@@ -1584,7 +1584,7 @@ gboolean IconImpl::prerenderTask(gpointer /*data*/) {
} while (!pendingRenders.empty() && !workDone);
}
- if (!inkscapeIsCrashing() && !pendingRenders.empty()) {
+ if (!Inkscape::Application::isCrashing() && !pendingRenders.empty()) {
return TRUE;
} else {
callbackHooked = false;
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 80fe93356..e59d459b9 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -470,7 +470,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
contextActions->push_back( act );
// Create the parent widget for x y w h tracker.
- GtkWidget *spw = sp_widget_new_global(INKSCAPE);
+ GtkWidget *spw = sp_widget_new_global();
// Remember the desktop's canvas widget, to be used for defocusing.
g_object_set_data(G_OBJECT(spw), "dtw", sp_desktop_canvas(desktop));
diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp
index fdf5ec500..5ab6b1bb5 100644
--- a/src/widgets/sp-widget.cpp
+++ b/src/widgets/sp-widget.cpp
@@ -15,6 +15,7 @@
#include "macros.h"
#include "document.h"
+#include "inkscape.h"
#include "sp-widget.h"
#include "helper/sp-marshal.h"
@@ -55,15 +56,15 @@ public:
#endif
static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
- static void modifySelectionCB(Application *inkscape, Selection *selection, guint flags, SPWidget *spw);
- static void changeSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw);
- static void setSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw);
+ static void modifySelectionCB(Selection *selection, guint flags, SPWidget *spw);
+ static void changeSelectionCB(Selection *selection, SPWidget *spw);
+ static void setSelectionCB(Selection *selection, SPWidget *spw);
- static GtkWidget *constructGlobal(SPWidget *spw, InkscapeApplication *inkscape);
+ static GtkWidget *constructGlobal(SPWidget *spw);
- void modifySelection(Application *inkscape, Selection *selection, guint flags);
- void changeSelection(Application *inkscape, Selection *selection);
- void setSelection(Application *inkscape, Selection *selection);
+ void modifySelection(Selection *selection, guint flags);
+ void changeSelection(Selection *selection);
+ void setSelection(Selection *selection);
private:
SPWidget &_target;
@@ -132,7 +133,6 @@ sp_widget_class_init(SPWidgetClass *klass)
static void sp_widget_init(SPWidget *spw)
{
- spw->inkscape = NULL;
spw->_impl = new SPWidgetImpl(*spw); // ctor invoked after all other init
}
@@ -151,16 +151,12 @@ void SPWidgetImpl::dispose(GObject *object)
{
SPWidget *spw = reinterpret_cast<SPWidget *>(object);
- if (spw->inkscape) {
- // Disconnect signals
-
- // the checks are necessary because when destroy is caused by the program shutting down,
- // the inkscape object may already be (partly?) invalid --bb
- if (G_IS_OBJECT(spw->inkscape) && G_OBJECT_GET_CLASS(spw->inkscape)) {
- sp_signal_disconnect_by_data(spw->inkscape, spw);
- }
- spw->inkscape = NULL;
- }
+ // Disconnect signals
+ if (Application::exists()) {
+ spw->selModified.disconnect();
+ spw->selChanged.disconnect();
+ spw->selSet.disconnect();
+ }
delete spw->_impl;
spw->_impl = 0;
@@ -174,11 +170,20 @@ void SPWidgetImpl::show(GtkWidget *widget)
{
SPWidget *spw = SP_WIDGET(widget);
- if (spw->inkscape) {
+ if (Application::exists()) {
// Connect signals
- g_signal_connect(spw->inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw);
- g_signal_connect(spw->inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw);
- g_signal_connect(spw->inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw);
+ spw->selModified = INKSCAPE.signal_selection_modified.connect(
+ sigc::bind(
+ sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)
+ );
+ spw->selChanged = INKSCAPE.signal_selection_changed.connect(
+ sigc::bind(
+ sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)
+ );
+ spw->selSet = INKSCAPE.signal_selection_set.connect(
+ sigc::bind(
+ sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)
+ );
}
if (GTK_WIDGET_CLASS(sp_widget_parent_class)->show) {
@@ -190,9 +195,11 @@ void SPWidgetImpl::hide(GtkWidget *widget)
{
SPWidget *spw = SP_WIDGET (widget);
- if (spw->inkscape) {
+ if (Application::exists()) {
// Disconnect signals
- sp_signal_disconnect_by_data(spw->inkscape, spw);
+ spw->selModified.disconnect();
+ spw->selChanged.disconnect();
+ spw->selSet.disconnect();
}
if (GTK_WIDGET_CLASS(sp_widget_parent_class)->hide) {
@@ -264,15 +271,21 @@ void SPWidgetImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
}
}
-GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, InkscapeApplication *inkscape)
+GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw)
{
- g_return_val_if_fail(!spw->inkscape, NULL);
-
- spw->inkscape = inkscape;
if (gtk_widget_get_visible(GTK_WIDGET(spw))) {
- g_signal_connect(inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw);
- g_signal_connect(inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw);
- g_signal_connect(inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw);
+ spw->selModified = INKSCAPE.signal_selection_modified.connect(
+ sigc::bind(
+ sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)
+ );
+ spw->selChanged = INKSCAPE.signal_selection_changed.connect(
+ sigc::bind(
+ sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)
+ );
+ spw->selSet = INKSCAPE.signal_selection_set.connect(
+ sigc::bind(
+ sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)
+ );
}
g_signal_emit(spw, signals[CONSTRUCT], 0);
@@ -280,32 +293,32 @@ GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, InkscapeApplication *ink
return GTK_WIDGET(spw);
}
-void SPWidgetImpl::modifySelectionCB(Application *inkscape, Selection *selection, guint flags, SPWidget *spw)
+void SPWidgetImpl::modifySelectionCB(Selection *selection, guint flags, SPWidget *spw)
{
- spw->_impl->modifySelection(inkscape, selection, flags);
+ spw->_impl->modifySelection(selection, flags);
}
-void SPWidgetImpl::changeSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw)
+void SPWidgetImpl::changeSelectionCB(Selection *selection, SPWidget *spw)
{
- spw->_impl->changeSelection(inkscape, selection);
+ spw->_impl->changeSelection(selection);
}
-void SPWidgetImpl::setSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw)
+void SPWidgetImpl::setSelectionCB(Selection *selection, SPWidget *spw)
{
- spw->_impl->setSelection(inkscape, selection);
+ spw->_impl->setSelection(selection);
}
-void SPWidgetImpl::modifySelection(Application * /*inkscape*/, Selection *selection, guint flags)
+void SPWidgetImpl::modifySelection(Selection *selection, guint flags)
{
g_signal_emit(&_target, signals[MODIFY_SELECTION], 0, selection, flags);
}
-void SPWidgetImpl::changeSelection(Application * /*inkscape*/, Selection *selection)
+void SPWidgetImpl::changeSelection(Selection *selection)
{
g_signal_emit(&_target, signals[CHANGE_SELECTION], 0, selection);
}
-void SPWidgetImpl::setSelection(Application * /*inkscape*/, Selection *selection)
+void SPWidgetImpl::setSelection(Selection *selection)
{
// Emit "set_selection" signal
g_signal_emit(&_target, signals[SET_SELECTION], 0, selection);
@@ -316,11 +329,11 @@ void SPWidgetImpl::setSelection(Application * /*inkscape*/, Selection *selection
// Methods
-GtkWidget *sp_widget_new_global(InkscapeApplication *inkscape)
+GtkWidget *sp_widget_new_global()
{
SPWidget *spw = reinterpret_cast<SPWidget*>(g_object_new(SP_TYPE_WIDGET, NULL));
- if (!SPWidgetImpl::constructGlobal(spw, inkscape)) {
+ if (!SPWidgetImpl::constructGlobal(spw)) {
g_object_unref(spw);
spw = 0;
}
diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h
index 6227c3a72..a53062cf4 100644
--- a/src/widgets/sp-widget.h
+++ b/src/widgets/sp-widget.h
@@ -16,6 +16,7 @@
*/
#include <gtk/gtk.h>
+#include "inkscape.h"
#define SP_TYPE_WIDGET (sp_widget_get_type())
#define SP_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_WIDGET, SPWidget))
@@ -23,9 +24,8 @@
#define SP_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_WIDGET))
#define SP_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_WIDGET))
-struct InkscapeApplication;
-
namespace Inkscape {
+
class Selection;
class SPWidgetImpl;
}
@@ -33,10 +33,15 @@ class SPWidgetImpl;
struct SPWidget {
friend class Inkscape::SPWidgetImpl;
+ static GType getType();
+
GtkBin bin;
- InkscapeApplication *inkscape;
Inkscape::SPWidgetImpl *_impl;
+private:
+ sigc::connection selModified;
+ sigc::connection selChanged;
+ sigc::connection selSet;
};
struct SPWidgetClass {
@@ -53,7 +58,7 @@ struct SPWidgetClass {
GType sp_widget_get_type();
/** Generic constructor for global widget. */
-GtkWidget *sp_widget_new_global(InkscapeApplication *inkscape);
+GtkWidget *sp_widget_new_global();
#endif // SEEN_SP_WIDGET_H
/*
diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp
index 23da54e94..24288299f 100644
--- a/src/widgets/stroke-marker-selector.cpp
+++ b/src/widgets/stroke-marker-selector.cpp
@@ -64,7 +64,7 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) :
sp_pixbuf_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("no-marker") ) ) );
sandbox = ink_markers_preview_doc ();
- desktop = inkscape_active_desktop();
+ desktop = INKSCAPE.active_desktop();
doc = sp_desktop_document(desktop);
modified_connection = doc->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&MarkerComboBox::handleDefsModified), this))) );