Skip to content

Commit 4f9a53a

Browse files
authored
Refactor cleanup (#117)
* bump platform * Reduce verbosity for constants, and add triple-spacing * move accels to window again * use actions for monospacebox * delegate more into the actual view object via actions * some more touchups * touchups * move toggle list in textview * fill in binding actions * solve spacing issues * remove some spaghetti code * move zoom actions into zoom controller * remove unused * Add quit to the textview * set appid domain later * use actions for NoteManager * dont cleanup licence * handle saving via action instead of signal * remove old signal * rollback platform * avoid ctrl+scroll propagating
1 parent 5d01384 commit 4f9a53a

22 files changed

Lines changed: 393 additions & 386 deletions

data/Application.css

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -77,65 +77,65 @@ window.scribbly editablelabel {
7777
}
7878

7979
/* Font zooms */
80-
window.s20 textview.view {font-size: 40%;}
81-
window.s20 editablelabel {font-size: 25%;}
82-
window.s20 editablelabel.editing {font-size: 20%;}
80+
.s20 textview.view {font-size: 40%;}
81+
.s20 editablelabel {font-size: 25%;}
82+
.s20 editablelabel.editing {font-size: 20%;}
8383

84-
window.s40 textview.view {font-size: 60%;}
85-
window.s40 editablelabel {font-size: 45%;}
86-
window.s40 editablelabel.editing {font-size: 40%;}
84+
.s40 textview.view {font-size: 60%;}
85+
.s40 editablelabel {font-size: 45%;}
86+
.s40 editablelabel.editing {font-size: 40%;}
8787

88-
window.s60 textview.view {font-size: 80%;}
89-
window.s60 editablelabel {font-size: 65%;}
90-
window.s60 editablelabel.editing {font-size: 60%;}
88+
.s60 textview.view {font-size: 80%;}
89+
.s60 editablelabel {font-size: 65%;}
90+
.s60 editablelabel.editing {font-size: 60%;}
9191

92-
window.s80 textview.view {font-size: 100%;}
93-
window.s80 editablelabel {font-size: 85%;}
94-
window.s80 editablelabel.editing {font-size: 80%;}
92+
.s80 textview.view {font-size: 100%;}
93+
.s80 editablelabel {font-size: 85%;}
94+
.s80 editablelabel.editing {font-size: 80%;}
9595

96-
window.s100 textview.view {font-size: 120%;}
97-
window.s100 editablelabel {font-size: 105%;}
98-
window.s100 editablelabel.editing {font-size: 100%;}
96+
.s100 textview.view {font-size: 120%;}
97+
.s100 editablelabel {font-size: 105%;}
98+
.s100 editablelabel.editing {font-size: 100%;}
9999

100-
window.s120 textview.view {font-size: 140%;}
101-
window.s120 editablelabel {font-size: 125%;}
102-
window.s120 editablelabel.editing {font-size: 120%;}
100+
.s120 textview.view {font-size: 140%;}
101+
.s120 editablelabel {font-size: 125%;}
102+
.s120 editablelabel.editing {font-size: 120%;}
103103

104-
window.s140 textview.view {font-size: 160%;}
105-
window.s140 editablelabel {font-size: 145%;}
106-
window.s140 editablelabel.editing {font-size: 140%;}
104+
.s140 textview.view {font-size: 160%;}
105+
.s140 editablelabel {font-size: 145%;}
106+
.s140 editablelabel.editing {font-size: 140%;}
107107

108-
window.s160 textview.view {font-size: 180%;}
109-
window.s160 editablelabel {font-size: 165%;}
110-
window.s160 editablelabel.editing {font-size: 160%;}
108+
.s160 textview.view {font-size: 180%;}
109+
.s160 editablelabel {font-size: 165%;}
110+
.s160 editablelabel.editing {font-size: 160%;}
111111

112-
window.s180 textview.view {font-size: 200%;}
113-
window.s180 editablelabel {font-size: 185%;}
114-
window.s180 editablelabel.editing {font-size: 180%;}
112+
.s180 textview.view {font-size: 200%;}
113+
.s180 editablelabel {font-size: 185%;}
114+
.s180 editablelabel.editing {font-size: 180%;}
115115

116-
window.s200 textview.view {font-size: 220%;}
117-
window.s200 editablelabel {font-size: 205%;}
118-
window.s200 editablelabel.editing {font-size: 200%;}
116+
.s200 textview.view {font-size: 220%;}
117+
.s200 editablelabel {font-size: 205%;}
118+
.s200 editablelabel.editing {font-size: 200%;}
119119

120-
window.s220 textview.view {font-size: 240%;}
121-
window.s220 editablelabel {font-size: 225%;}
122-
window.s220 editablelabel.editing {font-size: 220%;}
120+
.s220 textview.view {font-size: 240%;}
121+
.s220 editablelabel {font-size: 225%;}
122+
.s220 editablelabel.editing {font-size: 220%;}
123123

124-
window.s240 textview.view {font-size: 260%;}
125-
window.s240 editablelabel {font-size: 245%;}
126-
window.s240 editablelabel.editing {font-size: 240%;}
124+
.s240 textview.view {font-size: 260%;}
125+
.s240 editablelabel {font-size: 245%;}
126+
.s240 editablelabel.editing {font-size: 240%;}
127127

128-
window.s260 textview.view {font-size: 280%;}
129-
window.s260 editablelabel {font-size: 265%;}
130-
window.s260 editablelabel.editing {font-size: 260%;}
128+
.s260 textview.view {font-size: 280%;}
129+
.s260 editablelabel {font-size: 265%;}
130+
.s260 editablelabel.editing {font-size: 260%;}
131131

132-
window.s280 textview.view {font-size: 300%;}
133-
window.s280 editablelabel {font-size: 285%;}
134-
window.s280 editablelabel.editing {font-size: 280%;}
132+
.s280 textview.view {font-size: 300%;}
133+
.s280 editablelabel {font-size: 285%;}
134+
.s280 editablelabel.editing {font-size: 280%;}
135135

136-
window.s300 textview.view {font-size: 320%;}
137-
window.s300 editablelabel {font-size: 305%;}
138-
window.s300 editablelabel.editing {font-size: 300%;}
136+
.s300 textview.view {font-size: 320%;}
137+
.s300 editablelabel {font-size: 305%;}
138+
.s300 editablelabel.editing {font-size: 300%;}
139139

140140

141141
/* ANIMATION */

io.github.ellie_commons.jorts.flathub.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: io.github.ellie_commons.jorts
33
base: io.elementary.BaseApp
44
base-version: 'circe-25.08'
55
runtime: org.gnome.Platform
6-
runtime-version: '50beta'
6+
runtime-version: '49'
77
sdk: org.gnome.Sdk
88
command: io.github.ellie_commons.jorts
99

@@ -17,7 +17,6 @@ cleanup:
1717
- '/include'
1818
- '/lib/pkgconfig'
1919
- '/man'
20-
- '/share/doc'
2120
- '/share/gtk-doc'
2221
- '/share/man'
2322
- '/share/pkgconfig'

io.github.elly_code.jorts.devel.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ cleanup:
2323
- '/include'
2424
- '/lib/pkgconfig'
2525
- '/man'
26-
- '/share/doc'
2726
- '/share/gtk-doc'
2827
- '/share/man'
2928
- '/share/pkgconfig'

meson.build

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Name our project
22
project(
3-
'io.github.elly_code.jorts',
3+
'jorts',
44
'vala', 'c',
55
version: '4.0.2'
66
)
77

88
app_name = 'Jorts'
9-
10-
11-
correct_app_id = 'io.github.elly_code.jorts'
12-
legacy_app_id = 'io.github.ellie_commons.jorts'
9+
correct_app_id = 'io.github.elly_code.' + meson.project_name()
10+
legacy_app_id = 'io.github.ellie_commons.' + meson.project_name()
1311

1412
if get_option('legacy-rdnn')
1513
app_id = legacy_app_id

src/Application.vala

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class Jorts.Application : Gtk.Application {
4444
public static GLib.Settings gsettings;
4545
public static Gtk.Settings gtk_settings;
4646

47-
public Jorts.NoteManager manager;
47+
public Jorts.NoteManager note_manager;
4848
public static Jorts.PreferenceWindow? preferences;
4949

5050
// Used for commandline option handling
@@ -53,7 +53,6 @@ public class Jorts.Application : Gtk.Application {
5353

5454
public const string ACTION_PREFIX = "app.";
5555
public const string ACTION_QUIT = "action_quit";
56-
public const string ACTION_NEW = "action_new";
5756
public const string ACTION_TOGGLE_SCRIBBLY = "action_toggle_scribbly";
5857
public const string ACTION_TOGGLE_ACTIONBAR = "action_toggle_actionbar";
5958
public const string ACTION_SHOW_PREFERENCES = "action_show_preferences";
@@ -63,18 +62,33 @@ public class Jorts.Application : Gtk.Application {
6362

6463
private const GLib.ActionEntry[] ACTION_ENTRIES = {
6564
{ ACTION_QUIT, quit},
66-
{ ACTION_NEW, action_new },
6765
{ ACTION_TOGGLE_SCRIBBLY, action_toggle_scribbly},
6866
{ ACTION_TOGGLE_ACTIONBAR, action_toggle_actionbar},
6967
{ ACTION_SHOW_PREFERENCES, action_show_preferences},
70-
{ ACTION_SAVE, action_save},
7168
};
7269

7370
public Application () {
7471
Object (flags: ApplicationFlags.HANDLES_COMMAND_LINE,
7572
application_id: APP_ID);
7673
}
7774

75+
76+
/*************************************************/
77+
static construct {
78+
gsettings = new GLib.Settings (APP_ID);
79+
}
80+
81+
/*************************************************/
82+
construct {
83+
// The localization thingamabob
84+
Intl.setlocale (LocaleCategory.ALL, "");
85+
Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
86+
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
87+
Intl.textdomain (GETTEXT_PACKAGE);
88+
}
89+
90+
91+
7892
/*************************************************/
7993
public override void startup () {
8094
debug ("Jorts Startup…");
@@ -84,31 +98,18 @@ public class Jorts.Application : Gtk.Application {
8498

8599
add_action_entries (ACTION_ENTRIES, this);
86100
set_accels_for_action ("app.action_quit", {"<Control>Q"});
87-
set_accels_for_action ("app.action_new", {"<Control>N"});
88-
set_accels_for_action ("app.action_save", {"<Control>S"});
89101
set_accels_for_action ("app.action_toggle_actionbar", {"<Control>T"});
90102
set_accels_for_action ("app.action_show_preferences", {"<Control>P"});
91103
set_accels_for_action ("app.action_toggle_scribbly", {"<Control>H"});
92104

93-
set_accels_for_action ("win.action_delete", {"<Control>W"});
94-
set_accels_for_action ("win.action_zoom_out", {"<Control>minus", "<Control>KP_Subtract"});
95-
set_accels_for_action ("win.action_zoom_default", {"<Control>equal", "<Control>0", "<Control>KP_0"});
96-
set_accels_for_action ("win.action_zoom_in", {"<Control>plus", "<Control>KP_Add"});
97-
set_accels_for_action ("win.action_toggle_mono", {"<Control>m"});
98-
set_accels_for_action ("win.action_focus_title", {"<Control>L"});
99-
set_accels_for_action ("win.action_show_emoji", {"<Control>period"});
100-
set_accels_for_action ("win.action_toggle_list", {"<Shift>F12"});
101-
set_accels_for_action ("win.action_show_menu", {"<Control>G", "<Control>O"});
102-
103-
set_accels_for_action ("textview.action_toggle_list", {"<Shift>F12"});
104-
105-
105+
note_manager = new Jorts.NoteManager (this);
106+
add_action_entries (NoteManager.ACTION_ENTRIES, note_manager);
106107

107108
// Force the eOS icon theme, and set the blueberry as fallback, if for some reason it fails for individual notes
108109
var granite_settings = Granite.Settings.get_default ();
109110
gtk_settings = Gtk.Settings.get_default ();
110111
gtk_settings.gtk_icon_theme_name = "elementary";
111-
gtk_settings.gtk_theme_name = "io.elementary.stylesheet." + Jorts.Constants.DEFAULT_THEME.to_string ().ascii_down ();
112+
gtk_settings.gtk_theme_name = "io.elementary.stylesheet." + DEFAULT_THEME.to_string ().ascii_down ();
112113

113114
// Also follow dark if system is dark lIke mY sOul.
114115
gtk_settings.gtk_application_prefer_dark_theme = (
@@ -153,23 +154,6 @@ Please wait while the app remembers all the things...
153154
);
154155
}
155156

156-
/*************************************************/
157-
static construct {
158-
gsettings = new GLib.Settings (APP_ID);
159-
}
160-
161-
/*************************************************/
162-
construct {
163-
// The localization thingamabob
164-
Intl.setlocale (LocaleCategory.ALL, "");
165-
Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
166-
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
167-
Intl.textdomain (GETTEXT_PACKAGE);
168-
169-
//add_main_option_entries (CMD_OPTION_ENTRIES);
170-
manager = new Jorts.NoteManager (this);
171-
}
172-
173157
// Clicked: Either show all windows, or rebuild from storage
174158
protected override void activate () {
175159
debug ("[JORTS] Jorts, activate!");
@@ -178,27 +162,22 @@ Please wait while the app remembers all the things...
178162
//GLib.Environment.set_variable ("LANGUAGE", "pt_br", true);
179163

180164
/* Either we show all sticky notes, or we load everything lol */
181-
if (manager.open_notes.size > 0) {
182-
foreach (var window in manager.open_notes) {
165+
if (note_manager.open_notes.size > 0) {
166+
foreach (var window in note_manager.open_notes) {
183167
if (window.visible) {window.present ();}
184168
}
185169
} else {
186-
manager.init ();
170+
note_manager.init ();
187171
}
188172

189-
if (new_note) {manager.create_note (); new_note = false;}
173+
if (new_note) {note_manager.create_note (); new_note = false;}
190174
if (show_pref) {action_show_preferences (); show_pref = false;}
191175
}
192176

193177
public static int main (string[] args) {
194178
return new Application ().run (args);
195179
}
196180

197-
private void action_new () {
198-
debug ("New Note");
199-
manager.create_note ();
200-
}
201-
202181
private void action_show_preferences () {
203182
debug ("Showing preferences!");
204183

@@ -223,11 +202,6 @@ Please wait while the app remembers all the things...
223202
gsettings.set_boolean ("hide-bar", !current);
224203
}
225204

226-
private void action_save () {
227-
debug ("Saving...");
228-
manager.save_all ();
229-
}
230-
231205
// checked upon window closing to make sure we do not linger in the background
232206
public void check_if_quit () {
233207
debug ("Windows open: %s".printf (get_windows ().length ().to_string ()));

src/Constants.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* I just dump all my constants here
1111
*/
12-
namespace Jorts.Constants {
12+
namespace Jorts {
1313

1414
/*************************************************/
1515
const string DONATE_LINK = "https://ko-fi.com/teamcons/tip";
@@ -40,6 +40,7 @@ namespace Jorts.Constants {
4040

4141
const int SPACING_STANDARD = 5;
4242
const int SPACING_DOUBLE = 10;
43+
const int SPACING_TRIPLE = 15;
4344

4445
// Autocomplete save me
4546
const string KEY_SCRIBBLY = "scribbly-mode-active";

src/Objects/NoteData.vala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
public class Jorts.NoteData : Object {
1414

1515
// Will determine properties (or lack thereof) for any new note
16-
public static Jorts.Themes latest_theme = Jorts.Constants.DEFAULT_THEME;
17-
public static int latest_zoom = Jorts.Constants.DEFAULT_ZOOM;
18-
public static bool latest_mono = Jorts.Constants.DEFAULT_MONO;
16+
public static Jorts.Themes latest_theme = DEFAULT_THEME;
17+
public static int latest_zoom = DEFAULT_ZOOM;
18+
public static bool latest_mono = DEFAULT_MONO;
1919

2020
public string? title;
2121
public Jorts.Themes? theme;
@@ -36,8 +36,8 @@ public class Jorts.NoteData : Object {
3636
this.content = content ?? "";
3737
this.monospace = monospace ?? latest_mono;
3838
this.zoom = zoom ?? latest_zoom;
39-
this.width = width ?? Jorts.Constants.DEFAULT_WIDTH;
40-
this.height = height ?? Jorts.Constants.DEFAULT_HEIGHT;
39+
this.width = width ?? DEFAULT_WIDTH;
40+
this.height = height ?? DEFAULT_HEIGHT;
4141
}
4242

4343
/*************************************************/
@@ -48,15 +48,15 @@ public class Jorts.NoteData : Object {
4848
title = node.get_string_member_with_default ("title", (_("Forgot title!")));
4949
theme = (Jorts.Themes)node.get_int_member_with_default ("color", Jorts.Themes.random_theme ());
5050
content = node.get_string_member_with_default ("content","");
51-
monospace = node.get_boolean_member_with_default ("monospace", Jorts.Constants.DEFAULT_MONO);
52-
zoom = (int)node.get_int_member_with_default ("zoom", Jorts.Constants.DEFAULT_ZOOM);
51+
monospace = node.get_boolean_member_with_default ("monospace", DEFAULT_MONO);
52+
zoom = (int)node.get_int_member_with_default ("zoom", DEFAULT_ZOOM);
5353

5454
// Make sure the values are nothing crazy
55-
if (zoom < Jorts.Constants.ZOOM_MIN) { zoom = Jorts.Constants.ZOOM_MIN;}
56-
else if (zoom > Jorts.Constants.ZOOM_MAX) { zoom = Jorts.Constants.ZOOM_MAX;}
55+
if (zoom < ZOOM_MIN) { zoom = ZOOM_MIN;}
56+
else if (zoom > ZOOM_MAX) { zoom = ZOOM_MAX;}
5757

58-
width = (int)node.get_int_member_with_default ("width", Jorts.Constants.DEFAULT_WIDTH);
59-
height = (int)node.get_int_member_with_default ("height", Jorts.Constants.DEFAULT_HEIGHT);
58+
width = (int)node.get_int_member_with_default ("width", DEFAULT_WIDTH);
59+
height = (int)node.get_int_member_with_default ("height", DEFAULT_HEIGHT);
6060
}
6161

6262
/*************************************************/

src/Services/ColorController.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Jorts.ColorController : Object {
4747
Application.gtk_settings.gtk_theme_name = stylesheet;
4848

4949
// Cleanup;
50-
window.changed ();
50+
window.has_changed ();
5151
}
5252

5353
/**

0 commit comments

Comments
 (0)