Skip to content

Commit 3a3edee

Browse files
committed
Move and tidy
1 parent d49db40 commit 3a3edee

File tree

9 files changed

+124
-25
lines changed

9 files changed

+124
-25
lines changed

po/POTFILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ src/Widgets/ColorBox.vala
55
src/Widgets/MonospaceBox.vala
66
src/Widgets/ZoomBox.vala
77
src/Objects/Themes.vala
8+
src/Utils/ZoomConvert.vala
89
src/Utils/Random.vala
910
src/Utils/Libportal.vala
1011
src/Views/PreferencesView.vala

src/Services/Constants.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Jorts.Constants {
3636

3737
/*************************************************/
3838
// Shortcuts
39-
const string[] ACCELS_ZOOM_DEFAULT = { "<Control>equal" };
39+
const string[] ACCELS_ZOOM_DEFAULT = { "<Control>equal", "<Control>0", "<Control>KP_0" };
4040
const string[] ACCELS_ZOOM_IN = { "<Control>plus", "<Control>KP_Add" };
4141
const string[] ACCELS_ZOOM_OUT = { "<Control>minus", "<Control>KP_Subtract" };
4242

src/Services/Utils.vala renamed to src/Utils/ZoomConvert.vala

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

8-
/* CONTENT
9-
randrange does not include upper bound.
10-
11-
random_theme(skip_theme)
12-
random_title()
13-
random_emote(skip_emote)
14-
random_note(skip_theme)
15-
16-
*/
17-
188
namespace Jorts.Utils {
199

2010
/*************************************************/
@@ -42,7 +32,7 @@ namespace Jorts.Utils {
4232

4333
/*************************************************/
4434
// We cannot use numbers in CSS, so we have to translate a number into a string
45-
public uint8 zoom_to_UIsize (uint8 zoom) {
35+
public uint8 zoom_to_ui_size (uint8 zoom) {
4636
switch (zoom) {
4737
case 20: return 24;
4838
case 40: return 26;

src/Views/PopoverView.vala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ public class Jorts.PopoverView : Gtk.Popover {
5151
monospace_box = new Jorts.MonospaceBox ();
5252
font_size_box = new Jorts.ZoomBox ();
5353

54-
/* APPENDS */
5554
view.append (color_button_box);
5655
view.append (monospace_box);
57-
//view.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
5856
view.append (font_size_box);
5957

6058
child = view;
@@ -69,7 +67,7 @@ public class Jorts.PopoverView : Gtk.Popover {
6967
/**
7068
* Switches stylesheet
7169
* First use appropriate stylesheet, Then switch the theme classes
72-
*/
70+
*/
7371
private void on_color_changed (Jorts.Themes new_theme) {
7472
debug ("Updating theme to %s".printf (new_theme.to_string ()));
7573

@@ -125,7 +123,7 @@ public class Jorts.PopoverView : Gtk.Popover {
125123

126124
/**
127125
* Called when a signal from the popover says stuff got changed
128-
*/
126+
*/
129127
private void on_zoom_changed (Jorts.Zoomkind zoomkind) {
130128
debug ("Zoom changed!");
131129

@@ -159,7 +157,7 @@ public class Jorts.PopoverView : Gtk.Popover {
159157

160158
/**
161159
* Wrapper to check an increase doesnt go below limit
162-
*/
160+
*/
163161
public void zoom_out () {
164162
if ((_old_zoom - 20) >= Jorts.Constants.ZOOM_MIN) {
165163
zoom = _old_zoom - 20;
@@ -170,7 +168,7 @@ public class Jorts.PopoverView : Gtk.Popover {
170168

171169
/**
172170
* Switch zoom classes, then reflect in the UI and tell the application
173-
*/
171+
*/
174172
private void do_set_zoom (uint8 new_zoom) {
175173
debug ("Setting zoom: " + zoom.to_string ());
176174

@@ -180,7 +178,7 @@ public class Jorts.PopoverView : Gtk.Popover {
180178
parent_window.add_css_class (Jorts.Utils.zoom_to_class ( new_zoom));
181179

182180
// Adapt headerbar size to avoid weird flickering
183-
parent_window.headerbar.height_request = Jorts.Utils.zoom_to_UIsize (_old_zoom);
181+
parent_window.headerbar.height_request = Jorts.Utils.zoom_to_ui_size (_old_zoom);
184182

185183
// Reflect the number in the popover
186184
font_size_box.zoom = new_zoom;

src/Widgets/ActionBar.vala

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-or-later
3+
* SPDX-FileCopyrightText: 2017-2024 Lains
4+
* 2025 Stella & Charlie (teamcons.carrd.co)
5+
* 2025 Contributions from the ellie_Commons community (github.com/ellie-commons/)
6+
*/
7+
8+
/**
9+
* We use Granite.Bin to subclass ActionBar.
10+
* Everything is kept there but most widgets are public
11+
*/
12+
public class Jorts.ActionBar : Granite.Bin {
13+
14+
public Gtk.ActionBar actionbar;
15+
public Gtk.MenuButton emoji_button;
16+
public Gtk.EmojiChooser emojichooser_popover;
17+
public Gtk.MenuButton menu_button;
18+
19+
construct {
20+
21+
/* **** LEFT **** */
22+
var new_item = new Gtk.Button () {
23+
icon_name = "list-add-symbolic",
24+
width_request = 32,
25+
height_request = 32,
26+
tooltip_markup = Granite.markup_accel_tooltip (
27+
{"<Control>n"},
28+
_("New sticky note")
29+
)
30+
};
31+
new_item.action_name = Application.ACTION_PREFIX + Application.ACTION_NEW;
32+
new_item.add_css_class ("themedbutton");
33+
34+
delete_item = new Gtk.Button () {
35+
icon_name = "edit-delete-symbolic",
36+
width_request = 32,
37+
height_request = 32,
38+
tooltip_markup = Granite.markup_accel_tooltip (
39+
{"<Control>w"},
40+
_("Delete sticky note")
41+
)
42+
};
43+
delete_item.add_css_class ("themedbutton");
44+
45+
/* **** RIGHT **** */
46+
emojichooser_popover = new Gtk.EmojiChooser ();
47+
48+
emoji_button = new Gtk.MenuButton () {
49+
icon_name = Jorts.Utils.random_emote (),
50+
width_request = 32,
51+
height_request = 32,
52+
tooltip_markup = Granite.markup_accel_tooltip (
53+
{"<Control>period"},
54+
_("Insert emoji")
55+
)
56+
};
57+
emoji_button.add_css_class ("themedbutton");
58+
emoji_button.popover = emojichooser_popover;
59+
60+
menu_button = new Gtk.MenuButton () {
61+
icon_name = "open-menu-symbolic",
62+
width_request = 32,
63+
height_request = 32,
64+
tooltip_markup = Granite.markup_accel_tooltip (
65+
{"<Control>M"},
66+
_("Preferences for this sticky note")
67+
)
68+
};
69+
menu_button.direction = Gtk.ArrowType.UP;
70+
menu_button.add_css_class ("themedbutton");
71+
72+
/* **** Widget **** */
73+
actionbar = new Gtk.ActionBar () {
74+
hexpand = true
75+
};
76+
actionbar.revealed = false;
77+
actionbar.pack_start (new_item);
78+
actionbar.pack_start (delete_item);
79+
actionbar.pack_end (menu_button);
80+
actionbar.pack_end (emoji_button);
81+
82+
var handle = new Gtk.WindowHandle () {
83+
child = actionbar
84+
};
85+
86+
child = handle;
87+
88+
// Randomize-skip emoji icon
89+
emojichooser_popover.show.connect (on_emoji_popover);
90+
}
91+
92+
/**
93+
* Allow control of when to respect the hide-bar setting
94+
* StickyNoteWindow will decide itself whether to show immediately or not
95+
*/
96+
public void reveal_bind () {
97+
Application.gsettings.bind ("hide-bar", actionbar, "revealed", SettingsBindFlags.INVERT_BOOLEAN);
98+
}
99+
100+
// Skip the current icon to avoid picking it twice
101+
private void on_emoji_popover () {
102+
debug ("Emote requested!");
103+
104+
emoji_button.set_icon_name (
105+
Jorts.Utils.random_emote (
106+
emoji_button.get_icon_name ()
107+
)
108+
);
109+
}
110+
}

src/Widgets/MonospaceBox.vala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public class Jorts.MonospaceBox : Gtk.Box {
5555
mono_monospace_toggle.notify["active"].connect (on_monospace_changed);
5656
}
5757

58-
5958
public void on_monospace_changed () {
6059
monospace_changed (mono_monospace_toggle.active);
6160
}
62-
63-
}
61+
}

src/Widgets/ZoomBox.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ public class Jorts.ZoomBox : Gtk.Box {
6767
zoom_default_button.clicked.connect (() => {this.zoom_changed (Zoomkind.DEFAULT_ZOOM);});
6868
zoom_in_button.clicked.connect (() => {this.zoom_changed (Zoomkind.ZOOM_IN);});
6969
}
70-
}
70+
}

src/Windows/StickyNoteWindow.vala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
101101
editableheader = new Gtk.EditableLabel ("") {
102102
xalign = 0.5f,
103103
halign = Gtk.Align.CENTER,
104+
valign = Gtk.Align.CENTER,
104105
tooltip_markup = Granite.markup_accel_tooltip (
105106
{"<Control>L"},
106107
_("Click to edit the title")
@@ -123,7 +124,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
123124
/****************************************/
124125
/* LOADING */
125126
/****************************************/
126-
127+
127128
on_scribbly_changed ();
128129
load_data (data);
129130

@@ -271,7 +272,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
271272

272273
/**
273274
* Propagate the content of a NoteData into the various UI elements. Used when creating a new window
274-
*/
275+
*/
275276
private void load_data (NoteData data) {
276277
debug ("Loading noteData…");
277278

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ sources = files (
33
'Objects' / 'Themes.vala',
44
'Objects' / 'NoteData.vala',
55

6+
'Utils' / 'ZoomConvert.vala',
67
'Utils' / 'Random.vala',
78
'Utils' / 'Libportal.vala',
89

0 commit comments

Comments
 (0)