event-widget: factor out clock format function
This function will be used by other pieces of code later. We also gain a tiny performance improvement, as only one GSetting is ever created.
This commit is contained in:
@@ -188,13 +188,9 @@ static void
|
|||||||
gcal_event_widget_init (GcalEventWidget *self)
|
gcal_event_widget_init (GcalEventWidget *self)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GSettings *settings;
|
|
||||||
gchar *clock_format;
|
|
||||||
|
|
||||||
widget = GTK_WIDGET (self);
|
widget = GTK_WIDGET (self);
|
||||||
settings = g_settings_new ("org.gnome.desktop.interface");
|
self->clock_format_24h = is_clock_format_24h ();
|
||||||
clock_format = g_settings_get_string (settings, "clock-format");
|
|
||||||
self->clock_format_24h = g_strcmp0 (clock_format, "24h") == 0;
|
|
||||||
|
|
||||||
gtk_widget_set_has_window (widget, FALSE);
|
gtk_widget_set_has_window (widget, FALSE);
|
||||||
gtk_widget_set_can_focus (widget, TRUE);
|
gtk_widget_set_can_focus (widget, TRUE);
|
||||||
@@ -207,9 +203,6 @@ gcal_event_widget_init (GcalEventWidget *self)
|
|||||||
GDK_ACTION_COPY);
|
GDK_ACTION_COPY);
|
||||||
|
|
||||||
gtk_drag_source_add_text_targets (widget);
|
gtk_drag_source_add_text_targets (widget);
|
||||||
|
|
||||||
g_clear_object (&settings);
|
|
||||||
g_free (clock_format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -561,6 +561,20 @@ get_end_of_week (icaltimetype *date)
|
|||||||
return week_end;
|
return week_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
is_clock_format_24h (void)
|
||||||
|
{
|
||||||
|
static GSettings *settings = NULL;
|
||||||
|
g_autofree gchar *clock_format = NULL;
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
settings = g_settings_new ("org.gnome.desktop.interface");
|
||||||
|
|
||||||
|
clock_format = g_settings_get_string (settings, "clock-format");
|
||||||
|
|
||||||
|
return g_strcmp0 (clock_format, "24h") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Function to do a last minute fixup of the AM/PM stuff if the locale
|
/* Function to do a last minute fixup of the AM/PM stuff if the locale
|
||||||
* and gettext haven't done it right. Most English speaking countries
|
* and gettext haven't done it right. Most English speaking countries
|
||||||
* except the USA use the 24 hour clock (UK, Australia etc). However
|
* except the USA use the 24 hour clock (UK, Australia etc). However
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ GDateTime* get_start_of_week (icaltimetype
|
|||||||
|
|
||||||
GDateTime* get_end_of_week (icaltimetype *date);
|
GDateTime* get_end_of_week (icaltimetype *date);
|
||||||
|
|
||||||
|
gboolean is_clock_format_24h (void);
|
||||||
|
|
||||||
/* code brought from evolution */
|
/* code brought from evolution */
|
||||||
gsize e_strftime_fix_am_pm (gchar *str,
|
gsize e_strftime_fix_am_pm (gchar *str,
|
||||||
gsize max,
|
gsize max,
|
||||||
|
|||||||
Reference in New Issue
Block a user