GNOME Bugzilla – Bug 703321
respect GNOME's 12/24-hour time setting
Last modified: 2017-04-17 18:20:40 UTC
GNOME's Date & Time control center applet allows me to choose either 12-hour (AM/PM) or 24-hour time. (This gets stored in GSettings at /org/gnome/desktop/interface/clock-format.) Unfortunately gnome-calendar seems to ignore this setting: it always displays 12-hour time in the Week view, and always displays 24-hour time in the Event Details dialog.
Also, gnome-calendar ignores locale settings LC_TIME= and uses LANG= variable instead.
Created attachment 323145 [details] [review] Respecting gnome's 12/24 hour format.
Review of attachment 323145 [details] [review]: This patch is conceptually wrong. First, because we already set the format the 24h format by reading the settings (check gcal_time_selector_set_time_format() usage). Second, it has no commit message. Finally, see the comments below to help you learn a little bit more abot memory management cases. ::: src/gcal-time-selector.c @@ +239,3 @@ + gchar *clock_format; + + settings = g_settings_new("org.gnome.desktop.interface"); Memleak: unref the settings after using it. @@ +240,3 @@ + + settings = g_settings_new("org.gnome.desktop.interface"); + clock_format = g_settings_get_string(settings,"clock-format"); Memleak: free the string after using it.
gcal_time_selector_set_time_format() doesnt work, it always sets the format to 24h irrespective of desktop format because i think we initialise it to 24h format in gcal_time_selector_init().
Created attachment 323895 [details] [review] Edit dialog: Respecting GNOME's 12/24 hour format The edit dialog time picker didnt take into account GNOME's hour format The edit dialog time picker didnt take into account GNOME's hour format because the desktop settings clock-format from gcal-window was not passed to gcal-edit-dialog. Now the data is passed to gcal-edit-dialog through a function gcal_edit_dialog_time_format and everything works fine as expected.
Review of attachment 323895 [details] [review]: Needs some work yet. ::: src/gcal-edit-dialog.c @@ +556,3 @@ void +gcal_edit_dialog_set_time_format (GcalEditDialog *dialog, + gboolean use_24h_format) Fix the alignment. @@ +558,3 @@ + gboolean use_24h_format) +{ + dialog->format_24h = use_24h_format; 1. Check g_return_if_fail () 2. Check if dialog->format_24h != use_24h_format. ::: src/gcal-edit-dialog.h @@ +50,3 @@ +void gcal_edit_dialog_set_time_format (GcalEditDialog *dialog, + gboolean use_24h_format); Fix the alignment. ::: src/gcal-time-selector.c @@ -242,3 @@ - clock_format = g_settings_get_string(settings,"clock-format"); - - self->format_24h = (g_strcmp0(clock_format,"24h") == 0); This seems to be a diff from a previous commit of yours that is not present in git master. Thus, this patch does not apply. Remove this and I think it'll be fine. ::: src/gcal-window.c @@ +1352,3 @@ window->views[GCAL_WINDOW_VIEW_YEAR] = window->year_view; + gcal_edit_dialog_set_time_format (GCAL_EDIT_DIALOG (window->edit_dialog),use_24h_format); Space after ','
Created attachment 323917 [details] [review] Edit dialog: Respecting GNOME's 12/24 hour format The edit dialog time picker didnt take into account GNOME's hour format. The edit dialog time picker didnt take into account GNOME's hour format because the desktop settings clock-format from gcal-window was not passed to gcal-edit-dialog. Now the data is passed to gcal-edit-dialog through a function gcal_edit_dialog_time_format and everything works fine as required.
Review of attachment 323917 [details] [review]: Only a minor nitpick. ::: src/gcal-edit-dialog.c @@ +552,3 @@ dialog = g_object_new (GCAL_TYPE_EDIT_DIALOG, NULL); + return GTK_WIDGET (dialog); Due to the code removal, you can simply "return g_object_new (GCAL_TYPE_EDIT_DIALOG, NULL);" here.
Created attachment 323920 [details] [review] Edit dialog: Respecting GNOME's 12/24 hour format The edit dialog time picker didnt take into account GNOME's hour format. The edit dialog time picker didnt take into account GNOME's hour format because the desktop settings clock-format from gcal-window was not passed to gcal-edit-dialog. Now the data is passed through the function gcal_edit_dialog_time_format and everything works as required.
Thanks for working on this issue.