Calendar: remove dead code

this._weekdateHeader is never assigned, so _setWeekdateHeaderWidth is
useless. Everything else falls from that.

Spotted by mathematical.coffee@gmail.com, our human coverity :)

https://bugzilla.gnome.org/show_bug.cgi?id=687250
This commit is contained in:
Giovanni Campagna 2012-12-03 19:18:51 +01:00
parent 13b83c95b7
commit 5072ea7e47

View File

@ -11,7 +11,6 @@ const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const MSECS_IN_DAY = 24 * 60 * 60 * 1000; const MSECS_IN_DAY = 24 * 60 * 60 * 1000;
const WEEKDATE_HEADER_WIDTH_DIGITS = 3;
const SHOW_WEEKDATE_KEY = 'show-weekdate'; const SHOW_WEEKDATE_KEY = 'show-weekdate';
// in org.gnome.desktop.interface // in org.gnome.desktop.interface
@ -95,15 +94,6 @@ function _getCalendarWeekForDate(date) {
return weekNumber; return weekNumber;
} }
function _getDigitWidth(actor){
let context = actor.get_pango_context();
let themeNode = actor.get_theme_node();
let font = themeNode.get_font();
let metrics = context.get_metrics(font, context.get_language());
let width = metrics.get_approximate_digit_width();
return width;
}
function _getCalendarDayAbbreviation(dayNumber) { function _getCalendarDayAbbreviation(dayNumber) {
let abbreviations = [ let abbreviations = [
/* Translators: Calendar grid abbreviation for Sunday. /* Translators: Calendar grid abbreviation for Sunday.
@ -345,8 +335,6 @@ const Calendar = new Lang.Class({
_init: function() { _init: function() {
this._weekStart = Shell.util_get_week_start(); this._weekStart = Shell.util_get_week_start();
this._weekdate = NaN;
this._digitWidth = NaN;
this._settings = new Gio.Settings({ schema: 'org.gnome.shell.calendar' }); this._settings = new Gio.Settings({ schema: 'org.gnome.shell.calendar' });
this._settings.connect('changed::' + SHOW_WEEKDATE_KEY, Lang.bind(this, this._onSettingsChange)); this._settings.connect('changed::' + SHOW_WEEKDATE_KEY, Lang.bind(this, this._onSettingsChange));
@ -419,8 +407,6 @@ const Calendar = new Lang.Class({
this.actor.add(this._topBox, this.actor.add(this._topBox,
{ row: 0, col: 0, col_span: offsetCols + 7 }); { row: 0, col: 0, col_span: offsetCols + 7 });
this.actor.connect('style-changed', Lang.bind(this, this._onStyleChange));
let back = new St.Button({ style_class: 'calendar-change-month-back' }); let back = new St.Button({ style_class: 'calendar-change-month-back' });
this._topBox.add(back); this._topBox.add(back);
back.connect('clicked', Lang.bind(this, this._onPrevMonthButtonClicked)); back.connect('clicked', Lang.bind(this, this._onPrevMonthButtonClicked));
@ -457,18 +443,6 @@ const Calendar = new Lang.Class({
this._firstDayIndex = this.actor.get_n_children(); this._firstDayIndex = this.actor.get_n_children();
}, },
_onStyleChange: function(actor, event) {
// width of a digit in pango units
this._digitWidth = _getDigitWidth(this.actor) / Pango.SCALE;
this._setWeekdateHeaderWidth();
},
_setWeekdateHeaderWidth: function() {
if (this.digitWidth != NaN && this._useWeekdate && this._weekdateHeader) {
this._weekdateHeader.set_width (this._digitWidth * WEEKDATE_HEADER_WIDTH_DIGITS);
}
},
_onScroll : function(actor, event) { _onScroll : function(actor, event) {
switch (event.get_scroll_direction()) { switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP: case Clutter.ScrollDirection.UP: