diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-06-26 01:45:01 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-06-26 01:45:01 +0000 |
| commit | cdc7587062b42c39a23451e5c9ec7da06dd6fdb3 (patch) | |
| tree | de3ce9585caf538af3cb215cf117a9e4521df936 /src | |
| parent | 2. connect signals (diff) | |
| download | inkscape-cdc7587062b42c39a23451e5c9ec7da06dd6fdb3.tar.gz inkscape-cdc7587062b42c39a23451e5c9ec7da06dd6fdb3.zip | |
3. remove dead code, refactor existing code. Connect overlooked signals.
(bzr r13341.5.3)
Diffstat (limited to 'src')
34 files changed, 252 insertions, 629 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d40aad802..47b181522 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -344,7 +344,6 @@ set(inkscape_SRC # ige-mac-menu.h ink-action.h ink-comboboxentry-action.h - inkscape-private.h inkscape-version.h inkscape.h interface.h diff --git a/src/Makefile_insert b/src/Makefile_insert index 6d0d6b08c..9ac08a822 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -72,7 +72,7 @@ ink_common_sources += \ ink-action.h \ ink-comboboxentry-action.cpp \ ink-comboboxentry-action.h \ - inkscape.cpp inkscape.h inkscape-private.h \ + inkscape.cpp inkscape.h \ interface.cpp interface.h \ isinf.h \ isnormal.h \ diff --git a/src/desktop.cpp b/src/desktop.cpp index e90b2caec..935567462 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -56,7 +56,6 @@ #include "event-log.h" #include "helper/action-context.h" #include "interface.h" -#include "inkscape-private.h" #include "layer-fns.h" #include "layer-manager.h" #include "layer-model.h" diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp index a12e3eafc..01213f1c7 100644 --- a/src/dialogs/dialog-events.cpp +++ b/src/dialogs/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" diff --git a/src/dialogs/dialog-events.h b/src/dialogs/dialog-events.h index 623058282..5320685b2 100644 --- a/src/dialogs/dialog-events.h +++ b/src/dialogs/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 */ diff --git a/src/document.cpp b/src/document.cpp index ee1a48eb6..26e59e610 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" @@ -157,9 +157,6 @@ SPDocument::~SPDocument() { if (oldSignalsConnected) { priv->selChangeConnection.disconnect(); priv->desktopActivatedConnection.disconnect(); - //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(); @@ -475,11 +472,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) ))); - - /*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->oldSignalsConnected = true; return document; diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 2ebf8964d..c68845d8a 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" diff --git a/src/inkscape-private.h b/src/inkscape-private.h deleted file mode 100644 index a55d92829..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) (dynamic_cast<Inkscape::Application*>(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) (dynamic_cast<Inkscape::Application*> (obj) != NULL) -//#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 4e8b06ef4..2181b2814 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1,12 +1,13 @@ /** * @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 + * Copyright (C) 1999-2014 authors * g++ port Copyright (C) 2003 Nathan Hurst * * Released under GNU GPL, read the file 'COPYING' for more information @@ -50,109 +51,35 @@ #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 Inkscape::Application *inkscape = NULL; /* Backbones of configuration xml data */ #include "menus-skeleton.h" -#if 0 -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 -}; -#endif - #define DESKTOP_IS_ACTIVE(d) (!inkscape->desktops->empty() && ((d) == inkscape->desktops->front())) - -/*################################ -# FORWARD DECLARATIONS -################################*/ - -//namespace Inkscape { -//struct ApplicationClass; -//} - -//static void inkscape_class_init (Inkscape::ApplicationClass *klass); -//static void inkscape_init (SPObject *object); -//static void inkscape_dispose (GObject *object); - -//static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); -//static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); - -#if 0 -class AppSelectionModel { - Inkscape::LayerModel _layer_model; - Inkscape::Selection *_selection; - -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)); - } - - Inkscape::Selection *getSelection() const { return _selection; } -}; -#endif - -#if 0 -struct Inkscape::ApplicationClass { - GObjectClass object_class; - - /* Signals */ - void (* change_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection); - void (* change_subselection) (Inkscape::Application * inkscape, SPDesktop *desktop); - void (* modify_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection, guint flags); - void (* set_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection); - void (* set_eventcontext) (Inkscape::Application * inkscape, Inkscape::UI::Tools::ToolBase * eventcontext); - void (* activate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop); - void (* deactivate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop); - void (* destroy_document) (Inkscape::Application *inkscape, SPDocument *doc); - void (* color_set) (Inkscape::Application *inkscape, SPColor *color, double opacity); - void (* shut_down) (Inkscape::Application *inkscape); - void (* dialogs_hide) (Inkscape::Application *inkscape); - void (* dialogs_unhide) (Inkscape::Application *inkscape); - void (* external_change) (Inkscape::Application *inkscape); -}; -#endif - -// static guint inkscape_signals[LAST_SIGNAL] = {0}; - static void (* segv_handler) (int) = SIG_DFL; static void (* abrt_handler) (int) = SIG_DFL; static void (* fpe_handler) (int) = SIG_DFL; @@ -166,123 +93,39 @@ static void (* bus_handler) (int) = SIG_DFL; #define INKSCAPE_LEGACY_PROFILE_DIR ".inkscape" #define MENUS_FILE "menus.xml" - -/** - * Initializes the inkscape class, registering all of its signal handlers - * and virtual functions - */ - -#if 0 -static void -inkscape_class_init (Inkscape::ApplicationClass * klass) -{ - GObjectClass * object_class; - - object_class = (GObjectClass *) klass; - - parent_class = (GObjectClass *)g_type_class_peek_parent (klass); - - inkscape_signals[MODIFY_SELECTION] = g_signal_new ("modify_selection", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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 (Inkscape::ApplicationClass, 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; -} -#endif +#define SP_INDENT 8 #ifdef WIN32 typedef int uid_t; #define getuid() 0 #endif +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; +}; + Inkscape::Application * inkscape_ref(Inkscape::Application * in) { g_return_val_if_fail(in != NULL, NULL); - g_return_val_if_fail(dynamic_cast<Inkscape::Application *>(in) != NULL, NULL); in->refCount++; return in; @@ -291,7 +134,6 @@ Inkscape::Application * inkscape_ref(Inkscape::Application * in) Inkscape::Application * inkscape_unref(Inkscape::Application * in) { g_return_val_if_fail(in != NULL, NULL); - g_return_val_if_fail(dynamic_cast<Inkscape::Application *>(in) != NULL, NULL); in->refCount--; @@ -302,6 +144,40 @@ Inkscape::Application * inkscape_unref(Inkscape::Application * in) return NULL; } +int inkscape_autosave(gpointer) { + g_assert(inkscape != NULL); + return inkscape->autosave(); +} + +/** + * Returns the current Inkscape::Application global object + */ +Inkscape::Application * +inkscape_get_instance() +{ + return inkscape; +} + +/* fixme: This is EVIL, and belongs to main after all */ + +static bool crashIsHappening = false; + +bool inkscapeIsCrashing() +{ + return crashIsHappening; +} + + +void +inkscape_application_init (const gchar *argv0, gboolean use_gui) +{ + if (!inkscape) { + inkscape = new Inkscape::Application(argv0, use_gui); + } else { + g_assert_not_reached(); + } +} + namespace Inkscape { /** @@ -371,7 +247,6 @@ int Application::autosave() ++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; @@ -402,8 +277,6 @@ int Application::autosave() } } - // 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 @@ -425,8 +298,6 @@ int Application::autosave() 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; @@ -464,15 +335,6 @@ int Application::autosave() return TRUE; } -} // namespace Inkscape - -int inkscape_autosave(gpointer) { - g_assert(inkscape != NULL); - return inkscape->autosave(); -} - -namespace Inkscape { - void Application::autosave_init() { static guint32 autosave_timeout_id = 0; @@ -484,46 +346,114 @@ void Application::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); } } +void Application::argv0(char const* argv) +{ + _argv0 = g_strdup(argv); +} + -Application::Application() +Application::Application(const char* argv, bool use_gui) : + refCount(1), + _dialogs_toggle(TRUE), + _mapalt(GDK_MOD1_MASK), + _trackalt(FALSE), + _use_gui(use_gui), + menus(NULL), + desktops(NULL) { - if (!inkscape) { - inkscape = this; - } else { - g_assert_not_reached(); + /* fixme: load application defaults */ + + 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 + + _argv0 = g_strdup(argv); + + /* 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); + } } - this->menus = NULL; - this->desktops = NULL; - this->_dialogs_toggle = TRUE; - this->_mapalt = GDK_MOD1_MASK; - this->_trackalt = FALSE; + if (use_gui) { + load_menus(); + 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) + { + mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); + trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); + } + + /* Initialize the extensions */ + Inkscape::Extension::init(); + + autosave_init(); } Application::~Application() { - g_assert (!desktops); + if (desktops) { + g_error("FATAL: desktops still in list on application destruction!"); + } Inkscape::Preferences::unload(); if (menus) { - /* fixme: This is not the best place */ Inkscape::GC::release(menus); menus = NULL; } + if (_argv0) { + g_free(_argv0); + _argv0 = NULL; + } + + refCount = 0; gtk_main_quit (); } @@ -537,36 +467,8 @@ void Application::mapalt(guint maskvalue) } } -} // namespace Inkscape -#if 0 -static void -inkscape_activate_desktop_private (Inkscape::Application *, SPDesktop *desktop) -{ - desktop->set_active (true); -} - - -static void -inkscape_deactivate_desktop_private (Inkscape::Application *, SPDesktop *desktop) -{ - desktop->set_active (false); -} -#endif - -/* fixme: This is EVIL, and belongs to main after all */ - -#define SP_INDENT 8 - - -static bool crashIsHappening = false; - -bool inkscapeIsCrashing() -{ - return crashIsHappening; -} - -static void -inkscape_crash_handler (int /*signum*/) +void +Application::crash_handler (int /*signum*/) { using Inkscape::Debug::SimpleEvent; using Inkscape::Debug::EventTracker; @@ -606,7 +508,7 @@ 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(); @@ -771,117 +673,6 @@ 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 = new Inkscape::Application(); - /* 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::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 Inkscape::Application global object - */ -Inkscape::Application * -inkscape_get_instance() -{ - return inkscape; -} - -namespace Inkscape { - -//gboolean inkscape_use_gui() -//{ -// return inkscape_get_instance()->use_gui; -//} - /** * Menus management * @@ -894,7 +685,7 @@ bool Application::load_menus() 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; @@ -906,7 +697,7 @@ bool Application::load_menus() menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); } - return (inkscape->menus != 0); + return (menus != 0); } @@ -917,7 +708,6 @@ Application::selection_modified (Inkscape::Selection *selection, guint flags) if (DESKTOP_IS_ACTIVE (selection->desktop())) { signal_selection_modified.emit(this, selection, flags); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[MODIFY_SELECTION], 0, selection, flags); } } @@ -929,7 +719,6 @@ Application::selection_changed (Inkscape::Selection * selection) if (DESKTOP_IS_ACTIVE (selection->desktop())) { signal_selection_changed.emit(this, selection); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); } } @@ -940,7 +729,6 @@ Application::subselection_changed (SPDesktop *desktop) if (DESKTOP_IS_ACTIVE (desktop)) { signal_subselection_changed.emit(this, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SUBSELECTION], 0, desktop); } } @@ -953,8 +741,6 @@ Application::selection_set (Inkscape::Selection * selection) if (DESKTOP_IS_ACTIVE (selection->desktop())) { signal_selection_set.emit(this, selection); signal_selection_changed.emit(this, selection); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, selection); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); } } @@ -967,7 +753,6 @@ Application::eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext) if (DESKTOP_IS_ACTIVE (eventcontext->desktop)) { signal_eventcontext_set.emit(this, eventcontext); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, eventcontext); } } @@ -977,23 +762,20 @@ Application::add_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); if (desktops == NULL) { - desktops = new std::list<SPDesktop*>; + desktops = new std::vector<SPDesktop*>; g_message("Creating new desktop list."); } - //g_return_if_fail (inkscape != NULL); - g_assert (std::find(desktops->begin(), desktops->end(), desktop) == desktops->end()); + if (std::find(desktops->begin(), desktops->end(), desktop) != desktops->end()) { + g_error("Attempted to add desktop already in list."); + } - desktops->push_front(desktop); + desktops->insert(desktops->begin(), desktop); signal_activate_desktop.emit(this, desktop); signal_eventcontext_set.emit(this, desktop->getEventContext()); signal_selection_set.emit(this, sp_desktop_selection(desktop)); signal_selection_changed.emit(this, sp_desktop_selection(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)); } @@ -1004,39 +786,36 @@ Application::remove_desktop (SPDesktop * desktop) g_return_if_fail (desktop != NULL); g_return_if_fail (inkscape != NULL); - g_assert (std::find (desktops->begin(), desktops->end(), desktop) != desktops->end() ); + if (std::find (desktops->begin(), desktops->end(), desktop) == desktops->end() ) { + g_error("Attempted to remove desktop not in list."); + } if (DESKTOP_IS_ACTIVE (desktop)) { signal_deactivate_desktop.emit(this, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, desktop); if (desktops->size() > 1) { SPDesktop * new_desktop = *(++desktops->begin()); - desktops->remove(new_desktop); - desktops->push_front(new_desktop); + desktops->erase(std::find(desktops->begin(), desktops->end(), new_desktop)); + desktops->insert(desktops->begin(), new_desktop); signal_activate_desktop.emit(this, new_desktop); signal_eventcontext_set.emit(this, new_desktop->getEventContext()); signal_selection_set.emit(this, sp_desktop_selection(new_desktop)); signal_selection_changed.emit(this, sp_desktop_selection(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)); } else { signal_eventcontext_set.emit(this, NULL); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL); if (sp_desktop_selection(desktop)) sp_desktop_selection(desktop)->clear(); } } - desktops->remove(desktop); + desktops->erase(std::find(desktops->begin(), desktops->end(), desktop)); // if this was the last desktop, shut down the program if (desktops->empty()) { g_message("Shutting down."); this->exit(); delete desktops; + desktops = NULL; } } @@ -1051,28 +830,23 @@ Application::activate_desktop (SPDesktop * desktop) return; } - SPDesktop* oldDesktop = 0; - std::list<SPDesktop*>::iterator i; + std::vector<SPDesktop*>::iterator i; - g_assert ((i = std::find (desktops->begin(), desktops->end(), desktop)) != desktops->end()); + if ((i = std::find (desktops->begin(), desktops->end(), desktop)) == desktops->end()) { + g_error("Tried to activate desktop not added to list."); + } - oldDesktop = *i; SPDesktop *current = desktops->front(); signal_deactivate_desktop.emit(this, current); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current); - desktops->remove (desktop); - desktops->push_front (desktop); + desktops->erase (i); + desktops->insert (desktops->begin(), desktop); signal_activate_desktop.emit(this, desktop); signal_eventcontext_set.emit(this, desktop->getEventContext()); signal_selection_set(this, sp_desktop_selection(desktop)); signal_selection_changed(this, sp_desktop_selection(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)); } @@ -1086,7 +860,6 @@ Application::reactivate_desktop (SPDesktop * desktop) if (DESKTOP_IS_ACTIVE (desktop)) { signal_activate_desktop.emit(this, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); } } @@ -1095,7 +868,7 @@ Application::reactivate_desktop (SPDesktop * desktop) SPDesktop * Application::find_desktop_by_dkey (unsigned int dkey) { - for (std::list<SPDesktop*>::iterator r = desktops->begin(); r != desktops->end(); r++) { + for (std::vector<SPDesktop*>::iterator r = desktops->begin(), e = desktops->end(); r != e; ++r) { if ((*r)->dkey == dkey){ return *r; } @@ -1109,7 +882,7 @@ Application::maximum_dkey() { unsigned int dkey = 0; - for (std::list<SPDesktop*>::iterator r = desktops->begin(); r != desktops->end(); r++) { + for (std::vector<SPDesktop*>::iterator r = desktops->begin(), e = desktops->end(); r != e; ++r) { if ((*r)->dkey > dkey){ dkey = (*r)->dkey; } @@ -1127,7 +900,7 @@ Application::next_desktop () if (dkey_current < maximum_dkey()) { // find next existing - for (unsigned int i = dkey_current + 1; i <= maximum_dkey(); i++) { + for (unsigned int i = dkey_current + 1; i <= maximum_dkey(); ++i) { d = find_desktop_by_dkey (i); if (d) { break; @@ -1135,7 +908,7 @@ Application::next_desktop () } } else { // find first existing - for (unsigned int i = 0; i <= maximum_dkey(); i++) { + for (unsigned int i = 0; i <= maximum_dkey(); ++i) { d = find_desktop_by_dkey (i); if (d) { break; @@ -1157,7 +930,7 @@ Application::prev_desktop () if (dkey_current > 0) { // find prev existing - for (signed int i = dkey_current - 1; i >= 0; i--) { + for (signed int i = dkey_current - 1; i >= 0; --i) { d = find_desktop_by_dkey (i); if (d) { break; @@ -1191,7 +964,6 @@ void Application::dialogs_hide() { signal_dialogs_hide.emit(this); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0); _dialogs_toggle = FALSE; } @@ -1201,7 +973,6 @@ void Application::dialogs_unhide() { signal_dialogs_unhide.emit(this); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0); _dialogs_toggle = TRUE; } @@ -1220,9 +991,7 @@ Application::dialogs_toggle() void Application::external_change() { - //g_return_if_fail (inkscape != NULL); signal_external_change.emit(this); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[EXTERNAL_CHANGE], 0); } /** @@ -1318,7 +1087,7 @@ Application::sole_desktop_for_document(SPDesktop const &desktop) { if (!document) { return false; } - for ( std::list<SPDesktop*>::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++ ) { + 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 ) { @@ -1357,7 +1126,7 @@ Inkscape::ActionContext 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 (std::list<SPDesktop*>::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++) { + 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); @@ -1365,8 +1134,8 @@ Application::action_context_for_document(SPDocument *doc) } // 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()); @@ -1380,7 +1149,7 @@ Application::action_context_for_document(SPDocument *doc) void Application::refresh_display () { - for (std::list<SPDesktop*>::iterator l = desktops->begin(); l != desktops->end(); l++) { + for (std::vector<SPDesktop*>::iterator l = desktops->begin(), e = desktops->end(); l != e; ++l) { (*l)->requestRedraw(); } } @@ -1393,11 +1162,8 @@ Application::refresh_display () void Application::exit () { - g_assert (INKSCAPE); - //emit shutdown signal so that dialogs could remember layout signal_shut_down.emit(this); - //g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0); Inkscape::Preferences::unload(); gtk_main_quit (); @@ -1411,7 +1177,9 @@ Application::homedir_path(const char *filename) homedir = g_get_home_dir(); } if (!homedir) { - homedir = g_path_get_dirname(INKSCAPE->argv0); + if (inkscape) { + homedir = g_path_get_dirname(inkscape->_argv0); + } } return g_build_filename(homedir, filename, NULL); } @@ -1544,9 +1312,7 @@ Application::get_menus() void Application::get_all_desktops(std::list< SPDesktop* >& listbuf) { - for (std::list<SPDesktop*>::iterator it = desktops->begin(); it != desktops->end(); it++) { - listbuf.push_back(*it); - } + listbuf.insert(listbuf.end(), desktops->begin(), desktops->end()); } } // namespace Inkscape diff --git a/src/inkscape.h b/src/inkscape.h index f37da7472..4b969bddb 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -14,19 +14,20 @@ */ #include <map> -#include <list> -#include "selection.h" -#include "color.h" -#include "layer-model.h" +#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 { -struct Application; +class Application; namespace UI { namespace Tools { @@ -48,6 +49,8 @@ Inkscape::Application * inkscape_ref (Inkscape::Application * in); Inkscape::Application * inkscape_unref(Inkscape::Application * in); #define INKSCAPE inkscape_get_instance() +#define SP_INKSCAPE(obj) (dynamic_cast<Inkscape::Application*>(obj)) +#define SP_IS_INKSCAPE(obj) (dynamic_cast<Inkscape::Application*> (obj) != NULL) #define SP_ACTIVE_EVENTCONTEXT (INKSCAPE->active_event_context()) #define SP_ACTIVE_DOCUMENT (INKSCAPE->active_document()) #define SP_ACTIVE_DESKTOP (INKSCAPE->active_desktop()) @@ -72,24 +75,24 @@ public: namespace Inkscape { -struct Application { +class Application { private: unsigned refCount; gboolean _dialogs_toggle; guint _mapalt; guint _trackalt; - gboolean _use_gui; // may want to consider a virtual function - // for overriding things like the warning dlg's + char * _argv0; + bool _use_gui; // may want to consider a virtual function + // for overriding things like the warning dlg's public: - Application(); + Application(const char* argv0, bool use_gui); ~Application(); Inkscape::XML::Document *menus; std::map<SPDocument *, int> document_set; std::map<SPDocument *, AppSelectionModel *> selection_models; - std::list<SPDesktop *> * desktops; - gchar *argv0; + std::vector<SPDesktop *> * desktops; // 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 @@ -101,9 +104,12 @@ public: guint trackalt() const { return _trackalt; } void trackalt(guint trackvalue) { _trackalt = trackvalue; } - gboolean use_gui() const { return _use_gui; } + 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 *); + // signals // one of selections changed @@ -188,8 +194,8 @@ public: void add_document (SPDocument *document); bool remove_document (SPDocument *document); - gchar *homedir_path(const char *filename); - gchar *profile_path(const char *filename); + static char *homedir_path(const char *filename); + static char *profile_path(const char *filename); // fixme: This has to be rethought void refresh_display (); @@ -197,6 +203,8 @@ public: // fixme: This also void exit (); + static void crash_handler(int signum); + int autosave(); friend Application * ::inkscape_ref (Application * in); diff --git a/src/inkview.cpp b/src/inkview.cpp index df2661968..f1be398f7 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -232,7 +232,7 @@ main (int argc, const char **argv) ss.view = NULL; ss.fullscreen = false; - inkscape = new Inkscape::Application;//(Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); + inkscape = new Inkscape::Application(argv[0], true); // starting at where the commandline options stopped parsing because // we want all the files to be in the list diff --git a/src/interface.cpp b/src/interface.cpp index 987c4987e..7fd2b6275 100644 --- a/src/interface.cpp +++ b/src/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" diff --git a/src/main.cpp b/src/main.cpp index 597cda27d..77be9a275 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" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ebd5f4510..ec5bc659c 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" diff --git a/src/selection.cpp b/src/selection.cpp index b1fa4b32d..48f6e2414 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" diff --git a/src/test-helpers.h b/src/test-helpers.h index 001356e65..d2507128c 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 diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 8d9baff48..357fe440c 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -18,7 +18,7 @@ #include <cstring> #include <string> -#include "inkscape-private.h" +#include "inkscape.h" #include "desktop.h" #include "desktop-handles.h" #include <glibmm/i18n.h> diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 527f4d59c..35a9a8376 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1044,12 +1044,10 @@ AlignAndDistribute::AlignAndDistribute() contents->pack_start(_nodesFrame, true, true); //Connect to the global tool change signal - INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)))); - //g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this); + _toolChangeConn = INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)))); // Connect to the global selection change, to invalidate cached randomize_bbox - INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)))); - //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); + _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(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) ); @@ -1062,13 +1060,13 @@ AlignAndDistribute::AlignAndDistribute() 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(); } 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 b0298afa6..4d5d50de0 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1271,8 +1271,7 @@ CloneTiler::CloneTiler () : // external_change (so we're not fooled by undo) selectChangedConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg))); externChangedConn = INKSCAPE->signal_external_change.connect (sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg))); - //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), this); // update now @@ -1384,9 +1383,6 @@ void CloneTiler::clonetiler_external_change(GtkWidget *dlg) 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); diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 3a8f5176e..06f0216a7 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -45,7 +45,6 @@ void DesktopTracker::connect(GtkWidget *widget) sigc::bind( sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this) )); - //inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this ); GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET); if (wdgt && !base) { @@ -66,8 +65,6 @@ void DesktopTracker::disconnect() } if (inkID.connected()) { inkID.disconnect(); - //g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID); - //inkID = 0; } } diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index e98befc89..d0da70a60 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -48,37 +48,6 @@ gboolean sp_retransientize_again(gpointer dlgPtr) return FALSE; // so that it is only called once } -#if 0 -void sp_retransientize(SPDesktop *desktop, Dialog * dlgPtr) -{ - Dialog *dlg = static_cast<Dialog *>(dlgPtr); - dlg->onDesktopActivated (desktop); -} - -void sp_dialog_shutdown(GObject * /*object*/, Dialog * dlgPtr) -{ - Dialog *dlg = static_cast<Dialog *>(dlgPtr); - dlg->onShutdown(); -} - - -static void hideCallback(GObject * /*object*/, Dialog * dlgPtr) -{ - g_return_if_fail( dlgPtr != NULL ); - - Dialog *dlg = static_cast<Dialog *>(dlgPtr); - dlg->onHideF12(); -} - -static void unhideCallback(GObject * /*object*/, Dialog* dlgPtr) -{ - g_return_if_fail( dlgPtr != NULL ); - - Dialog *dlg = static_cast<Dialog *>(dlgPtr); - dlg->onShowF12(); -} -#endif - //===================================================================== Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num, @@ -108,10 +77,6 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onHideF12))); INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShowF12))); INKSCAPE->signal_shut_down.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShutdown))); - //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); 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/export.cpp b/src/ui/dialog/export.cpp index 3aad1a8a8..579b6aec7 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" diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 117420b47..028c94ec1 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(Inkscape::Application */*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 //######################################################################### @@ -606,7 +595,6 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) { // Selection Change signal INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)))); - //g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); } Gtk::Box *contents = this; diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index 1589c7058..470d0d1b3 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -49,7 +49,7 @@ public: virtual UI::Widget::Panel &getPanel() { return _panel; } protected: - static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { + /*static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { g_return_if_fail(data != NULL); static_cast<PanelDialogBase *>(data)->_propagateDesktopDeactivated(application, desktop); } @@ -57,7 +57,7 @@ protected: static void _handle_activate_desktop(Inkscape::Application *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(Inkscape::Application *, SPDesktop *); @@ -249,8 +249,6 @@ PanelDialog<Behavior::FloatingBehavior> *PanelDialog<Behavior::FloatingBehavior> 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)); - //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); return instance; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 9df328566..8bc9ad275 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -156,10 +156,8 @@ Transformation::Transformation() } // Connect to the global selection changed & modified signals - INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); - INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)))); - //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::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); + _selModifyConn = INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(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())); @@ -169,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/view/view.cpp b/src/ui/view/view.cpp index cfedb6921..2b5ff169d 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 { diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 4b22bba67..3448283b9 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -119,9 +119,7 @@ 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::hide(sigc::mem_fun(*this, &Dock::hide))); INKSCAPE->signal_dialogs_unhide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::show))); diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 537db0fdd..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( - Inkscape::Application *application, - SPDesktop *desktop, - ObjectCompositeSettings *w -) { - if (w->_subject) { - w->_subject->setDesktop(desktop); - } -} - -void ObjectCompositeSettings::_on_desktop_deactivate( - Inkscape::Application *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/verbs.cpp b/src/verbs.cpp index 420b243d0..4626621a9 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 "interface.h" #include "layer-fns.h" #include "layer-manager.h" diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index de5db279f..8822416a7 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 "interface.h" #include "macros.h" #include "preferences.h" diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 17ac887c4..9fb439a28 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1032,13 +1032,20 @@ 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); + + INKSCAPE->signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&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 ); + + INKSCAPE->signal_shut_down.connect( + sigc::hide<0>( + sigc::hide_return( + sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL) + ))); + INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg))); + INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg))); gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 98d528d4a..322b444b9 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -314,9 +314,6 @@ GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, Inkscape::Application *i spw->selModified = spw->inkscape->signal_selection_modified.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)); spw->selChanged = spw->inkscape->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)); spw->selSet = spw->inkscape->signal_selection_set.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::setSelectionCB), 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); } g_signal_emit(spw, signals[CONSTRUCT], 0); |
