Skip to content

Commit 702beef

Browse files
committed
Make NoteManager keep track of some values
1 parent e2418a1 commit 702beef

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/Services/NoteManager.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class Jorts.NoteManager : Object {
1111
public Gee.ArrayList<StickyNoteWindow> open_notes = new Gee.ArrayList<StickyNoteWindow> ();
1212
public Gtk.Application application;
1313

14-
public int latest_zoom;
15-
public bool latest_mono;
16-
public string latest_theme;
14+
public static int latest_zoom;
15+
public static bool latest_mono;
16+
public static string latest_theme;
1717

1818
public NoteManager (Jorts.Application app) {
1919
this.application = app;
@@ -63,7 +63,7 @@ public class Jorts.NoteManager : Object {
6363

6464
random_data = Jorts.Utils.golden_sticky (random_data);
6565

66-
random_data.zoom = this.latest_zoom;
66+
random_data.zoom = latest_zoom;
6767
note = new StickyNoteWindow (application, random_data);
6868
}
6969

@@ -90,7 +90,7 @@ public class Jorts.NoteManager : Object {
9090
StickyNoteWindow last_note = open_notes.last ();
9191
string skip_theme = last_note.theme;
9292
var random_data = Jorts.Utils.random_note (skip_theme);
93-
random_data.zoom = this.latest_zoom;
93+
random_data.zoom = latest_zoom;
9494
note = new StickyNoteWindow (application, random_data);
9595
open_notes.add (note);
9696
print ("new");

src/Services/Storage.vala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Jorts.Storage {
1515

1616
private string data_directory;
1717
private string storage_path;
18-
private string save_file;
18+
private File save_file;
1919

2020
construct {
2121
data_directory = Environment.get_user_data_dir ();
@@ -99,8 +99,7 @@ public class Jorts.Storage {
9999
loaded_data = Jorts.Jason.load_parser(parser);
100100

101101
} catch (Error e) {
102-
print("[WARNING] Failed to load from storage (Attempt 3)!!! " + e.message.to_string() + "\n");
103-
quit ();
102+
critical ("[WARNING] Failed to load from storage (Attempt 3)!!! " + e.message.to_string() + "\n");
104103
}
105104
}
106105

src/Windows/StickyNoteWindow.vala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
271271

272272
_theme = new_theme;
273273
add_css_class (new_theme);
274-
274+
NoteManager.latest_theme = new_theme;
275275
((Application)this.application).manager.save_to_stash ();
276276
}
277277

@@ -291,6 +291,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
291291
}
292292
view.textview.monospace = monospace;
293293
popover.monospace_box.monospace = monospace;
294+
NoteManager.latest_mono = monospace;
294295
((Application)this.application).manager.save_to_stash ();
295296
}
296297

@@ -346,7 +347,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
346347

347348
// Keep it for next new notes
348349
//((Application)this.application).latest_zoom = zoom;
349-
((Jorts.Application)this.application).manager.latest_zoom = zoom;
350+
NoteManager.latest_zoom = zoom;
350351
}
351352

352353
private void action_focus_title () {set_focus (editableheader); editableheader.editing = true;}

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+
'Services' / 'Storage.vala',
67
'Services' / 'NoteManager.vala',
78
'Services' / 'Constants.vala',
89
'Services' / 'Jason.vala',

0 commit comments

Comments
 (0)