[gnome-calendar] quick-add-popover: React to time format changes
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] quick-add-popover: React to time format changes
- Date: Fri, 26 Apr 2019 19:02:49 +0000 (UTC)
commit 527cb6fc5f903de1f27fa658b65ced2de703cd92
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Apr 26 13:41:07 2019 -0300
quick-add-popover: React to time format changes
src/gcal-quick-add-popover.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/gcal-quick-add-popover.c b/src/gcal-quick-add-popover.c
index 2fbcfddf..c0457734 100644
--- a/src/gcal-quick-add-popover.c
+++ b/src/gcal-quick-add-popover.c
@@ -41,8 +41,6 @@ struct _GcalQuickAddPopover
GtkWidget *selected_row;
- gboolean clock_format_24h;
-
GcalContext *context;
};
@@ -430,6 +428,9 @@ update_header (GcalQuickAddPopover *self)
gboolean multiday_or_timed;
gchar *title_date;
+ if (!self->date_start)
+ return;
+
multiday_or_timed = self->date_end &&
(g_date_time_difference (self->date_end, self->date_start) / G_TIME_SPAN_DAY > 1 ||
g_date_time_difference (self->date_end, self->date_start) / G_TIME_SPAN_MINUTE > 1);
@@ -449,9 +450,12 @@ update_header (GcalQuickAddPopover *self)
else
{
g_autofree gchar *start_hour, *end_hour, *event_date_name;
+ GcalTimeFormat time_format;
gchar *hour_format;
- if (self->clock_format_24h)
+ time_format = gcal_context_get_time_format (self->context);
+
+ if (time_format == GCAL_TIME_FORMAT_24H)
hour_format = "%R";
else
hour_format = "%I:%M %P";
@@ -802,6 +806,12 @@ gcal_quick_add_popover_set_property (GObject *object,
g_signal_connect (manager, "source-removed", G_CALLBACK (on_source_removed), self);
g_signal_connect_swapped (manager, "notify::default-calendar", G_CALLBACK
(update_default_calendar_row), self);
+ g_signal_connect_object (self->context,
+ "notify::time-format",
+ G_CALLBACK (update_header),
+ self,
+ G_CONNECT_SWAPPED);
+
g_object_notify (G_OBJECT (self), "context");
}
break;
@@ -919,8 +929,6 @@ gcal_quick_add_popover_init (GcalQuickAddPopover *self)
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->calendars_listbox), sort_func, NULL, NULL);
-
- self->clock_format_24h = is_clock_format_24h ();
}
GtkWidget*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]