1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Actions for opening, saving, etc. files which (mostly) open a dialog or an Inkscape window.
5 * Used by menu items under the "File" submenu.
8 * Sushant A A <sushant.co19@gmail.com>
10 * Copyright (C) 2021 Authors
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16 #include <glibmm/i18n.h>
18 #include "actions-file-window.h"
19 #include "actions-helper.h"
21 #include "inkscape-application.h"
22 #include "inkscape-window.h"
25 #include "preferences.h"
26 #include "ui/dialog/save-template-dialog.h"
27 #include "ui/dialog/new-from-template.h"
30 document_new(InkscapeWindow
* win
)
32 sp_file_new_default();
36 document_dialog_templates(InkscapeWindow
* win
)
39 Inkscape::UI::NewFromTemplate::load_new_from_template(*win
);
44 document_open(InkscapeWindow
* win
)
47 sp_file_open_dialog(*win
, nullptr, nullptr);
51 document_revert(InkscapeWindow
* win
)
53 sp_file_revert_dialog();
57 document_save(InkscapeWindow
* win
)
60 sp_file_save(*win
, nullptr, nullptr);
64 document_save_as(InkscapeWindow
* win
)
67 sp_file_save_as(*win
, nullptr, nullptr);
71 document_save_copy(InkscapeWindow
* win
)
74 sp_file_save_a_copy(*win
, nullptr, nullptr);
78 document_save_template(InkscapeWindow
* win
)
81 Inkscape::UI::Dialog::SaveTemplate::save_document_as_template(*win
);
85 document_import(InkscapeWindow
* win
)
91 document_print(InkscapeWindow
* win
)
98 document_cleanup(InkscapeWindow
* win
)
100 // Cleanup Up Document
101 sp_file_vacuum(win
->get_document());
104 // Close window, checking for data loss. If it's the last window, keep open with new document.
106 document_close(InkscapeWindow
* win
)
109 auto app
= InkscapeApplication::instance();
110 app
->destroyDesktop(win
->get_desktop(), true); // true == keep alive last window
113 std::vector
<std::vector
<Glib::ustring
>> raw_data_dialog_window
=
116 {"win.document-new", N_("New"), "Window-File", N_("Create new document from the default template")},
117 {"win.document-dialog-templates", N_("New from Template"), "Window-File", N_("Create new project from template")},
118 {"win.document-open", N_("Open File Dialog"), "Window-File", N_("Open an existing document")},
119 {"win.document-revert", N_("Revert"), "Window-File", N_("Revert to the last saved version of document (changes will be lost)")},
120 {"win.document-save", N_("Save"), "Window-File", N_("Save document")},
121 {"win.document-save-as", N_("Save As"), "Window-File", N_("Save document under a new name")},
122 {"win.document-save-copy", N_("Save a Copy"), "Window-File", N_("Save a copy of the document under a new name")},
123 {"win.document-save-template", N_("Save Template"), "Window-File", N_("Save a copy of the document as template")},
124 {"win.document-import", N_("Import"), "Window-File", N_("Import a bitmap or SVG image into this document")},
125 {"win.document-print", N_("Print"), "Window-File", N_("Print document")},
126 {"win.document-cleanup", N_("Clean Up Document"), "Window-File", N_("Remove unused definitions (such as gradients or clipping paths) from the document")},
127 {"win.document-close", N_("Close"), "Window-File", N_("Close window (unless last window)")},
132 add_actions_file_window(InkscapeWindow
* win
)
135 win
->add_action( "document-new", sigc::bind(sigc::ptr_fun(&document_new
), win
));
136 win
->add_action( "document-dialog-templates", sigc::bind(sigc::ptr_fun(&document_dialog_templates
), win
));
137 win
->add_action( "document-open", sigc::bind(sigc::ptr_fun(&document_open
), win
));
138 win
->add_action( "document-revert", sigc::bind(sigc::ptr_fun(&document_revert
), win
));
139 win
->add_action( "document-save", sigc::bind(sigc::ptr_fun(&document_save
), win
));
140 win
->add_action( "document-save-as", sigc::bind(sigc::ptr_fun(&document_save_as
), win
));
141 win
->add_action( "document-save-copy", sigc::bind(sigc::ptr_fun(&document_save_copy
), win
));
142 win
->add_action( "document-save-template", sigc::bind(sigc::ptr_fun(&document_save_template
), win
));
143 win
->add_action( "document-import", sigc::bind(sigc::ptr_fun(&document_import
), win
));
144 win
->add_action( "document-print", sigc::bind(sigc::ptr_fun(&document_print
), win
));
145 win
->add_action( "document-cleanup", sigc::bind(sigc::ptr_fun(&document_cleanup
), win
));
146 win
->add_action( "document-close", sigc::bind(sigc::ptr_fun(&document_close
), win
));
149 auto app
= InkscapeApplication::instance();
151 show_output("add_actions_file_window: no app!");
154 app
->get_action_extra_data().add_data(raw_data_dialog_window
);
160 c-file-style:"stroustrup"
161 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
166 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :