Context for the "About" label
[inkscape.git] / src / actions / actions-file-window.cpp
blob20a2fd066fa416c53da8c211f5d982eb1e0ce709
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** \file
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.
7 * Authors:
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.
15 #include <giomm.h>
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"
23 #include "desktop.h"
24 #include "file.h"
25 #include "preferences.h"
26 #include "ui/dialog/save-template-dialog.h"
27 #include "ui/dialog/new-from-template.h"
29 void
30 document_new(InkscapeWindow* win)
32 sp_file_new_default();
35 void
36 document_dialog_templates(InkscapeWindow* win)
38 if (win) {
39 Inkscape::UI::NewFromTemplate::load_new_from_template(*win);
43 void
44 document_open(InkscapeWindow* win)
46 // Open File Dialog
47 sp_file_open_dialog(*win, nullptr, nullptr);
50 void
51 document_revert(InkscapeWindow* win)
53 sp_file_revert_dialog();
56 void
57 document_save(InkscapeWindow* win)
59 // Save File
60 sp_file_save(*win, nullptr, nullptr);
63 void
64 document_save_as(InkscapeWindow* win)
66 // Save File As
67 sp_file_save_as(*win, nullptr, nullptr);
70 void
71 document_save_copy(InkscapeWindow* win)
73 // Save A copy
74 sp_file_save_a_copy(*win, nullptr, nullptr);
77 void
78 document_save_template(InkscapeWindow* win)
80 // Save As Template
81 Inkscape::UI::Dialog::SaveTemplate::save_document_as_template(*win);
84 void
85 document_import(InkscapeWindow* win)
87 sp_file_import(*win);
90 void
91 document_print(InkscapeWindow* win)
93 // Print File
94 sp_file_print(*win);
97 void
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.
105 void
106 document_close(InkscapeWindow* win)
108 // Close
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 =
115 // clang-format off
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)")},
128 // clang-format on
131 void
132 add_actions_file_window(InkscapeWindow* win)
134 // clang-format off
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));
147 // clang-format on
149 auto app = InkscapeApplication::instance();
150 if (!app) {
151 show_output("add_actions_file_window: no app!");
152 return;
154 app->get_action_extra_data().add_data(raw_data_dialog_window);
158 Local Variables:
159 mode:c++
160 c-file-style:"stroustrup"
161 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
162 indent-tabs-mode:nil
163 fill-column:99
164 End:
166 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :