[Xfce4-commits] <postler:master> Support org.gnome.desktop.interface.clock-format
Christian Dywan
noreply at xfce.org
Tue Aug 16 04:32:02 CEST 2011
Updating branch refs/heads/master
to ce4e71d5bb573442a563054f16d38d52f8194a74 (commit)
from c4b3cb0927792fd1f4bd4cbdf3702390838ec3de (commit)
commit ce4e71d5bb573442a563054f16d38d52f8194a74
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Aug 15 22:26:03 2011 +0200
Support org.gnome.desktop.interface.clock-format
Times should be displayed in 12 or 24 hour format as
system preferences indicate.
postler/postler-content.vala | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 20af75c..13d806e 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -32,6 +32,7 @@ public class Postler.Content : WebKit.WebView {
Gtk.Settings gtk_settings;
GLib.Settings glib_settings;
+ static bool 12h_time = false;
const string fallback_style_sheet = """
body {
@@ -153,6 +154,11 @@ public class Postler.Content : WebKit.WebView {
"default-monospace-font-size", font.get_size () / Pango.SCALE);
}
+ void clock_format_changed (GLib.Settings glib_settings, string key) {
+ string clock_format = glib_settings.get_string (key);
+ 12h_time = clock_format == "12h";
+ }
+
public Content () {
settings.set ("enable-scripts", false, "enable-plugins", false);
if (settings.get_class ().find_property ("enable-private-browsing") != null) {
@@ -172,6 +178,8 @@ public class Postler.Content : WebKit.WebView {
glib_settings = new GLib.Settings (schema);
glib_settings.changed["monospace-font-name"].connect (monospace_font_changed);
monospace_font_changed (glib_settings, "monospace-font-name");
+ glib_settings.changed["clock-format"].connect (clock_format_changed);
+ clock_format_changed (glib_settings, "clock-format");
}
}
@@ -427,8 +435,11 @@ public class Postler.Content : WebKit.WebView {
internal static string format_date (DateTime the_time) {
var now = new DateTime.now_local ();
- /* i18n: strftime format for hour and minute */
- string pretty_time = " " + the_time.format (_("%I:%M %P"));
+ string pretty_time = " " + the_time.format (12h_time
+ /* i18n: strftime format for hour and minute, AM/ PM */
+ ? _("%l:%M %p")
+ /* i18n: strftime format for hour and minute, 24 hours */
+ : _("%H:%M"));
if (the_time.get_day_of_month () == now.get_day_of_month ())
return _("Today") + pretty_time;
if (the_time.get_day_of_year () == now.get_day_of_year () - 1)
More information about the Xfce4-commits
mailing list