PowerStatus: show separate hour and minutes for primary device

Show "%d hours %d minutes" instead of "%d minutes", for better
readability.

https://bugzilla.gnome.org/show_bug.cgi?id=635728
This commit is contained in:
Giovanni Campagna 2010-11-26 22:22:07 +01:00
parent 24669e3ba7
commit aef005f451
2 changed files with 20 additions and 4 deletions

View File

@ -105,12 +105,26 @@ Indicator.prototype = {
this._deviceSep.actor.hide(); this._deviceSep.actor.hide();
return; return;
} }
let [device_id, device_type, icon, percentage, state, time] = device; let [device_id, device_type, icon, percentage, state, seconds] = device;
if (device_type == UPDeviceType.BATTERY) { if (device_type == UPDeviceType.BATTERY) {
this._hasPrimary = true; this._hasPrimary = true;
let minutes = Math.floor(time / 60); let time = Math.round(seconds / 60);
this._batteryItem.label.text = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes); let minutes = time % 60;
this._primaryPercentage.text = '%d%%'.format(Math.round(percentage)); let hours = Math.floor(time / 60);
let timestring;
if (time > 60) {
if (minutes == 0) {
timestring = Gettext.ngettext("%d hour remaining", "%d hours remaining", hours).format(hours);
} else {
/* TRANSLATORS: this is a time string, as in "%d hours %d minutes remaining" */
let template = _("%d %s %d %s remaining");
timestring = template.format (hours, Gettext.ngettext("hour", "hours", hours), minutes, Gettext.ngettext("minute", "minutes", minutes));
}
} else
timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes);
this._batteryItem.label.text = timestring;
this._primaryPercentage.text = Math.round(percentage) + '%';
this._batteryItem.actor.show(); this._batteryItem.actor.show();
if (this._deviceItems.length > 0) if (this._deviceItems.length > 0)
this._deviceSep.actor.show(); this._deviceSep.actor.show();

View File

@ -15,6 +15,8 @@ js/ui/popupMenu.js
js/ui/runDialog.js js/ui/runDialog.js
js/ui/statusMenu.js js/ui/statusMenu.js
js/ui/status/accessibility.js js/ui/status/accessibility.js
js/ui/status/power.js
js/ui/status/volume.js
js/ui/viewSelector.js js/ui/viewSelector.js
js/ui/windowAttentionHandler.js js/ui/windowAttentionHandler.js
js/ui/workspacesView.js js/ui/workspacesView.js