[gnome-contacts/feature/birthday-reminder: 25/25] sheet: Add reminder if a contact's birthday is today




commit eaf5ba751392d82c0846adc3737038664be8c77f
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Jan 12 13:34:35 2022 +0100

    sheet: Add reminder if a contact's birthday is today

 data/contacts.gresource.xml     |  2 +-
 src/contacts-contact-sheet.vala | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/data/contacts.gresource.xml b/data/contacts.gresource.xml
index 8d09a5ec..246036e1 100644
--- a/data/contacts.gresource.xml
+++ b/data/contacts.gresource.xml
@@ -5,9 +5,9 @@
 
     <file preprocess="xml-stripblanks">icons/scalable/actions/birthday-symbolic.svg</file>
     <file preprocess="xml-stripblanks">icons/scalable/actions/external-link-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">icons/scalable/actions/map-symbolic.svg</file>
     <file preprocess="xml-stripblanks">icons/scalable/actions/note-symbolic.svg</file>
     <file preprocess="xml-stripblanks">icons/scalable/actions/photo-camera-symbolic.svg</file>
-    <file preprocess="xml-stripblanks">icons/scalable/actions/map-symbolic.svg</file>
 
     <file compressed="true" preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/contacts-accounts-list.ui</file>
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index 54724c23..a586dd84 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -350,7 +350,18 @@ public class Contacts.ContactSheet : Gtk.Grid {
       return;
 
     var birthday_str = birthday_details.birthday.to_local ().format ("%x");
-    var row = new ContactSheetRow (property, birthday_str);
+
+    // Compare month and date so we can put a reminder
+    string? subtitle = null;
+    int bd_m, bd_d, now_m, now_d;
+    birthday_details.birthday.to_local ().get_ymd (null, out bd_m, out bd_d);
+    new DateTime.now_local ().get_ymd (null, out now_m, out now_d);
+
+    if (bd_m == now_m && bd_d == now_d) {
+      subtitle = _("Their birthday is today! 🎉");
+    }
+
+    var row = new ContactSheetRow (property, birthday_str, subtitle);
     this.attach_row (row);
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]