[california/wip/725767-week: 5/5] Merge branch 'master' into wip/725767-week



commit 4d51f55f09f973697a0658411e352ad3f2f24586
Merge: 595c5aa de3486b
Author: Jim Nelson <jim yorba org>
Date:   Fri May 9 15:17:13 2014 -0700

    Merge branch 'master' into wip/725767-week
    
    Conflicts:
        src/host/host-main-window.vala
        src/view/month/month-controller.vala

 po/pt_BR.po                                 |  275 +++++++++++++++++++++------
 src/Makefile.am                             |    2 +
 src/calendar/calendar-date-span.vala        |  185 +++----------------
 src/calendar/calendar-date.vala             |   74 ++++----
 src/calendar/calendar-exact-time-span.vala  |    2 +-
 src/calendar/calendar-month-of-year.vala    |   37 ++--
 src/calendar/calendar-month-span.vala       |  128 ++-----------
 src/calendar/calendar-span.vala             |  178 ++++++++++++++----
 src/calendar/calendar-unit-span.vala        |  119 ++++++++++++
 src/calendar/calendar-unit.vala             |  113 ++++++++++--
 src/calendar/calendar-week-span.vala        |  135 +++----------
 src/calendar/calendar-week.vala             |   47 ++++-
 src/calendar/calendar-year-span.vala        |   56 ++++++
 src/calendar/calendar-year.vala             |   30 +++-
 src/calendar/calendar.vala                  |   33 ++++
 src/component/component-date-time.vala      |    2 +-
 src/component/component-details-parser.vala |    4 +-
 src/component/component-instance.vala       |    2 +-
 src/component/component.vala                |   20 ++-
 src/tests/tests-calendar-date.vala          |   10 +-
 src/tests/tests-calendar-month-span.vala    |   30 ++-
 src/tests/tests-quick-add.vala              |    2 +-
 src/view/month/month-cell.vala              |    2 +-
 src/view/month/month-controller.vala        |   10 +-
 src/view/month/month-grid.vala              |    4 +-
 src/view/week/week-controller.vala          |   10 +-
 src/view/week/week-grid.vala                |    4 +-
 27 files changed, 915 insertions(+), 599 deletions(-)
---
diff --cc src/calendar/calendar-date.vala
index a2f1f6c,0644d02..a8beab0
--- a/src/calendar/calendar-date.vala
+++ b/src/calendar/calendar-date.vala
@@@ -39,13 -44,24 +44,28 @@@ public class Date : Unit<Date>, Gee.Com
           * Indicates that the localized string for "Today" should not be used if the date matches
           * { link System.today}.
           */
 -        NO_TODAY
 +        NO_TODAY,
 +        /**
 +         * Indicates the day of week should not be included.
 +         */
 +        NO_DAY_OF_WEEK
      }
      
+     
+     /**
+      * @inheritDoc
+      *
+      * Overridden to prevent a reference cycle in { link Span.start_date}.
+      */
+     public override Date start_date { get { return this; } }
+     
+     /**
+      * @inheritDoc
+      *
+      * Overridden to prevent a reference cycle in { link Span.end_date}.
+      */
+     public override Date end_date { get { return this; } }
+     
      public DayOfWeek day_of_week { get; private set; }
      public DayOfMonth day_of_month { get; private set; }
      public Month month { get; private set; }
diff --cc src/calendar/calendar-exact-time-span.vala
index a525a91,a525a91..2ed1473
--- a/src/calendar/calendar-exact-time-span.vala
+++ b/src/calendar/calendar-exact-time-span.vala
@@@ -67,7 -67,7 +67,7 @@@ public class ExactTimeSpan : BaseObject
          end_date = new Date.from_exact_time(end_exact_time);
      }
      
--    public ExactTimeSpan.from_date_span(DateSpan span, Timezone tz) {
++    public ExactTimeSpan.from_span(Span span, Timezone tz) {
          this (span.earliest_exact_time(tz), span.latest_exact_time(tz));
      }
      
diff --cc src/calendar/calendar.vala
index 4d6d705,6c4d5bc..d726823
--- a/src/calendar/calendar.vala
+++ b/src/calendar/calendar.vala
@@@ -17,31 -17,52 +17,56 @@@
  
  namespace California.Calendar {
  
+ /**
+  * An enumeration of various calendar units.
+  *
+  * @see Unit
+  */
+ 
+ public enum DateUnit {
+     DAY,
+     WEEK,
+     MONTH,
+     YEAR
+ }
+ 
+ /**
+  * An enumeration of various time units.
+  *
+  * @see WallTime
+  */
+ 
+ public enum TimeUnit {
+     SECOND,
+     MINUTE,
+     HOUR
+ }
+ 
  private int init_count = 0;
  
 -private static unowned string FMT_MONTH_YEAR_FULL;
 -private static unowned string FMT_MONTH_YEAR_ABBREV;
 -private static unowned string FMT_MONTH_FULL;
 -private static unowned string FMT_MONTH_ABBREV;
 -private static unowned string FMT_DAY_OF_WEEK_FULL;
 -private static unowned string FMT_DAY_OF_WEEK_ABBREV;
 -private static unowned string FMT_FULL_DATE;
 -private static unowned string FMT_PRETTY_DATE;
 -private static unowned string FMT_PRETTY_DATE_NO_YEAR;
 -private static unowned string FMT_PRETTY_DATE_ABBREV;
 -private static unowned string FMT_PRETTY_DATE_ABBREV_NO_YEAR;
 -private static unowned string FMT_AM;
 -private static unowned string FMT_BRIEF_AM;
 -private static unowned string FMT_PM;
 -private static unowned string FMT_BRIEF_PM;
 -private static unowned string FMT_12HOUR_MIN_MERIDIEM;
 -private static unowned string FMT_12HOUR_MIN_SEC_MERIDIEM;
 -private static unowned string FMT_24HOUR_MIN;
 -private static unowned string FMT_24HOUR_MIN_SEC;
 +private unowned string FMT_MONTH_YEAR_FULL;
 +private unowned string FMT_MONTH_YEAR_ABBREV;
 +private unowned string FMT_MONTH_FULL;
 +private unowned string FMT_MONTH_ABBREV;
 +private unowned string FMT_DAY_OF_WEEK_FULL;
 +private unowned string FMT_DAY_OF_WEEK_ABBREV;
 +private unowned string FMT_FULL_DATE;
 +private unowned string FMT_PRETTY_DATE;
 +private unowned string FMT_PRETTY_DATE_NO_YEAR;
 +private unowned string FMT_PRETTY_DATE_ABBREV;
 +private unowned string FMT_PRETTY_DATE_ABBREV_NO_YEAR;
 +private unowned string FMT_PRETTY_DATE_NO_DOW;
 +private unowned string FMT_PRETTY_DATE_ABBREV_NO_DOW;
 +private unowned string FMT_PRETTY_DATE_NO_DOW_NO_YEAR;
 +private unowned string FMT_PRETTY_DATE_ABBREV_NO_DOW_NO_YEAR;
 +private unowned string FMT_AM;
 +private unowned string FMT_BRIEF_AM;
 +private unowned string FMT_PM;
 +private unowned string FMT_BRIEF_PM;
 +private unowned string FMT_12HOUR_MIN_MERIDIEM;
 +private unowned string FMT_12HOUR_MIN_SEC_MERIDIEM;
 +private unowned string FMT_24HOUR_MIN;
 +private unowned string FMT_24HOUR_MIN_SEC;
  
  private unowned string MIDNIGHT;
  private unowned string NOON;
diff --cc src/view/month/month-controller.vala
index b40a2df,2273104..f4e9fac
--- a/src/view/month/month-controller.vala
+++ b/src/view/month/month-controller.vala
@@@ -120,30 -102,49 +120,30 @@@ public class Controller : BaseObject, V
          Calendar.System.instance.today_changed.disconnect(on_today_changed);
      }
      
 -    // Creates a new Grid for the MonthOfYear, storing locally and adding to the GtkStack.  Will
 -    // reuse existing Grids whenever possible.
 -    private void ensure_month_grid_exists(Calendar.MonthOfYear month_of_year) {
 -        if (month_grids.has_key(month_of_year))
 -            return;
 +    private Gtk.Widget model_presentation(Calendar.MonthOfYear moy, out string? id) {
 +        Grid grid = new Grid(this, moy);
 +        id = grid.id;
          
 -        Grid month_grid = new Grid(this, month_of_year);
 -        month_grid.show_all();
 +        return grid;
 +    }
 +    
 +    private bool trim_presentation_from_cache(Calendar.MonthOfYear moy, Calendar.MonthOfYear? visible_moy) {
 +        // always keep current month in cache
 +        if (moy.equal_to(Calendar.System.today.month_of_year()))
 +            return false;
          
-         return !(cache_span.has(moy));
 -        // add to local store and to the GtkStack itself
 -        month_grids.set(month_of_year, month_grid);
 -        stack.add_named(month_grid, month_grid.id);
++        return !(moy in cache_span);
      }
      
 -    // Performs Grid caching by ensuring that Grids are available for the current, next, and
 -    // previous month and that Grids outside that range are dropped.  The current chronological
 -    // month is never discarded.
 -    private void update_month_grid_cache() {
 -        Calendar.MonthSpan cache_span = new Calendar.MonthSpan(
 -            month_of_year.adjust(0 - (CACHE_NEIGHBORS_COUNT / 2)),
 -            month_of_year.adjust(CACHE_NEIGHBORS_COUNT / 2));
 +    private Gee.Collection<Calendar.MonthOfYear>? ensure_presentation_in_cache(
 +        Calendar.MonthOfYear? visible_moy) {
 +        // convert cache span into a collection on months
 +        Gee.List<Calendar.MonthOfYear> months = cache_span.as_list();
          
 -        // trim cache
 -        Gee.MapIterator<Calendar.MonthOfYear, Grid> iter = month_grids.map_iterator();
 -        while (iter.next()) {
 -            Calendar.MonthOfYear grid_moy = iter.get_key();
 -            
 -            // always keep current month
 -            if (grid_moy.equal_to(Calendar.System.today.month_of_year()))
 -                continue;
 -            
 -            // keep if grid is in cache span
 -            if (grid_moy in cache_span)
 -                continue;
 -            
 -            // drop, remove from GtkStack and local storage
 -            stack.remove(iter.get_value());
 -            iter.unset();
 -        }
 +        // add today's month
 +        months.add(Calendar.System.today.month_of_year());
          
 -        // ensure all-months in span are available
 -        foreach (Calendar.MonthOfYear moy in cache_span)
 -            ensure_month_grid_exists(moy);
 +        return months;
      }
      
      private unowned Grid? get_current_month_grid() {
@@@ -204,14 -215,49 +204,14 @@@
          current_label = month_of_year.full_name;
          update_is_viewing_today();
          
 -        // default date is first of month unless displaying current month, in which case it's
 -        // current date
 -        try {
 -            default_date = is_viewing_today ? Calendar.System.today
 -                : month_of_year.date_for(month_of_year.first_day_of_month());
 -        } catch (CalendarError calerr) {
 -            // this should always work
 -            error("Unable to set default date for %s: %s", month_of_year.to_string(), calerr.message);
 -        }
 -        
 -        // set up transition to give appearance of moving chronologically through the pages of
 -        // a calendar
 -        Grid? current_grid = get_current_month_grid();
 -        if (current_grid != null) {
 -            Calendar.MonthOfYear current_moy = current_grid.month_of_year;
 -            int compare = month_of_year.compare_to(current_moy);
 -            if (compare < 0)
 -                stack.transition_type = Gtk.StackTransitionType.SLIDE_RIGHT;
 -            else if (compare > 0)
 -                stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT;
 -            else
 -                return;
 -        }
 -        
 -        // because grid cache is populated/trimmed after sliding month into view, ensure the
 -        // desired month already exists
 -        ensure_month_grid_exists(month_of_year);
 -        
 -        // make visible using proper transition type
 -        stack.set_visible_child(month_grids.get(month_of_year));
 +        // update cache span, splitting down the middle of the current month
-         Calendar.DateSpan date_span = new Calendar.DateSpan(
-             month_of_year.adjust(0 - (CACHE_NEIGHBORS_COUNT / 2)).start_date,
-             month_of_year.adjust(CACHE_NEIGHBORS_COUNT / 2).end_date);
-         cache_span = new Calendar.MonthSpan(date_span);
++        cache_span = new Calendar.MonthSpan(
++            month_of_year.adjust(0 - (CACHE_NEIGHBORS_COUNT / 2)),
++            month_of_year.adjust(CACHE_NEIGHBORS_COUNT / 2)
++        );
          
 -        // now update the cache to store current month and neighbors ... do this after doing above
 -        // comparison because this update affects the GtkStack, which may revert to another page
 -        // when the cache is trimmed, making the notion of "current" indeterminate; the most
 -        // visible symptom of this is navigating far from today's month then clicking the Today
 -        // button and no transition occurs because, when the cache is trimmed, today's month is
 -        // the current child ... to avoid dropping the Widget before the transition completes,
 -        // wait before doing this; 3.12's "transition-running" property would be useful here
 -        Idle.add(() => {
 -            update_month_grid_cache();
 -            
 -            return false;
 -        }, Priority.LOW);
 +        // show (and add if not present) the current month
 +        stack_model.show(month_of_year);
      }
      
      public override string to_string() {
diff --cc src/view/month/month-grid.vala
index bb21d85,fd76f99..ba0bbb8
--- a/src/view/month/month-grid.vala
+++ b/src/view/month/month-grid.vala
@@@ -182,7 -182,7 +182,7 @@@ private class Grid : Gtk.Grid 
      
      private void update_subscriptions() {
          // convert DateSpan window into an ExactTimeSpan, which is what the subscription wants
--        Calendar.ExactTimeSpan time_window = new Calendar.ExactTimeSpan.from_date_span(window,
++        Calendar.ExactTimeSpan time_window = new Calendar.ExactTimeSpan.from_span(window,
              Calendar.Timezone.local);
          
          if (subscriptions != null && subscriptions.window.equal_to(time_window))
diff --cc src/view/week/week-controller.vala
index c1cda7d,0000000..f16a667
mode 100644,000000..100644
--- a/src/view/week/week-controller.vala
+++ b/src/view/week/week-controller.vala
@@@ -1,178 -1,0 +1,178 @@@
 +/* Copyright 2014 Yorba Foundation
 + *
 + * This software is licensed under the GNU Lesser General Public License
 + * (version 2.1 or later).  See the COPYING file in this distribution.
 + */
 +
 +namespace California.View.Week {
 +
 +/**
 + * The { link View.Controllable} for the week view.
 + */
 +
 +public class Controller : BaseObject, View.Controllable {
 +    public const string PROP_WEEK = "week";
 +    
 +    private const int CACHE_NEIGHBORS_COUNT = 4;
 +    
 +    private class ViewContainer : Gtk.Stack, View.Container {
 +        private Controller _owner;
 +        public unowned View.Controllable owner { get { return _owner; } }
 +        
 +        public ViewContainer(Controller owner) {
 +            _owner = owner;
 +        }
 +    }
 +    
 +    /**
 +     * The current week of the year being displayed.
 +     */
 +    public Calendar.Week week { get; private set; }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public string title { get { return _("Week"); } }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public string current_label { get; protected set; }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public bool is_viewing_today { get; protected set; }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public Calendar.FirstOfWeek first_of_week { get; set; }
 +    
 +    private ViewContainer stack;
 +    private Toolkit.StackModel<Calendar.Week> stack_model;
 +    private Calendar.WeekSpan cache_span;
 +    
 +    public Controller() {
 +        stack = new ViewContainer(this);
 +        stack.homogeneous = true;
 +        stack.transition_duration = Toolkit.SLOW_STACK_TRANSITION_DURATION_MSEC;
 +        
 +        stack_model = new Toolkit.StackModel<Calendar.Week>(stack,
 +            Toolkit.StackModel.OrderedTransitionType.SLIDE_LEFT_RIGHT, model_presentation,
 +            trim_presentation_from_cache, ensure_presentation_in_cache);
 +        
 +        // set this before signal handlers are in place (week and first_of_week are very closely
 +        // tied in this view)
 +        first_of_week = Calendar.FirstOfWeek.SUNDAY;
 +        
 +        // changing these properties drives a lot of the what the view displays
 +        notify[View.Controllable.PROP_FIRST_OF_WEEK].connect(on_first_of_week_changed);
 +        notify[PROP_WEEK].connect(on_week_changed);
 +        
 +        // set this now that signal handlers are in place
 +        week = Calendar.System.today.week_of(first_of_week);
 +    }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public View.Container get_container() {
 +        return stack;
 +    }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public void next() {
 +        week = week.adjust(1);
 +    }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public void previous() {
 +        week = week.adjust(-1);
 +    }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public void today() {
 +        Calendar.Week this_week = Calendar.System.today.week_of(first_of_week);
 +        if (!week.equal_to(this_week))
 +            week = this_week;
 +    }
 +    
 +    /**
 +     * @inheritDoc
 +     */
 +    public void unselect_all() {
 +    }
 +    
 +    private Gtk.Widget model_presentation(Calendar.Week week, out string? id) {
 +        Grid week_grid = new Grid(this, week);
 +        id = week_grid.id;
 +        
 +        return week_grid;
 +    }
 +    
 +    private bool trim_presentation_from_cache(Calendar.Week week, Calendar.Week? visible_week) {
 +        // always keep today's week in cache
 +        if (week.equal_to(Calendar.System.today.week_of(first_of_week)))
 +            return false;
 +        
 +        // otherwise only keep weeks that are in the current cache span
-         return !cache_span.has(week);
++        return !(week in cache_span);
 +    }
 +    
 +    private Gee.Collection<Calendar.Week>? ensure_presentation_in_cache(Calendar.Week? visible_week) {
 +        // return current cache span as a collection
 +        Gee.List<Calendar.Week> weeks = cache_span.as_list();
 +        
 +        // add today's week to the mix
 +        weeks.add(Calendar.System.today.week_of(first_of_week));
 +        
 +        return weeks;
 +    }
 +    
 +    private void on_first_of_week_changed() {
 +        // update week to reflect this change, but only if necessary
 +        if (first_of_week != week.first_of_week)
 +            week = week.start_date.week_of(first_of_week);
 +    }
 +    
 +    private void on_week_changed() {
 +        // current_label is Start Date - End Date, Year, unless bounding two years, in which case
 +        // Start Date, Year - End Date, Year
 +        Calendar.Date.PrettyFlag start_flags =
 +            Calendar.Date.PrettyFlag.ABBREV | Calendar.Date.PrettyFlag.NO_DAY_OF_WEEK;
 +        if (!week.start_date.year.equal_to(week.end_date.year))
 +            start_flags |= Calendar.Date.PrettyFlag.INCLUDE_YEAR;
 +        Calendar.Date.PrettyFlag end_flags =
 +            Calendar.Date.PrettyFlag.ABBREV | Calendar.Date.PrettyFlag.INCLUDE_YEAR
 +            | Calendar.Date.PrettyFlag.NO_DAY_OF_WEEK;
 +        
 +        // date formatting: "<Start Date> to <End Date>"
 +        current_label = _("%s to %s").printf(week.start_date.to_pretty_string(start_flags),
 +            week.end_date.to_pretty_string(end_flags));
 +        
 +        is_viewing_today = Calendar.System.today in week;
 +        
 +        // cache span is split between neighbors ahead and neighbors behind this week
-         Calendar.DateSpan cache_date_span = new Calendar.DateSpan(
-             week.adjust(0 - (CACHE_NEIGHBORS_COUNT / 2)).start_date,
-             week.adjust(CACHE_NEIGHBORS_COUNT / 2).end_date);
-         cache_span = new Calendar.WeekSpan(cache_date_span, week.first_of_week);
++        cache_span = new Calendar.WeekSpan(
++            week.adjust(0 - (CACHE_NEIGHBORS_COUNT / 2)),
++            week.adjust(CACHE_NEIGHBORS_COUNT / 2)
++        );
 +        
 +        // show this week via the stack model (which implies adding it to the model)
 +        stack_model.show(week);
 +    }
 +    
 +    public override string to_string() {
 +        return "Week.Controller %s".printf(week.to_string());
 +    }
 +}
 +
 +}
 +
diff --cc src/view/week/week-grid.vala
index 4bbb588,0000000..ead338a
mode 100644,000000..100644
--- a/src/view/week/week-grid.vala
+++ b/src/view/week/week-grid.vala
@@@ -1,148 -1,0 +1,148 @@@
 +/* Copyright 2014 Yorba Foundation
 + *
 + * This software is licensed under the GNU Lesser General Public License
 + * (version 2.1 or later).  See the COPYING file in this distribution.
 + */
 +
 +namespace California.View.Week {
 +
 +/**
 + * A GTK container that holds the various { link Pane}s for each day of thw week.
 + *
 + * Although this looks to be the perfect use of Gtk.Grid, some serious limitations with that widget
 + * forced this implementation to fall back on the old "boxes within boxes" of GTK 2.0.
 + * Specifically, the top-left cell in this widget must be a fixed width (the same as
 + * { link HourRunner}'s) and Gtk.Grid wouldn't let that occur, always giving it more space than it
 + * needed (although, strangely, always honoring the requested width for HourRunner).  This ruined
 + * the effect of an "empty" box in the top left corner where the date labels met the hour runner.
 + *
 + * The basic layout is a top row of date labels (with a spacer at the beginning, as mentioned)
 + * with a scrollable box of { link DayPane}s with an HourRunner on the left side which scrolls
 + * as well.  This layout ensures the date labels are always visible as the user scrolls down the
 + * time of day for all the panes.
 + */
 +
 +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.
 +     */
 +    public Calendar.Week week { get; private set; }
 +    
 +    /**
 +     * Name (id) of { link Grid}.
 +     *
 +     * This is for use in a Gtk.Stack.
 +     */
-     public string id { owned get { return week.to_string(); } }
++    public string id { owned get { return "%d:%s".printf(week.week_of_month, 
week.month_of_year.abbrev_name); } }
 +    
 +    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
 +        Gtk.Box label_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
 +        pack_start(label_box, false, true, 0);
 +        
 +        // fixed size space in top left corner of "grid"
 +        Gtk.DrawingArea spacer = new Gtk.DrawingArea();
 +        spacer.set_size_request(HourRunner.REQUESTED_WIDTH, -1);
 +        spacer.draw.connect(on_draw_bottom_line);
 +        label_box.pack_start(spacer, false, false, 0);
 +        
 +        // hold Panes (DayPanes and HourRunner) in a scrolling Gtk.Grid
 +        Gtk.Grid pane_grid = new Gtk.Grid();
 +        pane_grid.column_homogeneous = false;
 +        pane_grid.column_spacing = 0;
 +        pane_grid.row_homogeneous = false;
 +        pane_grid.row_spacing = 0;
 +        
 +        // attach an HourRunner to the left side of the Panes grid
 +        pane_grid.attach(new HourRunner(this), 0, 0, 1, 1);
 +        
 +        // date labels across the top, week panes extending across the bottom ... start col at one
 +        // to account for spacer/HourRunner
 +        int col = 1;
 +        foreach (Calendar.Date date in week) {
 +            Gtk.Label date_label = new Gtk.Label("%s %d/%d".printf(date.day_of_week.abbrev_name,
 +                date.month_of_year().month.value, date.day_of_month.value));
 +            
 +            // draw a line along the bottom of the label
 +            date_label.draw.connect(on_draw_bottom_line);
 +            
 +            label_box.pack_start(date_label, true, true, 0);
 +            
 +            DayPane pane = new DayPane(this, date);
 +            pane.expand = true;
 +            pane_grid.attach(pane, col, 0, 1, 1);
 +            
 +            col++;
 +        }
 +        
 +        // place Panes grid into a GtkScrolledWindow
 +        Gtk.ScrolledWindow scrolled_panes = new Gtk.ScrolledWindow(null, null);
 +        scrolled_panes.hscrollbar_policy = Gtk.PolicyType.NEVER;
 +        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));
++            new Calendar.ExactTimeSpan.from_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) {
 +        int width = widget.get_allocated_width();
 +        int height = widget.get_allocated_height();
 +        
 +        Palette.prepare_hairline_border(ctx);
 +        ctx.move_to(0, height);
 +        ctx.line_to(width, height);
 +        ctx.stroke();
 +        
 +        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]