Changes
2 changed files (+26/-1)
-
-
@@ -12,6 +12,8 @@ namespace TimeTracker.Widget {private class ActiveTimersView : Gtk.Box { public Model.Model model { get; construct; } private NewTimerForm form = new NewTimerForm(); public ActiveTimersView(Model.Model model) { Object(model: model, orientation: Gtk.Orientation.VERTICAL, spacing: 4); }
-
@@ -24,11 +26,19 @@ });list.vexpand = true; this.append(list); var form = new NewTimerForm(); form.create.connect((title) => { model.update(new Event.TimerStarted(title)); }); this.append(form); model.active_timers.notify["n-items"].connect(() => { on_item_count_changed(); }); on_item_count_changed(); } private void on_item_count_changed() { form.primary = model.active_timers.n_items == 0; } } }
-
-
-
@@ -12,6 +12,8 @@ namespace TimeTracker.Widget {public class NewTimerForm : Gtk.Box { public signal void create(string title); public bool primary { get; set; } private Gtk.Text title_input = new Gtk.Text(); private Gtk.Button submit_button = new Gtk.Button();
-
@@ -30,6 +32,11 @@submit_button.clicked.connect(this.submit); submit_button.label = "Start"; this.append(submit_button); this.notify["primary"].connect(() => { on_primary_changed(); }); on_primary_changed(); } private void submit() {
-
@@ -37,6 +44,14 @@ var title = title_input.text;create(title); title_input.text = ""; } private void on_primary_changed() { if (primary) { submit_button.add_css_class("suggested-action"); } else { submit_button.remove_css_class("suggested-action"); } } } }
-