From 408cb49b5559a81ea803df64bf58457a5dd4bf16 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 12 Nov 2018 21:22:44 +0100 Subject: Rewrite of main.cpp using InkscapeApplication (Gtk::Application) Use Gio::File for accessing files. Use Gio options to handle command line arguments. Use Gio::Actions for some command line arguments. Move file export code to src/io/file-export-cmd.h/.cpp. Make into class. --- src/inkscape-application.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/inkscape-application.h (limited to 'src/inkscape-application.h') diff --git a/src/inkscape-application.h b/src/inkscape-application.h new file mode 100644 index 000000000..b176c2921 --- /dev/null +++ b/src/inkscape-application.h @@ -0,0 +1,80 @@ +// 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 "helper/action.h" +#include "io/file-export-cmd.h" // File export (non-verb) + +class InkscapeApplication : public Gtk::Application +{ +protected: + InkscapeApplication(); + +public: + static Glib::RefPtr create(); + + SPDocument* get_active_document(); + +protected: + void on_startup() override; + void on_startup2(); + void on_activate() override; + void on_open(const Gio::Application::type_vec_files& files, const Glib::ustring& hint) override; + +private: + void create_window(const Glib::RefPtr& file = Glib::RefPtr()); + +private: + // Callbacks + int on_handle_local_options(const Glib::RefPtr& options); + + // Actions + void on_new(); + void on_quit(); + void on_about(); + + Glib::RefPtr _builder; + + bool _with_gui; + InkFileExportCmd _file_export; + + // Documents are owned by the application which is responsible for opening/saving/exporting. WIP + std::vector _documents; + + // Actions from the command line or file. + std::vector > _command_line_actions; +}; + +#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 : -- cgit v1.2.3