mate-desktop / mate-screensaver

MATE screen saver and locker
https://mate-desktop.org
GNU General Public License v2.0
48 stars 40 forks source link

Allow change of time and date formats on lock screen. #252

Closed eugenesan closed 3 years ago

eugenesan commented 3 years ago

This change allows modification of default time and date format defined by current locale. Closes https://github.com/mate-desktop/mate-screensaver/issues/100

Default ('local') settings maintains old behavior. User is able to use any format defined by https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format.

Examples: %R for time means 24H format. %F for date means YYYY-MM-DD (ISO 8601 format).

eugenesan commented 3 years ago
* tfmt, dfmt need to be of type gchar (see https://developer.gnome.org/gio/stable)/GSettings.html#g-settings-get-string)

* You need to free tfmt and dfmt with g_free

* You need to free gchar* when overwriting them

* You should use g_strcmp0 (https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strcmp0) instead of strcmp (it is null safe)

Oppsie, silly me. I was in such a rush that I forgot we are in "gnome" environment and stuff needs to be released ;-) I am sure going to apply all your recommendations.

Also, I wonder if I can skip checking return value of g_date_time_format()? Looks like it always outputs proper string. If the parsing fails, it just outputs input string. Worst case scenario the user will see that and correct.

P.S. I did some more testing and looks like g_date_time_format() eats every input. in worst case scenario special characters disrupted HTML formatting of g_strdup_printf() but I don't think there is anything we can do aside of doing full parsing verification of the format. Updated PR patch.

raveit65 commented 3 years ago

@mbkma Are your concerns solved?

raveit65 commented 3 years ago

@eugenesan Any chance to fix this indent issues?

eugenesan commented 3 years ago

@raveit65 Sorry for the delay (I was away). I've pushed requested changes.