From cf1e358e04ebda06625f9efcd238e5301838cab5 Mon Sep 17 00:00:00 2001
From: Bobby Rong <rjl931189261@126.com>
Date: Thu, 13 Oct 2022 15:41:30 +0800
Subject: [PATCH 1/2] pantheon.elementary-calendar: switch to merged patch

---
 .../apps/elementary-calendar/default.nix      |  9 ++-
 .../partly-revert-pr-301.patch                | 57 -------------------
 2 files changed, 6 insertions(+), 60 deletions(-)
 delete mode 100644 pkgs/desktops/pantheon/apps/elementary-calendar/partly-revert-pr-301.patch

diff --git a/pkgs/desktops/pantheon/apps/elementary-calendar/default.nix b/pkgs/desktops/pantheon/apps/elementary-calendar/default.nix
index 9f5613fcd22e..d90a56af2bb6 100644
--- a/pkgs/desktops/pantheon/apps/elementary-calendar/default.nix
+++ b/pkgs/desktops/pantheon/apps/elementary-calendar/default.nix
@@ -41,9 +41,12 @@ stdenv.mkDerivation rec {
       sha256 = "sha256-xatxoSwAIHiUA03vvBdM8HSW27vhPLvAxEuGK0gLiio=";
     })
 
-    # Workaround for showing date numbers (TODO: should try to fix upstream)
-    # https://github.com/elementary/calendar/issues/756#issuecomment-1252400047
-    ./partly-revert-pr-301.patch
+    # GridDay: Fix day in month in grid with GLib 2.73.1+
+    # https://github.com/elementary/calendar/pull/763
+    (fetchpatch {
+      url = "https://github.com/elementary/calendar/commit/20b0983c85935bedef065b786ec8bbca55ba7d9e.patch";
+      sha256 = "sha256-Tw9uNqqRAC+vOp7EWzZVeDmZxt3hTGl9UIP21FcunqA=";
+    })
   ];
 
   nativeBuildInputs = [
diff --git a/pkgs/desktops/pantheon/apps/elementary-calendar/partly-revert-pr-301.patch b/pkgs/desktops/pantheon/apps/elementary-calendar/partly-revert-pr-301.patch
deleted file mode 100644
index 0de31ee6365d..000000000000
--- a/pkgs/desktops/pantheon/apps/elementary-calendar/partly-revert-pr-301.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-diff --git a/src/Grid/Grid.vala b/src/Grid/Grid.vala
-index 61706fc8..9b69fc14 100644
---- a/src/Grid/Grid.vala
-+++ b/src/Grid/Grid.vala
-@@ -215,7 +215,7 @@ public class Grid : Gtk.Grid {
-
-         day.in_current_month = new_date.get_month () == month_start.get_month ();
-
--        day.date = new_date;
-+        day.update_date (new_date);
-         return day;
-     }
-
-diff --git a/src/Grid/GridDay.vala b/src/Grid/GridDay.vala
-index 3e59cb7b..df04fe6f 100644
---- a/src/Grid/GridDay.vala
-+++ b/src/Grid/GridDay.vala
-@@ -35,6 +35,7 @@ public class Maya.View.GridDay : Gtk.EventBox {
-     public bool draw_left_border = true;
-     private VAutoHider event_box;
-     private GLib.HashTable<string, EventButton> event_buttons;
-+    Gtk.Label label;
-
-     public bool in_current_month {
-         set {
-@@ -79,7 +80,7 @@ public class Maya.View.GridDay : Gtk.EventBox {
-         style_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-         style_context.add_class ("cell");
-
--        var label = new Gtk.Label ("");
-+        label = new Gtk.Label ("");
-         label.halign = Gtk.Align.END;
-         label.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-         label.margin = EVENT_MARGIN;
-@@ -100,10 +101,6 @@ public class Maya.View.GridDay : Gtk.EventBox {
-
-         Gtk.TargetEntry dnd = {"binary/calendar", 0, 0};
-         Gtk.drag_dest_set (this, Gtk.DestDefaults.MOTION, {dnd}, Gdk.DragAction.MOVE);
--
--        this.notify["date"].connect (() => {
--            label.label = date.get_day_of_month ().to_string ();
--        });
-     }
-
-     public override bool drag_drop (Gdk.DragContext context, int x, int y, uint time_) {
-@@ -174,6 +171,11 @@ public class Maya.View.GridDay : Gtk.EventBox {
-         event_buttons.remove_all ();
-     }
-
-+    public void update_date (DateTime date) {
-+        this.date = date;
-+        label.label = date.get_day_of_month ().to_string ();
-+    }
-+
-     public void set_selected (bool selected) {
-         if (selected) {
-             set_state_flags (Gtk.StateFlags.SELECTED, true);

From 872526f999ad70a9d09206921699da5ff87eb944 Mon Sep 17 00:00:00 2001
From: Bobby Rong <rjl931189261@126.com>
Date: Thu, 13 Oct 2022 15:44:25 +0800
Subject: [PATCH 2/2] pantheon.wingpanel-indicator-datetime: switch to merged
 patch

---
 .../wingpanel-indicators/datetime/default.nix | 10 +++--
 .../datetime/partly-revert-pr-150.patch       | 40 -------------------
 2 files changed, 7 insertions(+), 43 deletions(-)
 delete mode 100644 pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/partly-revert-pr-150.patch

diff --git a/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/default.nix b/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/default.nix
index c884dd2d247d..b00fdb95d3e0 100644
--- a/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/default.nix
+++ b/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/default.nix
@@ -1,6 +1,7 @@
 { lib
 , stdenv
 , fetchFromGitHub
+, fetchpatch
 , nix-update-script
 , substituteAll
 , pkg-config
@@ -38,9 +39,12 @@ stdenv.mkDerivation rec {
       elementary_calendar = elementary-calendar;
     })
 
-    # Workaround for showing date numbers (TODO: should try to fix upstream)
-    # https://github.com/elementary/calendar/issues/756#issuecomment-1252400047
-    ./partly-revert-pr-150.patch
+    # GridDay: Do not connect to the notify signal for the property
+    # https://github.com/elementary/wingpanel-indicator-datetime/pull/305
+    (fetchpatch {
+      url = "https://github.com/elementary/wingpanel-indicator-datetime/commit/845ac1345124571fe995ab7138d5dfe4d29847e9.patch";
+      sha256 = "sha256-/wd/FnhjC0c0Y8mCZg8XNoPOYAAmfK+g1F6L6TMEkdM=";
+    })
   ];
 
   nativeBuildInputs = [
diff --git a/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/partly-revert-pr-150.patch b/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/partly-revert-pr-150.patch
deleted file mode 100644
index 766c1dda29f7..000000000000
--- a/pkgs/desktops/pantheon/desktop/wingpanel-indicators/datetime/partly-revert-pr-150.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff --git a/src/Widgets/calendar/Grid.vala b/src/Widgets/calendar/Grid.vala
-index e440306..21a631a 100644
---- a/src/Widgets/calendar/Grid.vala
-+++ b/src/Widgets/calendar/Grid.vala
-@@ -229,7 +229,7 @@ namespace DateTime.Widgets {
-                 day.sensitive_container (false);
-             }
- 
--            day.date = new_date;
-+            day.update_date (new_date);
- 
-             return day;
-         }
-diff --git a/src/Widgets/calendar/GridDay.vala b/src/Widgets/calendar/GridDay.vala
-index 8602875..7bd6140 100644
---- a/src/Widgets/calendar/GridDay.vala
-+++ b/src/Widgets/calendar/GridDay.vala
-@@ -79,10 +79,6 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
-         button_press_event.connect (on_button_press);
-         key_press_event.connect (on_key_press);
- 
--        notify["date"].connect (() => {
--            label.label = date.get_day_of_month ().to_string ();
--        });
--
-         component_dots = new Gee.HashMap<string, Gtk.Widget> ();
-     }
- 
-@@ -124,6 +120,11 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
-         }
-     }
- 
-+    public void update_date (GLib.DateTime date) {
-+        this.date = date;
-+        label.label = date.get_day_of_month ().to_string ();
-+    }
-+
-     public void set_selected (bool selected) {
-         if (selected) {
-             set_state_flags (Gtk.StateFlags.SELECTED, true);