Skip to content

Commit 3c4f0bb

Browse files
committed
Remove headerbar reference and document a bit
1 parent e436e50 commit 3c4f0bb

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

src/Windows/StickyNoteWindow.vala

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,16 @@
66
*/
77

88

9-
/* CONTENT
10-
11-
Each StickyNoteWindow instance is a sticky note
12-
It takes a NoteData, and creates the UI
13-
14-
It is connected to settings and reacts to changes
15-
16-
It sometimes calls Application methods for actions that requires higher oversight level
17-
like creating a new note, or saving
18-
19-
Notably, it interacts with popover - a SettingsPopover instant, where stuff is more hairy
20-
Both interact through signals and methods.
21-
22-
A method packages the informations into one NoteData
23-
Theme and Zoom changing are just a matter of adding and removing classes
24-
25-
9+
/**
10+
* Represents a Sticky Note, with its own settings and content
11+
* There is a View, which contains the text
12+
* There is a Popover, which manages the per-window settings (Tail wagging the dog situation)
13+
* Can be packaged into a noteData file for convenient storage
14+
* Reports to the NoteManager for saving
2615
*/
2716
public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
2817
public Gtk.Settings gtk_settings;
2918

30-
public Gtk.HeaderBar headerbar;
3119
public Gtk.EditableLabel editableheader;
3220
public Jorts.NoteView view;
3321
private PopoverView popover;
@@ -38,7 +26,6 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
3826
set { load_data (value);}
3927
}
4028

41-
4229
private static uint debounce_timer_id;
4330

4431
private const string ACTION_PREFIX = "app.";
@@ -102,7 +89,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
10289
/* HEADERBAR */
10390
/*****************************************/
10491

105-
this.headerbar = new Gtk.HeaderBar () {
92+
var headerbar = new Gtk.HeaderBar () {
10693
show_title_buttons = false
10794
};
10895
headerbar.add_css_class (Granite.STYLE_CLASS_FLAT);
@@ -132,16 +119,13 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
132119
set_child (view);
133120
set_focus (view);
134121

135-
136122
/****************************************/
137123
/* LOADING */
138124
/****************************************/
139125

140-
141126
on_scribbly_changed ();
142127
load_data (data);
143128

144-
145129
/***************************************************/
146130
/* CONNECTS AND BINDS */
147131
/***************************************************/
@@ -169,15 +153,16 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
169153
"revealed",
170154
SettingsBindFlags.INVERT_BOOLEAN);
171155
}
172-
} // END OF MAIN CONSTRUCT
156+
}
173157

174158

175159
/********************************************/
176160
/* METHODS */
177161
/********************************************/
178162

179163
/**
180-
* Show UI elements shorty after the window is shown
164+
* Show Actionbar shortly after the window is shown
165+
* This is more for the Aesthetic
181166
*/
182167
private void delayed_show () {
183168
Timeout.add_once (1000, () => {
@@ -190,7 +175,10 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
190175
show.disconnect (delayed_show);
191176
}
192177

193-
// Add a debounce so we aren't writing the entire buffer every character input
178+
/**
179+
* Debouncer to avoid writing to disk all the time constantly
180+
* Called when something has changed
181+
*/
194182
private void debounce_save () {
195183
debug ("Changed! Timer: %s".printf (debounce_timer_id.to_string ()));
196184

@@ -205,12 +193,17 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
205193
});
206194
}
207195

196+
/**
197+
* Simple handler for the EditableLabel
198+
*/
208199
private void on_editable_changed () {
209200
title = editableheader.text + _(" - Jorts");
210201
debounce_save ();
211202
}
212203

213-
// Called when a change in settings is detected
204+
/**
205+
* Handler for scribbly mode settings changed
206+
*/
214207
private void on_scribbly_changed () {
215208
debug ("Scribbly mode changed!");
216209

@@ -226,7 +219,6 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
226219
}
227220
}
228221

229-
//
230222
/**
231223
* Changes the stylesheet accents to the notes color
232224
* Add or remove the Redacted font if the setting is active
@@ -251,7 +243,8 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
251243
}
252244

253245
/**
254-
* Package the note into a NoteData and pass it back
246+
* Package the note into a NoteData and pass it back.
247+
* Used by NoteManager to pass all informations conveniently for storage
255248
*/
256249
public NoteData packaged () {
257250
debug ("Packaging into a noteData…");
@@ -263,10 +256,10 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
263256

264257
var data = new NoteData (
265258
editableheader.text,
266-
popover.color,
267-
content,
268-
popover.monospace,
269-
popover.zoom,
259+
popover.color,
260+
content,
261+
popover.monospace,
262+
popover.zoom,
270263
width,
271264
height);
272265

@@ -276,7 +269,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
276269
}
277270

278271
/**
279-
* Propagate the content of a NoteData into the various UI elements
272+
* Propagate the content of a NoteData into the various UI elements. Used when creating a new window
280273
*/
281274
private void load_data (NoteData data) {
282275
debug ("Loading noteData…");

0 commit comments

Comments
 (0)