[gnome-clocks/zbrown/list-alarms: 26/36] alarm: return to buttons for selecting days to repeat
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/zbrown/list-alarms: 26/36] alarm: return to buttons for selecting days to repeat
- Date: Fri, 14 Feb 2020 18:13:03 +0000 (UTC)
commit 9dd99fcb7dbe58244e841b37dad32f30fd039996
Author: Zander Brown <zbrown gnome org>
Date: Thu Jan 16 00:41:00 2020 +0000
alarm: return to buttons for selecting days to repeat
Unfortunatly this add a bunch of new strings
data/css/gnome-clocks.css | 2 +-
data/ui/alarmdaypickerrow.ui | 21 ++++++---------------
data/ui/alarmrow.ui | 2 +-
src/alarm.vala | 42 +++++++++++++-----------------------------
src/utils.vala | 25 +++++++++++++++++++++++--
5 files changed, 44 insertions(+), 48 deletions(-)
---
diff --git a/data/css/gnome-clocks.css b/data/css/gnome-clocks.css
index 7ffe6dc..f8ad06e 100644
--- a/data/css/gnome-clocks.css
+++ b/data/css/gnome-clocks.css
@@ -65,7 +65,7 @@ row.snoozing {
font-weight: bold;
}
-.alarm-row button {
+.alarm-row button, .repeats button {
min-width: 24px;
min-height: 24px;
}
diff --git a/data/ui/alarmdaypickerrow.ui b/data/ui/alarmdaypickerrow.ui
index 594684b..40cb870 100644
--- a/data/ui/alarmdaypickerrow.ui
+++ b/data/ui/alarmdaypickerrow.ui
@@ -5,24 +5,15 @@
<property name="title">_Repeat</property>
<property name="use-underline">True</property>
<child type="action">
- <object class="GtkImage" id="icon">
+ <object class="GtkFlowBox" id="flow">
<property name="visible">True</property>
<property name="valign">center</property>
- <property name="halign">center</property>
- <property name="icon-name">pan-down-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- <child type="action">
- <object class="GtkLabel" id="current">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="label" translatable="yes">No Repeat</property>
+ <property name="hexpand">True</property>
+ <property name="homogeneous">True</property>
</object>
</child>
+ <style>
+ <class name="repeats"/>
+ </style>
</template>
- <object class="GtkPopover" id="popover">
- <property name="relative-to">icon</property>
- <signal name="closed" handler="popover_done" swapped="no"/>
- </object>
</interface>
diff --git a/data/ui/alarmrow.ui b/data/ui/alarmrow.ui
index 21d4583..f4c6d46 100644
--- a/data/ui/alarmrow.ui
+++ b/data/ui/alarmrow.ui
@@ -81,7 +81,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="label">Repeats</property>
+ <property name="tooltip_text" translatable="yes">Repeats</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<style>
diff --git a/src/alarm.vala b/src/alarm.vala
index c38c686..4823290 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -446,9 +446,7 @@ public class DayPickerRow : Hdy.ActionRow {
private Utils.Weekdays days = new Utils.Weekdays();
[GtkChild]
- private Gtk.Popover popover;
- [GtkChild]
- private Gtk.Label current;
+ private Gtk.FlowBox flow;
construct {
// Create actions to control propeties from menu items
@@ -463,44 +461,35 @@ public class DayPickerRow : Hdy.ActionRow {
insert_action_group ("repeats", group);
// Create an array with the weekday items with
- // items[0] referencing the button for Monday, and so on.
- var items = new GLib.MenuItem[7];
+ // buttons[0] referencing the button for Monday, and so on.
+ var buttons = new Gtk.ToggleButton[7];
for (int i = 0; i < 7; i++) {
- items[i] = new GLib.MenuItem (((Utils.Weekdays.Day) i).name (), "repeats.day-%i".printf(i));
+ var day = (Utils.Weekdays.Day) i;
+ buttons[i] = new Gtk.ToggleButton.with_label (day.symbol ());
+ buttons[i].action_name = "repeats.day-%i".printf(i);
+ buttons[i].tooltip_text = day.name ();
+ buttons[i].get_style_context ().add_class ("circular");
+ buttons[i].show ();
}
// Add the items, starting with the first day of the week
// depending on the locale.
var first_weekday = Utils.Weekdays.Day.get_first_weekday ();
- var menu = new GLib.Menu();
for (int i = 0; i < 7; i++) {
var day_number = (first_weekday + i) % 7;
- menu.insert_item (-1, items[day_number]);
+ flow.add (buttons[day_number]);
}
- // Populate the popover with the menu
- popover.bind_model (menu, null);
-
update ();
}
- public override void activate () {
- // Open the popover
- popover.popup ();
- }
-
- [GtkCallback]
- private void popover_done () {
- days_changed ();
- }
-
public void load (Utils.Weekdays current_days) {
// Copy in the days
for (int i = 0; i < 7; i++) {
days[(Utils.Weekdays.Day) i] = current_days[(Utils.Weekdays.Day) i];
}
- // Make sure the popover updates
+ // Make sure the buttons update
notify_property ("monday");
notify_property ("tuesday");
notify_property ("wednesday");
@@ -509,7 +498,6 @@ public class DayPickerRow : Hdy.ActionRow {
notify_property ("saturday");
notify_property ("sunday");
- // Sync the label to the new state
update ();
}
@@ -524,9 +512,6 @@ public class DayPickerRow : Hdy.ActionRow {
}
private void update () {
- var repeats = days.get_label();
- current.label = repeats.length > 0 ? repeats : _("None");
-
days_changed ();
}
}
@@ -543,7 +528,6 @@ private class SetupDialog : Hdy.Dialog {
[GtkChild]
private Gtk.Entry name_entry;
private AmPmToggleButton am_pm_button;
- private Gtk.ToggleButton[] day_buttons;
[GtkChild]
private DayPickerRow repeats;
[GtkChild]
@@ -898,7 +882,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
}
dialog.destroy ();
});
- dialog.show_all ();
+ dialog.show ();
}
internal void delete (Item alarm) {
@@ -930,7 +914,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
}
dialog.destroy ();
});
- dialog.show_all ();
+ dialog.show ();
}
public void activate_select () {
diff --git a/src/utils.vala b/src/utils.vala
index 61b8bba..e194ca4 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -149,7 +149,7 @@ public class Weekdays {
private static string[] names = null;
public enum Day {
- MON,
+ MON = 0,
TUE,
WED,
THU,
@@ -157,6 +157,23 @@ public class Weekdays {
SAT,
SUN;
+ private const string[] symbols = {
+ // Translators: This is used in the repeat toggle for Monday
+ NC_("Repeat|Monday", "M"),
+ // Translators: This is used in the repeat toggle for Tuesday
+ NC_("Repeat|Tuesday", "T"),
+ // Translators: This is used in the repeat toggle for Wednesday
+ NC_("Repeat|Wednesday", "W"),
+ // Translators: This is used in the repeat toggle for Thursday
+ NC_("Repeat|Thursday", "T"),
+ // Translators: This is used in the repeat toggle for Friday
+ NC_("Repeat|Friday", "F"),
+ // Translators: This is used in the repeat toggle for Saturday
+ NC_("Repeat|Saturday", "S"),
+ // Translators: This is used in the repeat toggle for Sunday
+ NC_("Repeat|Sunday", "S")
+ };
+
private const string[] plurals = {
N_("Mondays"),
N_("Tuesdays"),
@@ -166,7 +183,11 @@ public class Weekdays {
N_("Saturdays"),
N_("Sundays")
};
-
+
+ public string symbol () {
+ return _(symbols[this]);
+ }
+
public string plural () {
return _(plurals[this]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]