Update for comments from code review

See https://bugzilla.gnome.org/show_bug.cgi?id=632109#c41 for the review.

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
David Zeuthen 2011-01-28 12:05:17 -05:00
parent 803e74101c
commit 8a1313be71
4 changed files with 37 additions and 72 deletions

View File

@ -702,48 +702,36 @@ StTooltip StLabel {
spacing-columns: 0px; spacing-columns: 0px;
} }
.calendar-change-month { .calendar-month-label {
color: #666666; color: #666666;
font-size: 10px; font-size: 10px;
padding: 2px; padding: 2px;
} }
.calendar-change-month:hover {
background: #999999;
border-radius: 5px;
}
.calendar-change-month:active {
background: #aaaaaa;
border-radius: 5px;
}
.calendar-change-month-back { .calendar-change-month-back {
width: 20px; width: 20px;
height: 20px; height: 20px;
background-image: url("calendar-arrow-left.svg"); background-image: url("calendar-arrow-left.svg");
border-radius: 4px;
} }
.calendar-change-month-back:hover { .calendar-change-month-back:hover {
background: #999999; background-color: #999999;
background-image: url("calendar-arrow-left.svg");
} }
.calendar-change-month-back:active { .calendar-change-month-back:active {
background: #aaaaaa; background-color: #aaaaaa;
background-image: url("calendar-arrow-left.svg");
} }
.calendar-change-month-forward { .calendar-change-month-forward {
width: 20px; width: 20px;
height: 20px; height: 20px;
background-image: url("calendar-arrow-right.svg"); background-image: url("calendar-arrow-right.svg");
border-radius: 4px;
} }
.calendar-change-month-forward:hover { .calendar-change-month-forward:hover {
background: #999999; background-color: #999999;
background-image: url("calendar-arrow-right.svg");
} }
.calendar-change-month-forward:active { .calendar-change-month-forward:active {
background: #aaaaaa; background-color: #aaaaaa;
background-image: url("calendar-arrow-right.svg");
} }
.datemenu-date-label { .datemenu-date-label {
@ -794,7 +782,7 @@ StTooltip StLabel {
} }
.calendar-nonwork-day { .calendar-nonwork-day {
background: #181818; background-color: rgba(128, 128, 128, .1);
} }
.calendar-today { .calendar-today {
@ -860,16 +848,6 @@ StTooltip StLabel {
.events-event-box { .events-event-box {
} }
.open-calendar {
padding-bottom: 12px;
padding-left: 12px;
height: 40px;
}
.open-calendar:hover {
background: #666;
}
.url-highlighter { .url-highlighter {
link-color: #ccccff; link-color: #ccccff;
} }

View File

@ -390,7 +390,7 @@ Calendar.prototype = {
} }
// Start off with the current date // Start off with the current date
this.selectedDate = new Date(); this._selectedDate = new Date();
this.actor = new St.Table({ homogeneous: false, this.actor = new St.Table({ homogeneous: false,
style_class: 'calendar', style_class: 'calendar',
@ -405,10 +405,10 @@ Calendar.prototype = {
// Sets the calendar to show a specific date // Sets the calendar to show a specific date
setDate: function(date) { setDate: function(date) {
if (!_sameDay(date, this.selectedDate)) { if (!_sameDay(date, this._selectedDate)) {
this.selectedDate = date; this._selectedDate = date;
this._update(); this._update();
this.emit('selected-date-changed', new Date(this.selectedDate)); this.emit('selected-date-changed', new Date(this._selectedDate));
} }
}, },
@ -427,8 +427,8 @@ Calendar.prototype = {
this._topBox.add(back); this._topBox.add(back);
back.connect('clicked', Lang.bind(this, this._onPrevMonthButtonClicked)); back.connect('clicked', Lang.bind(this, this._onPrevMonthButtonClicked));
this._dateLabel = new St.Label({style_class: 'calendar-change-month'}); this._monthLabel = new St.Label({style_class: 'calendar-month-label'});
this._topBox.add(this._dateLabel, { expand: true, x_fill: false, x_align: St.Align.MIDDLE }); this._topBox.add(this._monthLabel, { expand: true, x_fill: false, x_align: St.Align.MIDDLE });
let forward = new St.Button({ style_class: 'calendar-change-month-forward' }); let forward = new St.Button({ style_class: 'calendar-change-month-forward' });
this._topBox.add(forward); this._topBox.add(forward);
@ -439,15 +439,15 @@ Calendar.prototype = {
// We need to figure out the abbreviated localized names for the days of the week; // We need to figure out the abbreviated localized names for the days of the week;
// we do this by just getting the next 7 days starting from right now and then putting // we do this by just getting the next 7 days starting from right now and then putting
// them in the right cell in the table. It doesn't matter if we add them in order // them in the right cell in the table. It doesn't matter if we add them in order
let iter = new Date(this.selectedDate); let iter = new Date(this._selectedDate);
iter.setSeconds(0); // Leap second protection. Hah! iter.setSeconds(0); // Leap second protection. Hah!
iter.setHours(12); iter.setHours(12);
for (let i = 0; i < 7; i++) { for (let i = 0; i < 7; i++) {
// Could use iter.toLocaleFormat('%a') but that normally gives three characters // Could use iter.toLocaleFormat('%a') but that normally gives three characters
// and we want, ideally, a single character for e.g. S M T W T F S // and we want, ideally, a single character for e.g. S M T W T F S
let customDayAbbrev = _getCalendarDayAbbreviation(iter.getDay()); let customDayAbbrev = _getCalendarDayAbbreviation(iter.getDay());
let label = new St.Label({ text: customDayAbbrev }); let label = new St.Label({ style_class: 'calendar-day-base calendar-day-heading',
label.style_class = 'calendar-day-base calendar-day-heading'; text: customDayAbbrev });
this.actor.add(label, this.actor.add(label,
{ row: 1, { row: 1,
col: offsetCols + (7 + iter.getDay() - this._weekStart) % 7, col: offsetCols + (7 + iter.getDay() - this._weekStart) % 7,
@ -485,7 +485,7 @@ Calendar.prototype = {
}, },
_onPrevMonthButtonClicked: function() { _onPrevMonthButtonClicked: function() {
let newDate = new Date(this.selectedDate); let newDate = new Date(this._selectedDate);
if (newDate.getMonth() == 0) { if (newDate.getMonth() == 0) {
newDate.setMonth(11); newDate.setMonth(11);
newDate.setFullYear(newDate.getFullYear() - 1); newDate.setFullYear(newDate.getFullYear() - 1);
@ -496,7 +496,7 @@ Calendar.prototype = {
}, },
_onNextMonthButtonClicked: function() { _onNextMonthButtonClicked: function() {
let newDate = new Date(this.selectedDate); let newDate = new Date(this._selectedDate);
if (newDate.getMonth() == 11) { if (newDate.getMonth() == 11) {
newDate.setMonth(0); newDate.setMonth(0);
newDate.setFullYear(newDate.getFullYear() + 1); newDate.setFullYear(newDate.getFullYear() + 1);
@ -515,10 +515,10 @@ Calendar.prototype = {
_update: function() { _update: function() {
let now = new Date(); let now = new Date();
if (_sameYear(this.selectedDate, now)) if (_sameYear(this._selectedDate, now))
this._dateLabel.text = this.selectedDate.toLocaleFormat(this._headerFormatWithoutYear); this._monthLabel.text = this._selectedDate.toLocaleFormat(this._headerFormatWithoutYear);
else else
this._dateLabel.text = this.selectedDate.toLocaleFormat(this._headerFormat); this._monthLabel.text = this._selectedDate.toLocaleFormat(this._headerFormat);
// Remove everything but the topBox and the weekday labels // Remove everything but the topBox and the weekday labels
let children = this.actor.get_children(); let children = this.actor.get_children();
@ -526,7 +526,7 @@ Calendar.prototype = {
children[i].destroy(); children[i].destroy();
// Start at the beginning of the week before the start of the month // Start at the beginning of the week before the start of the month
let beginDate = new Date(this.selectedDate); let beginDate = new Date(this._selectedDate);
beginDate.setDate(1); beginDate.setDate(1);
beginDate.setSeconds(0); beginDate.setSeconds(0);
beginDate.setHours(12); beginDate.setHours(12);
@ -540,14 +540,12 @@ Calendar.prototype = {
let iterStr = iter.toUTCString(); let iterStr = iter.toUTCString();
button.connect('clicked', Lang.bind(this, function() { button.connect('clicked', Lang.bind(this, function() {
let newly_selectedDate = new Date(iterStr); let newlySelectedDate = new Date(iterStr);
this.setDate(newly_selectedDate); this.setDate(newlySelectedDate);
})); }));
let styleClass; let hasEvents = this._eventSource.hasEvents(iter);
let hasEvents; let styleClass = 'calendar-day-base calendar-day';
hasEvents = this._eventSource.hasEvents(iter);
styleClass = 'calendar-day-base calendar-day';
if (_isWorkDay(iter)) if (_isWorkDay(iter))
styleClass += ' calendar-work-day' styleClass += ' calendar-work-day'
else else
@ -561,10 +559,10 @@ Calendar.prototype = {
if (_sameDay(now, iter)) if (_sameDay(now, iter))
styleClass += ' calendar-today'; styleClass += ' calendar-today';
else if (iter.getMonth() != this.selectedDate.getMonth()) else if (iter.getMonth() != this._selectedDate.getMonth())
styleClass += ' calendar-other-month-day'; styleClass += ' calendar-other-month-day';
if (_sameDay(this.selectedDate, iter)) if (_sameDay(this._selectedDate, iter))
button.add_style_pseudo_class('active'); button.add_style_pseudo_class('active');
if (hasEvents) if (hasEvents)
@ -586,7 +584,7 @@ Calendar.prototype = {
iter.setTime(iter.getTime() + MSECS_IN_DAY); iter.setTime(iter.getTime() + MSECS_IN_DAY);
if (iter.getDay() == this._weekStart) { if (iter.getDay() == this._weekStart) {
// We stop on the first "first day of the week" after the month we are displaying // We stop on the first "first day of the week" after the month we are displaying
if (iter.getMonth() > this.selectedDate.getMonth() || iter.getYear() > this.selectedDate.getYear()) if (iter.getMonth() > this._selectedDate.getMonth() || iter.getYear() > this._selectedDate.getYear())
break; break;
row++; row++;
} }

View File

@ -29,12 +29,10 @@ function _onVertSepRepaint (area)
let cr = area.get_context(); let cr = area.get_context();
let themeNode = area.get_theme_node(); let themeNode = area.get_theme_node();
let [width, height] = area.get_surface_size(); let [width, height] = area.get_surface_size();
let found;
let stippleWidth = 1.0;
let stippleColor = new Clutter.Color(); let stippleColor = new Clutter.Color();
[found, stippleWidth] = themeNode.lookup_length('-stipple-width', false); let stippleWidth = themeNode.get_length('-stipple-width');
themeNode.lookup_color('-stipple-color', false, stippleColor);
let x = Math.floor(width/2) + 0.5; let x = Math.floor(width/2) + 0.5;
themeNode.lookup_color('-stipple-color', false, stippleColor);
cr.moveTo(x, 0); cr.moveTo(x, 0);
cr.lineTo(x, height); cr.lineTo(x, height);
Clutter.cairo_set_source_color(cr, stippleColor); Clutter.cairo_set_source_color(cr, stippleColor);
@ -58,7 +56,6 @@ DateMenuButton.prototype = {
//this._eventSource = new Calendar.EmptyEventSource(); //this._eventSource = new Calendar.EmptyEventSource();
//this._eventSource = new Calendar.FakeEventSource(); //this._eventSource = new Calendar.FakeEventSource();
this._eventSource = new Calendar.EvolutionEventSource(); this._eventSource = new Calendar.EvolutionEventSource();
// TODO: write e.g. EvolutionEventSource
PanelMenu.Button.prototype._init.call(this, St.Align.START); PanelMenu.Button.prototype._init.call(this, St.Align.START);
@ -88,11 +85,9 @@ DateMenuButton.prototype = {
})); }));
vbox.add(this._calendar.actor); vbox.add(this._calendar.actor);
//item = new St.Button({style_class: 'popup-menu-item', label: 'foobar'});
//vbox.add(item);
item = new PopupMenu.PopupSeparatorMenuItem(); item = new PopupMenu.PopupSeparatorMenuItem();
item.actor.remove_actor(item._drawingArea); item.setColumnWidths(1);
vbox.add(item._drawingArea); vbox.add(item.actor);
item = new PopupMenu.PopupMenuItem(_("Date and Time Settings")); item = new PopupMenu.PopupMenuItem(_("Date and Time Settings"));
item.connect('activate', Lang.bind(this, this._onPreferencesActivate)); item.connect('activate', Lang.bind(this, this._onPreferencesActivate));
vbox.add(item.actor); vbox.add(item.actor);
@ -114,7 +109,7 @@ DateMenuButton.prototype = {
item = new PopupMenu.PopupMenuItem(_("Open Calendar")); item = new PopupMenu.PopupMenuItem(_("Open Calendar"));
item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate)); item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
vbox.add(item.actor, {y_align : St.Align.END, expand : true, y_fill : false}); vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false});
// Whenever the menu is opened, select today // Whenever the menu is opened, select today
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) { this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
@ -128,14 +123,6 @@ DateMenuButton.prototype = {
// Done with hbox for calendar and event list // Done with hbox for calendar and event list
// Add separator
//item = new PopupMenu.PopupSeparatorMenuItem();
//this.menu.addMenuItem(item);
// Add button to get to the Date and Time settings
//this.menu.addAction(_("Date and Time Settings"),
// Lang.bind(this, this._onPreferencesActivate));
// Track changes to clock settings // Track changes to clock settings
this._desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' }); this._desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
this._clockSettings = new Gio.Settings({ schema: 'org.gnome.shell.clock' }); this._clockSettings = new Gio.Settings({ schema: 'org.gnome.shell.clock' });

View File

@ -18,3 +18,5 @@ libcalendar_client_la_CFLAGS = \
$(NULL) $(NULL)
libcalendar_client_la_LIBADD = $(LIBECAL_LIBS) libcalendar_client_la_LIBADD = $(LIBECAL_LIBS)
EXTRA_DIST += calendar-client/README