diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c index 603bf921..41cc0e55 100644 --- a/src/gcal-edit-dialog.c +++ b/src/gcal-edit-dialog.c @@ -545,18 +545,24 @@ gcal_edit_dialog_all_day_changed (GtkWidget *widget, /* Public API */ GtkWidget* -gcal_edit_dialog_new (gboolean format_24h) +gcal_edit_dialog_new (void) { - GcalEditDialog *dialog; + return g_object_new (GCAL_TYPE_EDIT_DIALOG, NULL); +} - dialog = g_object_new (GCAL_TYPE_EDIT_DIALOG, NULL); +void +gcal_edit_dialog_set_time_format (GcalEditDialog *dialog, + gboolean use_24h_format) +{ + g_return_if_fail (GCAL_IS_EDIT_DIALOG (dialog)); - dialog->format_24h = format_24h; + if (dialog->format_24h != use_24h_format) + { + dialog->format_24h = use_24h_format; - gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->start_time_selector), format_24h); - gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->end_time_selector), format_24h); - - return GTK_WIDGET (dialog); + gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->start_time_selector), dialog->format_24h); + gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->end_time_selector), dialog->format_24h); + } } void diff --git a/src/gcal-edit-dialog.h b/src/gcal-edit-dialog.h index bd192582..1dff9a1f 100644 --- a/src/gcal-edit-dialog.h +++ b/src/gcal-edit-dialog.h @@ -35,7 +35,7 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (GcalEditDialog, gcal_edit_dialog, GCAL, EDIT_DIALOG, GtkDialog); -GtkWidget* gcal_edit_dialog_new (gboolean format_24h); +GtkWidget* gcal_edit_dialog_new (void); void gcal_edit_dialog_set_event_is_new (GcalEditDialog *dialog, gboolean event_is_new); @@ -48,6 +48,9 @@ void gcal_edit_dialog_set_event (GcalEditDialog *d void gcal_edit_dialog_set_manager (GcalEditDialog *dialog, GcalManager *manager); +void gcal_edit_dialog_set_time_format (GcalEditDialog *dialog, + gboolean use_24h_format); + GDateTime* gcal_edit_dialog_get_date_end (GcalEditDialog *dialog); GDateTime* gcal_edit_dialog_get_date_start (GcalEditDialog *dialog); diff --git a/src/gcal-time-selector.c b/src/gcal-time-selector.c index 7eb9bfc3..c9711e88 100644 --- a/src/gcal-time-selector.c +++ b/src/gcal-time-selector.c @@ -235,7 +235,6 @@ gcal_time_selector_class_init (GcalTimeSelectorClass *klass) static void gcal_time_selector_init (GcalTimeSelector *self) { - self->format_24h = TRUE; self->time = g_date_time_new_now_local (); gtk_widget_init_template (GTK_WIDGET (self)); diff --git a/src/gcal-window.c b/src/gcal-window.c index 7bcadbd6..869bf119 100644 --- a/src/gcal-window.c +++ b/src/gcal-window.c @@ -1351,6 +1351,8 @@ gcal_window_constructed (GObject *object) window->views[GCAL_WINDOW_VIEW_MONTH] = window->month_view; window->views[GCAL_WINDOW_VIEW_YEAR] = window->year_view; + gcal_edit_dialog_set_time_format (GCAL_EDIT_DIALOG (window->edit_dialog), use_24h_format); + gcal_month_view_set_first_weekday (GCAL_MONTH_VIEW (window->views[GCAL_WINDOW_VIEW_MONTH]), get_first_weekday ()); gcal_month_view_set_use_24h_format (GCAL_MONTH_VIEW (window->views[GCAL_WINDOW_VIEW_MONTH]), use_24h_format);