Enhance save as template and new from template dialogs
[inkscape.git] / src / ui / themes.h
blob1ce675eaac4662b8eb839fab3da8c05ab3532507
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** \file
3 * Gtk <themes> helper code.
4 */
5 /*
6 * Authors:
7 * Jabiertxof
8 * Martin Owens
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
18 #include <map>
19 #include <memory>
20 #include <vector>
21 #include <sigc++/signal.h>
22 #include <glibmm/refptr.h>
23 #include <glibmm/ustring.h>
24 #include <pangomm/fontdescription.h>
26 #include "preferences.h"
28 namespace Gtk {
29 class CssProvider;
30 class Window;
31 } // namespace Gtk
33 namespace Inkscape::UI {
35 class ThemeContext final
37 public:
38 ThemeContext();
39 ~ThemeContext();
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);
84 private:
85 // user change 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;
93 #if __APPLE__
94 Glib::RefPtr<Gtk::CssProvider> _macstyleprovider;
95 #endif
96 std::unique_ptr<Preferences::Observer> _spinbutton_observer;
97 Glib::RefPtr<Gtk::CssProvider> _fontsizeprovider;
100 } // namespace Inkscape::UI
102 #endif /* !UI_THEMES_H_SEEN */
105 Local Variables:
106 mode:c++
107 c-file-style:"stroustrup"
108 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
109 indent-tabs-mode:nil
110 fill-column:99
111 End:
113 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :