[california/wip/725767-week] Adding calendar source subscriptions
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725767-week] Adding calendar source subscriptions
- Date: Thu, 8 May 2014 23:19:45 +0000 (UTC)
commit 595c5aa090aebd7a7f611ad9cc206aa6dc27df00
Author: Jim Nelson <jim yorba org>
Date: Thu May 8 16:19:27 2014 -0700
Adding calendar source subscriptions
src/view/week/week-controller.vala | 2 +-
src/view/week/week-grid.vala | 44 +++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/src/view/week/week-controller.vala b/src/view/week/week-controller.vala
index e76f559..c1cda7d 100644
--- a/src/view/week/week-controller.vala
+++ b/src/view/week/week-controller.vala
@@ -111,7 +111,7 @@ public class Controller : BaseObject, View.Controllable {
}
private Gtk.Widget model_presentation(Calendar.Week week, out string? id) {
- Grid week_grid = new Grid(week);
+ Grid week_grid = new Grid(this, week);
id = week_grid.id;
return week_grid;
diff --git a/src/view/week/week-grid.vala b/src/view/week/week-grid.vala
index a68c24d..4bbb588 100644
--- a/src/view/week/week-grid.vala
+++ b/src/view/week/week-grid.vala
@@ -25,6 +25,8 @@ namespace California.View.Week {
internal class Grid : Gtk.Box {
public const string PROP_WEEK = "week";
+ public weak Controller owner { get; private set; }
+
/**
* The calendar { link Week} this { link Grid} displays.
*/
@@ -37,9 +39,12 @@ internal class Grid : Gtk.Box {
*/
public string id { owned get { return week.to_string(); } }
- public Grid(Calendar.Week week) {
+ private Backing.CalendarSubscriptionManager subscriptions;
+
+ public Grid(Controller owner, Calendar.Week week) {
Object(orientation: Gtk.Orientation.VERTICAL, spacing: 0);
+ this.owner = owner;
this.week = week;
// hold date labels in a horizontal box
@@ -87,6 +92,31 @@ internal class Grid : Gtk.Box {
scrolled_panes.vscrollbar_policy = Gtk.PolicyType.ALWAYS;
scrolled_panes.add(pane_grid);
pack_end(scrolled_panes, true, true, 0);
+
+ // set up calendar subscriptions for the week
+ subscriptions = new Backing.CalendarSubscriptionManager(
+ new Calendar.ExactTimeSpan.from_date_span(week, Calendar.Timezone.local));
+ subscriptions.calendar_added.connect(on_calendar_added);
+ subscriptions.calendar_removed.connect(on_calendar_removed);
+ subscriptions.instance_added.connect(on_calendar_instance_added);
+ subscriptions.instance_removed.connect(on_calendar_instance_removed);
+
+ // only start now if owner is display this week, otherwise use timeout (to prevent
+ // subscriptions all coming up at once) ... use distance from current week as a way to
+ // spread out the timings, also assume that user will go forward rather than go backward,
+ // so weeks in past get +1 dinged against them
+ int diff = owner.week.difference(week);
+ if (diff < 0)
+ diff = diff.abs() + 1;
+
+ if (diff != 0)
+ diff = 300 + (diff * 100);
+
+ Timeout.add(diff, () => {
+ subscriptions.start_async.begin();
+
+ return false;
+ });
}
private bool on_draw_bottom_line(Gtk.Widget widget, Cairo.Context ctx) {
@@ -100,6 +130,18 @@ internal class Grid : Gtk.Box {
return false;
}
+
+ private void on_calendar_added(Backing.CalendarSource calendar) {
+ }
+
+ private void on_calendar_removed(Backing.CalendarSource calendar) {
+ }
+
+ private void on_calendar_instance_added(Component.Instance instance) {
+ }
+
+ private void on_calendar_instance_removed(Component.Instance instance) {
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]