Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Sep 20, 2023
1 parent 9ed84bd commit 3cbb1af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
7 changes: 6 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ namespace Khronos {
var log = new Log ();
log.name = column_entry.text;
log.timedate = "%s\n%s%s".printf(column_time_label.label,
("%s").printf (dt_start.format ("%d/%m/%Y %H%M%S")),
("%s").printf (dt_start.format ("%a, %d/%m %H%M%S")),
("%s").printf (dt_stop.format ("%H%M%S")));
log.tags = column_tag_entry.text;
reset_timer ();
Expand Down Expand Up @@ -299,6 +299,11 @@ namespace Khronos {

uint num = view_model.logs.get_n_items ();
event_searchbar.placeholder_text = num.to_string() + " " + (_("events"));

if (num == 0) {
view_model.delete_trash.begin (this);
trash_button.sensitive = false;
}
}

[GtkCallback]
Expand Down
32 changes: 16 additions & 16 deletions src/Services/FileManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace Khronos.FileManager {
tasks += "task,timedate,tags\n";
for (i = 0; i < n; i++) {
var item = view_model.logs.get_item (i);
tasks += "\"" + ((Log)item).name.replace("\"", "") +
"\",\"" + ((Log)item).timedate.replace("\"", "").replace("\n", "") +
tasks += "\"" + ((Log)item).name.replace ("\"", "") +
"\",\"" + ((Log)item).timedate.replace ("\"", "").replace ("\n", "") +
"\",\"" + ((Log)item).tags + "\"\n";
}

GLib.FileUtils.set_contents (file.get_path(), tasks);
GLib.FileUtils.set_contents (file.get_path (), tasks);
}

public async Gee.ArrayList<Log> load_as () throws Error {
Expand All @@ -36,25 +36,25 @@ namespace Khronos.FileManager {
line = line.strip ();
if (line.has_prefix ("\"")) {
GLib.DateTime dt = new GLib.DateTime.now_local ();
string[] logged = line.replace ("\"", "").strip().split(",");
string[] logged = line.replace ("\"", "").strip ().split (",");

GLib.DateTime taskdt = new GLib.DateTime.local (dt.get_year (),
int.parse(logged[2].substring(1,2)),
int.parse(logged[2].substring(4,2)),
int.parse(logged[2].substring(7,2)),
int.parse(logged[2].substring(12,2)),
double.parse(logged[2].substring(17,2)));
int.parse (logged[2].substring (1, 2)),
int.parse (logged[2].substring (4, 2)),
int.parse (logged[2].substring (7, 2)),
int.parse (logged[2].substring (12, 2)),
double.parse (logged[2].substring (17, 2)));

current_log = new Log ();
current_log.name = logged[0];
current_log.timedate = "%s\n%s%s".printf(logged[1].substring(0,12),
("%s").printf (logged[1].substring(13,3) + ", " + logged[2].substring(0,20)),
current_log.timedate = "%s\n%s%s".printf (logged[1].substring(0, 12),
("%s").printf (logged[1].substring (13, 3) + ", " + logged[2].substring (0, 20)),
("%s").printf (taskdt.add_full (dt.get_year (),
int.parse(logged[2].substring(1,2)),
int.parse(logged[2].substring(4,2)),
int.parse(logged[1].substring(1,2)),
int.parse(logged[1].substring(5,2)),
double.parse(logged[1].substring(10,2))).format ("%H%M%S")));
int.parse (logged[2].substring (1, 2)),
int.parse (logged[2].substring (4, 2)),
int.parse (logged[1].substring (1, 2)),
int.parse (logged[1].substring (5, 2)),
double.parse (logged[1].substring (10, 2))).format ("%H%M%S")));

current_log.tags = logged[3];
logs.add (current_log);
Expand Down

0 comments on commit 3cbb1af

Please sign in to comment.