From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/ui/themes.h | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/ui/themes.h (limited to 'src/ui/themes.h') diff --git a/src/ui/themes.h b/src/ui/themes.h new file mode 100644 index 0000000..4e896e2 --- /dev/null +++ b/src/ui/themes.h @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** \file + * Gtk helper code. + */ +/* + * Authors: + * Jabiertxof + * Martin Owens + * + * Copyright (C) 2017-2021 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ +#ifndef UI_THEMES_H_SEEN +#define UI_THEMES_H_SEEN + +#include +#include +#include +#include +#include +#include +#include +#include "preferences.h" + +namespace Inkscape { +namespace UI { + +/** + * A simple mediator class that sets the state of a Gtk::ToggleToolButton when + * a preference is changed. Unlike the PrefPusher class, this does not provide + * the reverse process, so you still need to write your own handler for the + * "toggled" signal on the ToggleToolButton. + */ +typedef std::map gtkThemeList; +class ThemeContext +{ +public: +ThemeContext(); +~ThemeContext() = default; +// Name of theme -> has dark theme +typedef std::map gtkThemeList; +void inkscape_fill_gtk(const gchar *path, gtkThemeList &themes); +std::map get_available_themes(); +void add_gtk_css(bool only_providers, bool cached = false); +void add_icon_theme(); +Glib::ustring get_symbolic_colors(); +Glib::RefPtr getColorizeProvider() { return _colorizeprovider;} +Glib::RefPtr getContrastThemeProvider() { return _contrastthemeprovider;} +Glib::RefPtr getThemeProvider() { return _themeprovider;} +Glib::RefPtr getStyleProvider() { return _styleprovider;} +sigc::signal getChangeThemeSignal() { return _signal_change_theme;} +// set application-wide font size adjustment by a factor, where 1 is 100% (no change) +void adjust_global_font_scale(double factor); + +// True if current theme (applied one) is dark +bool isCurrentThemeDark(Gtk::Container *window); + +static std::vector getHighlightColors(Gtk::Window *window); + +private: + // user change theme + sigc::signal _signal_change_theme; + Glib::RefPtr _styleprovider; + Glib::RefPtr _themeprovider; + Glib::RefPtr _contrastthemeprovider; + Glib::RefPtr _colorizeprovider; + Glib::RefPtr _spinbuttonprovider; +#if __APPLE__ + Glib::RefPtr _macstyleprovider; +#endif + std::unique_ptr _spinbutton_observer; + Glib::RefPtr _fontsizeprovider = Gtk::CssProvider::create(); +}; + +} +} +#endif /* !UI_THEMES_H_SEEN */ + +/* + 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:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3