[gnome-shell] util: Add createTimeLabel()
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] util: Add createTimeLabel()
- Date: Wed, 4 Mar 2015 12:55:54 +0000 (UTC)
commit 8f424e7d96c823552f30cde2bd4471fedb42031e
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 25 23:23:49 2015 +0100
util: Add createTimeLabel()
On locales that support it, time formats should follow the 12-hour/24-hour
preference, which implies that they should be updated when the setting
changes. So add another utility method which creates a label for a specific
time and keeps it in sync with the format setting.
https://bugzilla.gnome.org/show_bug.cgi?id=745111
js/misc/util.js | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/js/misc/util.js b/js/misc/util.js
index c938fdc..748c7b7 100644
--- a/js/misc/util.js
+++ b/js/misc/util.js
@@ -246,6 +246,20 @@ function formatTime(time, params) {
return date.format(Shell.util_translate_time_string(format));
}
+function createTimeLabel(date, params) {
+ if (_desktopSettings == null)
+ _desktopSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' });
+
+ let label = new St.Label({ text: formatTime(date, params) });
+ let id = _desktopSettings.connect('changed::clock-format', function() {
+ label.text = formatTime(date, params);
+ });
+ label.connect('destroy', function() {
+ _desktopSettings.disconnect(id);
+ });
+ return label;
+}
+
// lowerBound:
// @array: an array or array-like object, already sorted
// according to @cmp
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]