[gnome-clocks/bilelmoussaoui/redesign: 7/10] Timers: multitimers support
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/bilelmoussaoui/redesign: 7/10] Timers: multitimers support
- Date: Fri, 20 Sep 2019 19:13:50 +0000 (UTC)
commit b690651939778ab45f7f3e8ce063f55a72d393f6
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Wed Sep 18 23:19:35 2019 +0200
Timers: multitimers support
data/gnome-clocks.gresource.xml | 1 +
data/org.gnome.clocks.gschema.xml.in | 12 +-
data/ui/timer.ui | 490 +++-----------------------------
data/ui/timerrow.ui | 522 +++++++++++++++++++++++++++++++++++
src/timer.vala | 242 ++++++++++++----
src/window.vala | 2 +-
6 files changed, 757 insertions(+), 512 deletions(-)
---
diff --git a/data/gnome-clocks.gresource.xml b/data/gnome-clocks.gresource.xml
index c4a345f..a48b522 100644
--- a/data/gnome-clocks.gresource.xml
+++ b/data/gnome-clocks.gresource.xml
@@ -18,6 +18,7 @@
<file preprocess="xml-stripblanks">ui/stopwatch.ui</file>
<file preprocess="xml-stripblanks">ui/stopwatchlapsrow.ui</file>
<file preprocess="xml-stripblanks">ui/timer.ui</file>
+ <file preprocess="xml-stripblanks">ui/timerrow.ui</file>
</gresource>
<gresource prefix="/org/gnome/clocks/icons">
<file alias="globe-symbolic.svg">gtk/icons/globe-symbolic.svg</file>
diff --git a/data/org.gnome.clocks.gschema.xml.in b/data/org.gnome.clocks.gschema.xml.in
index 01f79c5..71128ff 100644
--- a/data/org.gnome.clocks.gschema.xml.in
+++ b/data/org.gnome.clocks.gschema.xml.in
@@ -14,12 +14,12 @@
List of alarms set.
</description>
</key>
- <key name="timer" type="u">
- <default>300</default>
- <summary>Timer</summary>
- <description>
- Configured timer duration in seconds.
- </description>
+ <key name="timers" type="aa{sv}">
+ <default>[]</default>
+ <summary>Configured Timers</summary>
+ <description>
+ List of timers set.
+ </description>
</key>
<key name="geolocation" type="b">
<default>true</default>
diff --git a/data/ui/timer.ui b/data/ui/timer.ui
index 00d26e1..64afb74 100644
--- a/data/ui/timer.ui
+++ b/data/ui/timer.ui
@@ -1,472 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
<interface>
- <!-- interface-requires gtk+ 3.6 -->
- <object class="GtkAdjustment" id="adjustment_hours">
- <property name="upper">99</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkAdjustment" id="adjustment_minutes">
- <property name="upper">59</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkAdjustment" id="adjustment_seconds">
- <property name="upper">59</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
+ <requires lib="gtk+" version="3.18"/>
<template class="ClocksTimerFace" parent="GtkStack">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="notify::visible-child" handler="visible_child_changed" swapped="no"/>
<child>
- <object class="GtkBox" id="setup_frame">
+ <object class="GtkGrid" id="empty_view">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_start">48</property>
- <property name="margin_end">48</property>
- <property name="margin_top">48</property>
- <property name="margin_bottom">48</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="row_spacing">6</property>
<child>
- <object class="GtkGrid" id="setup_grid">
+ <object class="GtkImage" id="image1">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="row_spacing">24</property>
- <child>
- <object class="GtkGrid" id="grid_spinbuttons">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkLabel" id="dummy_label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="label"></property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="h_spinbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <property name="xalign">0.5</property>
- <property name="invisible_char_set">True</property>
- <property name="input_purpose">number</property>
- <property name="orientation">vertical</property>
- <property name="adjustment">adjustment_hours</property>
- <property name="numeric">True</property>
- <property name="width_chars">2</property>
- <property name="wrap">True</property>
- <signal name="output" handler="show_leading_zeros" swapped="no"/>
- <signal name="changed" handler="update_start_button" swapped="no"/>
- <style>
- <class name="clocks-spinbutton"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="colon_label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">∶</property>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="m_spinbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <property name="xalign">0.5</property>
- <property name="invisible_char_set">True</property>
- <property name="input_purpose">number</property>
- <property name="orientation">vertical</property>
- <property name="adjustment">adjustment_minutes</property>
- <property name="numeric">True</property>
- <property name="width_chars">2</property>
- <property name="wrap">True</property>
- <signal name="output" handler="show_leading_zeros" swapped="no"/>
- <signal name="changed" handler="update_start_button" swapped="no"/>
- <signal name="input" handler="input_minutes" swapped="no"/>
- <style>
- <class name="clocks-spinbutton"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">3</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="colon_label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">∶</property>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">4</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="s_spinbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <property name="xalign">0.5</property>
- <property name="invisible_char_set">True</property>
- <property name="input_purpose">number</property>
- <property name="orientation">vertical</property>
- <property name="adjustment">adjustment_seconds</property>
- <property name="numeric">True</property>
- <property name="width_chars">2</property>
- <property name="wrap">True</property>
- <signal name="output" handler="show_leading_zeros" swapped="no"/>
- <signal name="changed" handler="update_start_button" swapped="no"/>
- <signal name="input" handler="input_seconds" swapped="no"/>
- <style>
- <class name="clocks-spinbutton"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">5</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="dummy_label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="label"></property>
- </object>
- <packing>
- <property name="left_attach">6</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="start_button">
- <property name="label" translatable="yes">Start</property>
- <property name="width_request">280</property>
- <property name="height_request">40</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <signal name="clicked" handler="on_start_button_clicked" swapped="no"/>
- <style>
- <class name="clocks-button"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
+ <property name="icon_name">timer-symbolic</property>
+ <property name="icon_size">6</property>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="countdown_frame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">48</property>
- <property name="margin_end">48</property>
- <property name="margin_top">48</property>
- <property name="margin_bottom">48</property>
<child>
- <object class="GtkGrid" id="countdown_grid">
+ <object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="row_spacing">24</property>
- <child>
- <object class="GtkGrid" id="grid_labels">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkLabel" id="dummy_label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="label"></property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="h_label">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <property name="xalign">0.5</property>
- <property name="invisible_char_set">True</property>
- <property name="input_purpose">number</property>
- <property name="orientation">vertical</property>
- <property name="adjustment">adjustment_hours</property>
- <property name="numeric">True</property>
- <property name="width_chars">2</property>
- <property name="wrap">True</property>
- <signal name="output" handler="show_leading_zeros" swapped="no"/>
- <signal name="changed" handler="update_start_button" swapped="no"/>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="colon_label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">∶</property>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="m_label">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <property name="xalign">0.5</property>
- <property name="invisible_char_set">True</property>
- <property name="input_purpose">number</property>
- <property name="orientation">vertical</property>
- <property name="adjustment">adjustment_minutes</property>
- <property name="numeric">True</property>
- <property name="width_chars">2</property>
- <property name="wrap">True</property>
- <signal name="output" handler="show_leading_zeros" swapped="no"/>
- <signal name="changed" handler="update_start_button" swapped="no"/>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">3</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="colon_label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">∶</property>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">4</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="s_label">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <property name="xalign">0.5</property>
- <property name="invisible_char_set">True</property>
- <property name="input_purpose">number</property>
- <property name="orientation">vertical</property>
- <property name="adjustment">adjustment_seconds</property>
- <property name="numeric">True</property>
- <property name="width_chars">2</property>
- <property name="wrap">True</property>
- <signal name="output" handler="show_leading_zeros" swapped="no"/>
- <signal name="changed" handler="update_start_button" swapped="no"/>
- <style>
- <class name="clocks-timer-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">5</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="dummy_label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="label"></property>
- </object>
- <packing>
- <property name="left_attach">6</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="button_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="homogeneous">True</property>
- <property name="spacing">16</property>
- <child>
- <object class="GtkButton" id="left_button">
- <property name="label" translatable="yes">Pause</property>
- <property name="width_request">132</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <signal name="clicked" handler="on_left_button_clicked" swapped="no"/>
- <style>
- <class name="clocks-button"/>
- </style>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="right_button">
- <property name="label" translatable="yes">Reset</property>
- <property name="width_request">132</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <signal name="clicked" handler="on_right_button_clicked" swapped="no"/>
- <style>
- <class name="clocks-button"/>
- </style>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">Select <b>New</b> to add an
timer</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
</child>
</object>
+ <packing>
+ <property name="name">empty</property>
+ </packing>
+ </child>
+ <child>
+ <object class="ClocksContentView" id="content_view">
+ <property name="visible">True</property>
+ <signal name="item-activated" handler="item_activated" swapped="no"/>
+ </object>
+ <packing>
+ <property name="name">timers</property>
+ <property name="position">1</property>
+ </packing>
</child>
</template>
- <object class="GtkSizeGroup" id="sizegroup1">
- <widgets>
- <widget name="grid_spinbuttons"/>
- <widget name="start_button"/>
- <widget name="grid_labels"/>
- <widget name="button_box"/>
- </widgets>
- </object>
- <object class="GtkSizeGroup" id="sizegroup2">
- <property name="mode">vertical</property>
- <widgets>
- <widget name="grid_spinbuttons"/>
- <widget name="grid_labels"/>
- </widgets>
- </object>
- <object class="GtkSizeGroup" id="sizegroup3">
- <property name="mode">vertical</property>
- <widgets>
- <widget name="start_button"/>
- <widget name="button_box"/>
- </widgets>
- </object>
</interface>
diff --git a/data/ui/timerrow.ui b/data/ui/timerrow.ui
new file mode 100644
index 0000000..da719f3
--- /dev/null
+++ b/data/ui/timerrow.ui
@@ -0,0 +1,522 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkAdjustment" id="adjustment_hours">
+ <property name="upper">99</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment_minutes">
+ <property name="upper">59</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment_seconds">
+ <property name="upper">59</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <template class="ClocksTimerRow" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkStack" id="timer_stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="setup_frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">48</property>
+ <property name="margin_right">48</property>
+ <property name="margin_start">48</property>
+ <property name="margin_end">48</property>
+ <property name="margin_top">48</property>
+ <property name="margin_bottom">48</property>
+ <child>
+ <object class="GtkGrid" id="grid_spinbuttons">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkLabel" id="dummy_label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="h_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ <property name="text" translatable="yes">0</property>
+ <property name="xalign">0.5</property>
+ <property name="input_purpose">number</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_hours</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
+ <signal name="changed" handler="update_start_button" swapped="no"/>
+ <signal name="output" handler="show_leading_zeros" swapped="no"/>
+ <style>
+ <class name="clocks-spinbutton"/>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="colon_label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">∶</property>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="m_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ <property name="text" translatable="yes">0</property>
+ <property name="xalign">0.5</property>
+ <property name="input_purpose">number</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_minutes</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
+ <signal name="changed" handler="update_start_button" swapped="no"/>
+ <signal name="input" handler="input_minutes" swapped="no"/>
+ <signal name="output" handler="show_leading_zeros" swapped="no"/>
+ <style>
+ <class name="clocks-spinbutton"/>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="colon_label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">∶</property>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="s_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ <property name="text" translatable="yes">0</property>
+ <property name="xalign">0.5</property>
+ <property name="input_purpose">number</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_seconds</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
+ <signal name="changed" handler="update_start_button" swapped="no"/>
+ <signal name="input" handler="input_seconds" swapped="no"/>
+ <signal name="output" handler="show_leading_zeros" swapped="no"/>
+ <style>
+ <class name="clocks-spinbutton"/>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="dummy_label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">6</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="countdown_frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin_left">48</property>
+ <property name="margin_right">48</property>
+ <property name="margin_start">48</property>
+ <property name="margin_end">48</property>
+ <property name="margin_top">48</property>
+ <property name="margin_bottom">48</property>
+ <child>
+ <object class="GtkGrid" id="grid_labels">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkLabel" id="dummy_label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="h_label">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ <property name="text" translatable="yes">0</property>
+ <property name="xalign">0.5</property>
+ <property name="input_purpose">number</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_hours</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
+ <signal name="changed" handler="update_start_button" swapped="no"/>
+ <signal name="output" handler="show_leading_zeros" swapped="no"/>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="colon_label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">∶</property>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="m_label">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ <property name="text" translatable="yes">0</property>
+ <property name="xalign">0.5</property>
+ <property name="input_purpose">number</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_minutes</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
+ <signal name="changed" handler="update_start_button" swapped="no"/>
+ <signal name="output" handler="show_leading_zeros" swapped="no"/>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="colon_label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">∶</property>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="s_label">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ <property name="text" translatable="yes">0</property>
+ <property name="xalign">0.5</property>
+ <property name="input_purpose">number</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_seconds</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
+ <signal name="changed" handler="update_start_button" swapped="no"/>
+ <signal name="output" handler="show_leading_zeros" swapped="no"/>
+ <style>
+ <class name="clocks-timer-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="dummy_label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">6</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="placeholder_text" translatable="yes">Title...</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">24</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkStack" id="start_stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="hhomogeneous">False</property>
+ <property name="vhomogeneous">False</property>
+ <child>
+ <object class="GtkButton" id="pause_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_pause_button_clicked" swapped="no"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">media-playback-pause-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="name">pause</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="start_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_start_button_clicked" swapped="no"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">media-playback-start-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="name">start</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="reset_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_reset_button_clicked" swapped="no"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">view-refresh-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="delete_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-delete-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">18</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </template>
+ <object class="GtkSizeGroup" id="sizegroup2">
+ <property name="mode">vertical</property>
+ <widgets>
+ <widget name="grid_spinbuttons"/>
+ <widget name="grid_labels"/>
+ </widgets>
+ </object>
+ <object class="GtkSizeGroup" id="sizegroup1"/>
+ <object class="GtkSizeGroup" id="sizegroup3">
+ <property name="mode">vertical</property>
+ </object>
+</interface>
diff --git a/src/timer.vala b/src/timer.vala
index f72e88b..597fd1e 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -18,27 +18,94 @@
namespace Clocks {
namespace Timer {
-[GtkTemplate (ui = "/org/gnome/clocks/ui/timer.ui")]
-public class Face : Gtk.Stack, Clocks.Clock {
+
+
+public class Item : Object, ContentItem {
+ public bool selectable { get; set; default = false; }
+ public bool selected { get; set; default = false; }
+
+ public string name {
+ get {
+ return _name;
+ }
+ set {
+ // ignored
+ }
+ }
+
+ public int hours {
+ get {
+ return timer.hour;
+ }
+ }
+ public int minutes {
+ get {
+ return timer.minute;
+ }
+ }
+
+ public int seconds {
+ get {
+ return timer.second;
+ }
+ }
+
+ public int in_seconds() {
+ return timer.second + timer.minute * 60 + timer.hour * 3600;
+ }
+
+ private string _name;
+ public GLib.Time timer { get; set; }
+
+ public void serialize (GLib.VariantBuilder builder) {
+ builder.open (new GLib.VariantType ("a{sv}"));
+ builder.add ("{sv}", "time", new GLib.Variant.int32(in_seconds()));
+ if (name != null) {
+ builder.add ("{sv}", "name", new GLib.Variant.string(name));
+ }
+ builder.close ();
+ }
+
+ public static Item? deserialize (GLib.Variant time_variant) {
+ GLib.Time? time = null;
+ string? name = null;
+
+ foreach (var v in time_variant) {
+ var key = v.get_child_value (0).get_string ();
+ switch (key) {
+ case "time":
+ time = GLib.Time.gm(v.get_child_value (1).get_child_value (0).get_int32());
+ break;
+ case "name":
+ name = v.get_child_value (1).get_child_value (0).get_string();
+ break;
+ }
+ }
+ return time != null ? new Item (time, name) : null;
+ }
+
+ public Item (GLib.Time timer, string name) {
+ Object (name: name);
+ timer = timer;
+ }
+}
+
+
+
+[GtkTemplate (ui = "/org/gnome/clocks/ui/timerrow.ui")]
+public class Row : Gtk.Box {
public enum State {
STOPPED,
RUNNING,
PAUSED
}
- public string label { get; construct set; }
- public string icon_name { get; construct set; }
- public HeaderBar header_bar { get; construct set; }
- public PanelId panel_id { get; construct set; }
-
public State state { get; private set; default = State.STOPPED; }
+ public Item item { get; construct set; }
- private GLib.Settings settings;
private double span;
private GLib.Timer timer;
private uint timeout_id;
- private Utils.Bell bell;
- private GLib.Notification notification;
[GtkChild]
private Gtk.Box setup_frame;
[GtkChild]
@@ -54,8 +121,14 @@ public class Face : Gtk.Stack, Clocks.Clock {
[GtkChild]
private Gtk.Button start_button;
[GtkChild]
+ private Gtk.Button pause_button;
+ [GtkChild]
private Gtk.Box countdown_frame;
[GtkChild]
+ private Gtk.Stack timer_stack;
+ [GtkChild]
+ private Gtk.Stack start_stack;
+ [GtkChild]
// We cheat and use spibuttons also when displaying the time
// making them insensitive and hiding the +/- via css
// this is needed to ensure the text does not move in the transition
@@ -64,18 +137,9 @@ public class Face : Gtk.Stack, Clocks.Clock {
private Gtk.SpinButton m_label;
[GtkChild]
private Gtk.SpinButton s_label;
- [GtkChild]
- private Gtk.Button left_button;
-
- public Face (HeaderBar header_bar) {
- Object (label: _("Timer"),
- icon_name: "timer-symbolic",
- header_bar: header_bar,
- panel_id: PanelId.TIMER,
- transition_type: Gtk.StackTransitionType.CROSSFADE);
-
- settings = new GLib.Settings ("org.gnome.clocks");
+ public Row (Item item) {
+ Object(item: item);
span = 0;
timer = new GLib.Timer ();
@@ -87,10 +151,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
}
});
- bell = new Utils.Bell ("complete");
- notification = new GLib.Notification (_("Time is up!"));
- notification.set_body (_("Timer countdown finished"));
-
// Force LTR since we do not want to reverse [hh] : [mm] : [ss]
grid_spinbuttons.set_direction (Gtk.TextDirection.LTR);
grid_labels.set_direction (Gtk.TextDirection.LTR);
@@ -98,11 +158,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
reset ();
}
- public virtual signal void ring () {
- var app = GLib.Application.get_default () as Clocks.Application;
- app.send_notification ("timer-is-up", notification);
- bell.ring_once ();
- }
[GtkCallback]
private bool show_leading_zeros (Gtk.SpinButton spin_button) {
@@ -152,30 +207,28 @@ public class Face : Gtk.Stack, Clocks.Clock {
if (h != 0 || m != 0 || s != 0) {
start_button.set_sensitive (true);
- start_button.get_style_context ().add_class ("suggested-action");
} else {
start_button.set_sensitive (false);
- start_button.get_style_context ().remove_class ("suggested-action");
}
}
[GtkCallback]
private void on_start_button_clicked () {
- start ();
+ switch (state) {
+ case State.PAUSED:
+ case State.STOPPED:
+ start ();
+ break;
+ default:
+ assert_not_reached ();
+ }
}
[GtkCallback]
- private void on_left_button_clicked () {
+ private void on_pause_button_clicked () {
switch (state) {
case State.RUNNING:
pause ();
- left_button.set_label (_("Continue"));
- left_button.get_style_context ().add_class ("suggested-action");
- break;
- case State.PAUSED:
- start ();
- left_button.set_label (_("Pause"));
- left_button.get_style_context ().remove_class("suggested-action");
break;
default:
assert_not_reached ();
@@ -183,22 +236,20 @@ public class Face : Gtk.Stack, Clocks.Clock {
}
[GtkCallback]
- private void on_right_button_clicked () {
+ private void on_reset_button_clicked () {
reset ();
- left_button.set_label (_("Pause"));
}
private void reset () {
state = State.STOPPED;
timer.reset ();
- span = settings.get_uint ("timer");
- h_spinbutton.value = (int) span / 3600;
- m_spinbutton.value = (int) span % 3600 / 60;
- s_spinbutton.value = span % 60;
- left_button.get_style_context ().remove_class("clocks-go");
+ h_spinbutton.value = item.hours;
+ m_spinbutton.value = item.minutes;
+ s_spinbutton.value = item.seconds;
countdown_frame.get_style_context ().remove_class ("clocks-paused");
- start_button.set_sensitive (span > 0);
- visible_child = setup_frame;
+ start_button.set_sensitive (item.in_seconds() > 0);
+ timer_stack.visible_child = setup_frame;
+ start_stack.visible_child_name = "start";
}
private void start () {
@@ -210,12 +261,13 @@ public class Face : Gtk.Stack, Clocks.Clock {
var s = s_spinbutton.get_value_as_int ();
span = h * 3600 + m * 60 + s;
- settings.set_uint ("timer", (uint) span);
+ // settings.set_uint ("timer", (uint) span);
// countdown_frame.span = span;
- visible_child = countdown_frame;
+ timer_stack.visible_child = countdown_frame;
update_countdown_label (h, m, s);
}
+ start_stack.visible_child_name = "pause";
state = State.RUNNING;
timer.start ();
@@ -227,7 +279,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
var e = timer.elapsed ();
if (e >= span) {
reset ();
- ring ();
+ // ring ();
timeout_id = 0;
return false;
}
@@ -240,6 +292,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
state = State.PAUSED;
timer.stop ();
span -= timer.elapsed ();
+ start_stack.visible_child_name = "start";
}
private void update_countdown (double elapsed) {
@@ -264,7 +317,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
}
public override void grab_focus () {
- if (visible_child == setup_frame) {
+ if (timer_stack.visible_child == setup_frame) {
start_button.grab_focus ();
}
}
@@ -280,5 +333,86 @@ public class Face : Gtk.Stack, Clocks.Clock {
}
}
+
+[GtkTemplate (ui = "/org/gnome/clocks/ui/timer.ui")]
+public class Face : Gtk.Stack, Clocks.Clock {
+ public string label { get; construct set; }
+ public string icon_name { get; construct set; }
+
+ public HeaderBar header_bar { get; construct set; }
+ public PanelId panel_id { get; construct set; }
+
+ [GtkChild]
+ private ContentView content_view;
+
+ private Utils.Bell bell;
+ private GLib.Notification notification;
+ private ContentStore timers;
+ private GLib.Settings settings;
+
+ public Face(HeaderBar header_bar) {
+ Object (label: _("Timer"),
+ icon_name: "timer-symbolic",
+ header_bar: header_bar,
+ panel_id: PanelId.TIMER);
+
+ bell = new Utils.Bell ("complete");
+ notification = new GLib.Notification (_("Time is up!"));
+ notification.set_body (_("Timer countdown finished"));
+
+ timers = new ContentStore ();
+ settings = new GLib.Settings ("org.gnome.clocks");
+
+ timers.set_sorting ((item1, item2) => {
+ /*var offset1 = ((Item) item1).location.get_timezone ().get_offset ();
+ var offset2 = ((Item) item2).location.get_timezone ().get_offset ();
+ if (offset1 < offset2)
+ return -1;
+ if (offset1 > offset2)
+ return 1;
+ return 0;
+ */
+ return 1;
+ });
+
+ content_view.bind_model (timers, (item) => {
+ return new Row((Item)item);
+ });
+
+ content_view.set_header_bar (header_bar);
+
+ var new_button = new Gtk.Button.from_icon_name ("list-add-symbolic", Gtk.IconSize.BUTTON);
+ new_button.valign = Gtk.Align.CENTER;
+ new_button.clicked.connect(on_add_clicked);
+ header_bar.pack_start (new_button);
+ }
+
+ private void add_timer_item (Item item) {
+ timers.add (item);
+ visible_child_name = "timers";
+ save ();
+ }
+
+ private void on_add_clicked (Gtk.Button widget) {
+ var item = new Item (GLib.Time.gm(0), "");
+ add_timer_item (item);
+
+ }
+
+ private void load () {
+ timers.deserialize (settings.get_value ("timers"), Item.deserialize);
+ }
+
+ private void save () {
+ settings.set_value ("timers", timers.serialize ());
+ }
+
+ public virtual signal void ring () {
+ var app = GLib.Application.get_default () as Clocks.Application;
+ app.send_notification ("timer-is-up", notification);
+ bell.ring_once ();
+ }
+}
+
} // namespace Timer
} // namespace Clocks
diff --git a/src/window.vala b/src/window.vala
index d0791e0..2186343 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -133,7 +133,7 @@ public class Window : Gtk.ApplicationWindow {
});
timer.notify["state"].connect ((w) => {
- stack.child_set_property (timer, "needs-attention", timer.state == Timer.Face.State.RUNNING);
+ // stack.child_set_property (timer, "needs-attention", timer.state == Timer.Face.State.RUNNING);
});
unowned Gtk.BindingSet binding_set = Gtk.BindingSet.by_class (get_class ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]