-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathColorController.vala
More file actions
65 lines (54 loc) · 2.02 KB
/
ColorController.vala
File metadata and controls
65 lines (54 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2017-2024 Lains
* 2025 Contributions from the ellie_Commons community (github.com/ellie-commons/)
* 2025-2026 Stella & Charlie (teamcons.carrd.co)
*/
/*************************************************/
/**
* Responsible to apply RedactedScript font
* Give it a window and it will simply follow settings
*/
public class Jorts.ColorController : Object {
private weak Jorts.StickyNoteWindow window;
private Jorts.Themes _theme;
public Jorts.Themes theme {
get { return _theme;}
set { on_color_changed (value);}
}
public ColorController (Jorts.StickyNoteWindow window) {
this.window = window;
}
/**
* Switches stylesheet
* First use appropriate stylesheet, Then switch the theme classes
*/
public void on_color_changed (Jorts.Themes new_theme) {
debug ("Updating theme to %s".printf (new_theme.to_string ()));
// Add remove class
if (_theme.to_string () in window.css_classes) {
window.remove_css_class (_theme.to_string ());
}
window.add_css_class (new_theme.to_string ());
// Propagate values
_theme = new_theme;
window.popover.color = new_theme;
NoteData.latest_theme = new_theme;
// Avoid using the wrong accent until the popover is closed
var stylesheet = "io.elementary.stylesheet." + new_theme.to_string ().ascii_down ();
Application.gtk_settings.gtk_theme_name = stylesheet;
// Cleanup;
window.has_changed ();
}
/**
* Changes the stylesheet accents to the notes color
* Add or remove the Redacted font if the setting is active
*/
public void on_focus_changed () {
debug ("Focus changed!");
if (window.is_active) {
var stylesheet = "io.elementary.stylesheet." + _theme.to_string ().ascii_down ();
Application.gtk_settings.gtk_theme_name = stylesheet;
}
}
}