Changes
2 changed files (+139/-8)
-
-
@@ -11,15 +11,28 @@ using GLib;namespace TimeTracker.Widget { private class CalendarCell : Gtk.Box { public DateTime date { get; construct; } public Array<Model.Timer> timers { get; construct; } public bool dimmed { get; set; default = false; } private Gtk.Label date_label = new Gtk.Label(""); private Gtk.Label date_label = new Gtk.Label("") { css_classes = { "caption-heading" }, margin_top = 8, }; public CalendarCell(DateTime date) { Object(date: date, orientation: Gtk.Orientation.VERTICAL, spacing: 2); private Gtk.Label count_label = new Gtk.Label(""); public CalendarCell(DateTime date, Array<Model.Timer> timers) { Object( date: date, timers: timers, orientation: Gtk.Orientation.VERTICAL, spacing: 4 ); } construct { this.add_css_class("card"); this.notify["dimmed"].connect(() => { if (this.dimmed) { date_label.add_css_class("dimmed");
-
@@ -30,6 +43,34 @@ namespace TimeTracker.Widget {date_label.label = @"$(date.get_day_of_month())"; this.append(date_label); for (uint i = 0; i < 3; i++) { var label = new Gtk.Label("") { css_classes = { "caption" }, ellipsize = END, single_line_mode = true, margin_start = 6, margin_end = 6, xalign = 0, }; if (i < timers.length && timers.data[i] != null) { label.label = timers.data[i].title; } this.append(label); } var more_label = new Gtk.Label("") { css_classes = { "caption", "dimmed" }, single_line_mode = true, margin_start = 6, margin_end = 6, margin_bottom = 8, xalign = 1, }; if (timers.length > 3) { more_label.label = @"...$(timers.length - 3) more"; } this.append(more_label); } } }
-
-
-
@@ -13,10 +13,27 @@ namespace TimeTracker.Widget {public Model.Model model { get; construct; } public DateTime month { get; set construct; } private Gtk.Grid grid = new Gtk.Grid(); private Gtk.Box weekdays = new Gtk.Box(HORIZONTAL, 6) { homogeneous = true, margin_top = 4, margin_start = 8, margin_end = 8, valign = START, vexpand_set = true, }; private Gtk.Grid grid = new Gtk.Grid() { column_homogeneous = true, column_spacing = 6, row_spacing = 6, margin_top = 8, margin_bottom = 8, margin_start = 8, margin_end = 8, }; private Gtk.Label title = new Gtk.Label("") { css_classes = { "numeric" }, css_classes = { "numeric", "heading" }, hexpand = true, hexpand_set = true, };
-
@@ -28,11 +45,13 @@ namespace TimeTracker.Widget {model: model, month: new DateTime.now_local(), orientation: Gtk.Orientation.VERTICAL, spacing: 16 spacing: 8 ); } construct { this.add_css_class("background"); var header = new Gtk.Box(HORIZONTAL, 4) { hexpand = true, margin_top = 4,
-
@@ -60,7 +79,62 @@ namespace TimeTracker.Widget {header.append(next); this.append(header); this.append(grid); for (int i = 0; i < 7; i++) { var cell = new Gtk.Box(VERTICAL, 0) { hexpand = true, vexpand = true, }; var label = new Gtk.Label("") { css_classes = { "caption" }, halign = CENTER, margin_top = 4, margin_bottom = 4, margin_start = 4, margin_end = 4, }; switch (i) { case 0: label.label = "Mon"; break; case 1: label.label = "Tue"; break; case 2: label.label = "Wed"; break; case 3: label.label = "Thu"; break; case 4: label.label = "Fri"; break; case 5: label.label = "Sat"; label.add_css_class("error"); break; case 6: label.label = "Sun"; label.add_css_class("error"); break; } cell.append(label); weekdays.append(cell); } this.append(weekdays); var scrollable = new Gtk.ScrolledWindow() { hscrollbar_policy = NEVER, hexpand = true, vexpand = true, }; this.append(scrollable); scrollable.child = grid; this.notify["month"].connect(() => { this.render();
-
@@ -83,7 +157,23 @@ namespace TimeTracker.Widget {var last_cell = end_of_week(end_of_month(month)); for (var d = first_cell; d.compare(last_cell) < 1; d = d.add_days(1)) { var cell = new CalendarCell(d) { var timers = new Array<Model.Timer>(); for (uint i = 0; i < model.stopped_timers.n_items; i++) { var timer = (Model.Timer) model.stopped_timers.get_item(i); if (timer == null) { continue; } var end = new DateTime.from_unix_local(timer.stopped_at); if (d.get_year() != end.get_year() || d.get_day_of_year() != end.get_day_of_year()) { continue; } timers.append_val(timer); } var cell = new CalendarCell(d, timers) { dimmed = d.get_month() != month.get_month(), hexpand = true, vexpand = true,
-