Use fake events

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
David Zeuthen 2010-11-30 10:50:20 -05:00
parent b7fe72e74a
commit 8dd05f9e7b
2 changed files with 64 additions and 22 deletions

View File

@ -456,7 +456,13 @@ function EventsList() {
EventsList.prototype = { EventsList.prototype = {
_init: function() { _init: function() {
this.actor = new St.BoxLayout({ vertical: true }); 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) { _addPeriod: function(header, begin, end, isDay) {
@ -471,24 +477,49 @@ EventsList.prototype = {
box.add(eventTitleBox); box.add(eventTitleBox);
this.actor.add(box); this.actor.add(box);
this.evolutionTasks.getForInterval(begin, end, Lang.bind(this, function(tasks) { // FIXME: these are fake events
if (!tasks.length) { switch (begin.getDay()) {
eventTitleBox.add(new St.Label({ style_class: 'events-no-events', text: _("No events") })); case 1: // Monday
return; 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++) { // FIXME: Evolution backend is currently disabled
let time = tasks[i].time.getHours() + ':'; // this.evolutionTasks.getForInterval(begin, end, Lang.bind(this, function(tasks) {
if (tasks[i].time.getMinutes() < 10) // log('blah ' + tasks.length);
time += '0';
time += tasks[i].time.getMinutes(); // if (!tasks.length) {
timeBox.add(new St.Label({ style_class: 'events-day-time', text: time })); // eventTitleBox.add(new St.Label({ style_class: 'events-no-events', text: _("No events") }));
eventTitleBox.add(new St.Label({ style_class: 'events-day-task', text: tasks[i].title }), { expand: false }); // return;
if (!isDay) // }
continue;
dayNameBox.add(new St.Label({ text: tasks[i].time.toLocaleFormat("%a") })); // 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) { showDay: function(day) {

View File

@ -98,13 +98,24 @@ DateMenuButton.prototype = {
vbox.add(this._taskList.actor, { x_fill: true, vbox.add(this._taskList.actor, { x_fill: true,
y_fill: true }); y_fill: true });
// Update event list when opening the menu .. // Update event list when opening the menu ..
this.menu.connect('opening', Lang.bind(this, function() { this.menu.connect('open-state-changed', Lang.bind(this, function(menu, is_open) {
if (is_open) {
this._calendar.clearButtonsState(); this._calendar.clearButtonsState();
this._taskList.update(); this._taskList.update();
}
})); }));
// .. and also update when selecting a new day // .. and also update when selecting a new day
this._calendar.connect('activate', Lang.bind(this, function(obj, day) { this._calendar.connect('activate', Lang.bind(this, function(obj, 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); this._taskList.showDay(day);
}
})); }));
// .. TODO: and also update when changing the month // .. TODO: and also update when changing the month