diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-06-25 15:32:51 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-06-25 15:32:51 +0000 |
| commit | 69ae98cb453849c6d32a1c7ea8bc057fb13deea3 (patch) | |
| tree | 6defcecd267d9757d9667367541d00d07c2a5e40 /src | |
| parent | fix bug introduced in rev. 13403 (merge with trunk) (diff) | |
| download | inkscape-69ae98cb453849c6d32a1c7ea8bc057fb13deea3.tar.gz inkscape-69ae98cb453849c6d32a1c7ea8bc057fb13deea3.zip | |
1. make it compile
(bzr r13341.5.1)
Diffstat (limited to 'src')
42 files changed, 542 insertions, 458 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp index 13a8d0e3e..080ff2e21 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -403,7 +403,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/desktop.cpp b/src/desktop.cpp index f14a314b9..e90b2caec 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1431,7 +1431,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/document-undo.cpp b/src/document-undo.cpp index 39c8a04a0..da40dcd4d 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -271,7 +271,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) doc->priv->seeking = false; if (ret) - inkscape_external_change(); + INKSCAPE->external_change(); return ret; } @@ -316,7 +316,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.cpp b/src/document.cpp index f79a00178..80e9bfe4f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -218,7 +218,7 @@ SPDocument::~SPDocument() { } if (keepalive) { - inkscape_unref(); + inkscape_unref(INKSCAPE); keepalive = FALSE; } @@ -448,7 +448,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 diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 3c8ee5844..2ebf8964d 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -89,11 +89,11 @@ 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()) { + if (INKSCAPE != NULL && 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..2970bf8d9 100644 --- a/src/extension/error-file.cpp +++ b/src/extension/error-file.cpp @@ -50,7 +50,7 @@ ErrorFileNotice::ErrorFileNotice (void) : { /* 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->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 06e35ff3e..b62cfd8af 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -662,7 +662,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->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 f0fd3711b..bacb126ef 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -1031,7 +1031,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..57d7f9e33 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->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 0111ed626..6048c232c 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -237,7 +237,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..04d3f27e1 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->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 63581bd8a..fbb8b0793 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -696,7 +696,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 6fc79237b..6b435746b 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -236,7 +236,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 c244d9c16..e81ec0e42 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 51e629c7d..2c0ba5365 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -175,7 +175,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->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"); @@ -314,7 +314,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/inkscape-private.h b/src/inkscape-private.h index d28ed223e..a55d92829 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -14,42 +14,42 @@ */ #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)) +//#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); +//GType inkscape_get_type (void); -void inkscape_ref (void); -void inkscape_unref (void); +//void inkscape_ref (void); +//void inkscape_unref (void); -guint inkscape_mapalt(); -void inkscape_mapalt(guint); +//guint inkscape_mapalt(); +//void inkscape_mapalt(guint); -guint inkscape_trackalt(); -void inkscape_trackalt(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_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); +//void inkscape_set_color (SPColor *color, float opacity); #endif // SEEN_INKSCAPE_PRIVATE_H diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 4b4c8c678..23c2b001a 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -76,6 +76,7 @@ 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 @@ -91,25 +92,27 @@ enum { // may not be reflected by a selection change and thus needs a separate signal LAST_SIGNAL }; +#endif -#define DESKTOP_IS_ACTIVE(d) (inkscape->desktops && ((d) == inkscape->desktops->data)) +#define DESKTOP_IS_ACTIVE(d) (!inkscape->desktops->empty() && ((d) == inkscape->desktops->front())) /*################################ # FORWARD DECLARATIONS ################################*/ -namespace Inkscape { -struct ApplicationClass; -} +//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_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); +//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; @@ -125,21 +128,9 @@ public: Inkscape::Selection *getSelection() const { return _selection; } }; +#endif -struct Inkscape::Application { - 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; -}; - +#if 0 struct Inkscape::ApplicationClass { GObjectClass object_class; @@ -158,9 +149,9 @@ struct Inkscape::ApplicationClass { void (* dialogs_unhide) (Inkscape::Application *inkscape); void (* external_change) (Inkscape::Application *inkscape); }; +#endif -static GObjectClass * parent_class; -static guint inkscape_signals[LAST_SIGNAL] = {0}; +// static guint inkscape_signals[LAST_SIGNAL] = {0}; static void (* segv_handler) (int) = SIG_DFL; static void (* abrt_handler) (int) = SIG_DFL; @@ -177,33 +168,11 @@ static void (* bus_handler) (int) = SIG_DFL; /** - * Retrieves the GType for the Inkscape Application object. - */ -GType -inkscape_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (Inkscape::ApplicationClass), - NULL, NULL, - (GClassInitFunc) inkscape_class_init, - NULL, NULL, - sizeof (Inkscape::Application), - 4, - (GInstanceInitFunc) inkscape_init, - NULL - }; - type = g_type_register_static (G_TYPE_OBJECT, "Inkscape_Application", &info, (GTypeFlags)0); - } - return type; -} - - -/** * Initializes the inkscape class, registering all of its signal handlers * and virtual functions */ + +#if 0 static void inkscape_class_init (Inkscape::ApplicationClass * klass) { @@ -303,21 +272,47 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) klass->activate_desktop = inkscape_activate_desktop_private; klass->deactivate_desktop = inkscape_deactivate_desktop_private; } +#endif #ifdef WIN32 typedef int uid_t; #define getuid() 0 #endif +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; +} + +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--; + + if (in->refCount <= 0) { + delete in; + } + + return NULL; +} + +namespace Inkscape { + /** * 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(); @@ -336,7 +331,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 @@ -367,8 +362,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; @@ -469,7 +464,16 @@ static gint inkscape_autosave(gpointer) return TRUE; } -void inkscape_autosave_init() +} // 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; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -493,105 +497,61 @@ void inkscape_autosave_init() } -static void -inkscape_init (SPObject * object) +Application::Application() { if (!inkscape) { - inkscape = (Inkscape::Application *) object; + inkscape = this; } else { - g_assert_not_reached (); + 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; + this->menus = NULL; + //this->desktops = NULL; + this->_dialogs_toggle = TRUE; + this->_mapalt = GDK_MOD1_MASK; + this->_trackalt = FALSE; } -static void -inkscape_dispose (GObject *object) +Application::~Application() { - Inkscape::Application *inkscape = (Inkscape::Application *) object; - - g_assert (!inkscape->desktops); + g_assert (!desktops); Inkscape::Preferences::unload(); - if (inkscape->menus) { + if (menus) { /* fixme: This is not the best place */ - Inkscape::GC::release(inkscape->menus); - inkscape->menus = NULL; + Inkscape::GC::release(menus); + menus = NULL; } - inkscape->selection_models.~map(); - inkscape->document_set.~map(); - - G_OBJECT_CLASS (parent_class)->dispose (object); - gtk_main_quit (); } - -void -inkscape_ref (void) -{ - if (inkscape) - g_object_ref (G_OBJECT (inkscape)); -} - - -void -inkscape_unref (void) -{ - if (inkscape) - g_object_unref (G_OBJECT (inkscape)); -} - -/* 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; -} - /* Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default */ -void inkscape_mapalt(guint maskvalue) +void Application::mapalt(guint maskvalue) { - 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 ( maskvalue < 2 || maskvalue > 5 ) { // MOD5 is the highest defined in gdktypes.h + _mapalt = 0; + } else { + _mapalt = (GDK_MOD1_MASK << (maskvalue-1)); } } -guint -inkscape_trackalt() { - return inkscape->trackalt; -} - -void inkscape_trackalt(guint trackvalue) -{ - inkscape->trackalt = trackvalue; -} - - +} // namespace Inkscape +#if 0 static void -inkscape_activate_desktop_private (Inkscape::Application */*inkscape*/, SPDesktop *desktop) +inkscape_activate_desktop_private (Inkscape::Application *, SPDesktop *desktop) { desktop->set_active (true); } static void -inkscape_deactivate_desktop_private (Inkscape::Application */*inkscape*/, SPDesktop *desktop) +inkscape_deactivate_desktop_private (Inkscape::Application *, SPDesktop *desktop) { desktop->set_active (false); } - +#endif /* fixme: This is EVIL, and belongs to main after all */ @@ -791,7 +751,10 @@ inkscape_crash_handler (int /*signum*/) } *(b + pos) = '\0'; - if ( inkscape_get_instance() && inkscape_use_gui() ) { + // checking whether we have an Inkscape instance after that instance caused an exception is like + // checking if your mother existed after sitting on you and nearly hospitalizing you + + if ( inkscape_get_instance() && inkscape->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); @@ -835,7 +798,7 @@ private: void inkscape_application_init (const gchar *argv0, gboolean use_gui) { - inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); + inkscape = new Inkscape::Application(); /* fixme: load application defaults */ segv_handler = signal (SIGSEGV, inkscape_crash_handler); @@ -846,7 +809,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) bus_handler = signal (SIGBUS, inkscape_crash_handler); #endif - inkscape->use_gui = use_gui; + inkscape->use_gui(use_gui); inkscape->argv0 = g_strdup(argv0); /* Load the preferences and menus */ @@ -862,7 +825,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) } if (use_gui) { - inkscape_load_menus(inkscape); + inkscape->load_menus(); Inkscape::DeviceManager::getManager().loadConfig(); } Inkscape::ResourceManager::getManager(); @@ -891,16 +854,16 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) /* 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))); + 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(); + inkscape->autosave_init(); - return; + //return; } /** @@ -912,25 +875,23 @@ inkscape_get_instance() return inkscape; } -gboolean inkscape_use_gui() -{ - return inkscape_get_instance()->use_gui; -} +namespace Inkscape { + +//gboolean inkscape_use_gui() +//{ +// return inkscape_get_instance()->use_gui; +//} /** * Menus management * */ -bool inkscape_load_menus( Inkscape::Application * 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); @@ -941,8 +902,8 @@ bool inkscape_load_menus( Inkscape::Application * 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 != 0); @@ -950,137 +911,162 @@ bool inkscape_load_menus( Inkscape::Application * inkscape ) 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(this, selection, flags); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[MODIFY_SELECTION], 0, 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(this, selection); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, 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(this, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SUBSELECTION], 0, 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(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); } } 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(this, eventcontext); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, eventcontext); } } void -inkscape_add_desktop (SPDesktop * desktop) +Application::add_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); - g_return_if_fail (inkscape != NULL); + //g_return_if_fail (inkscape != NULL); - g_assert (!g_slist_find (inkscape->desktops, desktop)); + g_assert (std::find(desktops->begin(), desktops->end(), desktop) == desktops->end()); - inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop); + desktops->push_front(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(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)); } 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)); + g_assert (std::find (desktops->begin(), desktops->end(), desktop) != desktops->end() ); 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(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); + + 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 { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL); + 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(); } } - inkscape->desktops = g_slist_remove (inkscape->desktops, desktop); + desktops->remove(desktop); // if this was the last desktop, shut down the program - if (inkscape->desktops == NULL) { - inkscape_exit (inkscape); + if (desktops->empty()) { + this->exit(); } } 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)); + SPDesktop* oldDesktop = 0; + std::list<SPDesktop*>::iterator i; + + g_assert ((i = std::find (desktops->begin(), desktops->end(), desktop)) != desktops->end()); - SPDesktop *current = static_cast<SPDesktop *>(inkscape->desktops->data); + oldDesktop = *i; + SPDesktop *current = desktops->front(); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current); + signal_deactivate_desktop.emit(this, current); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current); - inkscape->desktops = g_slist_remove (inkscape->desktops, desktop); - inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop); + desktops->remove (desktop); + desktops->push_front (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(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)); } @@ -1088,65 +1074,63 @@ 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(this, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, 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::list<SPDesktop*>::iterator r = desktops->begin(); r != desktops->end(); 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::list<SPDesktop*>::iterator r = desktops->begin(); r != desktops->end(); 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; } @@ -1154,22 +1138,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); + d = find_desktop_by_dkey (i); if (d) { break; } @@ -1177,81 +1160,78 @@ 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(this); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0); + _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(this); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0); + _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); + //g_return_if_fail (inkscape != NULL); + signal_external_change.emit(this); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[EXTERNAL_CHANGE], 0); } /** * 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 @@ -1261,10 +1241,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); } } } @@ -1272,24 +1252,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; @@ -1303,37 +1283,38 @@ inkscape_remove_document (SPDocument *document) } SPDesktop * -inkscape_active_desktop (void) +Application::active_desktop() { - if (inkscape->desktops == NULL) { + if (desktops == NULL) { 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::list<SPDesktop*>::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++ ) { + SPDesktop *other_desktop = *iter; + SPDocument *other_document = other_desktop->doc(); if ( other_document == document && other_desktop != &desktop ) { return false; } @@ -1342,7 +1323,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(); @@ -1352,26 +1333,26 @@ 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); + for (std::list<SPDesktop*>::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++) { + SPDesktop *desktop = *iter; if (desktop->doc() == doc) { return Inkscape::ActionContext(desktop); } @@ -1391,10 +1372,10 @@ inkscape_action_context_for_document(SPDocument *doc) #####################*/ void -inkscape_refresh_display (Inkscape::Application *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::list<SPDesktop*>::iterator l = desktops->begin(); l != desktops->end(); l++) { + (*l)->requestRedraw(); } } @@ -1404,19 +1385,20 @@ inkscape_refresh_display (Inkscape::Application *inkscape) * saves the preferences if appropriate, and quits. */ void -inkscape_exit (Inkscape::Application */*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(this); + //g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0); 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) { @@ -1434,7 +1416,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; @@ -1546,21 +1528,23 @@ profile_path(const char *filename) } Inkscape::XML::Node * -inkscape_get_menus (Inkscape::Application * 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)); + for (std::list<SPDesktop*>::iterator it = desktops->begin(); it != desktops->end(); it++) { + listbuf.push_back(*it); } } +} // namespace Inkscape + /* Local Variables: mode:c++ diff --git a/src/inkscape.h b/src/inkscape.h index 823e7524f..f37da7472 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -6,115 +6,215 @@ * * 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 <map> #include <list> +#include "selection.h" +#include "color.h" +#include "layer-model.h" #include <glib.h> +#include <sigc++/signal.h> class SPDesktop; class SPDocument; namespace Inkscape { + +struct Application; namespace UI { namespace Tools { class ToolBase; -} -} -} +} // namespace Tools +} // namespace UI -namespace Inkscape { - class ActionContext; - struct Application; - namespace XML { - class Node; - struct Document; - } -} +class ActionContext; -#define INKSCAPE inkscape_get_instance() +namespace XML { +class Node; +struct Document; +} // namespace XML -void inkscape_autosave_init(); +} // namespace Inkscape -void inkscape_application_init (const gchar *argv0, gboolean use_gui); +Inkscape::Application * inkscape_ref (Inkscape::Application * in); +Inkscape::Application * inkscape_unref(Inkscape::Application * in); -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); +#define INKSCAPE inkscape_get_instance() +#define SP_ACTIVE_EVENTCONTEXT (INKSCAPE->active_event_context()) +#define SP_ACTIVE_DOCUMENT (INKSCAPE->active_document()) +#define SP_ACTIVE_DESKTOP (INKSCAPE->active_desktop()) +// \TODO hack +#define inkscape_active_desktop() SP_ACTIVE_DESKTOP + +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; } +}; -/* Menus */ -bool inkscape_load_menus (Inkscape::Application * inkscape); -bool inkscape_save_menus (Inkscape::Application * inkscape); -Inkscape::XML::Node *inkscape_get_menus (Inkscape::Application * inkscape); +namespace Inkscape { -Inkscape::Application *inkscape_get_instance(); -gboolean inkscape_use_gui(); +struct 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 + +public: + Application(); + ~Application(); + + Inkscape::XML::Document *menus; + std::map<SPDocument *, int> document_set; + std::map<SPDocument *, AppSelectionModel *> selection_models; + std::list<SPDesktop *> * desktops; + gchar *argv0; + + // 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; } + + gboolean use_gui() const { return _use_gui; } + void use_gui(gboolean guival) { _use_gui = guival; } + + // signals + + // one of selections changed + sigc::signal<void, Inkscape::Application *, Inkscape::Selection *> signal_selection_changed; + // one of subselections (text selection, gradient handle, etc) changed + sigc::signal<void, Inkscape::Application *, SPDesktop *> signal_subselection_changed; + // one of selections modified + sigc::signal<void, Inkscape::Application *, Inkscape::Selection *, guint /*flags*/> signal_selection_modified; + // one of selections set + sigc::signal<void, Inkscape::Application *, Inkscape::Selection *> signal_selection_set; + // tool switched + sigc::signal<void, Inkscape::Application *, Inkscape::UI::Tools::ToolBase * /*eventcontext*/> signal_eventcontext_set; + // some desktop got focus + sigc::signal<void, Inkscape::Application *, SPDesktop *> signal_activate_desktop; + // some desktop lost focus + sigc::signal<void, Inkscape::Application *, SPDesktop *> signal_deactivate_desktop; + + // probably orphaned signals + sigc::signal<void, Inkscape::Application *, SPDocument *> signal_destroy_document; + sigc::signal<void, Inkscape::Application *, SPColor *, double /*opacity*/> signal_color_set; + + // inkscape is quitting + sigc::signal<void, Inkscape::Application *> signal_shut_down; + // user pressed F12 + sigc::signal<void, Inkscape::Application *> signal_dialogs_hide; + // user pressed F12 + sigc::signal<void, Inkscape::Application *> 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, Inkscape::Application *> signal_external_change; + + // 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(); + + //static Inkscape::Application* get_instance(); + + 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); + + gchar *homedir_path(const char *filename); + gchar *profile_path(const char *filename); + + // fixme: This has to be rethought + void refresh_display (); + + // fixme: This also + void exit (); + + int autosave(); + + friend Application * ::inkscape_ref (Application * in); + friend Application * ::inkscape_unref(Application * in); +}; + +} // namespace Inkscape bool inkscapeIsCrashing(); -SPDesktop * inkscape_find_desktop_by_dkey (unsigned int dkey); - -#define SP_ACTIVE_EVENTCONTEXT inkscape_active_event_context () -Inkscape::UI::Tools::ToolBase * inkscape_active_event_context (void); - -#define SP_ACTIVE_DOCUMENT inkscape_active_document () -SPDocument * inkscape_active_document (void); - -#define SP_ACTIVE_DESKTOP inkscape_active_desktop () -SPDesktop * inkscape_active_desktop (void); - -// 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); - -// 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(); - -bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop); +// gets the current instance and calls autosave() +int inkscape_autosave(gpointer unused); -gchar *homedir_path(const char *filename); -gchar *profile_path(const char *filename); +// hmm, I wonder what this does /s +Inkscape::Application* inkscape_get_instance(); -/* 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 (Inkscape::Application *inkscape); - -/* - * fixme: This also - */ - -void inkscape_exit (Inkscape::Application *inkscape); +// only temporary until I can properly clean this up +void inkscape_application_init (const gchar *argv0, gboolean use_gui); #endif diff --git a/src/inkview.cpp b/src/inkview.cpp index 82bd08e34..df2661968 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -60,7 +60,7 @@ #include "io/inkjar.h" #endif -#include "inkscape-private.h" +#include "inkscape.h" Inkscape::Application *inkscape; @@ -232,7 +232,7 @@ main (int argc, const char **argv) ss.view = NULL; ss.fullscreen = false; - inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); + inkscape = new Inkscape::Application;//(Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); // 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 1cbeb44a3..987c4987e 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -270,7 +270,7 @@ sp_create_window(SPViewWidget *vw, gboolean 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; } @@ -2106,13 +2106,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/io/resource.cpp b/src/io/resource.cpp index ac1c5f06b..94bd7fca1 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->profile_path(name); } break; } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index c255f8665..a7748c5a8 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -60,7 +60,7 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : concatenate_before_pwd2 = true; // don't split the path into its subpaths _provides_knotholder_entities = true; - Persp3D *persp = persp3d_document_first_persp(inkscape_active_document()); + Persp3D *persp = persp3d_document_first_persp(SP_ACTIVE_DOCUMENT); Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; pmat.copy_tmat(tmat); } diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index 6af616e34..9da7f6a79 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 517ba0506..597cda27d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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->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); @@ -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; } diff --git a/src/persp3d.cpp b/src/persp3d.cpp index b10e5f23b..1088f098d 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(); diff --git a/src/preferences.cpp b/src/preferences.cpp index d0c3783b5..ede60c686 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -91,11 +91,11 @@ Preferences::Preferences() : _hasError(false) { // profile_path essentailly returns the argument prefixed by the profile directory. - gchar *path = profile_path(NULL); + gchar *path = INKSCAPE->profile_path(NULL); _prefs_dir = path; g_free(path); - path = profile_path(_prefs_basename.c_str()); + path = INKSCAPE->profile_path(_prefs_basename.c_str()); _prefs_filename = path; g_free(path); @@ -155,7 +155,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->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 a350dd7a7..ebd5f4510 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3512,7 +3512,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..b1fa4b32d 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -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..016a48d8f 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->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->profile_path("keys")) && !strcmp(lower, "default.xml")) { // Dont add the users custom keys file continue; diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index fe9d32f43..8d9baff48 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -153,7 +153,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/dialog/export.cpp b/src/ui/dialog/export.cpp index 913713e5c..3aad1a8a8 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -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 8ba3ad684..c4281babc 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1044,7 +1044,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->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/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index f1a29e971..f1535175a 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1908,7 +1908,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->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/swatches.cpp b/src/ui/dialog/swatches.cpp index 4f0cb211a..6dbb1d5e9 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->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 c58df864c..9e5e94498 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -572,9 +572,9 @@ void SymbolsDialog::get_symbols() { 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->profile_path("symbols"), G_FILE_TEST_EXISTS ) && + Inkscape::IO::file_test( INKSCAPE->profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { + directories.push_back( INKSCAPE->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 d75f81456..1bd9510dc 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->profile_path("templates") + _loading_path); // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index 72548e213..cfedb6921 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -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/vanishing-point.cpp b/src/vanishing-point.cpp index bb6a2c4d7..66e699b41 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -633,7 +633,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(); diff --git a/src/verbs.cpp b/src/verbs.cpp index 0c329cab8..420b243d0 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -873,10 +873,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); @@ -1170,11 +1170,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: @@ -1188,7 +1188,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: @@ -1929,7 +1929,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; @@ -1948,7 +1948,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)); @@ -2011,7 +2011,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(); @@ -2083,7 +2083,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 6d6b86c4d..ecc7890b9 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -194,7 +194,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")); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 2c28dfbfa..de5db279f 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -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/icon.cpp b/src/widgets/icon.cpp index a96f47124..0814d56d6 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1257,7 +1257,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->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); |
