Skip to content

Commit e436e50

Browse files
committed
Add accels for changing theme
1 parent 7531f21 commit e436e50

File tree

3 files changed

+79
-4
lines changed

3 files changed

+79
-4
lines changed

src/Application.vala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ public class Jorts.Application : Gtk.Application {
9797
set_accels_for_action ("app.action_show_emoji", {"<Control>period"});
9898
set_accels_for_action ("app.action_show_menu", {"<Control>M"});
9999

100+
set_accels_for_action ("app.action_theme_1", {"<Control>1"});
101+
set_accels_for_action ("app.action_theme_2", {"<Control>2"});
102+
set_accels_for_action ("app.action_theme_3", {"<Control>3"});
103+
set_accels_for_action ("app.action_theme_4", {"<Control>4"});
104+
set_accels_for_action ("app.action_theme_5", {"<Control>5"});
105+
set_accels_for_action ("app.action_theme_6", {"<Control>6"});
106+
set_accels_for_action ("app.action_theme_7", {"<Control>7"});
107+
set_accels_for_action ("app.action_theme_8", {"<Control>8"});
108+
set_accels_for_action ("app.action_theme_9", {"<Control>9"});
109+
set_accels_for_action ("app.action_theme_0", {"<Control>0"});
110+
111+
100112
// Force the eOS icon theme, and set the blueberry as fallback, if for some reason it fails for individual notes
101113
var granite_settings = Granite.Settings.get_default ();
102114
var gtk_settings = Gtk.Settings.get_default ();

src/Widgets/ColorBox.vala

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
* 2025 Contributions from the ellie_Commons community (github.com/ellie-commons/)
66
*/
77

8-
/*
9-
I just dont wanna rewrite the same button over and over
10-
8+
/**
9+
* A box mimicking the one in elementary OS Appearance settings page
10+
* It shows a row with all the colours
1111
*/
12-
1312
public class Jorts.ColorBox : Gtk.Box {
1413

1514
private Themes _color = Constants.DEFAULT_THEME;
@@ -31,6 +30,7 @@ public class Jorts.ColorBox : Gtk.Box {
3130
private Jorts.ColorPill color_button_cocoa;
3231
private Jorts.ColorPill color_button_slate;
3332

33+
// TODO: We could loop instead of by-hand definition
3434
public ColorBox () {
3535
orientation = Gtk.Orientation.HORIZONTAL;
3636

@@ -51,6 +51,37 @@ public class Jorts.ColorBox : Gtk.Box {
5151
color_button_cocoa = new ColorPill (Jorts.Themes.COCOA);
5252
color_button_slate = new ColorPill (Jorts.Themes.SLATE);
5353

54+
color_button_blueberry.tooltip_markup = Granite.markup_accel_tooltip (
55+
{"<Control>1"}, Jorts.Themes.BLUEBERRY.to_nicename ());
56+
57+
color_button_lime.tooltip_markup = Granite.markup_accel_tooltip (
58+
{"<Control>2"}, Jorts.Themes.LIME.to_nicename ());
59+
60+
color_button_mint.tooltip_markup = Granite.markup_accel_tooltip (
61+
{"<Control>3"}, Jorts.Themes.MINT.to_nicename ());
62+
63+
color_button_banana.tooltip_markup = Granite.markup_accel_tooltip (
64+
{"<Control>4"}, Jorts.Themes.BANANA.to_nicename ());
65+
66+
color_button_strawberry.tooltip_markup = Granite.markup_accel_tooltip (
67+
{"<Control>5"}, Jorts.Themes.STRAWBERRY.to_nicename ());
68+
69+
color_button_orange.tooltip_markup = Granite.markup_accel_tooltip (
70+
{"<Control>6"}, Jorts.Themes.ORANGE.to_nicename ());
71+
72+
color_button_bubblegum.tooltip_markup = Granite.markup_accel_tooltip (
73+
{"<Control>7"}, Jorts.Themes.BUBBLEGUM.to_nicename ());
74+
75+
color_button_grape.tooltip_markup = Granite.markup_accel_tooltip (
76+
{"<Control>8"}, Jorts.Themes.GRAPE.to_nicename ());
77+
78+
color_button_cocoa.tooltip_markup = Granite.markup_accel_tooltip (
79+
{"<Control>9"}, Jorts.Themes.COCOA.to_nicename ());
80+
81+
color_button_slate.tooltip_markup = Granite.markup_accel_tooltip (
82+
{"<Control>0"}, Jorts.Themes.SLATE.to_nicename ());
83+
84+
5485
color_button_lime.set_group (color_button_blueberry);
5586
color_button_mint.set_group (color_button_blueberry);
5687
color_button_banana.set_group (color_button_blueberry);

src/Windows/StickyNoteWindow.vala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
5050
private const string ACTION_ZOOM_DEFAULT = "action_zoom_default";
5151
private const string ACTION_ZOOM_IN = "action_zoom_in";
5252

53+
private const string ACTION_THEME_1 = "action_theme_1";
54+
private const string ACTION_THEME_2 = "action_theme_2";
55+
private const string ACTION_THEME_3 = "action_theme_3";
56+
private const string ACTION_THEME_4 = "action_theme_4";
57+
private const string ACTION_THEME_5 = "action_theme_5";
58+
private const string ACTION_THEME_6 = "action_theme_6";
59+
private const string ACTION_THEME_7 = "action_theme_7";
60+
private const string ACTION_THEME_8 = "action_theme_8";
61+
private const string ACTION_THEME_9 = "action_theme_9";
62+
private const string ACTION_THEME_0 = "action_theme_0";
63+
5364
public static Gee.MultiMap<string, string> action_accelerators;
5465

5566
private const GLib.ActionEntry[] ACTION_ENTRIES = {
@@ -60,6 +71,16 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
6071
{ ACTION_ZOOM_OUT, action_zoom_out},
6172
{ ACTION_ZOOM_DEFAULT, action_zoom_default},
6273
{ ACTION_ZOOM_IN, action_zoom_in},
74+
{ ACTION_THEME_1, action_theme_1},
75+
{ ACTION_THEME_2, action_theme_2},
76+
{ ACTION_THEME_3, action_theme_3},
77+
{ ACTION_THEME_4, action_theme_4},
78+
{ ACTION_THEME_5, action_theme_5},
79+
{ ACTION_THEME_6, action_theme_6},
80+
{ ACTION_THEME_7, action_theme_7},
81+
{ ACTION_THEME_8, action_theme_8},
82+
{ ACTION_THEME_9, action_theme_9},
83+
{ ACTION_THEME_0, action_theme_0},
6384
};
6485

6586
public StickyNoteWindow (Gtk.Application app, NoteData data) {
@@ -278,4 +299,15 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
278299
private void action_zoom_out () {popover.zoom_out ();}
279300
private void action_zoom_default () {popover.zoom_default ();}
280301
private void action_zoom_in () {popover.zoom_in ();}
302+
303+
private void action_theme_1 () {popover.color = (Jorts.Themes.all ())[0];}
304+
private void action_theme_2 () {popover.color = (Jorts.Themes.all ())[1];}
305+
private void action_theme_3 () {popover.color = (Jorts.Themes.all ())[2];}
306+
private void action_theme_4 () {popover.color = (Jorts.Themes.all ())[3];}
307+
private void action_theme_5 () {popover.color = (Jorts.Themes.all ())[4];}
308+
private void action_theme_6 () {popover.color = (Jorts.Themes.all ())[5];}
309+
private void action_theme_7 () {popover.color = (Jorts.Themes.all ())[6];}
310+
private void action_theme_8 () {popover.color = (Jorts.Themes.all ())[7];}
311+
private void action_theme_9 () {popover.color = (Jorts.Themes.all ())[8];}
312+
private void action_theme_0 () {popover.color = (Jorts.Themes.all ())[9];}
281313
}

0 commit comments

Comments
 (0)