calendar: Port calendar to ClutterTableLayout

We don't make use of any functionality StTable provides over
ClutterTableLayout, so port all users to the Clutter layout
in order to remove our own copy of the code.

https://bugzilla.gnome.org/show_bug.cgi?id=703833
This commit is contained in:
Florian Müllner 2013-07-06 14:37:22 +02:00
parent 1b77149ec9
commit ec714864f2
2 changed files with 12 additions and 15 deletions

View File

@ -1300,8 +1300,6 @@ StScrollBar StButton#vhandle:active {
.calendar { .calendar {
padding: .4em 1.75em .8em 1.75em; padding: .4em 1.75em .8em 1.75em;
spacing-rows: 0px;
spacing-columns: 0px;
} }
.calendar-month-label { .calendar-month-label {

View File

@ -408,8 +408,8 @@ const Calendar = new Lang.Class({
this._shouldDateGrabFocus = false; this._shouldDateGrabFocus = false;
this.actor = new St.Table({ homogeneous: false, this.actor = new St.Widget({ style_class: 'calendar',
style_class: 'calendar', layout_manager: new Clutter.TableLayout(),
reactive: true }); reactive: true });
this.actor.connect('scroll-event', this.actor.connect('scroll-event',
@ -441,13 +441,14 @@ const Calendar = new Lang.Class({
}, },
_buildHeader: function() { _buildHeader: function() {
let layout = this.actor.layout_manager;
let offsetCols = this._useWeekdate ? 1 : 0; let offsetCols = this._useWeekdate ? 1 : 0;
this.actor.destroy_all_children(); this.actor.destroy_all_children();
// Top line of the calendar '<| September 2009 |>' // Top line of the calendar '<| September 2009 |>'
this._topBox = new St.BoxLayout(); this._topBox = new St.BoxLayout();
this.actor.add(this._topBox, layout.pack(this._topBox, 0, 0);
{ row: 0, col: 0, col_span: offsetCols + 7 }); layout.set_span(this._topBox, offsetCols + 7, 1);
this._backButton = new St.Button({ style_class: 'calendar-change-month-back', this._backButton = new St.Button({ style_class: 'calendar-change-month-back',
accessible_name: _("Previous month"), accessible_name: _("Previous month"),
@ -479,10 +480,8 @@ const Calendar = new Lang.Class({
let customDayAbbrev = _getCalendarDayAbbreviation(iter.getDay()); let customDayAbbrev = _getCalendarDayAbbreviation(iter.getDay());
let label = new St.Label({ style_class: 'calendar-day-base calendar-day-heading', let label = new St.Label({ style_class: 'calendar-day-base calendar-day-heading',
text: customDayAbbrev }); text: customDayAbbrev });
this.actor.add(label, let col = offsetCols + (7 + iter.getDay() - this._weekStart) % 7;
{ row: 1, layout.pack(label, col, 1);
col: offsetCols + (7 + iter.getDay() - this._weekStart) % 7,
x_fill: false, x_align: St.Align.MIDDLE });
iter.setTime(iter.getTime() + MSECS_IN_DAY); iter.setTime(iter.getTime() + MSECS_IN_DAY);
} }
@ -601,6 +600,7 @@ const Calendar = new Lang.Class({
beginDate.setTime(beginDate.getTime() - (weekPadding + daysToWeekStart) * MSECS_IN_DAY); beginDate.setTime(beginDate.getTime() - (weekPadding + daysToWeekStart) * MSECS_IN_DAY);
let layout = this.actor.layout_manager;
let iter = new Date(beginDate); let iter = new Date(beginDate);
let row = 2; let row = 2;
// nRows here means 6 weeks + one header + one navbar // nRows here means 6 weeks + one header + one navbar
@ -648,16 +648,15 @@ const Calendar = new Lang.Class({
button.style_class = styleClass; button.style_class = styleClass;
let offsetCols = this._useWeekdate ? 1 : 0; let offsetCols = this._useWeekdate ? 1 : 0;
this.actor.add(button, let col = offsetCols + (7 + iter.getDay() - this._weekStart) % 7;
{ row: row, col: offsetCols + (7 + iter.getDay() - this._weekStart) % 7 }); layout.pack(button, col, row);
this._buttons.push(button); this._buttons.push(button);
if (this._useWeekdate && iter.getDay() == 4) { if (this._useWeekdate && iter.getDay() == 4) {
let label = new St.Label({ text: _getCalendarWeekForDate(iter).toString(), let label = new St.Label({ text: _getCalendarWeekForDate(iter).toString(),
style_class: 'calendar-day-base calendar-week-number'}); style_class: 'calendar-day-base calendar-week-number'});
this.actor.add(label, layout.pack(label, 0, row);
{ row: row, col: 0, y_align: St.Align.MIDDLE });
} }
iter.setTime(iter.getTime() + MSECS_IN_DAY); iter.setTime(iter.getTime() + MSECS_IN_DAY);