[gnome-clocks/zbrown/world-clocks] alarms: change action button based on create/edit mode
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/zbrown/world-clocks] alarms: change action button based on create/edit mode
- Date: Sun, 23 Feb 2020 17:59:38 +0000 (UTC)
commit 1aa3031ee0dd95089507984e60f0d38c9ee847e6
Author: Zander Brown <zbrown gnome org>
Date: Thu Feb 6 00:18:07 2020 +0000
alarms: change action button based on create/edit mode
data/ui/alarmdaypickerrow.ui | 1 +
data/ui/alarmsetupdialog.ui | 84 ++++----------------------------------------
src/alarm.vala | 18 +++++++---
3 files changed, 22 insertions(+), 81 deletions(-)
---
diff --git a/data/ui/alarmdaypickerrow.ui b/data/ui/alarmdaypickerrow.ui
index ffb3a79..de283ab 100644
--- a/data/ui/alarmdaypickerrow.ui
+++ b/data/ui/alarmdaypickerrow.ui
@@ -8,6 +8,7 @@
<object class="GtkFlowBox" id="flow">
<property name="visible">True</property>
<property name="valign">center</property>
+ <property name="halign">end</property>
<property name="hexpand">True</property>
<property name="homogeneous">True</property>
</object>
diff --git a/data/ui/alarmsetupdialog.ui b/data/ui/alarmsetupdialog.ui
index 4a6d308..beffec9 100644
--- a/data/ui/alarmsetupdialog.ui
+++ b/data/ui/alarmsetupdialog.ui
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="0.0"/>
@@ -18,64 +17,14 @@
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
+ <property name="default-height">350</property>
+ <property name="height-request">350</property>
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
- <child type="titlebar">
- <object class="GtkHeaderBar" id="dialog-header-bar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">Add a New World Clock</property>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="valign">center</property>
- <property name="use_underline">True</property>
- <style>
- <class name="text-button"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="button2">
- <property name="label" translatable="yes">_Done</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="valign">center</property>
- <property name="use_underline">True</property>
- <style>
- <class name="text-button"/>
- <class name="suggested-action"/>
- </style>
- </object>
- <packing>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
+ <property name="title" translatable="yes">Add a New World Clock</property>
<child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
<child>
<object class="HdyColumn">
<property name="visible">True</property>
@@ -83,20 +32,17 @@
<child>
<object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">12</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid" id="time_grid">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="halign">center</property>
<property name="margin_top">12</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="dummy_label1">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="margin_start">6</property>
<property name="margin_end">6</property>
</object>
@@ -108,7 +54,6 @@
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="label">∶</property>
</object>
<packing>
@@ -119,10 +64,8 @@
<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="activates_default">True</property>
+ <property name="activates_default">False</property>
<property name="text">0</property>
<property name="xalign">0.5</property>
<property name="input_purpose">number</property>
@@ -142,7 +85,6 @@
<child>
<object class="GtkStack" id="am_pm_stack">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="margin_start">6</property>
<property name="margin_end">6</property>
<child>
@@ -160,10 +102,8 @@
<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="activates_default">True</property>
+ <property name="activates_default">False</property>
<property name="text">0</property>
<property name="xalign">0.5</property>
<property name="input_purpose">number</property>
@@ -188,7 +128,6 @@
<child>
<object class="GtkListBox" id="listbox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="selection_mode">none</property>
<property name="margin">6</property>
<child>
@@ -200,14 +139,12 @@
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="activatable_widget">name_entry</property>
<property name="title" translatable="yes">Name</property>
<property name="subtitle" translatable="yes">Optional</property>
<child type="action">
<object class="GtkEntry" id="name_entry">
<property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
@@ -224,7 +161,6 @@
<child>
<object class="GtkButton" id="delete_button">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="label" translatable="yes">R_emove Alarm</property>
<property name="use-underline">True</property>
<property name="margin">6</property>
@@ -238,11 +174,9 @@
<child>
<object class="GtkRevealer" id="label_revealer">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="warn_label">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="label" translatable="yes">You already have an alarm for this
time.</property>
</object>
</child>
@@ -254,10 +188,6 @@
</child>
</object>
</child>
- <action-widgets>
- <action-widget response="0">button1</action-widget>
- <action-widget response="1">button2</action-widget>
- </action-widgets>
</template>
<object class="GtkSizeGroup" id="am_pm_sizegroup">
<widgets>
diff --git a/src/alarm.vala b/src/alarm.vala
index 9e49558..d2656ec 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -551,7 +551,17 @@ private class SetupDialog : Hdy.Dialog {
}
public SetupDialog (Gtk.Window parent, Item? alarm, ListModel all_alarms) {
- Object (transient_for: parent, title: alarm != null ? _("Edit Alarm") : _("New Alarm"),
use_header_bar: 1);
+ Object (transient_for: parent,
+ title: alarm != null ? _("Edit Alarm") : _("New Alarm"),
+ use_header_bar: 1);
+
+ add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
+ if (alarm != null) {
+ add_button (_("Done"), Gtk.ResponseType.OK);
+ } else {
+ add_button (_("Add"), Gtk.ResponseType.OK);
+ }
+ set_default_response (Gtk.ResponseType.OK);
delete_button.visible = alarm != null;
listbox.set_header_func((Gtk.ListBoxUpdateHeaderFunc) Hdy.list_box_separator_header);
@@ -672,7 +682,7 @@ private class SetupDialog : Hdy.Dialog {
apply_to_alarm (alarm);
var duplicate = alarm.check_duplicate_alarm (other_alarms);
- this.set_response_sensitive (1, !duplicate);
+ this.set_response_sensitive (Gtk.ResponseType.OK, !duplicate);
label_revealer.set_reveal_child (duplicate);
}
@@ -883,7 +893,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
dialog.response.connect ((dialog, response) => {
alarm.editing = false;
- if (response == 1) {
+ if (response == Gtk.ResponseType.OK) {
((SetupDialog) dialog).apply_to_alarm (alarm);
save ();
} else if (response == DELETE_ALARM) {
@@ -916,7 +926,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
public void activate_new () {
var dialog = new SetupDialog ((Gtk.Window) get_toplevel (), null, alarms);
dialog.response.connect ((dialog, response) => {
- if (response == 1) {
+ if (response == Gtk.ResponseType.OK) {
var alarm = new Item ();
((SetupDialog) dialog).apply_to_alarm (alarm);
alarms.add (alarm);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]