13#include <gtkmm/aspectframe.h>
14#include <gtkmm/binlayout.h>
15#include <gtkmm/cssprovider.h>
16#include <gtkmm/eventcontrollerkey.h>
17#include <gtkmm/picture.h>
18#include <gtkmm/textview.h>
41class AboutWindow :
public Gtk::Window {
43 AboutWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>&
builder): Gtk::Window(cobject) {
46 g_error(
"AboutWindow: Missing about screens.");
51 _viewer1->set_layout_manager(Gtk::BinLayout::create());
53 _viewer2->set_layout_manager(Gtk::BinLayout::create());
54 _frame = &get_widget<Gtk::AspectFrame>(
builder,
"aspect-frame");
59 _refresh = Glib::signal_timeout().connect_seconds([
this] {
69 auto ctx =
_viewer2->get_style_context();
70 ctx->remove_class(
"fade-out");
71 ctx->remove_class(
"fade-in");
83 Glib::RefPtr<Glib::TimeoutSource>
_timer;
89 void find_about_screens() {
93 g_warning(
"Error loading about screens SVGZs: no such documents in share/screen/about folder.");
100 Cairo::RefPtr<Cairo::ImageSurface> load_next(Gtk::Picture *viewer,
const Glib::ustring& fname,
int device_scale) {
102 auto surface = renderer.render_surface(device_scale);
104 auto width = renderer.get_width_px();
105 auto height = renderer.get_height_px();
113 void set_footer_matching_color(Cairo::RefPtr<Cairo::ImageSurface>
const &
image)
117 auto scale = get_scale_factor();
123 auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32,
width,
height);
124 cairo_surface_set_device_scale(
surface->cobj(), scale, scale);
125 auto ctx = Cairo::Context::create(
surface);
126 ctx->set_source(
image, 0, -y);
130 bool dark = INKSCAPE.themecontext->isCurrentThemeDark(
this);
133 auto style_context =
_footer->get_style_context();
135 _footer_style->load_from_data(
"box {background-color:" + foot.toString() +
";}");
136 if (_footer_style) style_context->remove_provider(_footer_style);
137 style_context->add_provider(_footer_style, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
144 auto image = load_next(nv, _about_screens[_about_index++ %
_about_screens.size()], get_scale_factor());
146 auto ctx =
_viewer2->get_style_context();
148 ctx->add_class(
"fade-out");
149 ctx->remove_class(
"fade-in");
152 ctx->remove_class(
"fade-out");
153 ctx->add_class(
"fade-in");
156 set_footer_matching_color(
image);
160void copy(Gtk::Button *button, Gtk::Label *
label, Glib::ustring
const &text)
162 auto clipboard = Gdk::Display::get_default()->get_clipboard();
163 clipboard->set_text(text);
166 Glib::signal_timeout().connect_seconds(
167 sigc::track_object([=] {
178template <
class Random>
182 std::vector<std::string> lines;
183 std::size_t capacity = 0;
184 for (std::string line; getline(fn, line);) {
185 capacity += line.size() + 1;
186 lines.push_back(std::move(line));
188 std::shuffle(lines.begin(), lines.end(), random);
189 return std::pair{std::move(lines), capacity};
196 auto window = &get_derived_widget<AboutWindow>(
builder,
"about-screen-window");
197 auto tabs = &get_widget<Gtk::Notebook>(
builder,
"tabs");
198 auto version = &get_widget<Gtk::Button> (
builder,
"version");
199 auto version_lbl = &get_widget<Gtk::Label> (
builder,
"version-label");
200 auto label = &get_widget<Gtk::Label> (
builder,
"version-copied");
202 auto label2 = &get_widget<Gtk::Label> (
builder,
"debug-info-copied");
203 auto copyright = &get_widget<Gtk::Label> (
builder,
"copyright");
204 auto authors = &get_widget<Gtk::TextView>(
builder,
"credits-authors");
205 auto translators = &get_widget<Gtk::TextView>(
builder,
"credits-translators");
206 auto license = &get_widget<Gtk::Label> (
builder,
"license-text");
209 version_lbl->set_label(text);
210 version->signal_clicked().connect(
211 sigc::bind(©, version,
label, std::move(text)));
216 copyright->set_label(
219 std::random_device
rd;
220 std::mt19937 g(
rd());
222 std::string str_authors;
223 str_authors.reserve(capacity);
224 for (
auto const &author : authors_data) {
225 str_authors.append(author).append(1,
'\n');
227 authors->get_buffer()->set_text(str_authors.c_str());
230 std::string str_translators;
231 str_translators.reserve(capacity2);
232 std::regex e(
"(.*?)(<.*|)");
233 for (
auto const &translator : translators_data) {
234 str_translators.append(std::regex_replace(translator, e,
"$1")).
append(1,
'\n');
236 translators->get_buffer()->set_text(str_translators.c_str());
239 std::string str((std::istreambuf_iterator<char>(fn)),
240 std::istreambuf_iterator<char>());
241 license->set_markup(str.c_str());
244 auto const controller = Gtk::EventControllerKey::create();
245 controller->signal_key_pressed().connect(
246 sigc::track_object([window] (
unsigned keyval,
unsigned, Gdk::ModifierType) {
247 if (keyval == GDK_KEY_Escape) {
254 window->add_controller(controller);
256 if (
auto top = SP_ACTIVE_DESKTOP ? SP_ACTIVE_DESKTOP->getInkscapeWindow() :
nullptr) {
257 window->set_transient_for(*top);
259 tabs->set_current_page(0);
260 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.