summaryrefslogtreecommitdiffstats
path: root/src/help.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:29:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:29:01 +0000
commit35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch)
tree657d15a03cc46bd099fc2c6546a7a4ad43815d9f /src/help.cpp
parentInitial commit. (diff)
downloadinkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.tar.xz
inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.zip
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/help.cpp')
-rw-r--r--src/help.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/help.cpp b/src/help.cpp
new file mode 100644
index 0000000..479dbfc
--- /dev/null
+++ b/src/help.cpp
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/**
+ * Help/About window
+ *
+ * Authors:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ * bulia byak <buliabyak@users.sf.net>
+ *
+ * Copyright (C) 1999-2005 authors
+ * Copyright (C) 2000-2002 Ximian, Inc.
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#include "help.h"
+
+#include <glibmm.h>
+#include <glibmm/i18n.h>
+#include <gtkmm.h>
+
+#include "inkscape-application.h"
+
+#include "include/gtkmm_version.h"
+#include "io/resource.h"
+#include "ui/interface.h" // sp_ui_error_dialog
+#include "ui/dialog/aboutbox.h"
+
+void sp_help_about()
+{
+ Inkscape::UI::Dialog::AboutBox::show_about();
+}
+
+/** Open an URL in the the default application
+ *
+ * See documentation of gtk_show_uri_on_window() for details
+ *
+ * @param url URL to be opened
+ * @param window Parent window for which the URL is opened
+ */
+// TODO: Do we really need a window reference here? It's the way recommended by gtk, though.
+void sp_help_open_url(const Glib::ustring &url, Gtk::Window *window)
+{
+#if GTKMM_CHECK_VERSION(3,24,0)
+ try {
+ window->show_uri(url, GDK_CURRENT_TIME);
+ } catch (const Glib::Error &e) {
+ g_warning("Unable to show '%s': %s", url.c_str(), e.what().c_str());
+ }
+#else
+ GError *error = nullptr;
+ gtk_show_uri_on_window(window->gobj(), url.c_str(), GDK_CURRENT_TIME, &error);
+ if (error) {
+ g_warning("Unable to show '%s': %s", url.c_str(), error->message);
+ g_error_free(error);
+ }
+#endif
+}
+
+void sp_help_open_tutorial(Glib::ustring name)
+{
+ Glib::ustring filename = name + ".svg";
+
+ filename = Inkscape::IO::Resource::get_filename(Inkscape::IO::Resource::TUTORIALS, filename.c_str(), true);
+ if (!filename.empty()) {
+ Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(filename);
+ ConcreteInkscapeApplication<Gtk::Application>* app = &(ConcreteInkscapeApplication<Gtk::Application>::get_instance());
+ app->create_window(file, false, false);
+ } else {
+ // TRANSLATORS: Please don't translate link unless the page exists in your language. Add your language code to
+ // the link this way: https://inkscape.org/[lang]/learn/tutorials/
+ sp_ui_error_dialog(_("The tutorial files are not installed.\nFor Linux, you may need to install "
+ "'inkscape-tutorials'; for Windows, please re-run the setup and select 'Tutorials'.\nThe "
+ "tutorials can also be found online at https://inkscape.org/en/learn/tutorials/"));
+ }
+}
+
+/*
+ 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 :