Skip to content

Commit 41a7599

Browse files
committed
further linting
1 parent 8b68b6b commit 41a7599

File tree

6 files changed

+61
-57
lines changed

6 files changed

+61
-57
lines changed

src/Application.vala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ namespace Jorts {
9696
add_action (quit_action);
9797
quit_action.activate.connect (() => {
9898
this.save_to_stash ();
99-
this.quit();
99+
this.quit ();
100100
});
101101
var new_action = new SimpleAction ("new", null);
102102
set_accels_for_action ("app.action_new", {"<Control>n"});
103103
add_action (new_action);
104104
new_action.activate.connect (() => {
105-
this.create_note(null);
105+
this.create_note (null);
106106
});
107107

108108
var delete_action = new SimpleAction ("delete", null);
@@ -129,7 +129,7 @@ namespace Jorts {
129129
set_accels_for_action ("app.toggle_scribbly", { "<Control>h", null });
130130
add_action (toggle_scribbly);
131131
toggle_scribbly.activate.connect (() => {
132-
this.toggle_scribbly();
132+
this.toggle_scribbly ();
133133
});
134134
var toggle_hidebar = new SimpleAction ("toggle_hidebar", null);
135135
set_accels_for_action ("app.toggle_hidebar", { "<Control>t", null });
@@ -144,7 +144,7 @@ namespace Jorts {
144144
// Test Lang
145145
//GLib.Environment.set_variable ("LANGUAGE", "pt_br", true);
146146
if (get_windows ().length () > 0) {
147-
show_all();
147+
show_all ();
148148
} else {
149149
this.init_all_notes ();
150150
}
@@ -186,19 +186,19 @@ namespace Jorts {
186186
Jorts.Stash.check_if_stash ();
187187
string json_data = Jorts.Jason.jsonify (open_notes);
188188
Jorts.Stash.overwrite_stash (json_data, Jorts.Constants.FILENAME_STASH);
189-
print("Saved " + open_notes.size.to_string() + "!\n");
189+
print ("Saved " + open_notes.size.to_string() + "!\n");
190190
}
191191

192192

193-
public void toggle_scribbly() {
193+
public void toggle_scribbly () {
194194
if (Application.gsettings.get_boolean ("scribbly-mode-active")) {
195195
gsettings.set_boolean ("scribbly-mode-active",false);
196196
} else {
197197
gsettings.set_boolean ("scribbly-mode-active",true);
198198
}
199199
}
200200

201-
public void toggle_hidebar() {
201+
public void toggle_hidebar () {
202202
if (Application.gsettings.get_boolean ("hide-bar")) {
203203
gsettings.set_boolean ("hide-bar",false);
204204
} else {
@@ -220,13 +220,13 @@ namespace Jorts {
220220

221221

222222
/*************************************************/
223-
public void init_all_notes() {
223+
public void init_all_notes () {
224224
Gee.ArrayList<NoteData> loaded_data = Jorts.Stash.load_from_stash();
225225

226226
// Load everything we have
227227
foreach (NoteData data in loaded_data) {
228-
debug("Loaded: " + data.title + "\n");
229-
this.create_note(data);
228+
debug ("Loaded: " + data.title + "\n");
229+
this.create_note (data);
230230
}
231231

232232

@@ -238,7 +238,7 @@ namespace Jorts {
238238
Jorts.Stash.overwrite_stash (json_data, Jorts.Constants.FILENAME_BACKUP);
239239

240240
var now = new DateTime.now_utc ().to_string() ;
241-
gsettings.set_string("last-backup", now);
241+
gsettings.set_string ("last-backup", now);
242242
}
243243

244244
}
@@ -276,8 +276,8 @@ namespace Jorts {
276276
}
277277

278278
public static int main (string[] args) {
279-
var app = new Application();
280-
return app.run(args);
279+
var app = new Application ();
280+
return app.run (args);
281281
}
282282
}
283283
}

src/Services/Constants.vala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ namespace Jorts.Constants {
4242
// in ms
4343
const int DEBOUNCE = 1000;
4444

45-
4645
// We need to say stop at some point
4746
const int ZOOM_MAX = 240;
4847
const int DEFAULT_ZOOM = 100;
@@ -56,8 +55,6 @@ namespace Jorts.Constants {
5655
const int DEFAULT_PREF_WIDTH = 530;
5756
const int DEFAULT_PREF_HEIGHT = 290;
5857

59-
60-
6158
/*************************************************/
6259
// Shortcuts
6360
const string[] ACCELS_ZOOM_DEFAULT = { "<Control>equal", "<control>0", "<Control>KP_0" };
@@ -122,8 +119,4 @@ namespace Jorts.Constants {
122119
"face-wink-symbolic",
123120
"face-worried-symbolic"
124121
};
125-
126-
127-
128-
129122
}

src/Services/Stash.vala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ namespace Jorts.Stash {
4040

4141
/*************************************************/
4242
// Ok first check if we have a directory to store data
43-
public void check_if_stash() {
44-
debug("do we have a data directory?");
45-
var data_directory = File.new_for_path(Environment.get_user_data_dir ());
43+
public void check_if_stash () {
44+
debug ("do we have a data directory?");
45+
var data_directory = File.new_for_path (Environment.get_user_data_dir ());
4646
try {
47-
if (!data_directory.query_exists()) {
48-
data_directory.make_directory();
47+
if (!data_directory.query_exists ()) {
48+
data_directory.make_directory ();
4949
print("Prepared target data directory");
5050
}
5151
} catch (Error e) {
@@ -66,15 +66,15 @@ namespace Jorts.Stash {
6666
var file = File.new_for_path (storage_path);
6767

6868
try {
69-
if (!dir.query_exists()) {
70-
dir.make_directory();
69+
if (!dir.query_exists ()) {
70+
dir.make_directory ();
7171
}
7272
if (file.query_exists ()) {
7373
file.delete ();
7474
}
7575
var file_stream = file.create (FileCreateFlags.REPLACE_DESTINATION);
7676
var data_stream = new DataOutputStream (file_stream);
77-
data_stream.put_string(json_data);
77+
data_stream.put_string (json_data);
7878

7979
} catch (Error e) {
8080
warning ("Failed to save notes %s\n", e.message);
@@ -89,7 +89,7 @@ namespace Jorts.Stash {
8989
// We first try from main storage
9090
// If that fails, we go for backup
9191
// Still failing ? Start anew
92-
public Gee.ArrayList<NoteData> load_from_stash() {
92+
public Gee.ArrayList<NoteData> load_from_stash () {
9393
debug("loading from stash...");
9494

9595
Gee.ArrayList<NoteData> loaded_data = new Gee.ArrayList<NoteData>();
@@ -102,7 +102,7 @@ namespace Jorts.Stash {
102102
// Try standard storage
103103
try {
104104
parser.load_from_mapped_file (storage_path);
105-
loaded_data = Jorts.Jason.load_parser(parser);
105+
loaded_data = Jorts.Jason.load_parser (parser);
106106

107107
} catch (Error e) {
108108
print("[WARNING] Failed to load from main storage! " + e.message.to_string() + "\n");
@@ -125,11 +125,11 @@ namespace Jorts.Stash {
125125

126126
// If we load nothing: Fallback to a random with blue theme as first
127127
if (loaded_data.size == 0 ) {
128-
debug("nothing loaded");
129-
NoteData blank_slate = Jorts.Utils.random_note(null);
128+
debug ("nothing loaded");
129+
NoteData blank_slate = Jorts.Utils.random_note (null);
130130
blank_slate.theme = Jorts.Constants.DEFAULT_THEME ;
131131

132-
loaded_data.add(blank_slate);
132+
loaded_data.add (blank_slate);
133133
}
134134

135135
return loaded_data;
@@ -142,8 +142,8 @@ namespace Jorts.Stash {
142142
// We first check if we have a backup or a last saved date
143143
// if none of those two, tell we need immediate backup
144144
// else, then depending how old we know the backup to be
145-
public bool need_backup(string last_backup) {
146-
debug("lets check if we need to backup");
145+
public bool need_backup (string last_backup) {
146+
debug ("lets check if we need to backup");
147147

148148
string data_directory = Environment.get_user_data_dir ();
149149
string backup_path = data_directory + "/" + Jorts.Constants.FILENAME_BACKUP;
@@ -156,7 +156,7 @@ namespace Jorts.Stash {
156156
} else {
157157
var now = new DateTime.now_utc () ;
158158
var date_last_backup = new DateTime.from_iso8601 (last_backup, null);
159-
TimeSpan date_diff = now.difference(date_last_backup);
159+
TimeSpan date_diff = now.difference (date_last_backup);
160160
var days_in_micro = Jorts.Constants.DAYS_BETWEEN_BACKUPS * TimeSpan.DAY;
161161
return (date_diff > days_in_micro);
162162
}

src/Services/Themer.vala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Jorts.Themer {
3535
// Here we go
3636
// Take up a elementary OS color name and gurgle back a CSS string
3737
public static string generate_css (string theme) {
38-
debug("Generating css");
38+
debug ("Generating css");
3939
string style = "";
4040

4141
style = (N_("""
@@ -134,7 +134,7 @@ namespace Jorts.Themer {
134134
135135
"""));
136136

137-
style = style.replace ("${accent_color}",theme);
137+
style = style.replace ("${accent_color}", theme);
138138

139139
return style;
140140
}
@@ -144,8 +144,8 @@ namespace Jorts.Themer {
144144
/*************************************************/
145145
// Called once, at the start of the app
146146
// Loads the standard sheet, then do all the different themes
147-
public static void init_all_themes() {
148-
debug("Init all themes");
147+
public static void init_all_themes () {
148+
debug ("Init all themes");
149149

150150
// Use standard sheet
151151
var app_provider = new Gtk.CssProvider ();

src/Services/Utils.vala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Jorts.Utils {
3232

3333
/*************************************************/
3434
// We cannot use numbers in CSS, so we have to translate a number into a string
35-
public string zoom_to_class(int zoom) {
35+
public string zoom_to_class (int zoom) {
3636
switch (zoom) {
3737
case 20: return "antsized";
3838
case 40: return "muchsmaller";
@@ -55,7 +55,7 @@ namespace Jorts.Utils {
5555

5656
/*************************************************/
5757
// We cannot use numbers in CSS, so we have to translate a number into a string
58-
public int zoom_to_UIsize(int zoom) {
58+
public int zoom_to_UIsize (int zoom) {
5959
switch (zoom) {
6060
case 20: return 24;
6161
case 40: return 26;
@@ -191,18 +191,21 @@ Have a great day!🎇
191191
}
192192

193193

194-
195-
196-
197194
/*************************************************/
198195
// Spits out a fresh new note
199196
public NoteData random_note (string? skip_theme) {
200197
debug("Generating random note... Skip:" + skip_theme);
201-
var randtitle = Jorts.Utils.random_title();
198+
var randtitle = Jorts.Utils.random_title ();
202199
string randtheme = Jorts.Utils.random_theme (skip_theme);
203200

204-
NoteData randnote = new NoteData( randtitle, randtheme, "", Jorts.Constants.DEFAULT_ZOOM, Jorts.Constants.DEFAULT_WIDTH, Jorts.Constants.DEFAULT_HEIGHT);
205-
201+
NoteData randnote = new NoteData (
202+
randtitle,
203+
randtheme,
204+
"",
205+
Jorts.Constants.DEFAULT_ZOOM,
206+
Jorts.Constants.DEFAULT_WIDTH,
207+
Jorts.Constants.DEFAULT_HEIGHT
208+
);
206209

207210
return randnote;
208211
}

src/StickyNoteWindow.vala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ namespace Jorts {
5050
private Gtk.Button delete_item;
5151
//private Gtk.ToggleButton hide_item;
5252

53+
private Gtk.MenuButton emoji_button;
54+
5355
private SettingsPopover popover;
5456

5557
public Jorts.NoteData data;
@@ -202,7 +204,7 @@ namespace Jorts {
202204
this.on_scribbly_changed ();
203205

204206
var emojichooser_popover = new Gtk.EmojiChooser ();
205-
var emoji_button = new Gtk.MenuButton ();
207+
emoji_button = new Gtk.MenuButton ();
206208
emoji_button.tooltip_markup = Granite.markup_accel_tooltip ({"<Control>period"}, _("Insert emoji"));
207209
emoji_button.has_tooltip = true;
208210
emoji_button.set_icon_name (Jorts.Utils.random_emote (null));
@@ -213,12 +215,7 @@ namespace Jorts {
213215

214216
// Display the current zoom level when the popover opens
215217
// Else it does not get set
216-
emojichooser_popover.show.connect (() => {
217-
emoji_button.set_icon_name (
218-
Jorts.Utils.random_emote (
219-
emoji_button.get_icon_name ())
220-
);
221-
});
218+
emojichooser_popover.show.connect (on_emoji_popover);
222219

223220
// User chose emoji, add it to buffer
224221
emojichooser_popover.emoji_picked.connect ((emoji) => {
@@ -280,8 +277,11 @@ namespace Jorts {
280277
Application.gsettings.changed["scribbly-mode-active"].connect (on_scribbly_changed);
281278

282279
//The application tells us the squiffly state has changed!
283-
Application.gsettings.bind ("hide-bar", swoosh, "reveal_child", SettingsBindFlags.INVERT_BOOLEAN);
284-
//Application.gsettings.changed["hide-bar"].connect (on_hidebar_changed);
280+
Application.gsettings.bind (
281+
"hide-bar",
282+
swoosh,
283+
"reveal_child",
284+
SettingsBindFlags.INVERT_BOOLEAN);
285285

286286
gtk_settings.notify["enable-animations"].connect (on_reduceanimation_changed);
287287

@@ -360,6 +360,14 @@ namespace Jorts {
360360
this.swoosh.reveal_child = (Application.gsettings.get_boolean ("hide-bar") == false);
361361
}
362362

363+
public void on_emoji_popover () {
364+
emoji_button.set_icon_name (
365+
Jorts.Utils.random_emote (
366+
emoji_button.get_icon_name ()
367+
)
368+
);
369+
}
370+
363371
// Called when the window is-active property changes
364372
public void on_reduceanimation_changed () {
365373

0 commit comments

Comments
 (0)