[gnome-clocks/wip/exalm/libhandy-1: 6/10] alarm: Split alarm ringing panel
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/wip/exalm/libhandy-1: 6/10] alarm: Split alarm ringing panel
- Date: Mon, 8 Jun 2020 07:52:16 +0000 (UTC)
commit e0fb772569e22ed768f60e2c58332d85350e87c8
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue May 26 22:42:08 2020 +0500
alarm: Split alarm ringing panel
Add it to the window itself instead.
data/ui/alarm.ui | 7 --
data/ui/alarmringing.ui | 223 +++++++++++++++++++++++++-----------------------
data/ui/window.ui | 124 +++++++++++++++------------
src/alarm.vala | 45 +++-------
src/window.vala | 19 +++--
5 files changed, 208 insertions(+), 210 deletions(-)
---
diff --git a/data/ui/alarm.ui b/data/ui/alarm.ui
index bb13b11..41168a8 100644
--- a/data/ui/alarm.ui
+++ b/data/ui/alarm.ui
@@ -5,7 +5,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">False</property>
- <signal name="notify::visible-child" handler="visible_child_changed" swapped="no"/>
<child>
<object class="GtkBox" id="empty_view">
<property name="visible">True</property>
@@ -61,11 +60,5 @@
</child>
</object>
</child>
- <child>
- <object class="ClocksAlarmRingingPanel" id="ringing_panel">
- <property name="visible">True</property>
- <signal name="dismiss" handler="dismiss_ringing_panel" swapped="no"/>
- </object>
- </child>
</template>
</interface>
diff --git a/data/ui/alarmringing.ui b/data/ui/alarmringing.ui
index 80b009f..7697377 100644
--- a/data/ui/alarmringing.ui
+++ b/data/ui/alarmringing.ui
@@ -2,121 +2,130 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
- <template class="ClocksAlarmRingingPanel" parent="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">6</property>
- <property name="margin_right">6</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="row_spacing">48</property>
- <property name="column_spacing">24</property>
+ <template class="ClocksAlarmRingingPanel" parent="GtkBin">
<child>
- <object class="GtkGrid" id="button_grid">
+ <object class="HdyWindowHandle">
<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>
- <property name="column_spacing">24</property>
<child>
- <object class="GtkButton" id="stop_button">
- <property name="label" translatable="yes">Stop</property>
- <property name="width_request">200</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <signal name="clicked" handler="stop_clicked" swapped="no"/>
- <style>
- <class name="clocks-button"/>
- <class name="clocks-stop"/>
- <class name="destructive-action"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="snooze_button">
- <property name="label" translatable="yes">Snooze</property>
- <property name="width_request">200</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
- <signal name="clicked" handler="snooze_clicked" swapped="no"/>
- <style>
- <class name="clocks-button"/>
- <class name="clocks-snooze"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <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="orientation">vertical</property>
- <child>
- <object class="GtkLabel" id="title_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="justify">center</property>
- <property name="wrap">True</property>
- <attributes>
- <attribute name="font-features" value="tnum=1"/>
- </attributes>
- <style>
- <class name="clocks-ringing-title"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="time_label">
+ <object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="justify">center</property>
- <property name="wrap">True</property>
- <property name="xalign">0.5</property>
- <style>
- <class name="clocks-ringing-label"/>
- </style>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="row_spacing">48</property>
+ <property name="column_spacing">24</property>
+ <child>
+ <object class="GtkGrid" id="button_grid">
+ <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>
+ <property name="column_spacing">24</property>
+ <child>
+ <object class="GtkButton" id="stop_button">
+ <property name="label" translatable="yes">Stop</property>
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="stop_clicked" swapped="no"/>
+ <style>
+ <class name="clocks-button"/>
+ <class name="clocks-stop"/>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="snooze_button">
+ <property name="label" translatable="yes">Snooze</property>
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="relief">none</property>
+ <signal name="clicked" handler="snooze_clicked" swapped="no"/>
+ <style>
+ <class name="clocks-button"/>
+ <class name="clocks-snooze"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <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="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="justify">center</property>
+ <property name="wrap">True</property>
+ <attributes>
+ <attribute name="font-features" value="tnum=1"/>
+ </attributes>
+ <style>
+ <class name="clocks-ringing-title"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="time_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="justify">center</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0.5</property>
+ <style>
+ <class name="clocks-ringing-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</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">0</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="expand">False</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">0</property>
- </packing>
</child>
</template>
</interface>
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 6038e68..f8b392d 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -6,88 +6,100 @@
<template class="ClocksWindow" parent="HdyApplicationWindow">
<property name="title" bind-source="header_bar" bind-property="title" bind-flags="sync-create" />
<child>
- <object class="HdyDeck" id="world_deck">
+ <object class="HdyDeck" id="alarm_deck">
<property name="visible">True</property>
- <property name="can-swipe-back">True</property>
+ <property name="orientation">vertical</property>
+ <property name="visible-child">world_deck</property>
+ <property name="transition-type">under</property>
<child>
- <object class="GtkBox" id="main_view">
+ <object class="ClocksAlarmRingingPanel" id="alarm_ringing_panel">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="ClocksHeaderBar" id="header_bar">
- <property name="visible">True</property>
- <property name="stack">stack</property>
- <property name="switcher_bar">switcher_bar</property>
- <style>
- <class name="titlebar"/>
- </style>
- </object>
- </child>
+ <signal name="dismiss" handler="alarm_dismissed"/>
+ </object>
+ </child>
+ <child>
+ <object class="HdyDeck" id="world_deck">
+ <property name="visible">True</property>
+ <property name="can-swipe-back">True</property>
<child>
- <object class="GtkStack" id="stack">
+ <object class="GtkBox" id="main_view">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="homogeneous">True</property>
- <signal name="notify::visible-child" handler="pane_changed" swapped="no"/>
+ <property name="orientation">vertical</property>
<child>
- <object class="ClocksWorldFace" id="world">
+ <object class="ClocksHeaderBar" id="header_bar">
<property name="visible">True</property>
+ <property name="stack">stack</property>
+ <property name="switcher_bar">switcher_bar</property>
</object>
- <packing>
- <property name="name">world</property>
- <property name="title" translatable="yes">World</property>
- <property name="icon-name">globe-symbolic</property>
- </packing>
</child>
<child>
- <object class="ClocksAlarmFace" id="alarm">
+ <object class="GtkStack" id="stack">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="homogeneous">True</property>
+ <property name="transition-type">crossfade</property>
+ <signal name="notify::visible-child" handler="pane_changed" swapped="no"/>
+ <child>
+ <object class="ClocksWorldFace" id="world">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">world</property>
+ <property name="title" translatable="yes">World</property>
+ <property name="icon-name">globe-symbolic</property>
+ </packing>
+ </child>
+ <child>
+ <object class="ClocksAlarmFace" id="alarm">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">alarm</property>
+ <property name="title" translatable="yes">Alarms</property>
+ <property name="icon-name">alarm-symbolic</property>
+ </packing>
+ </child>
+ <child>
+ <object class="ClocksStopwatchFace" id="stopwatch">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">stopwatch</property>
+ <property name="title" translatable="yes">Stopwatch</property>
+ <property name="icon-name">stopwatch-symbolic</property>
+ </packing>
+ </child>
+ <child>
+ <object class="ClocksTimerFace" id="timer">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">timer</property>
+ <property name="title" translatable="yes">Timer</property>
+ <property name="icon-name">timer-symbolic</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="name">alarm</property>
- <property name="title" translatable="yes">Alarms</property>
- <property name="icon-name">alarm-symbolic</property>
- </packing>
</child>
<child>
- <object class="ClocksStopwatchFace" id="stopwatch">
+ <object class="HdyViewSwitcherBar" id="switcher_bar">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stack">stack</property>
</object>
- <packing>
- <property name="name">stopwatch</property>
- <property name="title" translatable="yes">Stopwatch</property>
- <property name="icon-name">stopwatch-symbolic</property>
- </packing>
- </child>
- <child>
- <object class="ClocksTimerFace" id="timer">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="name">timer</property>
- <property name="title" translatable="yes">Timer</property>
- <property name="icon-name">timer-symbolic</property>
- </packing>
</child>
</object>
</child>
<child>
- <object class="HdyViewSwitcherBar" id="switcher_bar">
+ <object class="ClocksWorldStandalone" id="world_standalone">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stack">stack</property>
</object>
</child>
</object>
</child>
- <child>
- <object class="ClocksWorldStandalone" id="world_standalone">
- <property name="visible">True</property>
- </object>
- </child>
</object>
</child>
</template>
diff --git a/src/alarm.vala b/src/alarm.vala
index 79a14f2..6897a50 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -717,7 +717,7 @@ private class SetupDialog : Gtk.Dialog {
[GtkTemplate (ui = "/org/gnome/clocks/ui/alarmringing.ui")]
-private class RingingPanel : Gtk.Grid {
+private class RingingPanel : Gtk.Bin {
public Item? alarm {
get {
return _alarm;
@@ -736,6 +736,8 @@ private class RingingPanel : Gtk.Grid {
}
});
}
+
+ update ();
}
}
@@ -746,6 +748,11 @@ private class RingingPanel : Gtk.Grid {
[GtkChild]
private Gtk.Label time_label;
+ construct {
+ // Start ticking...
+ Utils.WallClock.get_default ().tick.connect (update);
+ }
+
[GtkCallback]
private void stop_clicked () requires (alarm != null) {
((Item) alarm).stop ();
@@ -765,7 +772,7 @@ private class RingingPanel : Gtk.Grid {
alarm = null;
}
- public void update () {
+ private void update () {
if (alarm != null) {
title_label.label = (string) ((Item) alarm).name;
if (((Item) alarm).state == SNOOZING) {
@@ -798,8 +805,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
private Gtk.ListBox listbox;
[GtkChild]
private Gtk.ScrolledWindow list_view;
- [GtkChild]
- private RingingPanel ringing_panel;
construct {
panel_id = ALARM;
@@ -849,33 +854,14 @@ public class Face : Gtk.Stack, Clocks.Clock {
var a = (Item)i;
if (a.tick ()) {
if (a.state == Item.State.RINGING) {
- show_ringing_panel (a);
- ring ();
- } else if (ringing_panel.alarm == a) {
- ringing_panel.update ();
+ ring (a);
}
}
});
});
}
- public signal void ring ();
-
- [GtkCallback]
- private void dismiss_ringing_panel () {
- reset_view ();
- button_mode = NEW;
- title = _("Clocks");
- }
-
- [GtkCallback]
- private void visible_child_changed () {
- if (visible_child == empty_view || visible_child == list_view) {
- view_mode = NORMAL;
- } else if (visible_child == ringing_panel) {
- view_mode = STANDALONE;
- }
- }
+ internal signal void ring (Item item);
private void load () {
alarms.deserialize (settings.get_value ("alarms"), Item.deserialize);
@@ -910,15 +896,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
save ();
}
- private void show_ringing_panel (Item alarm) {
- ringing_panel.alarm = alarm;
- ringing_panel.update ();
- visible_child = ringing_panel;
- title = _("Alarm");
- view_mode = STANDALONE;
- button_mode = NONE;
- }
-
private void reset_view () {
visible_child = alarms.get_n_items () == 0 ? empty_view : list_view;
}
diff --git a/src/window.vala b/src/window.vala
index 0a36d27..4c0de84 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -32,6 +32,8 @@ public class Window : Hdy.ApplicationWindow {
[GtkChild]
private HeaderBar header_bar;
[GtkChild]
+ private Hdy.Deck alarm_deck;
+ [GtkChild]
private Hdy.Deck world_deck;
[GtkChild]
private Gtk.Box main_view;
@@ -44,6 +46,8 @@ public class Window : Hdy.ApplicationWindow {
[GtkChild]
private World.Standalone world_standalone;
[GtkChild]
+ private Alarm.RingingPanel alarm_ringing_panel;
+ [GtkChild]
private Stopwatch.Face stopwatch;
[GtkChild]
private Timer.Face timer;
@@ -96,9 +100,11 @@ public class Window : Hdy.ApplicationWindow {
world_deck.navigate (Hdy.NavigationDirection.FORWARD);
});
- alarm.ring.connect ((w) => {
+ alarm.ring.connect ((w, a) => {
close_standalone ();
stack.visible_child = w;
+ alarm_ringing_panel.alarm = a;
+ alarm_deck.visible_child = alarm_ringing_panel;
});
stopwatch.notify["state"].connect ((w) => {
@@ -192,11 +198,7 @@ public class Window : Hdy.ApplicationWindow {
}
private void on_back_activate () {
- if (world_deck.visible_child == main_view) {
- ((Clock) stack.visible_child).activate_back ();
- } else {
- world_deck.navigate (Hdy.NavigationDirection.BACK);
- }
+ world_deck.navigate (Hdy.NavigationDirection.BACK);
}
public void show_world () {
@@ -360,6 +362,11 @@ public class Window : Hdy.ApplicationWindow {
stack.visible_child.grab_focus ();
}
+ [GtkCallback]
+ private void alarm_dismissed () {
+ alarm_deck.visible_child = world_deck;
+ }
+
private void close_standalone () {
world_deck.visible_child = main_view;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]