Commit 3270d75c authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui
Browse files

Timer: re-add needs-attention

set the stack child's needs-attention prop to true
if there are any timers running
parent 8a8ddf94
......@@ -312,11 +312,7 @@ public class Row : Gtk.ListBoxRow {
[GtkCallback]
private void on_pause_button_clicked () {
if (item.state == Item.State.RUNNING) {
item.pause ();
} else {
item.start ();
}
item.pause ();
}
[GtkCallback]
......@@ -410,6 +406,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
public PanelId panel_id { get; construct set; }
public ButtonMode button_mode { get; set; default = NONE; }
public ViewMode view_mode { get; set; default = NORMAL; }
public bool is_running { get; set; default = false; }
public bool can_select { get; set; default = false; }
public bool n_selected { get; set; }
public string title { get; set; default = _("Clocks"); }
......@@ -436,7 +433,9 @@ public class Face : Gtk.Stack, Clocks.Clock {
row.deleted.connect (() => remove_timer ((Item) timer));
row.edited.connect (() => save ());
((Item)timer).ring.connect (() => ring ());
((Item)timer).notify["state"].connect (() => {
this.is_running = this.get_total_active_timers () != 0;
});
return row;
});
......@@ -472,6 +471,16 @@ public class Face : Gtk.Stack, Clocks.Clock {
load ();
}
private int get_total_active_timers () {
var total_items = 0;
this.timers.foreach ((timer) => {
if (((Item)timer).state == Item.State.RUNNING) {
total_items += 1;
}
});
return total_items;
}
private void remove_timer (Item item) {
timers.remove (item);
}
......
......@@ -106,6 +106,11 @@ public class Window : Gtk.ApplicationWindow {
stack.visible_child = w;
});
timer.notify["is-running"].connect ((w) => {
stack.child_set_property (timer, "needs-attention", timer.is_running);
});
unowned Gtk.BindingSet binding_set = Gtk.BindingSet.by_class (get_class ());
// plain ctrl+page_up/down is easten by the scrolled window...
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment