[california/wip/734698-agenda] Need to back up here ... Agenda.Row isn't sophisticated enough for multiple events on the same day.



commit 3b2b4377f8e25fbc4465e91bb5de6edbfead757c
Author: Jim Nelson <jim yorba org>
Date:   Fri Nov 21 12:16:21 2014 -0800

    Need to back up here ... Agenda.Row isn't sophisticated enough for
    multiple events on the same day.

 po/POTFILES.in                     |    2 +
 po/POTFILES.skip                   |    1 +
 src/Makefile.am                    |    2 +
 src/california-resources.xml       |    3 ++
 src/component/component-event.vala |    1 -
 src/rc/agenda-row.ui               |   48 ++++++++++++++++++++++++++++++++
 src/view/agenda/agenda-row.vala    |   54 ++++++++++++++++++++++++++++++++++++
 7 files changed, 110 insertions(+), 1 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 27a9a8e..78b96b6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,9 +25,11 @@ 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/agenda/agenda-row.vala
 src/view/month/month-controller.vala
 src/view/week/week-controller.vala
 [type: gettext/glade]src/rc/activator-list.ui
+[type: gettext/glade]src/rc/agenda-row.ui
 [type: gettext/glade]src/rc/app-menu.interface
 [type: gettext/glade]src/rc/attendees-editor.ui
 [type: gettext/glade]src/rc/calendar-import.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index cc34c4e..e3bb2ca 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -22,6 +22,7 @@ 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/agenda/agenda-row.vala
 src/view/month/month-controller.c
 src/view/week/week-controller.c
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 795efe1..944a2af 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -169,6 +169,7 @@ california_VALASOURCES = \
        \
        view/agenda/agenda.vala \
        view/agenda/agenda-controller.vala \
+       view/agenda/agenda-row.vala \
        \
        view/common/common.vala \
        view/common/common-events-cell.vala \
@@ -196,6 +197,7 @@ california_SOURCES = \
 
 california_RC = \
        rc/activator-list.ui \
+       rc/agenda-row.ui \
        rc/app-menu.interface \
        rc/attendees-editor.ui \
        rc/calendar-import.ui \
diff --git a/src/california-resources.xml b/src/california-resources.xml
index dd29fad..83cbcb2 100644
--- a/src/california-resources.xml
+++ b/src/california-resources.xml
@@ -4,6 +4,9 @@
         <file compressed="true">rc/activator-list.ui</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
+        <file compressed="false">rc/agenda-row.ui</file>
+    </gresource>
+    <gresource prefix="/org/yorba/california">
         <file compressed="true">rc/app-menu.interface</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index 3f0734e..c21ee7c 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -274,7 +274,6 @@ public class Event : Instance, Gee.Comparable<Event> {
      *
      * This will return a DateSpan whether the Event is a DATE or DATE-TIME VEVENT.
      */
-    // TODO: Make date_span/exact_time_span a separate object
     public Calendar.DateSpan get_event_date_span(Calendar.Timezone? tz) {
         if (date_span != null)
             return date_span;
diff --git a/src/rc/agenda-row.ui b/src/rc/agenda-row.ui
new file mode 100644
index 0000000..67f1b4f
--- /dev/null
+++ b/src/rc/agenda-row.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <template class="CaliforniaViewAgendaRow" parent="GtkBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="spacing">4</property>
+    <child>
+      <object class="GtkLabel" id="date_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label">(date)</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="time_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label">(time)</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="summary_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="xalign">0</property>
+        <property name="label">(summary)</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+  </template>
+</interface>
diff --git a/src/view/agenda/agenda-row.vala b/src/view/agenda/agenda-row.vala
new file mode 100644
index 0000000..eb7f8fb
--- /dev/null
+++ b/src/view/agenda/agenda-row.vala
@@ -0,0 +1,54 @@
+/* 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 {
+
+[GtkTemplate (ui = "/org/yorba/california/rc/agenda-row.ui")]
+public class Row : Gtk.Box {
+    public new Component.Event event { get; private set; }
+    
+    [GtkChild]
+    private Gtk.Label date_label;
+    
+    [GtkChild]
+    private Gtk.Label time_label;
+    
+    [GtkChild]
+    private Gtk.Label summary_label;
+    
+    public Row(Component.Event event) {
+        this.event = event;
+        
+        event.notify[Component.Event.PROP_DATE_SPAN].connect(on_date_time_changed);
+        event.notify[Component.Event.PROP_EXACT_TIME_SPAN].connect(on_date_time_changed);
+        
+        event.bind_property(Component.Event.PROP_SUMMARY, summary_label, "label",
+            BindingFlags.SYNC_CREATE, transform_summary_to_label);
+    }
+    
+    private bool transform_summary_to_label(Binding binding, Value source_value,
+        ref Value target_value) {
+        target_value = event.summary ?? _("(no name)");
+        
+        return true;
+    }
+    
+    private void on_date_time_changed() {
+        date_label.label = event.get_event_date_span(Calendar.Timezone.local).to_pretty_string(
+            Calendar.Date.PrettyFlag.COMPACT | Calendar.Date.PrettyFlag.INCLUDE_YEAR);
+        
+        if (event.is_all_day) {
+            time_label.label = _("All day");
+        } else {
+            // hex value is an endash
+            time_label.label = "%s &#x2013; %s".printf(
+                event.exact_time_span.start_exact_time.to_wall_time()
+        }
+    }
+}
+
+}
+


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