4#include <sigc++/signal.h>
6#include <glibmm/main.h>
8#include <giomm/filemonitor.h>
12#include <sigc++/scoped_connection.h>
19class ManagerImpl final :
public Manager
26 std::shared_ptr<Css const>
css;
36 void monitor_file(std::string
const&
file_name);
41ManagerImpl::ManagerImpl()
59void ManagerImpl::monitor_file(std::string
const&
file_name)
62 auto file = Gio::File::create_for_path(path);
64 monitor->signal_changed().connect([
this] (Glib::RefPtr<Gio::File>
const &, Glib::RefPtr<Gio::File>
const &, Gio::FileMonitor::Event) {
66 timeout = Glib::signal_timeout().connect([
this] {
74void ManagerImpl::updateCss()
76 auto& filename = get_handle_themes().at(current_theme).file_name;
84 static ManagerImpl instance;
90 auto &d =
static_cast<ManagerImpl
const &
>(*this);
96 auto &d =
static_cast<ManagerImpl &
>(*this);
97 return d.signal_css_updated.connect(std::move(slot));
102#define translation_context "Handle color scheme name"
103 static std::vector<ColorTheme> themes = {
105 {
"handle-theme-azure.css", C_(translation_context,
"Azure"),
true, 0x2a7fff},
107 {
"handle-theme-crimson.css", C_(translation_context,
"Crimson"),
true, 0xff1a5e},
109 {
"handle-theme-spruce.css", C_(translation_context,
"Spruce"),
true, 0x05ca85},
111 {
"handle-theme-violet.css", C_(translation_context,
"Violet"),
true, 0xbb61f3},
113 {
"handle-theme-gold.css", C_(translation_context,
"Gold"),
true, 0xebca00},
115 {
"handle-theme-steel.css", C_(translation_context,
"Steel"),
true, 0x9db4d8},
117 {
"handle-theme-negative.css", C_(translation_context,
"Negative"),
false, 0xa0a0b0},
122#undef translation_context
127 if (
static_cast<size_t>(
index) >= themes.size()) {
128 g_warning(
"Invalid handle color theme index, css not loaded.");
133 auto &d =
static_cast<ManagerImpl&
>(*this);
135 d.signal_css_updated.emit();
std::shared_ptr< Css const > getCss() const
const std::vector< ColorTheme > & get_handle_themes() const
void select_theme(int index)
sigc::connection connectCssUpdated(sigc::slot< void()> &&slot)
static Preferences * get()
Access the singleton Preferences object.
void setInt(Glib::ustring const &pref_path, int value)
Set an integer value.
int getIntLimited(Glib::ustring const &pref_path, int def=0, int min=INT_MIN, int max=INT_MAX)
Retrieve a limited integer.
Glib::RefPtr< Gio::FileMonitor > monitor
sigc::signal< void()> signal_css_updated
std::shared_ptr< Css const > css
sigc::scoped_connection timeout
Classes related to control handle styling.
Css parse_css(const std::string &css_file_name)
constexpr auto USER_CUSTOM_CSS_FILE_NAME
std::string get_path_string(Domain domain, Type type, char const *filename, char const *extra)
Singleton class to access the preferences file in a convenient way.
Inkscape::IO::Resource - simple resource API.