[california/wip/734698-agenda] Hook up the plumbing



commit 52ca5572cbdc428d5b2368adc5a679425d07cbbb
Author: Jim Nelson <jim yorba org>
Date:   Thu Nov 20 18:40:36 2014 -0800

    Hook up the plumbing

 po/POTFILES.in                         |    1 +
 po/POTFILES.skip                       |    1 +
 src/Makefile.am                        |    3 +
 src/host/host-main-window.vala         |    3 +
 src/view/agenda/agenda-controller.vala |  158 ++++++++++++++++++++++++++++++++
 src/view/agenda/agenda.vala            |   28 ++++++
 src/view/month/month-controller.vala   |    5 -
 src/view/view.vala                     |    2 +
 8 files changed, 196 insertions(+), 5 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d286503..27a9a8e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -24,6 +24,7 @@ src/host/host-quick-create-event.vala
 src/host/host-show-event.vala
 src/manager/manager-calendar-list-item.vala
 src/manager/manager-remove-calendar.vala
+src/view/agenda/agenda-controller.vala
 src/view/month/month-controller.vala
 src/view/week/week-controller.vala
 [type: gettext/glade]src/rc/activator-list.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 4c5659f..cc34c4e 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -21,6 +21,7 @@ src/host/host-quick-create-event.c
 src/host/host-show-event.c
 src/manager/manager-calendar-list-item.c
 src/manager/manager-remove-calendar.c
+src/view/agenda/agenda-controller.c
 src/view/month/month-controller.c
 src/view/week/week-controller.c
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 2dd4438..795efe1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -167,6 +167,9 @@ california_VALASOURCES = \
        view/view-controllable.vala \
        view/view-palette.vala \
        \
+       view/agenda/agenda.vala \
+       view/agenda/agenda-controller.vala \
+       \
        view/common/common.vala \
        view/common/common-events-cell.vala \
        view/common/common-instance-container.vala \
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 55ad35f..8b5996b 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -89,6 +89,7 @@ public class MainWindow : Gtk.ApplicationWindow {
     private View.Palette palette;
     private View.Controllable month_view;
     private View.Controllable week_view;
+    private View.Controllable agenda_view;
     private View.Controllable? current_controller = null;
     private Gee.HashSet<Binding> current_bindings = new Gee.HashSet<Binding>();
     private Gtk.Stack view_stack = new Gtk.Stack();
@@ -142,10 +143,12 @@ public class MainWindow : Gtk.ApplicationWindow {
         // ... then create the hosted views
         month_view = new View.Month.Controller(palette);
         week_view = new View.Week.Controller(palette);
+        agenda_view = new View.Agenda.Controller(palette);
         
         // add views to view stack, first added is first shown
         add_controller(month_view);
         add_controller(week_view);
+        add_controller(agenda_view);
         
         // if not on Unity, use headerbar as the titlebar (removes window chrome) and provide close
         // button for users who might have trouble finding it otherwise
diff --git a/src/view/agenda/agenda-controller.vala b/src/view/agenda/agenda-controller.vala
new file mode 100644
index 0000000..4d151ed
--- /dev/null
+++ b/src/view/agenda/agenda-controller.vala
@@ -0,0 +1,158 @@
+/* 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.Agenda {
+
+public class Controller : BaseObject, View.Controllable {
+    public const string VIEW_ID = "agenda";
+    
+    private class Container : View.Container, Gtk.ListBox {
+        /**
+         * @inheritDoc
+         */
+        private weak Controllable _owner;
+        public unowned Controllable owner { get { return _owner; } }
+        
+        public Container(Controller owner) {
+            _owner = owner;
+        }
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public string id { get { return VIEW_ID; } }
+    
+    /**
+     * @inheritDoc
+     */
+    public string title { get { return _("Agenda"); } }
+    
+    /**
+     * @inheritDoc
+     */
+    public string current_label { get; protected set; }
+    
+    /**
+     * @inheritDoc
+     */
+    public bool is_viewing_today { get; protected set; }
+    
+    /**
+     * @inheritDoc
+     */
+    public ChronologyMotion motion { get { return ChronologyMotion.VERTICAL; } }
+    
+    /**
+     * @inheritDoc
+     */
+    public bool in_transition { get; protected set; }
+    
+    /**
+     * { link View.Palette} for the entire view.
+     */
+    public View.Palette palette { get; private set; }
+    
+    private Container container;
+    private Toolkit.ListBoxModel<Component.Event> model;
+    private Calendar.DateSpan current_span;
+    private Backing.CalendarSubscriptionManager? subscriptions = null;
+    
+    public Controller(View.Palette palette) {
+        this.palette = palette;
+        container = new Container(this);
+        model = new Toolkit.ListBoxModel<Component.Event>(container, model_presentation);
+        current_span = new Calendar.DateSpan(Calendar.System.today,
+            Calendar.System.today.adjust_by(1, Calendar.DateUnit.MONTH));
+        
+        update_subscriptions();
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public View.Container get_container() {
+        return container;
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void next() {
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void previous() {
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void today() {
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void unselect_all() {
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public Gtk.Widget? get_widget_for_date(Calendar.Date date) {
+        return null;
+    }
+    
+    private Gtk.Widget model_presentation(Component.Event event) {
+        Gtk.Label label = new Gtk.Label(event.summary);
+        label.xalign = 0.0f;
+        
+        return label;
+    }
+    
+    private void update_subscriptions() {
+        subscriptions = new Backing.CalendarSubscriptionManager(
+            current_span.to_exact_time_span(Calendar.Timezone.local));
+        
+        subscriptions.instance_added.connect(on_instance_added);
+        subscriptions.instance_altered.connect(on_instance_altered);
+        subscriptions.instance_removed.connect(on_instance_removed);
+        
+        subscriptions.start_async.begin();
+    }
+    
+    private void on_instance_added(Component.Instance instance) {
+        Component.Event? event = instance as Component.Event;
+        if (event == null)
+            return;
+        
+        model.add(event);
+    }
+    
+    private void on_instance_altered(Component.Instance instance) {
+        Component.Event? event = instance as Component.Event;
+        if (event == null)
+            return;
+    }
+    
+    private void on_instance_removed(Component.Instance instance) {
+        Component.Event? event = instance as Component.Event;
+        if (event == null)
+            return;
+        
+        model.remove(event);
+    }
+    
+    public override string to_string() {
+        return classname;
+    }
+}
+
+}
+
diff --git a/src/view/agenda/agenda.vala b/src/view/agenda/agenda.vala
new file mode 100644
index 0000000..d12eb80
--- /dev/null
+++ b/src/view/agenda/agenda.vala
@@ -0,0 +1,28 @@
+/* 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.Agenda {
+
+private int init_count = 0;
+
+public void init() throws Error {
+    if (!Unit.do_init(ref init_count))
+        return;
+    
+    Toolkit.init();
+    Calendar.init();
+}
+
+public void terminate() {
+    if (!Unit.do_terminate(ref init_count))
+        return;
+    
+    Calendar.terminate();
+    Toolkit.terminate();
+}
+
+}
+
diff --git a/src/view/month/month-controller.vala b/src/view/month/month-controller.vala
index f70d30c..5a588a0 100644
--- a/src/view/month/month-controller.vala
+++ b/src/view/month/month-controller.vala
@@ -68,11 +68,6 @@ public class Controller : BaseObject, View.Controllable {
     /**
      * @inheritDoc
      */
-    public Calendar.Date default_date { get; protected set; }
-    
-    /**
-     * @inheritDoc
-     */
     public bool in_transition { get; protected set; }
     
     /**
diff --git a/src/view/view.vala b/src/view/view.vala
index 584bfaa..22ea522 100644
--- a/src/view/view.vala
+++ b/src/view/view.vala
@@ -24,12 +24,14 @@ public void init() throws Error {
     View.Common.init();
     View.Month.init();
     View.Week.init();
+    View.Agenda.init();
 }
 
 public void terminate() {
     if (!Unit.do_terminate(ref init_count))
         return;
     
+    View.Agenda.terminate();
     View.Week.terminate();
     View.Month.terminate();
     View.Common.terminate();


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