15#include <cairomm/context.h>
16#include <cairomm/refptr.h>
17#include <cairomm/surface.h>
20#include <glibmm/miscutils.h>
21#include <glibmm/ustring.h>
22#include <gtkmm/image.h>
23#include <gtkmm/window.h>
29#include <glibmm/main.h>
30#include <gtkmm/aspectframe.h>
31#include <gtkmm/builder.h>
32#include <gtkmm/button.h>
33#include <gdkmm/clipboard.h>
34#include <gtkmm/label.h>
35#include <gtkmm/notebook.h>
36#include <gtkmm/textview.h>
37#include <gtkmm/window.h>
38#include <sigc++/adaptors/bind.h>
42#include <sigc++/scoped_connection.h>
61class AboutWindow :
public Gtk::Window {
63 AboutWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>&
builder): Gtk::Window(cobject) {
66 g_error(
"AboutWindow: Missing about screens.");
72 _frame = &get_widget<Gtk::AspectFrame>(
builder,
"aspect-frame");
77 _refresh = Glib::signal_timeout().connect_seconds([
this] {
87 auto ctx =
_viewer2->get_style_context();
88 ctx->remove_class(
"fade-out");
89 ctx->remove_class(
"fade-in");
101 Glib::RefPtr<Glib::TimeoutSource>
_timer;
107 void find_about_screens() {
111 g_warning(
"Error loading about screens SVGZs: no such documents in share/screen/about folder.");
118 Cairo::RefPtr<Cairo::ImageSurface> load_next(Gtk::Picture *viewer,
const Glib::ustring& fname,
int device_scale) {
120 auto surface = renderer.render_surface(device_scale);
122 auto width = renderer.get_width_px();
123 auto height = renderer.get_height_px();
131 void set_footer_matching_color(Cairo::RefPtr<Cairo::ImageSurface>
const &
image)
135 auto scale = get_scale_factor();
141 auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32,
width,
height);
142 cairo_surface_set_device_scale(
surface->cobj(), scale, scale);
143 auto ctx = Cairo::Context::create(
surface);
144 ctx->set_source(
image, 0, -y);
148 bool dark = INKSCAPE.themecontext->isCurrentThemeDark(
this);
151 auto style_context =
_footer->get_style_context();
153 _footer_style->load_from_data(
"box {background-color:" + foot.toString() +
";}");
154 if (_footer_style) style_context->remove_provider(_footer_style);
155 style_context->add_provider(_footer_style, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
162 auto image = load_next(nv, _about_screens[_about_index++ %
_about_screens.size()], get_scale_factor());
164 auto ctx =
_viewer2->get_style_context();
166 ctx->add_class(
"fade-out");
167 ctx->remove_class(
"fade-in");
170 ctx->remove_class(
"fade-out");
171 ctx->add_class(
"fade-in");
174 set_footer_matching_color(
image);
178void copy(Gtk::Button *button, Gtk::Label *
label, Glib::ustring
const &text)
180 auto clipboard = Gdk::Display::get_default()->get_clipboard();
181 clipboard->set_text(text);
184 Glib::signal_timeout().connect_seconds(
185 sigc::track_object([=] {
196template <
class Random>
200 std::vector<std::string> lines;
201 std::size_t capacity = 0;
202 for (std::string line; getline(fn, line);) {
203 capacity += line.size() + 1;
204 lines.push_back(std::move(line));
206 std::shuffle(lines.begin(), lines.end(), random);
207 return std::pair{std::move(lines), capacity};
214 auto window = &get_derived_widget<AboutWindow>(
builder,
"about-screen-window");
215 auto tabs = &get_widget<Gtk::Notebook>(
builder,
"tabs");
216 auto version = &get_widget<Gtk::Button> (
builder,
"version");
217 auto version_lbl = &get_widget<Gtk::Label> (
builder,
"version-label");
218 auto label = &get_widget<Gtk::Label> (
builder,
"version-copied");
220 auto label2 = &get_widget<Gtk::Label> (
builder,
"debug-info-copied");
221 auto copyright = &get_widget<Gtk::Label> (
builder,
"copyright");
222 auto authors = &get_widget<Gtk::TextView>(
builder,
"credits-authors");
223 auto translators = &get_widget<Gtk::TextView>(
builder,
"credits-translators");
224 auto license = &get_widget<Gtk::Label> (
builder,
"license-text");
227 version_lbl->set_label(text);
228 version->signal_clicked().connect(
229 sigc::bind(©, version,
label, std::move(text)));
234 copyright->set_label(
237 std::random_device
rd;
238 std::mt19937 g(
rd());
240 std::string str_authors;
241 str_authors.reserve(capacity);
242 for (
auto const &author : authors_data) {
243 str_authors.append(author).append(1,
'\n');
245 authors->get_buffer()->set_text(str_authors.c_str());
248 std::string str_translators;
249 str_translators.reserve(capacity2);
250 std::regex e(
"(.*?)(<.*|)");
251 for (
auto const &translator : translators_data) {
252 str_translators.append(std::regex_replace(translator, e,
"$1")).
append(1,
'\n');
254 translators->get_buffer()->set_text(str_translators.c_str());
257 std::string str((std::istreambuf_iterator<char>(fn)),
258 std::istreambuf_iterator<char>());
259 license->set_markup(str.c_str());
262 auto const controller = Gtk::EventControllerKey::create();
263 controller->signal_key_pressed().connect(
264 sigc::track_object([window] (
unsigned keyval,
unsigned, Gdk::ModifierType) {
265 if (keyval == GDK_KEY_Escape) {
272 window->add_controller(controller);
274 if (
auto top = SP_ACTIVE_DESKTOP ? SP_ACTIVE_DESKTOP->getInkscapeWindow() :
nullptr) {
275 window->set_transient_for(*top);
277 tabs->set_current_page(0);
278 window->show_window();
std::vector< std::string > _about_screens
constexpr int SLIDESHOW_DELAY_sec
Gtk::AspectFrame * _frame
Glib::RefPtr< Glib::TimeoutSource > _timer
sigc::scoped_connection _refresh
Glib::RefPtr< Gtk::CssProvider > _footer_style
A dialog for the about screen.
Colors::Color ink_cairo_surface_average_color(cairo_surface_t *surface, cairo_surface_t *mask)
Get the average color from the given surface.
Cairo integration helpers.
Cairo::RefPtr< Cairo::ImageSurface > surface
Editable view implementation.
std::unique_ptr< Magick::Image > image
Consolidates version info for Inkscape, its various dependencies and the OS we're running on.
Inkscape - An SVG editor.
void copy(InkscapeApplication *app)
Color make_theme_color(Color const &orig, bool dark)
Make a themed dark or light color based on a previous shade, returns RGB color.
std::string get_filename(Type type, char const *filename, bool localized, bool silent)
void get_filenames_from_path(std::vector< std::string > &files, std::string const &path, std::vector< const char * > const &extensions, std::vector< const char * > const &exclusions)
static auto get_shuffled_lines(std::string const &filename, Random &&random)
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
static void append(std::vector< T > &target, std::vector< T > &&source)
unsigned short int inkscape_build_year()
Return build year as 4 digit.
std::string debug_info()
Return full debug info.
std::string inkscape_version()
Return Inkscape version string.
Inkscape::IO::Resource - simple resource API.
Gtk <themes> helper code.
Glib::RefPtr< Gtk::Builder > builder
Glib::RefPtr< Gdk::Texture > to_texture(Cairo::RefPtr< Cairo::Surface > const &surface)
Convert an image surface in ARGB32 format to a texture.
void reveal_widget(Gtk::Widget *widget, bool show)
Show widget, if the widget has a Gtk::Reveal parent, reveal instead.