1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Gtk <themes> helper code.
10 * Copyright (C) 2017-2021 Authors
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 #ifndef UI_THEMES_H_SEEN
16 #define UI_THEMES_H_SEEN
21 #include <sigc++/signal.h>
22 #include <glibmm/refptr.h>
23 #include <glibmm/ustring.h>
24 #include <pangomm/fontdescription.h>
26 #include "preferences.h"
33 namespace Inkscape::UI
{
35 class ThemeContext final
41 // Name of theme -> has dark theme
42 typedef std::map
<Glib::ustring
, bool> gtkThemeList
;
43 void inkscape_fill_gtk(const gchar
*path
, gtkThemeList
&themes
);
45 std::map
<Glib::ustring
, bool> get_available_themes();
46 void add_gtk_css(bool only_providers
, bool cached
= false);
47 void add_icon_theme();
48 Glib::ustring
get_symbolic_colors();
50 Glib::RefPtr
<Gtk::CssProvider
> const &getColorizeProvider () const { return _colorizeprovider
; }
51 Glib::RefPtr
<Gtk::CssProvider
> const &getContrastThemeProvider() const { return _contrastthemeprovider
; }
52 Glib::RefPtr
<Gtk::CssProvider
> const &getThemeProvider () const { return _themeprovider
; }
53 Glib::RefPtr
<Gtk::CssProvider
> const &getStyleProvider () const { return _styleprovider
; }
54 Glib::RefPtr
<Gtk::CssProvider
> const &getUserProvider () const { return _userprovider
; }
56 sigc::signal
<void ()> getChangeThemeSignal() { return _signal_change_theme
;}
57 void themechangecallback();
59 /// Set application-wide font size adjustment by a factor, where 1 is 100% (no change)
60 void adjustGlobalFontScale(double factor
);
62 /// Get current font scaling factor (50 - 150, percent of "normal" size)
63 double getFontScale() const;
65 /// Save font scaling factor in preferences
66 void saveFontScale(double scale
);
68 static Glib::ustring
get_font_scale_pref_path() { return "/theme/fontscale"; }
70 /// User-selected monospaced font used by XML dialog and attribute editor
71 Pango::FontDescription
getMonospacedFont() const;
72 void saveMonospacedFont(Pango::FontDescription desc
);
73 static Glib::ustring
get_monospaced_font_pref_path() { return "/ui/mono-font/desc"; }
75 // True if current theme (applied one) is dark
76 bool isCurrentThemeDark(Gtk::Window
*window
);
78 // Get CSS foreground colors resulting from classes ".highlight-color-[1-8]"
79 static std::vector
<guint32
> getHighlightColors(Gtk::Window
*window
);
81 static void initialize_source_syntax_styles();
82 static void select_default_syntax_style(bool dark_theme
);
86 sigc::signal
<void ()> _signal_change_theme
;
87 Glib::RefPtr
<Gtk::CssProvider
> _styleprovider
;
88 Glib::RefPtr
<Gtk::CssProvider
> _themeprovider
;
89 Glib::RefPtr
<Gtk::CssProvider
> _contrastthemeprovider
;
90 Glib::RefPtr
<Gtk::CssProvider
> _colorizeprovider
;
91 Glib::RefPtr
<Gtk::CssProvider
> _spinbuttonprovider
;
92 Glib::RefPtr
<Gtk::CssProvider
> _userprovider
;
94 Glib::RefPtr
<Gtk::CssProvider
> _macstyleprovider
;
96 std::unique_ptr
<Preferences::Observer
> _spinbutton_observer
;
97 Glib::RefPtr
<Gtk::CssProvider
> _fontsizeprovider
;
100 } // namespace Inkscape::UI
102 #endif /* !UI_THEMES_H_SEEN */
107 c-file-style:"stroustrup"
108 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
113 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :