[california/wip/734698-agenda] Basic view-only functionality
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/734698-agenda] Basic view-only functionality
- Date: Thu, 27 Nov 2014 02:56:09 +0000 (UTC)
commit 2920bf0fa1f925de8d54a16d4d10da57c2d3a6fa
Author: Jim Nelson <jim yorba org>
Date: Wed Nov 26 18:47:23 2014 -0800
Basic view-only functionality
Gtk.ListBox will have to go -- even with selection mode set to NONE,
there's a mouse hover prelight that is unsightly. It also appears
that listbox has a border that causes the elements not to line up
correctly.
po/POTFILES.in | 4 +-
po/POTFILES.skip | 2 +-
src/Makefile.am | 6 ++-
src/california-resources.xml | 5 ++-
...{view-agenda-row.ui => view-agenda-date-row.ui} | 29 ++++-------
...view-agenda-row.ui => view-agenda-event-row.ui} | 27 +++------
src/view/agenda/agenda-controller.vala | 49 +++++++++++------
src/view/agenda/agenda-date-row.vala | 55 +++++++++++++++++++
src/view/agenda/agenda-event-row.vala | 56 ++++++++++++++++++++
src/view/agenda/agenda-row.vala | 56 --------------------
src/view/agenda/agenda.vala | 7 +++
11 files changed, 179 insertions(+), 117 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 43df6bf..72e528f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -27,7 +27,7 @@ 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/agenda/agenda-event-row.vala
src/view/month/month-controller.vala
src/view/week/week-controller.vala
[type: gettext/glade]src/rc/activator-generic-subscribe.ui
@@ -35,7 +35,6 @@ src/view/week/week-controller.vala
[type: gettext/glade]src/rc/activator-google-calendar-list-pane.ui
[type: gettext/glade]src/rc/activator-google-login-pane.ui
[type: gettext/glade]src/rc/activator-instance-list.ui
-[type: gettext/glade]src/rc/agenda-row.ui
[type: gettext/glade]src/rc/app-menu.interface
[type: gettext/glade]src/rc/event-editor-attendees-card.ui
[type: gettext/glade]src/rc/event-editor-date-time-card.ui
@@ -50,4 +49,5 @@ src/view/week/week-controller.vala
[type: gettext/glade]src/rc/manager-calendar-list.ui
[type: gettext/glade]src/rc/manager-calendar-list-item.ui
[type: gettext/glade]src/rc/manager-remove-calendar.ui
+[type: gettext/glade]src/rc/view-agenda-event-row.ui
[type: gettext/glade]src/rc/window-menu.interface
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index fb9591e..22513c9 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -25,7 +25,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/agenda/agenda-event-row.c
src/view/month/month-controller.c
src/view/week/week-controller.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 64d4cd1..55ba09a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -172,7 +172,8 @@ california_VALASOURCES = \
\
view/agenda/agenda.vala \
view/agenda/agenda-controller.vala \
- view/agenda/agenda-row.vala \
+ view/agenda/agenda-date-row.vala \
+ view/agenda/agenda-event-row.vala \
\
view/common/common.vala \
view/common/common-events-cell.vala \
@@ -218,7 +219,8 @@ california_RC = \
rc/manager-calendar-list.ui \
rc/manager-calendar-list-item.ui \
rc/manager-remove-calendar.ui \
- rc/view-agenda-row.ui \
+ rc/view-agenda-date-row.ui \
+ rc/view-agenda-event-row.ui \
rc/window-menu.interface \
$(NULL)
diff --git a/src/california-resources.xml b/src/california-resources.xml
index 366cfe0..5a72f09 100644
--- a/src/california-resources.xml
+++ b/src/california-resources.xml
@@ -58,7 +58,10 @@
<file compressed="true">rc/manager-remove-calendar.ui</file>
</gresource>
<gresource prefix="/org/yorba/california">
- <file compressed="false">rc/view-agenda-row.ui</file>
+ <file compressed="false">rc/view-agenda-date-row.ui</file>
+ </gresource>
+ <gresource prefix="/org/yorba/california">
+ <file compressed="false">rc/view-agenda-event-row.ui</file>
</gresource>
<gresource prefix="/org/yorba/california">
<file compressed="true">rc/window-menu.interface</file>
diff --git a/src/rc/view-agenda-row.ui b/src/rc/view-agenda-date-row.ui
similarity index 54%
copy from src/rc/view-agenda-row.ui
copy to src/rc/view-agenda-date-row.ui
index 67f1b4f..0021891 100644
--- a/src/rc/view-agenda-row.ui
+++ b/src/rc/view-agenda-date-row.ui
@@ -2,15 +2,20 @@
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <template class="CaliforniaViewAgendaRow" parent="GtkBox">
+ <template class="CaliforniaViewAgendaDateRow" 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="margin_right">6</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0</property>
<property name="label">(date)</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
@@ -19,30 +24,16 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="time_label">
+ <object class="GtkListBox" id="event_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label">(time)</property>
+ <property name="selection_mode">none</property>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</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/rc/view-agenda-row.ui b/src/rc/view-agenda-event-row.ui
similarity index 63%
rename from src/rc/view-agenda-row.ui
rename to src/rc/view-agenda-event-row.ui
index 67f1b4f..efd29a8 100644
--- a/src/rc/view-agenda-row.ui
+++ b/src/rc/view-agenda-event-row.ui
@@ -2,46 +2,37 @@
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <template class="CaliforniaViewAgendaRow" parent="GtkBox">
+ <template class="CaliforniaViewAgendaEventRow" 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="margin_right">12</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
<property name="label">(time)</property>
+ <property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</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="yalign">0</property>
<property name="label">(summary)</property>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</template>
diff --git a/src/view/agenda/agenda-controller.vala b/src/view/agenda/agenda-controller.vala
index 4d151ed..e382cd3 100644
--- a/src/view/agenda/agenda-controller.vala
+++ b/src/view/agenda/agenda-controller.vala
@@ -9,15 +9,14 @@ 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;
+ private class Container : Gtk.ScrolledWindow, View.Container {
+ private unowned Controllable _owner;
public unowned Controllable owner { get { return _owner; } }
- public Container(Controller owner) {
- _owner = owner;
+ public Container(Controller controller, Gtk.Widget child) {
+ _owner = controller;
+
+ add_with_viewport(child);
}
}
@@ -57,16 +56,21 @@ public class Controller : BaseObject, View.Controllable {
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;
+ private Gtk.ListBox listbox = new Gtk.ListBox();
+ private Toolkit.ListBoxModel<Calendar.Date> listbox_model;
public Controller(View.Palette palette) {
this.palette = palette;
- container = new Container(this);
- model = new Toolkit.ListBoxModel<Component.Event>(container, model_presentation);
+
+ container = new Container(this, listbox);
current_span = new Calendar.DateSpan(Calendar.System.today,
Calendar.System.today.adjust_by(1, Calendar.DateUnit.MONTH));
+ listbox_model = new Toolkit.ListBoxModel<Calendar.Date>(listbox, model_presentation);
+
+ listbox.selection_mode = Gtk.SelectionMode.NONE;
+ listbox.activate_on_single_click = false;
update_subscriptions();
}
@@ -109,11 +113,8 @@ public class Controller : BaseObject, View.Controllable {
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 Gtk.Widget model_presentation(Calendar.Date date) {
+ return new DateRow(date);
}
private void update_subscriptions() {
@@ -125,6 +126,14 @@ public class Controller : BaseObject, View.Controllable {
subscriptions.instance_removed.connect(on_instance_removed);
subscriptions.start_async.begin();
+
+ current_label = current_span.to_pretty_string(
+ Calendar.Date.PrettyFlag.COMPACT
+ | Calendar.Date.PrettyFlag.INCLUDE_YEAR
+ | Calendar.Date.PrettyFlag.NO_DAY_OF_WEEK
+ | Calendar.Date.PrettyFlag.NO_TODAY
+ );
+ is_viewing_today = Calendar.System.today in current_span;
}
private void on_instance_added(Component.Instance instance) {
@@ -132,7 +141,13 @@ public class Controller : BaseObject, View.Controllable {
if (event == null)
return;
- model.add(event);
+ foreach (Calendar.Date date in event.get_event_date_span(Calendar.Timezone.local)) {
+ if (!listbox_model.contains(date))
+ listbox_model.add(date);
+
+ DateRow date_row = (DateRow) listbox_model.get_widget_for_item(date);
+ date_row.add_event(event);
+ }
}
private void on_instance_altered(Component.Instance instance) {
@@ -145,8 +160,6 @@ public class Controller : BaseObject, View.Controllable {
Component.Event? event = instance as Component.Event;
if (event == null)
return;
-
- model.remove(event);
}
public override string to_string() {
diff --git a/src/view/agenda/agenda-date-row.vala b/src/view/agenda/agenda-date-row.vala
new file mode 100644
index 0000000..c006888
--- /dev/null
+++ b/src/view/agenda/agenda-date-row.vala
@@ -0,0 +1,55 @@
+/* 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/view-agenda-date-row.ui")]
+private class DateRow : Gtk.Box {
+ private const Calendar.Date.PrettyFlag DATE_PRETTY_FLAGS =
+ Calendar.Date.PrettyFlag.INCLUDE_OTHER_YEAR;
+
+ private static Gtk.SizeGroup date_label_size_group;
+
+ public Calendar.Date date { get; private set; }
+
+ [GtkChild]
+ private Gtk.Label date_label;
+
+ [GtkChild]
+ private Gtk.ListBox event_listbox;
+
+ private Toolkit.ListBoxModel<Component.Event> model;
+
+ public DateRow(Calendar.Date date) {
+ this.date = date;
+
+ model = new Toolkit.ListBoxModel<Component.Event>(event_listbox, model_presentation);
+
+ date_label.label = date.to_pretty_string(DATE_PRETTY_FLAGS);
+
+ // all date labels are same width
+ date_label_size_group.add_widget(date_label);
+ }
+
+ internal static void init() {
+ date_label_size_group = new Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL);
+ }
+
+ internal static void terminate() {
+ date_label_size_group = null;
+ }
+
+ public void add_event(Component.Event event) {
+ model.add(event);
+ }
+
+ private Gtk.Widget model_presentation(Component.Event event) {
+ return new EventRow(event);
+ }
+}
+
+}
+
diff --git a/src/view/agenda/agenda-event-row.vala b/src/view/agenda/agenda-event-row.vala
new file mode 100644
index 0000000..df43465
--- /dev/null
+++ b/src/view/agenda/agenda-event-row.vala
@@ -0,0 +1,56 @@
+/* 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/view-agenda-event-row.ui")]
+private class EventRow : Gtk.Box {
+ private const Calendar.WallTime.PrettyFlag TIME_PRETTY_FLAGS = Calendar.WallTime.PrettyFlag.NONE;
+
+ private static Gtk.SizeGroup time_label_size_group;
+
+ public new Component.Event event { get; private set; }
+
+ [GtkChild]
+ private Gtk.Label time_label;
+
+ [GtkChild]
+ private Gtk.Label summary_label;
+
+ public EventRow(Component.Event event) {
+ this.event = event;
+
+ // all time labels are the same width
+ time_label_size_group.add_widget(time_label);
+
+ update_ui();
+ }
+
+ internal static void init() {
+ time_label_size_group = new Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL);
+ }
+
+ internal static void terminate() {
+ time_label_size_group = null;
+ }
+
+ private void update_ui() {
+ summary_label.label = event.summary;
+
+ if (event.is_all_day) {
+ time_label.label = _("All day");
+ } else {
+ // hex value is an endash
+ time_label.label = "%s – %s".printf(
+ event.exact_time_span.start_exact_time.to_wall_time().to_pretty_string(TIME_PRETTY_FLAGS),
+ event.exact_time_span.end_exact_time.to_wall_time().to_pretty_string(TIME_PRETTY_FLAGS)
+ );
+ }
+ }
+}
+
+}
+
diff --git a/src/view/agenda/agenda.vala b/src/view/agenda/agenda.vala
index d12eb80..66cfb7a 100644
--- a/src/view/agenda/agenda.vala
+++ b/src/view/agenda/agenda.vala
@@ -14,12 +14,19 @@ public void init() throws Error {
Toolkit.init();
Calendar.init();
+
+ // internal unit init
+ DateRow.init();
+ EventRow.init();
}
public void terminate() {
if (!Unit.do_terminate(ref init_count))
return;
+ EventRow.terminate();
+ DateRow.terminate();
+
Calendar.terminate();
Toolkit.terminate();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]