1
1
public class Time : Gazette.Plugin
11
settings = new Settings("org.pantheon.gazette.files");
10
debug("Creating time");
11
Timeout.add(60000, update);
13
public override void create () {
12
14
label = new ShadowedLabel ("");
13
15
service.add_content(label);
14
Timeout.add(60000, update);
17
17
public override bool update ()
19
debug("Updating time");
19
20
var date = new GLib.DateTime.now_local ();
21
/*Date display, see http://unstable.valadoc.org/#!api=glib-2.0/GLib.DateTime.format for more details.
22
%v is added here to provide the English date suffixes th, nd and so on*/
23
var day_format = _("%A, %B %e%v");
24
/*Time display, see http://unstable.valadoc.org/#!api=glib-2.0/GLib.DateTime.format for more details*/
25
var time_format = _("%l:%M");
26
/*AM/PM display, see http://unstable.valadoc.org/#!api=glib-2.0/GLib.DateTime.format for more details*/
27
var meridiem_format = _(" %p");
29
//there is no %v, but we need one, so we add one
30
var num = date.get_day_of_month ();
31
day_format = day_format.replace ("%v", get_english_number_suffix (num));
33
service.clear_contents ();
34
service.add_content(new ShadowedLabel(date.format (
35
"<span face='Open Sans Light' font='24'>"+
21
var day_format = _("%A, %B %e");
22
// TODO provide a localizable date suffix
23
string tfmt = (new Settings("org.gnome.desktop.interface")). get_string ("clock-format");
24
var time_format = _("<span weight='bold'>" + ((tfmt=="12h")?"%l":"%H") + ":</span><span weight='ultralight'>%M</span>");
25
label.label = date.format (
26
"\n<span face='Raleway' font='80'>"+
28
"</span>\n<span face='Open Sans Light' font='24'>"+
37
"</span>\n<span face='Raleway' weight='100' font='72'> "+
39
"</span><span face='Raleway' weight='100' font='50'>"+
46
* Utility to get the English number suffix
47
* @param number The number to find the the suffix for
48
* @return The according English suffix
50
string get_english_number_suffix (int number) {
71
34
public Time plugin_init () {
72
35
// types are registered automatically