summaryrefslogtreecommitdiff
path: root/src/gs-lock-plug.c
diff options
context:
space:
mode:
authorEugene San (eugenesan) <[email protected]>2021-06-06 07:50:26 -0700
committerraveit65 <[email protected]>2021-07-24 16:17:58 +0200
commita7a0c1cc6f76b2c5d844bbbd32dad70d4f7473e8 (patch)
tree32b2cd095af4520f645c577fdfb704ed2c42febe /src/gs-lock-plug.c
parent7ffbcab9ca98bddef8bc5170210aa9a9dacf13dd (diff)
downloadmate-screensaver-a7a0c1cc6f76b2c5d844bbbd32dad70d4f7473e8.tar.bz2
mate-screensaver-a7a0c1cc6f76b2c5d844bbbd32dad70d4f7473e8.tar.xz
Allow change of time and date formats on lock screen v4
Diffstat (limited to 'src/gs-lock-plug.c')
-rw-r--r--src/gs-lock-plug.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 7d223c8..5e09f9c 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -59,6 +59,10 @@
#define KEY_LOCK_DIALOG_THEME "lock-dialog-theme"
+#define KEY_LOCK_DIALOG_T_FMT "lock-dialog-time-format"
+#define KEY_LOCK_DIALOG_D_FMT "lock-dialog-date-format"
+
+
#define MDM_FLEXISERVER_COMMAND "mdmflexiserver"
#define MDM_FLEXISERVER_ARGS "--startnew Standard"
@@ -294,12 +298,42 @@ date_time_update (GSLockPlug *plug)
GDateTime *datetime;
gchar *time;
gchar *date;
+ gchar *tfmt;
+ gchar *dfmt;
+
gchar *str;
+ GSettings *settings;
+
+ settings = g_settings_new (GSETTINGS_SCHEMA);
+ tfmt = g_settings_get_string (settings, KEY_LOCK_DIALOG_T_FMT);
+ dfmt = g_settings_get_string (settings, KEY_LOCK_DIALOG_D_FMT);
+ g_object_unref (settings);
+
+ /* Time/Date formating https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format */
+
datetime = g_date_time_new_now_local ();
- time = g_date_time_format (datetime, "%X");
- /* Translators: Date format, see https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format */
- date = g_date_time_format (datetime, _("%A, %B %e"));
+ if (g_strcmp0(tfmt, "locale") == 0)
+ {
+ // Use locale default format
+ time = g_date_time_format (datetime, "%X");
+ }
+ else
+ {
+ // Apply user defined format
+ time = g_date_time_format (datetime, tfmt);
+ }
+
+ if (g_strcmp0(dfmt, "locale") == 0)
+ {
+ // Use locale default format
+ date = g_date_time_format (datetime, _("%A, %B %e"));
+ }
+ else
+ {
+ // Apply user defined format
+ date = g_date_time_format (datetime, dfmt);
+ }
str = g_strdup_printf ("<span size=\"xx-large\" weight=\"ultrabold\">%s</span>", time);
gtk_label_set_text (GTK_LABEL (plug->priv->auth_time_label), str);
@@ -313,6 +347,8 @@ date_time_update (GSLockPlug *plug)
g_free (time);
g_free (date);
+ g_free (tfmt);
+ g_free (dfmt);
g_date_time_unref (datetime);
}