Skip to content

Commit 855aa62

Browse files
committed
code style
1 parent 225519f commit 855aa62

File tree

5 files changed

+66
-99
lines changed

5 files changed

+66
-99
lines changed

src/Application.vala

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ At some point i may move this in its own file
2828

2929
namespace Jorts {
3030
public class Application : Gtk.Application {
31-
public Gee.ArrayList<StickyNoteWindow> open_notes = new Gee.ArrayList<StickyNoteWindow>();
31+
public static Gee.ArrayList<StickyNoteWindow> open_notes;
3232
public static GLib.Settings gsettings;
3333

3434
public Application () {
@@ -67,17 +67,6 @@ namespace Jorts {
6767
);
6868
});
6969

70-
// var portal = new Xdp.Portal();
71-
// GenericArray<weak string> cmd = new GenericArray<weak string> ();
72-
// cmd.add ("io.github.ellie_commons.jorts");
73-
74-
// portal.request_background(
75-
// null,
76-
// "autostart",
77-
// cmd,
78-
// Xdp.BackgroundFlags.AUTOSTART,
79-
// null);
80-
8170
// build all the stylesheets
8271
Jorts.Themer.init_all_themes();
8372
}
@@ -153,15 +142,15 @@ namespace Jorts {
153142
// Create new instances of StickyNoteWindow
154143
// If we have data, nice, just load it into a new instance
155144
// Else we do a lil new note
156-
public void create_note(NoteData? data) {
145+
public void create_note(NoteData? data = null) {
157146
StickyNoteWindow note;
158147
if (data != null) {
159148
note = new StickyNoteWindow(this, data);
160149
}
161150
else {
162151

163152
// Skip theme from previous window, but use same text zoom
164-
StickyNoteWindow last_note = this.open_notes.last ();
153+
StickyNoteWindow last_note = open_notes.last ();
165154
string skip_theme = last_note.theme;
166155
var random_data = Jorts.Utils.random_note(skip_theme);
167156

@@ -171,14 +160,14 @@ namespace Jorts {
171160
random_data.zoom = this.latest_zoom;
172161
note = new StickyNoteWindow(this, random_data);
173162
}
174-
this.open_notes.add(note);
163+
open_notes.add(note);
175164
this.save_to_stash ();
176165
}
177166

178167
// Simply remove from the list of things to save, and close
179168
public void remove_note(StickyNoteWindow note) {
180169
debug ("Removing a note…\n");
181-
this.open_notes.remove (note);
170+
open_notes.remove (note);
182171
this.save_to_stash ();
183172
}
184173

@@ -206,8 +195,6 @@ namespace Jorts {
206195
}
207196
}
208197

209-
210-
211198
public void show_all() {
212199
foreach (var window in open_notes) {
213200
if (window.visible) {
@@ -217,8 +204,6 @@ namespace Jorts {
217204
}
218205

219206

220-
221-
222207
/*************************************************/
223208
public void init_all_notes () {
224209
Gee.ArrayList<NoteData> loaded_data = Jorts.Stash.load_from_stash();
@@ -234,7 +219,7 @@ namespace Jorts {
234219
print("Doing a backup! :)");
235220

236221
Jorts.Stash.check_if_stash ();
237-
string json_data = Jorts.Jason.jsonify (this.open_notes);
222+
string json_data = Jorts.Jason.jsonify (open_notes);
238223
Jorts.Stash.overwrite_stash (json_data, Jorts.Constants.FILENAME_BACKUP);
239224

240225
var now = new DateTime.now_utc ().to_string() ;
@@ -243,9 +228,6 @@ namespace Jorts {
243228

244229
}
245230

246-
247-
248-
249231
/*************************************************/
250232
protected override int command_line (ApplicationCommandLine command_line) {
251233
PreferenceWindow preferences;
@@ -254,19 +236,16 @@ namespace Jorts {
254236
switch (args[1]) {
255237

256238
case "--new-note":
257-
activate ();
258-
create_note(null);
239+
activate ();
240+
241+
create_note();
259242
break;
260243

261244
case "--preferences":
262245
activate ();
263246
preferences = new Jorts.PreferenceWindow();
264247
break;
265248

266-
case "--dump":
267-
print(Jorts.Jason.jsonify (open_notes));
268-
break;
269-
270249
default:
271250
activate ();
272251
break;

src/Objects/NoteData.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ namespace Jorts {
2929
public int width;
3030
public int height;
3131

32-
public NoteData (string title, string theme, string content, int zoom, int width, int height)
32+
public NoteData (
33+
string? title = null, string? theme = null, string? content = null,
34+
int? zoom = null, int? width = null, int? height = null)
3335
{
3436
this.title = title;
3537
this.theme = theme;

src/Services/Constants.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ namespace Jorts.Constants {
3030

3131

3232
/*************************************************/
33-
const string RDNN = "io.github.ellie_commons.jorts";
34-
const string DONATE_LINK = "https://ko-fi.com/teamcons";
33+
const string RDNN = "io.github.ellie_commons.jorts";
34+
const string DONATE_LINK = "https://ko-fi.com/teamcons";
3535

3636
// signature theme
3737
const string DEFAULT_THEME = "BLUEBERRY";
@@ -40,7 +40,7 @@ namespace Jorts.Constants {
4040
const string FILENAME_BACKUP = "backup_state.json";
4141

4242
// in ms
43-
const int DEBOUNCE = 1000;
43+
const int DEBOUNCE = 1000;
4444

4545
// We need to say stop at some point
4646
const int ZOOM_MAX = 240;

src/Services/Utils.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace Jorts.Utils {
8080
// Spits out a random theme for a new note
8181
// If there is the name of a string to skip, just skip it.
8282
// Having an gee.arraylist defined from the start only causes issues
83-
public string random_theme (string? skip_theme) {
83+
public string random_theme (string? skip_theme = null) {
8484
Gee.ArrayList<string> themes = new Gee.ArrayList<string> ();
8585
themes.add_all_array (Jorts.Constants.THEMES);
8686

@@ -143,7 +143,7 @@ namespace Jorts.Utils {
143143

144144
/*************************************************/
145145
// Spits out a cute or funny random title for a new sticky note
146-
public string random_emote (string? skip_emote) {
146+
public string random_emote (string? skip_emote = null) {
147147

148148
Gee.ArrayList<string> allemotes = new Gee.ArrayList<string> ();
149149
allemotes.add_all_array (Jorts.Constants.EMOTES);
@@ -193,7 +193,7 @@ Have a great day!🎇
193193

194194
/*************************************************/
195195
// Spits out a fresh new note
196-
public NoteData random_note (string? skip_theme) {
196+
public NoteData random_note (string? skip_theme = null) {
197197
debug("Generating random note... Skip:" + skip_theme);
198198
var randtitle = Jorts.Utils.random_title ();
199199
string randtheme = Jorts.Utils.random_theme (skip_theme);

0 commit comments

Comments
 (0)