Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
themes.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/*
6 * Authors:
7 * Jabiertxof
8 * Martin Owens
9 *
10 * Copyright (C) 2017-2021 Authors
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
15#ifndef UI_THEMES_H_SEEN
16#define UI_THEMES_H_SEEN
17
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>
25
26#include "preferences.h"
27
28namespace Gtk {
29class CssProvider;
30class Window;
31} // namespace Gtk
32
33namespace Inkscape::UI {
34
35class ThemeContext final
36{
37public:
40
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);
44
45 std::map<Glib::ustring, bool> get_available_themes();
46 void add_gtk_css(bool only_providers, bool cached = false);
48 Glib::ustring get_symbolic_colors();
49
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 ; }
55
56 sigc::signal<void ()> getChangeThemeSignal() { return _signal_change_theme;}
58
60 void adjustGlobalFontScale(double factor);
61
63 double getFontScale() const;
64
66 void saveFontScale(double scale);
67
68 static Glib::ustring get_font_scale_pref_path() { return "/theme/fontscale"; }
69
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"; }
74
75 // True if current theme (applied one) is dark
76 bool isCurrentThemeDark(Gtk::Window *window);
77
78 // Get CSS foreground colors resulting from classes ".highlight-color-[1-8]"
79 static std::vector<guint32> getHighlightColors(Gtk::Window *window);
80
82 static void select_default_syntax_style(bool dark_theme);
83
84private:
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;
98};
99
100} // namespace Inkscape::UI
101
102#endif /* !UI_THEMES_H_SEEN */
103
104/*
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:
112*/
113// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
static std::vector< guint32 > getHighlightColors(Gtk::Window *window)
Load the highlight colours from the current theme.
Definition themes.cpp:581
Glib::RefPtr< Gtk::CssProvider > _styleprovider
Definition themes.h:87
Glib::RefPtr< Gtk::CssProvider > _userprovider
Definition themes.h:92
Pango::FontDescription getMonospacedFont() const
User-selected monospaced font used by XML dialog and attribute editor.
Definition themes.cpp:670
Glib::RefPtr< Gtk::CssProvider > _themeprovider
Definition themes.h:88
std::unique_ptr< Preferences::Observer > _spinbutton_observer
Definition themes.h:96
std::map< Glib::ustring, bool > gtkThemeList
Definition themes.h:42
Glib::RefPtr< Gtk::CssProvider > const & getUserProvider() const
Definition themes.h:54
Glib::RefPtr< Gtk::CssProvider > _colorizeprovider
Definition themes.h:90
Glib::ustring get_symbolic_colors()
Definition themes.cpp:154
bool isCurrentThemeDark(Gtk::Window *window)
Check if current applied theme is dark or not by looking at style context.
Definition themes.cpp:498
static void select_default_syntax_style(bool dark_theme)
Definition themes.cpp:652
void inkscape_fill_gtk(const gchar *path, gtkThemeList &themes)
Inkscape fill gtk, taken from glib/gtk code with our own checks.
Definition themes.cpp:65
Glib::RefPtr< Gtk::CssProvider > const & getThemeProvider() const
Definition themes.h:52
sigc::signal< void()> _signal_change_theme
Definition themes.h:86
std::map< Glib::ustring, bool > get_available_themes()
Get available themes based on locations of gtk directories.
Definition themes.cpp:96
void add_gtk_css(bool only_providers, bool cached=false)
Add our CSS style sheets.
Definition themes.cpp:264
Glib::RefPtr< Gtk::CssProvider > _macstyleprovider
Definition themes.h:94
void adjustGlobalFontScale(double factor)
Set application-wide font size adjustment by a factor, where 1 is 100% (no change)
Definition themes.cpp:608
Glib::RefPtr< Gtk::CssProvider > _spinbuttonprovider
Definition themes.h:91
Glib::RefPtr< Gtk::CssProvider > _fontsizeprovider
Definition themes.h:97
double getFontScale() const
Get current font scaling factor (50 - 150, percent of "normal" size)
Definition themes.cpp:676
Glib::RefPtr< Gtk::CssProvider > const & getStyleProvider() const
Definition themes.h:53
static void initialize_source_syntax_styles()
Definition themes.cpp:643
void saveMonospacedFont(Pango::FontDescription desc)
Definition themes.cpp:665
Glib::RefPtr< Gtk::CssProvider > const & getColorizeProvider() const
Definition themes.h:50
Glib::RefPtr< Gtk::CssProvider > const & getContrastThemeProvider() const
Definition themes.h:51
static Glib::ustring get_monospaced_font_pref_path()
Definition themes.h:73
sigc::signal< void()> getChangeThemeSignal()
Definition themes.h:56
void saveFontScale(double scale)
Save font scaling factor in preferences.
Definition themes.cpp:681
static Glib::ustring get_font_scale_pref_path()
Definition themes.h:68
Glib::RefPtr< Gtk::CssProvider > _contrastthemeprovider
Definition themes.h:89
Definition desktop.h:50
User interface code.
Definition desktop.h:113
Singleton class to access the preferences file in a convenient way.