utils: Use nominative/genitive month names correctly
These changes are needed since the standalone (nominative) vs. full date format (genitive) month names support has been introduced in Linux with glibc 2.27. They are also supported in *BSD systems. See also: https://bugzilla.gnome.org/show_bug.cgi?id=749206 https://sourceware.org/bugzilla/show_bug.cgi?id=10871 https://gitlab.gnome.org/GNOME/gnome-calendar/issues/125
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
e7e693765b
commit
e6483e96e2
+24
@@ -78,6 +78,30 @@ nl_time_first_weekday_src = '''
|
||||
config_h.set('HAVE__NL_TIME_FIRST_WEEKDAY', cc.compiles(nl_time_first_weekday_src),
|
||||
description: 'Define if _NL_TIME_FIRST_WEEKDAY is available')
|
||||
|
||||
# Not all systems support nl_langinfo (ALTMON_*)
|
||||
altmon_src = '''
|
||||
/* _GNU_SOURCE is required by glibc 2.27. */
|
||||
#define _GNU_SOURCE
|
||||
#include <langinfo.h>
|
||||
int main() {
|
||||
nl_langinfo (ALTMON_1);
|
||||
nl_langinfo (ALTMON_2);
|
||||
nl_langinfo (ALTMON_3);
|
||||
nl_langinfo (ALTMON_4);
|
||||
nl_langinfo (ALTMON_5);
|
||||
nl_langinfo (ALTMON_6);
|
||||
nl_langinfo (ALTMON_7);
|
||||
nl_langinfo (ALTMON_8);
|
||||
nl_langinfo (ALTMON_9);
|
||||
nl_langinfo (ALTMON_10);
|
||||
nl_langinfo (ALTMON_11);
|
||||
nl_langinfo (ALTMON_12);
|
||||
};
|
||||
'''
|
||||
|
||||
config_h.set('HAVE_ALTMON', cc.compiles(altmon_src),
|
||||
description: 'Define if ALTMON_* constants are available')
|
||||
|
||||
# Compiler flags
|
||||
common_flags = [
|
||||
'-DHAVE_CONFIG_H',
|
||||
|
||||
+3
-18
@@ -224,20 +224,6 @@ calendar_get_weekday_name (gint i)
|
||||
return text;
|
||||
}
|
||||
|
||||
/* 0 = january */
|
||||
static gchar *
|
||||
calendar_get_month_name (gint i)
|
||||
{
|
||||
GDateTime *date;
|
||||
gchar *text;
|
||||
|
||||
date = g_date_time_new_local (2015, i + 1, 1, 1, 1, 1);
|
||||
text = g_date_time_format (date, "%B");
|
||||
g_date_time_unref (date);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
static void
|
||||
calendar_init_weekday_display (GcalDateChooser *self)
|
||||
{
|
||||
@@ -257,7 +243,7 @@ format_month (GcalMultiChoice *choice,
|
||||
gint value,
|
||||
gpointer data)
|
||||
{
|
||||
return calendar_get_month_name (value);
|
||||
return g_strdup (gcal_get_month_name (value));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -269,9 +255,8 @@ calendar_init_month_display (GcalDateChooser *self)
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
month = calendar_get_month_name (i);
|
||||
months[i] = g_strdup_printf ("%s", month);
|
||||
g_free (month);
|
||||
month = gcal_get_month_name (i);
|
||||
months[i] = g_strdup (month);
|
||||
}
|
||||
|
||||
months[12] = NULL;
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#define G_LOG_DOMAIN "Utils"
|
||||
|
||||
/* langinfo.h in glibc 2.27 defines ALTMON_* only if _GNU_SOURCE is defined. */
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "gcal-enums.h"
|
||||
#include "gcal-utils.h"
|
||||
#include "gcal-event-widget.h"
|
||||
@@ -57,6 +60,29 @@ ab_day[7] =
|
||||
static const gint
|
||||
month_item[12] =
|
||||
{
|
||||
/* ALTMON_* constants have been introduced in glibc 2.27 (Feb 1, 2018), also
|
||||
* have been supported in *BSD family (but not in OS X) since 1990s.
|
||||
* If they exist they are the correct way to obtain the month names in
|
||||
* nominative case, standalone, without the day number, as used in the
|
||||
* calendar header. This is obligatory in some languages (Slavic, Baltic,
|
||||
* Greek, etc.) but also recommended to use in all languages because for
|
||||
* other languages there is no difference between ALTMON_* and MON_*.
|
||||
* If ALTMON_* is not supported then we must use MON_*.
|
||||
*/
|
||||
#ifdef HAVE_ALTMON
|
||||
ALTMON_1,
|
||||
ALTMON_2,
|
||||
ALTMON_3,
|
||||
ALTMON_4,
|
||||
ALTMON_5,
|
||||
ALTMON_6,
|
||||
ALTMON_7,
|
||||
ALTMON_8,
|
||||
ALTMON_9,
|
||||
ALTMON_10,
|
||||
ALTMON_11,
|
||||
ALTMON_12
|
||||
#else
|
||||
MON_1,
|
||||
MON_2,
|
||||
MON_3,
|
||||
@@ -69,6 +95,7 @@ month_item[12] =
|
||||
MON_10,
|
||||
MON_11,
|
||||
MON_12
|
||||
#endif
|
||||
};
|
||||
|
||||
#define SCROLL_HARDNESS 10.0
|
||||
|
||||
Reference in New Issue
Block a user