From 8dd05f9e7b62ad90bca15dc2d2a14d36b26cf97b Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Tue, 30 Nov 2010 10:50:20 -0500 Subject: [PATCH] Use fake events Signed-off-by: David Zeuthen --- js/ui/calendar.js | 67 ++++++++++++++++++++++++++++++++++------------- js/ui/dateMenu.js | 19 +++++++++++--- 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 7aeb5ede4..96813e684 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -456,7 +456,13 @@ function EventsList() { EventsList.prototype = { _init: function() { this.actor = new St.BoxLayout({ vertical: true }); - this.evolutionTasks = new EvolutionEventsSource(); + // FIXME: Evolution backend is currently disabled + // this.evolutionTasks = new EvolutionEventsSource(); + }, + + _addEvent: function(timeBox, eventTitleBox, time, desc) { + eventTitleBox.add(new St.Label({ style_class: 'events-day-time', text: time}), { expand: false }); + eventTitleBox.add(new St.Label({ style_class: 'events-day-task', text: desc}), { expand: false }); }, _addPeriod: function(header, begin, end, isDay) { @@ -471,24 +477,49 @@ EventsList.prototype = { box.add(eventTitleBox); this.actor.add(box); - this.evolutionTasks.getForInterval(begin, end, Lang.bind(this, function(tasks) { - if (!tasks.length) { - eventTitleBox.add(new St.Label({ style_class: 'events-no-events', text: _("No events") })); - return; - } + // FIXME: these are fake events + switch (begin.getDay()) { + case 1: // Monday + this._addEvent(timeBox, eventTitleBox, '10:00 AM', 'Write Status Report'); + break; + case 2: // Tuesday + this._addEvent(timeBox, eventTitleBox, '3:00 PM', 'Fix bug #632109'); + break; + case 4: // Thursday + this._addEvent(timeBox, eventTitleBox, '11:00 AM', 'Desktop Meeting'); + this._addEvent(timeBox, eventTitleBox, '1:15 PM', 'Dentist'); + break; + case 5: // Friday + this._addEvent(timeBox, eventTitleBox, '11:00 AM', 'Friday Meeting'); + this._addEvent(timeBox, eventTitleBox, '4:00 PM', 'Tech Talk'); + this._addEvent(timeBox, eventTitleBox, '7:00 PM', 'Wining & Dining'); + break; + case 6: // Saturday + this._addEvent(timeBox, eventTitleBox, '10:00 AM', 'Mow the Lawn'); + break; + } - for (let i = 0; i < tasks.length; i++) { - let time = tasks[i].time.getHours() + ':'; - if (tasks[i].time.getMinutes() < 10) - time += '0'; - time += tasks[i].time.getMinutes(); - timeBox.add(new St.Label({ style_class: 'events-day-time', text: time })); - eventTitleBox.add(new St.Label({ style_class: 'events-day-task', text: tasks[i].title }), { expand: false }); - if (!isDay) - continue; - dayNameBox.add(new St.Label({ text: tasks[i].time.toLocaleFormat("%a") })); - } - })); + // FIXME: Evolution backend is currently disabled + // this.evolutionTasks.getForInterval(begin, end, Lang.bind(this, function(tasks) { + // log('blah ' + tasks.length); + + // if (!tasks.length) { + // eventTitleBox.add(new St.Label({ style_class: 'events-no-events', text: _("No events") })); + // return; + // } + + // for (let i = 0; i < tasks.length; i++) { + // let time = tasks[i].time.getHours() + ':'; + // if (tasks[i].time.getMinutes() < 10) + // time += '0'; + // time += tasks[i].time.getMinutes(); + // timeBox.add(new St.Label({ style_class: 'events-day-time', text: time })); + // eventTitleBox.add(new St.Label({ style_class: 'events-day-task', text: tasks[i].title }), { expand: false }); + // if (!isDay) + // continue; + // dayNameBox.add(new St.Label({ text: tasks[i].time.toLocaleFormat("%a") })); + // } + // })); }, showDay: function(day) { diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 76c3a7e4c..8fd388cc3 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -98,13 +98,24 @@ DateMenuButton.prototype = { vbox.add(this._taskList.actor, { x_fill: true, y_fill: true }); // Update event list when opening the menu .. - this.menu.connect('opening', Lang.bind(this, function() { - this._calendar.clearButtonsState(); - this._taskList.update(); + this.menu.connect('open-state-changed', Lang.bind(this, function(menu, is_open) { + if (is_open) { + this._calendar.clearButtonsState(); + this._taskList.update(); + } })); // .. and also update when selecting a new day this._calendar.connect('activate', Lang.bind(this, function(obj, day) { - this._taskList.showDay(day); + let now = new Date(); + if (now.getDate() == day.getDate() && + now.getMonth() == day.getMonth() && + now.getFullYear() == day.getFullYear()) { + // Today - show: Today, Tomorrow and This Week + this._taskList.update(); + } else { + // Not Today - show only events from that day + this._taskList.showDay(day); + } })); // .. TODO: and also update when changing the month