summaryrefslogtreecommitdiffstats
path: root/src/inkscape-application.h
blob: 90553cd0da6145c260e429bafac71fa056e8a027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// 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 <gtkmm.h>

#include "document.h"
#include "selection.h"

#include "helper/action.h"
#include "io/file-export-cmd.h"   // File export (non-verb)

typedef std::vector<std::pair<std::string, Glib::VariantBase> > action_vector_t;

class InkscapeApplication : public Gtk::Application
{
protected:
    InkscapeApplication();

public:
    static Glib::RefPtr<InkscapeApplication> create();

    SPDocument* get_active_document();
    Inkscape::Selection* get_active_selection();

    InkFileExportCmd* file_export() { return &_file_export; }

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:
    SPDesktop* create_window(const Glib::RefPtr<Gio::File>& file = Glib::RefPtr<Gio::File>());
    void parse_actions(const Glib::ustring& input, action_vector_t& action_vector);
    void shell();
    void shell2();

private:
    // Callbacks
    int  on_handle_local_options(const Glib::RefPtr<Glib::VariantDict>& options);

    // Actions
    void on_new();
    void on_quit();
    void on_about();

    Glib::RefPtr<Gtk::Builder> _builder;

    bool _with_gui;
    bool _use_shell;
    InkFileExportCmd _file_export;

    // Documents are owned by the application which is responsible for opening/saving/exporting. WIP
    std::vector<SPDocument*> _documents;

    // Actions from the command line or file.
    action_vector_t _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 :