[gnome-clocks/wip/exalm/libhandy-1: 8/15] Split subscreens and use HdyDeck
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/wip/exalm/libhandy-1: 8/15] Split subscreens and use HdyDeck
- Date: Fri, 22 May 2020 23:32:08 +0000 (UTC)
commit 2e023e65f8b16adc5c97c51d52ce48dedabd2b5e
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat May 23 01:02:58 2020 +0500
Split subscreens and use HdyDeck
Yay huge commits.
Introduce World.Standalone, mvoe it to the window and put in a HdyDeck,
enable swipe to go back.
Make Alarm.RingingPanel standalone, move it to the main window, put it
into another HdyDeck that's not swipeable and uses a vertical transition.
data/gnome-clocks.gresource.xml | 1 +
data/ui/alarm.ui | 7 --
data/ui/alarmringing.ui | 223 +++++++++++++++++++++-------------------
data/ui/headerbar.ui | 97 +++--------------
data/ui/window.ui | 134 ++++++++++++++----------
data/ui/world.ui | 136 ------------------------
data/ui/worldstandalone.ui | 158 ++++++++++++++++++++++++++++
src/alarm.vala | 52 +++-------
src/clock.vala | 6 --
src/headerbar.vala | 51 +--------
src/meson.build | 3 +-
src/stopwatch.vala | 3 -
src/timer.vala | 3 -
src/window.vala | 84 +++++++++------
src/world-standalone.vala | 72 +++++++++++++
src/world.vala | 68 +-----------
16 files changed, 511 insertions(+), 587 deletions(-)
---
diff --git a/data/gnome-clocks.gresource.xml b/data/gnome-clocks.gresource.xml
index 3f03601..13b5937 100644
--- a/data/gnome-clocks.gresource.xml
+++ b/data/gnome-clocks.gresource.xml
@@ -8,6 +8,7 @@
<file preprocess="xml-stripblanks">ui/headerbar.ui</file>
<file preprocess="xml-stripblanks">ui/worldlocationdialog.ui</file>
<file preprocess="xml-stripblanks">ui/world.ui</file>
+ <file preprocess="xml-stripblanks">ui/worldstandalone.ui</file>
<file preprocess="xml-stripblanks">ui/worldtile.ui</file>
<file preprocess="xml-stripblanks">ui/alarmringing.ui</file>
<file preprocess="xml-stripblanks">ui/alarmrow.ui</file>
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/headerbar.ui b/data/ui/headerbar.ui
index d83aa1f..342f617 100644
--- a/data/ui/headerbar.ui
+++ b/data/ui/headerbar.ui
@@ -21,64 +21,18 @@
<template class="ClocksHeaderBar" parent="HdyHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="title" translatable="yes">Clocks</property>
<property name="centering_policy">strict</property>
<property name="show_close_button">True</property>
- <signal name="notify::subtitle" handler="subtitle_changed" swapped="no"/>
<child type="title">
- <object class="GtkStack" id="title_stack">
+ <object class="HdyViewSwitcherTitle" id="view_switcher_title">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="homogeneous">False</property>
- <property name="transition_type">none</property>
- <child>
- <object class="HdyViewSwitcherTitle" id="view_switcher_title">
- <property name="visible">True</property>
- <property name="stack" bind-source="ClocksHeaderBar" bind-property="stack"
bind-flags="sync-create">ignore-me</property>
- <property name="title" bind-source="ClocksHeaderBar" bind-property="title"
bind-flags="sync-create" />
- <signal name="notify::title-visible" handler="title_visible_changed"/>
- </object>
- <packing>
- <property name="name">switcher</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" bind-source="ClocksHeaderBar" bind-property="title"
bind-flags="sync-create" />
- <property name="ellipsize">end</property>
- <style>
- <class name="title"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkRevealer" id="reveal_subtitle">
- <property name="visible">True</property>
- <property name="reveal-child">False</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" bind-source="ClocksHeaderBar" bind-property="subtitle"
bind-flags="sync-create" />
- <property name="ellipsize">end</property>
- <style>
- <class name="subtitle"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">title</property>
- </packing>
- </child>
+ <property name="title" translatable="yes">Clocks</property>
+ <property name="stack" bind-source="ClocksHeaderBar" bind-property="stack"
bind-flags="sync-create">ignore-me</property>
+ <signal name="notify::title-visible" handler="title_visible_changed"/>
</object>
+ <packing>
+ <property name="name">switcher</property>
+ </packing>
</child>
<child>
<object class="GtkStack" id="start_button_stack">
@@ -136,40 +90,19 @@
</object>
</child>
<child>
- <object class="GtkStack" id="end_button_stack">
+ <object class="GtkMenuButton">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hhomogeneous">False</property>
- <property name="transition_type">crossfade</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">win.show-primary-menu</property>
+ <property name="tooltip-text" translatable="yes">Menu</property>
+ <property name="menu_model">primary-menu</property>
<child>
- <object class="GtkMenuButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">win.show-primary-menu</property>
- <property name="tooltip-text" translatable="yes">Menu</property>
- <property name="menu_model">primary-menu</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">open-menu-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">menu</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
+ <object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
+ <property name="icon_name">open-menu-symbolic</property>
</object>
- <packing>
- <property name="name">empty</property>
- </packing>
</child>
</object>
<packing>
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 09dda47..5d1d9ce 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -6,76 +6,102 @@
<template class="ClocksWindow" parent="HdyApplicationWindow">
<property name="title" bind-source="header_bar" bind-property="title" bind-flags="sync-create" />
<child>
- <object class="GtkBox">
+ <object class="HdyDeck" id="alarm_deck">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="orientation">vertical</property>
+ <property name="visible-child">world_deck</property>
+ <property name="transition-type">under</property>
+ <signal name="notify::visible-child" handler="visible_child_changed"/>
<child>
- <object class="ClocksHeaderBar" id="header_bar">
+ <object class="ClocksAlarmRingingPanel" id="alarm_ringing_panel">
<property name="visible">True</property>
- <property name="stack">stack</property>
- <property name="switcher_bar">switcher_bar</property>
- <style>
- <class name="titlebar"/>
- </style>
+ <signal name="dismiss" handler="alarm_dismissed"/>
</object>
</child>
<child>
- <object class="GtkStack" id="stack">
+ <object class="HdyDeck" id="world_deck">
<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="can-swipe-back">True</property>
+ <signal name="notify::visible-child" handler="visible_child_changed"/>
<child>
- <object class="ClocksWorldFace" id="world">
+ <object class="GtkBox" id="main_view">
<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>
+ <child>
+ <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>
+ <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>
+ </child>
+ <child>
+ <object class="HdyViewSwitcherBar" id="switcher_bar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
</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="ClocksWorldStandalone" id="world_standalone">
<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>
- </child>
- <child>
- <object class="HdyViewSwitcherBar" id="switcher_bar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stack">stack</property>
- <property name="reveal">True</property>
</object>
</child>
</object>
diff --git a/data/ui/world.ui b/data/ui/world.ui
index 9d07156..75e6ce2 100644
--- a/data/ui/world.ui
+++ b/data/ui/world.ui
@@ -67,141 +67,5 @@
</child>
</object>
</child>
- <child>
- <object class="GtkGrid" id="standalone">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkGrid" id="grid2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="margin_start">34</property>
- <property name="margin_end">34</property>
- <property name="margin_bottom">12</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <child>
- <object class="GtkLabel" id="dummy_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="standalone_time_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-standalone-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="standalone_day_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <style>
- <class name="clocks-secondary-standalone-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="grid3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="margin_bottom">24</property>
- <property name="column_spacing">12</property>
- <style>
- <class name="clocks-secondary-standalone-label"/>
- </style>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Sunrise</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Sunset</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="standalone_sunrise_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">label</property>
- <attributes>
- <attribute name="font-features" value="tnum=1"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="standalone_sunset_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <attributes>
- <attribute name="font-features" value="tnum=1"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">1</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>
- </object>
- </child>
</template>
</interface>
diff --git a/data/ui/worldstandalone.ui b/data/ui/worldstandalone.ui
new file mode 100644
index 0000000..46667d7
--- /dev/null
+++ b/data/ui/worldstandalone.ui
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.18"/>
+ <template class="ClocksWorldStandalone" parent="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <signal name="notify::location" handler="location_changed"/>
+ <child>
+ <object class="HdyHeaderBar">
+ <property name="visible">True</property>
+ <property name="show-close-button">True</property>
+ <property name="title" bind-source="ClocksWorldStandalone" bind-property="title"
bind-flags="sync-create" />
+ <property name="subtitle" bind-source="ClocksWorldStandalone" bind-property="subtitle"
bind-flags="sync-create" />
+ <style>
+ <class name="titlebar"/>
+ </style>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">win.back</property>
+ <property name="tooltip-text" translatable="yes">Back</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-previous-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin_start">34</property>
+ <property name="margin_end">34</property>
+ <property name="margin_bottom">12</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkLabel" id="dummy_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"> </property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</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>
+ <attributes>
+ <attribute name="font-features" value="tnum=1"/>
+ </attributes>
+ <style>
+ <class name="clocks-standalone-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="day_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <style>
+ <class name="clocks-secondary-standalone-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="margin_bottom">24</property>
+ <property name="column_spacing">12</property>
+ <style>
+ <class name="clocks-secondary-standalone-label"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Sunrise</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Sunset</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="sunrise_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">label</property>
+ <attributes>
+ <attribute name="font-features" value="tnum=1"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="sunset_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <attributes>
+ <attribute name="font-features" value="tnum=1"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/alarm.vala b/src/alarm.vala
index 2cf0c36..0e8b4fa 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -20,12 +20,12 @@
namespace Clocks {
namespace Alarm {
-private struct AlarmTime {
+public struct AlarmTime {
public int hour;
public int minute;
}
-private class Item : Object, ContentItem {
+public class Item : Object, ContentItem {
const int SNOOZE_MINUTES = 9;
const int RING_MINUTES = 3;
@@ -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) {
@@ -782,11 +789,8 @@ private class RingingPanel : Gtk.Grid {
[GtkTemplate (ui = "/org/gnome/clocks/ui/alarm.ui")]
public class Face : Gtk.Stack, Clocks.Clock {
- public ViewMode view_mode { get; set; default = NORMAL; }
public PanelId panel_id { get; construct set; }
public ButtonMode button_mode { get; set; default = NEW; }
- public string title { get; set; default = _("Clocks"); }
- public string subtitle { get; set; }
// Translators: Tooltip for the + button
public string? new_label { get; default = _("New Alarm"); }
@@ -798,8 +802,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;
@@ -850,33 +852,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;
- }
- }
+ public signal void ring (Item item);
private void load () {
alarms.deserialize (settings.get_value ("alarms"), Item.deserialize);
@@ -911,15 +894,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/clock.vala b/src/clock.vala
index 7449085..58f4988 100644
--- a/src/clock.vala
+++ b/src/clock.vala
@@ -27,17 +27,11 @@ public enum Clocks.PanelId {
public interface Clocks.Clock : GLib.Object {
public abstract PanelId panel_id { get; protected construct set; }
public abstract ButtonMode button_mode { get; set; }
- public abstract ViewMode view_mode { get; set; }
- public abstract string title { get; protected set; }
- public abstract string subtitle { get; protected set; }
public abstract string? new_label { get; }
public virtual void activate_new () {
}
- public virtual void activate_back () {
- }
-
public virtual bool escape_pressed () {
return false;
}
diff --git a/src/headerbar.vala b/src/headerbar.vala
index a2fc802..53f334d 100644
--- a/src/headerbar.vala
+++ b/src/headerbar.vala
@@ -21,45 +21,11 @@
public enum Clocks.ButtonMode {
NEW,
- BACK,
NONE
}
-
-public enum Clocks.ViewMode {
- NORMAL,
- STANDALONE
-}
-
-
[GtkTemplate (ui = "/org/gnome/clocks/ui/headerbar.ui")]
public class Clocks.HeaderBar : Hdy.HeaderBar {
- public ViewMode view_mode {
- get {
- return _mode;
- }
-
- set {
- _mode = value;
-
- switch (_mode) {
- case NORMAL:
- title_stack.visible_child_name = "switcher";
- start_button_stack.show ();
- end_button_stack.show ();
- end_button_stack.visible_child_name = "menu";
- break;
- case STANDALONE:
- title_stack.visible_child_name = "title";
- start_button_stack.show ();
- end_button_stack.hide ();
- break;
- }
-
- title_visible_changed ();
- }
- }
-
public ButtonMode button_mode {
get {
return _button_mode;
@@ -70,9 +36,6 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
case NEW:
start_button_stack.visible_child_name = "new";
break;
- case BACK:
- start_button_stack.visible_child_name = "back";
- break;
case NONE:
start_button_stack.visible_child_name = "empty";
break;
@@ -85,27 +48,15 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
public Hdy.ViewSwitcherBar switcher_bar { get; set; }
public string? new_label { get; set; }
- private ViewMode _mode;
private ButtonMode _button_mode;
[GtkChild]
private Gtk.Stack start_button_stack;
[GtkChild]
- private Gtk.Stack end_button_stack;
- [GtkChild]
private Hdy.ViewSwitcherTitle view_switcher_title;
- [GtkChild]
- private Gtk.Stack title_stack;
- [GtkChild]
- private Gtk.Revealer reveal_subtitle;
-
- [GtkCallback]
- private void subtitle_changed () {
- reveal_subtitle.reveal_child = ((string?) subtitle) != null && subtitle.length > 0;
- }
[GtkCallback]
private void title_visible_changed () {
- switcher_bar.reveal = view_switcher_title.title_visible && view_mode == NORMAL;
+ switcher_bar.reveal = view_switcher_title.title_visible;
}
}
diff --git a/src/meson.build b/src/meson.build
index 7e08e15..4e782a4 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -15,7 +15,8 @@ clocks_vala_sources = [
'utils.vala',
'widgets.vala',
'window.vala',
- 'world.vala'
+ 'world.vala',
+ 'world-standalone.vala'
]
clocks_c_sources = [
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index 462affc..d8196b2 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -120,9 +120,6 @@ public class Face : Gtk.Box, Clocks.Clock {
public HeaderBar header_bar { get; construct set; }
public PanelId panel_id { get; construct set; }
public ButtonMode button_mode { get; set; default = NONE; }
- public ViewMode view_mode { get; set; default = NORMAL; }
- public string title { get; set; default = _("Clocks"); }
- public string subtitle { get; set; }
public string? new_label { get; default = null; }
public State state { get; private set; default = State.RESET; }
diff --git a/src/timer.vala b/src/timer.vala
index fc18b75..ac0062f 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -383,10 +383,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 string title { get; set; default = _("Clocks"); }
- public string subtitle { get; set; }
// Translators: Tooltip for the + button
public string? new_label { get; default = _("New Timer"); }
diff --git a/src/window.vala b/src/window.vala
index 6c5c2ce..2ae812b 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -32,12 +32,22 @@ 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;
+ [GtkChild]
private Gtk.Stack stack;
[GtkChild]
private World.Face world;
[GtkChild]
private Alarm.Face alarm;
[GtkChild]
+ private World.Standalone world_standalone;
+ [GtkChild]
+ private Alarm.RingingPanel alarm_ringing_panel;
+ [GtkChild]
private Stopwatch.Face stopwatch;
[GtkChild]
private Timer.Face timer;
@@ -46,9 +56,6 @@ public class Window : Hdy.ApplicationWindow {
// DIY DzlBindingGroup
private Binding? bind_button_mode = null;
- private Binding? bind_view_mode = null;
- private Binding? bind_title = null;
- private Binding? bind_subtitle = null;
private Binding? bind_new_label = null;
private bool inited = false;
@@ -84,9 +91,17 @@ public class Window : Hdy.ApplicationWindow {
settings.get ("size", "(ii)", out width, out height);
resize (width, height);
- alarm.ring.connect ((w) => {
- world.reset_view ();
+ world.show_standalone.connect ((w, l) => {
stack.visible_child = w;
+ world_standalone.location = l;
+ world_deck.navigate (Hdy.NavigationDirection.FORWARD);
+ });
+
+ alarm.ring.connect ((w, a) => {
+ stack.visible_child = w;
+ alarm_ringing_panel.alarm = a;
+ alarm_deck.visible_child = alarm_ringing_panel;
+ deletable = false;
});
stopwatch.notify["state"].connect ((w) => {
@@ -94,7 +109,7 @@ public class Window : Hdy.ApplicationWindow {
});
timer.ring.connect ((w) => {
- world.reset_view ();
+ close_standalone ();
stack.visible_child = w;
});
@@ -182,11 +197,11 @@ public class Window : Hdy.ApplicationWindow {
}
private void on_back_activate () {
- ((Clock) stack.visible_child).activate_back ();
+ world_deck.navigate (Hdy.NavigationDirection.BACK);
}
public void show_world () {
- world.reset_view ();
+ close_standalone ();
stack.visible_child = world;
}
@@ -199,7 +214,11 @@ public class Window : Hdy.ApplicationWindow {
bool handled = false;
if (((Gdk.Event)(event)).get_keyval (out keyval) && keyval == Gdk.Key.Escape) {
- handled = ((Clock) stack.visible_child).escape_pressed ();
+ if (world_deck.visible_child == main_view) {
+ handled = ((Clock) stack.visible_child).escape_pressed ();
+ } else {
+ world_deck.navigate (Hdy.NavigationDirection.BACK);
+ }
}
if (handled) {
@@ -214,7 +233,7 @@ public class Window : Hdy.ApplicationWindow {
uint button;
if (((Gdk.Event) (event)).get_button (out button) && button == BUTTON_BACK) {
- ((Clock) stack.visible_child).activate_back ();
+ on_back_activate ();
return true;
}
@@ -307,30 +326,6 @@ public class Window : Hdy.ApplicationWindow {
"button-mode",
SYNC_CREATE);
- if (bind_view_mode != null) {
- ((Binding) bind_view_mode).unbind ();
- }
- bind_view_mode = panel.bind_property ("view-mode",
- header_bar,
- "view-mode",
- SYNC_CREATE);
-
- if (bind_title != null) {
- ((Binding) bind_title).unbind ();
- }
- bind_title = panel.bind_property ("title",
- header_bar,
- "title",
- SYNC_CREATE);
-
- if (bind_subtitle != null) {
- ((Binding) bind_subtitle).unbind ();
- }
- bind_subtitle = panel.bind_property ("subtitle",
- header_bar,
- "subtitle",
- SYNC_CREATE);
-
if (bind_new_label != null) {
((Binding) bind_new_label).unbind ();
}
@@ -341,6 +336,27 @@ public class Window : Hdy.ApplicationWindow {
stack.visible_child.grab_focus ();
}
+
+ [GtkCallback]
+ private void visible_child_changed () {
+ if (alarm_deck.visible_child == alarm_ringing_panel) {
+ title = _("Alarm");
+ } else if (world_deck.visible_child == world_standalone) {
+ title = world_standalone.title;
+ } else {
+ title = _("Clocks");
+ }
+ }
+
+ [GtkCallback]
+ private void alarm_dismissed () {
+ alarm_deck.visible_child = world_deck;
+ deletable = true;
+ }
+
+ private void close_standalone () {
+ world_deck.visible_child = main_view;
+ }
}
} // namespace Clocks
diff --git a/src/world-standalone.vala b/src/world-standalone.vala
new file mode 100644
index 0000000..5ad78ac
--- /dev/null
+++ b/src/world-standalone.vala
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 Paolo Borelli <pborelli gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+namespace Clocks {
+namespace World {
+
+[GtkTemplate (ui = "/org/gnome/clocks/ui/worldstandalone.ui")]
+public class Standalone : Gtk.Box {
+ public string title { get; set; default = _("Clocks"); }
+ public string subtitle { get; set; }
+ public Item? location { get; set; }
+
+ [GtkChild]
+ private Gtk.Label time_label;
+ [GtkChild]
+ private Gtk.Label day_label;
+ [GtkChild]
+ private Gtk.Label sunrise_label;
+ [GtkChild]
+ private Gtk.Label sunset_label;
+
+ construct {
+ // Start ticking...
+ Utils.WallClock.get_default ().tick.connect (update);
+ }
+
+ private void update () {
+ if (location != null) {
+ time_label.label = ((Item) location).time_label;
+ day_label.label = (string) ((Item) location).day_label;
+ sunrise_label.label = ((Item) location).sunrise_label;
+ sunset_label.label = ((Item) location).sunset_label;
+ }
+ }
+
+ [GtkCallback]
+ private void location_changed () {
+ if (location == null) {
+ return;
+ }
+
+ update ();
+
+ var item = (Item) location;
+
+ if (item.state_name != null) {
+ title = "%s, %s".printf (item.city_name, (string) item.state_name);
+ } else {
+ title = item.city_name;
+ }
+
+ subtitle = (string) item.country_name;
+ }
+}
+
+} // namespace World
+} // namespace Clocks
diff --git a/src/world.vala b/src/world.vala
index d6fc8a6..6a6454a 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -591,33 +591,21 @@ private class LocationDialog : Gtk.Dialog {
[GtkTemplate (ui = "/org/gnome/clocks/ui/world.ui")]
public class Face : Gtk.Stack, Clocks.Clock {
+ public signal void show_standalone (Item location);
+
public PanelId panel_id { get; construct set; }
public ButtonMode button_mode { get; set; default = NEW; }
- public ViewMode view_mode { get; set; default = NORMAL; }
- public string title { get; set; default = _("Clocks"); }
- public string subtitle { get; set; }
// Translators: Tooltip for the + button
public string? new_label { get; default = _("Add Location"); }
private ContentStore locations;
private GLib.Settings settings;
- private Item? standalone_location;
[GtkChild]
private Gtk.Widget empty_view;
[GtkChild]
private Gtk.ScrolledWindow list_view;
[GtkChild]
private Gtk.ListBox listbox;
- [GtkChild]
- private Gtk.Widget standalone;
- [GtkChild]
- private Gtk.Label standalone_time_label;
- [GtkChild]
- private Gtk.Label standalone_day_label;
- [GtkChild]
- private Gtk.Label standalone_sunrise_label;
- [GtkChild]
- private Gtk.Label standalone_sunset_label;
construct {
panel_id = WORLD;
@@ -667,7 +655,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
});
// TODO Only need to queue what changed
listbox.queue_draw ();
- update_standalone ();
});
}
@@ -676,40 +663,6 @@ public class Face : Gtk.Stack, Clocks.Clock {
show_standalone (((Tile) row).location);
}
- [GtkCallback]
- private void visible_child_changed () {
- if (visible_child == empty_view || visible_child == list_view) {
- view_mode = NORMAL;
- button_mode = NEW;
- title = _("Clocks");
- subtitle = (string) null;
- } else if (visible_child == standalone) {
- view_mode = STANDALONE;
- button_mode = BACK;
- }
- }
-
- private void update_standalone () {
- if (standalone_location != null) {
- standalone_time_label.label = ((Item) standalone_location).time_label;
- standalone_day_label.label = (string) ((Item) standalone_location).day_label;
- standalone_sunrise_label.label = ((Item) standalone_location).sunrise_label;
- standalone_sunset_label.label = ((Item) standalone_location).sunset_label;
- }
- }
-
- private void show_standalone (Item location) {
- standalone_location = location;
- update_standalone ();
- visible_child = standalone;
- if (location.state_name != null) {
- title = "%s, %s".printf (location.city_name, (string) location.state_name);
- } else {
- title = location.city_name;
- }
- subtitle = (string) location.country_name;
- }
-
private void load () {
locations.deserialize (settings.get_value ("world-clocks"), Item.deserialize);
}
@@ -776,22 +729,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
dialog.show ();
}
- public void activate_back () {
- reset_view ();
- }
-
-
- public bool escape_pressed () {
- if (visible_child == standalone) {
- reset_view ();
- return true;
- }
-
- return false;
- }
-
- public void reset_view () {
- standalone_location = null;
+ private void reset_view () {
visible_child = locations.get_n_items () == 0 ? empty_view : list_view;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]