Skip to content

Commit

Permalink
Formatting lol
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Nov 28, 2023
1 parent f1b4758 commit 2e0d2f0
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/add-category-dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class AddCategoryDialog : Adw.MessageDialog {
this.set_response_enabled ("add", false);
this.set_close_response ("cancel");

var lb = new Gtk.ListBox() { css_classes = { "boxed-list" } };
name_entry = new Adw.EntryRow() {
var lb = new Gtk.ListBox () { css_classes = { "boxed-list" } };
name_entry = new Adw.EntryRow () {
input_hints = Gtk.InputHints.SPELLCHECK,
title = _("Category Name")
};
Expand Down
66 changes: 33 additions & 33 deletions src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MyApp : Adw.Application {



public MyApp() {
public MyApp () {
Object (
application_id: "io.github.leolost2605.gradebook",
flags: ApplicationFlags.FLAGS_NONE
Expand Down Expand Up @@ -42,7 +42,7 @@ public class MyApp : Adw.Application {


public void on_help_action () {
Gtk.show_uri(main_window, "https://github.com/leolost2605/Gradebook/wiki", 0);
Gtk.show_uri (main_window, "https://github.com/leolost2605/Gradebook/wiki", 0);
}


Expand All @@ -51,10 +51,10 @@ public class MyApp : Adw.Application {
public void on_newsubject_action () {
var dialog = new NewSubjectDialog (main_window);
dialog.close_request.connect (() => {
if(dialog.accept) {
if (dialog.accept) {
new_subject (dialog.name_entry_box.get_text (), dialog.categories);
}
dialog.destroy();
dialog.destroy ();
return true;
});
dialog.present ();
Expand Down Expand Up @@ -146,34 +146,34 @@ public class MyApp : Adw.Application {
}


public void read_data() {
public void read_data () {
subjects = new Subject[number_of_subjects];

for (int i = 0; i < subjects.length && FileUtils.test (Environment.get_user_data_dir () + @"/gradebook/savedata/subjectsave$i", FileTest.EXISTS); i++) {
File file = File.new_for_path (Environment.get_user_data_dir () + @"/gradebook/savedata/subjectsave$i");

var parser = new SubjectParser();
Subject sub = parser.to_object(read_from_file(file));
var parser = new SubjectParser ();
Subject sub = parser.to_object (read_from_file (file));
subjects[i] = sub;
}

}

public void write_data () {
int z = 0;
File dir = File.new_for_path(Environment.get_user_data_dir () + "/gradebook/savedata/");
if(!dir.query_exists ()) {
File dir = File.new_for_path (Environment.get_user_data_dir () + "/gradebook/savedata/");
if (!dir.query_exists ()) {
try {
dir.make_directory_with_parents();
dir.make_directory_with_parents ();
} catch (Error e) {
print(e.message);
print (e.message);
}
}
for (int i = 0; i < subjects.length && subjects[i] != null; i++) {
var parser = new SubjectParser ();
File file = File.new_for_path (Environment.get_user_data_dir () + @"/gradebook/savedata/subjectsave$i");

write_to_file (file, parser.to_string(subjects[i]));
write_to_file (file, parser.to_string (subjects[i]));
z = i + 1;
}
for (int i = z; i < subjects.length && FileUtils.test (Environment.get_user_data_dir () + @"/gradebook/savedata/subjectsave$i", FileTest.EXISTS); i++) {
Expand All @@ -182,10 +182,10 @@ public class MyApp : Adw.Application {
try {
file.delete ();
} catch (Error e) {
print(e.message);
print (e.message);
}
}
main_window.destroy();
main_window.destroy ();
}


Expand Down Expand Up @@ -236,7 +236,7 @@ public class MyApp : Adw.Application {

public void new_grade_dialog (int index) {

if(subjects[index].categories[0] != null){
if (subjects[index].categories[0] != null){
var dialog = new NewGradeDialog (main_window, subjects, index);

dialog.response.connect ((response_id) => {
Expand All @@ -248,10 +248,10 @@ public class MyApp : Adw.Application {
});
dialog.present ();
} else {
var ErrorDialog = new Adw.MessageDialog(main_window, _("Error"), _("This subject has no categories. Add at least one category in order to add a grade."));
ErrorDialog.add_css_class("error");
ErrorDialog.add_response("ok", _("OK"));
ErrorDialog.present();
var ErrorDialog = new Adw.MessageDialog (main_window, _("Error"), _("This subject has no categories. Add at least one category in order to add a grade."));
ErrorDialog.add_css_class ("error");
ErrorDialog.add_response ("ok", _("OK"));
ErrorDialog.present ();
}
}

Expand All @@ -262,7 +262,7 @@ public class MyApp : Adw.Application {

dialog.close_request.connect ((response_id) => {
if (dialog.accept) {
if(dialog.subject != null) {
if (dialog.subject != null) {
subjects[index] = dialog.subject;
} else {
subjects[index] = null;
Expand Down Expand Up @@ -304,7 +304,7 @@ public class MyApp : Adw.Application {
var menu_button = new Gtk.MenuButton () {
icon_name = "open-menu-symbolic"
};
header_bar.pack_end(menu_button);
header_bar.pack_end (menu_button);

var menu = new Menu ();
var menu_section1 = new Menu ();
Expand Down Expand Up @@ -342,7 +342,7 @@ public class MyApp : Adw.Application {

stack_box.add_top_bar (header_bar);

var placeholderlabel = new Adw.StatusPage() {
var placeholderlabel = new Adw.StatusPage () {
vexpand = true,
hexpand = true,
title = _("No Subjects"),
Expand All @@ -353,7 +353,7 @@ public class MyApp : Adw.Application {
} else {

//Create StackPages for every subject
for(int i = 0; subjects[i] != null; i++)
for( int i = 0; subjects[i] != null; i++)
{

subject_boxes[i] = new Adw.ToolbarView ();
Expand All @@ -363,7 +363,7 @@ public class MyApp : Adw.Application {
var menu_button = new Gtk.MenuButton () {
icon_name = "open-menu-symbolic"
};
header_bar.pack_end(menu_button);
header_bar.pack_end (menu_button);

var menu = new Menu ();
var menu_section1 = new Menu ();
Expand Down Expand Up @@ -424,7 +424,7 @@ public class MyApp : Adw.Application {
};
gtk_sw.set_child (adw_c);
adw_c.set_child (nyttbox);

//TOP BOX
var top_box = new Gtk.Box (HORIZONTAL, 0) {
height_request = 40,
Expand Down Expand Up @@ -524,7 +524,7 @@ public class MyApp : Adw.Application {

main_box.set_content (stack);
}




Expand Down Expand Up @@ -553,13 +553,13 @@ public class MyApp : Adw.Application {
} else {

var list_box = new Gtk.ListBox () {vexpand = false, margin_top = 20};
list_box.add_css_class("boxed-list");
list_box.add_css_class ("boxed-list");
//list_box.set_sort_func (sort_list);
//list_box.set_filter_func (filter_list);
nyttbox.append (list_box);

for(int j = 0; subjects[i].grades[j] != null; j++) {
average[subjects[i].grades[j].cat] += int.parse(subjects[i].grades[j].grade);
for (int j = 0; subjects[i].grades[j] != null; j++) {
average[subjects[i].grades[j].cat] += int.parse (subjects[i].grades[j].grade);
number_of_grades[subjects[i].grades[j].cat]++;


Expand Down Expand Up @@ -607,13 +607,13 @@ public class MyApp : Adw.Application {
double percentage_divider = 0;

for (int j = 0; j < subjects[i].categories.length && subjects[i].categories[j] != null; j++) {
if(number_of_grades[j] != 0) {
if (number_of_grades[j] != 0) {
avg_calculated[j] = average[j] / number_of_grades[j];
final_avg += avg_calculated[j] * subjects[i].categories[j].percentage;
percentage_divider += subjects[i].categories[j].percentage;
}
}
if(percentage_divider != 0) {
if (percentage_divider != 0) {
string average_string = "%.2f".printf (final_avg / percentage_divider);
avg[i].set_label (average_string);
}
Expand Down Expand Up @@ -665,14 +665,14 @@ public class MyApp : Adw.Application {
main_window.add_breakpoint (bpoint);

window_stack_ui (0);

//PRESENT WINDOW
main_window.present ();


main_window.close_request.connect (() => {
main_window.set_visible (false);
write_data();
write_data ();
return true;
});
}
Expand Down
24 changes: 12 additions & 12 deletions src/edit-subject-dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public Subject subject;
};

var cb = new Gtk.Button.with_label (_("Cancel"));
cb.clicked.connect(() => {
cb.clicked.connect (() => {
accept = false;
this.close ();
});

var ab = new Gtk.Button.with_label (_("Save")) { css_classes = { "suggested-action" } };
ab.clicked.connect(() => {
ab.clicked.connect (() => {
accept = true;
this.close ();
});
Expand Down Expand Up @@ -67,19 +67,19 @@ public Subject subject;

load_list ();

subject_delete_button = new Gtk.Button.with_label(_("Delete Subject…")) { hexpand = false, halign = Gtk.Align.START, margin_top = 20 };
subject_delete_button.add_css_class("destructive-action");
main_box.append(subject_delete_button);
subject_delete_button = new Gtk.Button.with_label (_("Delete Subject…")) { hexpand = false, halign = Gtk.Align.START, margin_top = 20 };
subject_delete_button.add_css_class ("destructive-action");
main_box.append (subject_delete_button);

subject_delete_button.clicked.connect (() => {
string n = s.name;
///TRANSLATORS: %s is the name of a school subject
var message_dialog = new Adw.MessageDialog(this, _("Delete %s?").printf(n), null);
message_dialog.set_body (_("If you delete %s, its information will be deleted permanently.").printf(n));
var message_dialog = new Adw.MessageDialog( this, _("Delete %s?").printf( n), null);
message_dialog.set_body (_("If you delete %s, its information will be deleted permanently.").printf( n));
message_dialog.add_response ("0", _("Cancel"));
message_dialog.add_response ("1", _("Delete"));
message_dialog.set_response_appearance ("1", DESTRUCTIVE);
message_dialog.present();
message_dialog.present ();
message_dialog.response.connect ((id) => {
switch (id) {
case "0":
Expand Down Expand Up @@ -118,7 +118,7 @@ public Subject subject;

public void add_cat (string n, double p) {
for (int i = 0; i < categories.length; i++) {
if(categories[i] == null) {
if (categories[i] == null) {
categories[i] = new Category (n, p);
i = categories.length;
load_list ();
Expand Down Expand Up @@ -149,7 +149,7 @@ public Subject subject;

dialog.response.connect ((response_id) => {
if (response_id == "add") {
add_cat(dialog.name_entry.get_text(), dialog.percentage.get_value());
add_cat (dialog.name_entry.get_text (), dialog.percentage.get_value ());
}
dialog.destroy ();
});
Expand All @@ -159,8 +159,8 @@ public Subject subject;

cat_list_box.set_header_suffix (new_cat_button);

main_box.append(cat_list_box);
main_box.append(subject_delete_button);
main_box.append (cat_list_box);
main_box.append (subject_delete_button);

for (int i = 0; i < subject.categories.length && subject.categories[i] != null; i++) {
var cat_row = new Adw.ActionRow () {
Expand Down
2 changes: 1 addition & 1 deletion src/grade.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ public class Grade : Object{
public string grade { get; set; }
public string note { get; set; }
public int cat { get; set; }

public Grade (string g, string n, int c) {
this.grade = g;
this.note = n;
Expand Down
12 changes: 6 additions & 6 deletions src/new-subject-dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class NewSubjectDialog : Adw.Window {
};

var cb = new Gtk.Button.with_label (_("Cancel"));
cb.clicked.connect(() => {
cb.clicked.connect (() => {
accept = false;
this.close ();
});

var ab = new Gtk.Button.with_label (_("Save")) { css_classes = { "suggested-action" }, sensitive = false };
ab.clicked.connect(() => {
ab.clicked.connect (() => {
accept = true;
this.close ();
});
Expand Down Expand Up @@ -102,7 +102,7 @@ public class NewSubjectDialog : Adw.Window {

public void add_cat (string n, double p) {
for (int i = 0; i < categories.length; i++) {
if(categories[i] == null) {
if (categories[i] == null) {
categories[i] = new Category (n, p);
i = categories.length;
categories_list_ui ();
Expand Down Expand Up @@ -135,7 +135,7 @@ public class NewSubjectDialog : Adw.Window {

dialog.response.connect ((response_id) => {
if (response_id == "add") {
add_cat(dialog.name_entry.get_text(), dialog.percentage.get_value());
add_cat (dialog.name_entry.get_text (), dialog.percentage.get_value ());
}
dialog.destroy ();
});
Expand All @@ -144,15 +144,15 @@ public class NewSubjectDialog : Adw.Window {
});

cat_list_box.set_header_suffix (new_cat_button);
main_box.insert_child_after(cat_list_box, main_box.get_first_child ());
main_box.insert_child_after (cat_list_box, main_box.get_first_child ());


for (int i = 0; i < categories.length && categories[i] != null; i++) {
var cat_row = new Adw.ActionRow () {
title = categories[i].name,
subtitle = categories[i].percentage.to_string () + "%"
};
cat_list_box.add(cat_row);
cat_list_box.add (cat_row);
}
}
}
2 changes: 1 addition & 1 deletion src/newgradebutton.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public class NewGradeButton : Gtk.Button{
public int index;

public NewGradeButton (int i) {
index = i;
}
Expand Down
Loading

0 comments on commit 2e0d2f0

Please sign in to comment.