// SPDX-License-Identifier: GPL-2.0-or-later /* * The main Inkscape application. * * Copyright (C) 2018 Tavmjong Bah * * The contents of this file may be used under the GNU General Public License Version 2 or later. * */ #ifndef INKSCAPE_APPLICATION_H #define INKSCAPE_APPLICATION_H /* * The main Inkscape application. * * Copyright (C) 2018 Tavmjong Bah * * The contents of this file may be used under the GNU General Public License Version 2 or later. * */ #include #include "document.h" #include "selection.h" #include "helper/action.h" #include "io/file-export-cmd.h" // File export (non-verb) typedef std::vector > action_vector_t; class InkscapeWindow; class SPDocument; class SPDesktop; class InkscapeApplication { public: virtual void on_startup() = 0; virtual void on_startup2() = 0; virtual InkFileExportCmd* file_export() = 0; virtual int on_handle_local_options(const Glib::RefPtr& options) = 0; virtual void on_new() = 0; virtual void on_quit() = 0; SPDocument* get_active_document() { return _active_document; }; Inkscape::Selection* get_active_selection(); // { return _active_selection; }; protected: bool _with_gui; bool _batch_process; // Temp bool _use_shell; InkscapeApplication(); // Documents are owned by the application which is responsible for opening/saving/exporting. WIP // std::vector _documents; For a true headless version std::map > _documents; // We keep track of these things so we don't need a window to find them (for headless operation). SPDocument* _active_document; Inkscape::Selection* active_selection; // This should be a view once view doesn't depend on GUI. InkFileExportCmd _file_export; // Actions from the command line or file. action_vector_t _command_line_actions; }; // T can be either: // Gio::Application (window server is not present) or // Gtk::Application (window server is present). // With Gtk::Application, one can still run "headless" by not creating any windows. template class ConcreteInkscapeApplication : public T, public InkscapeApplication { public: ConcreteInkscapeApplication(); public: InkFileExportCmd* file_export() override { return &_file_export; } protected: void on_startup() override; void on_startup2() override; void on_activate() override; void on_open(const Gio::Application::type_vec_files& files, const Glib::ustring& hint) override; SPDesktop* create_window(const Glib::RefPtr& file = Glib::RefPtr()); void parse_actions(const Glib::ustring& input, action_vector_t& action_vector); private: // Callbacks int on_handle_local_options(const Glib::RefPtr& options) override; // Actions void on_new() override; void on_quit() override; void on_about(); void shell(); void shell2(); Glib::RefPtr _builder; }; #endif // INKSCAPE_APPLICATION_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 :