[gnome-shell] dateMenu: Don't generate JS garbage every clock tick
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dateMenu: Don't generate JS garbage every clock tick
- Date: Wed, 1 Oct 2014 21:43:03 +0000 (UTC)
commit 42066a7c4674cab9ce0da0ed29b463ea9271a636
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Oct 1 15:28:14 2014 -0600
dateMenu: Don't generate JS garbage every clock tick
Instead of waking up the JS every second to set the clock and update a
date label the user will rarely see, simply use property binding to
bypass JS string handling, and update the date in the menu when the menu
is opened.
js/ui/dateMenu.js | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 1a86a6a..db8f2a5 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -3,6 +3,7 @@
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const GnomeDesktop = imports.gi.GnomeDesktop;
+const GObject = imports.gi.GObject;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Cairo = imports.cairo;
@@ -124,14 +125,19 @@ const DateMenuButton = new Lang.Class({
if (isOpen) {
let now = new Date();
this._calendar.setDate(now);
+
+ /* Translators: This is the date format to use when the calendar popup is
+ * shown - it is shown just below the time in the shell (e.g. "Tue 9:29 AM").
+ */
+ let dateFormat = _("%A %B %e, %Y");
+ this._date.set_label(now.toLocaleFormat(dateFormat));
}
}));
// Done with hbox for calendar and event list
this._clock = new GnomeDesktop.WallClock();
- this._clock.connect('notify::clock', Lang.bind(this, this._updateClockAndDate));
- this._updateClockAndDate();
+ this._clock.bind_property('clock', this._clockDisplay, 'text', GObject.BindingFlags.SYNC_CREATE);
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._sessionUpdated();
@@ -196,16 +202,6 @@ const DateMenuButton = new Lang.Class({
this._dateAndTimeSeparator.actor.visible = Main.sessionMode.allowSettings;
},
- _updateClockAndDate: function() {
- this._clockDisplay.set_text(this._clock.clock);
- /* Translators: This is the date format to use when the calendar popup is
- * shown - it is shown just below the time in the shell (e.g. "Tue 9:29 AM").
- */
- let dateFormat = _("%A %B %e, %Y");
- let displayDate = new Date();
- this._date.set_label(displayDate.toLocaleFormat(dateFormat));
- },
-
_getCalendarApp: function() {
if (this._calendarApp !== undefined)
return this._calendarApp;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]