Get month names and weekdays from locale.

Added modification to extract month names from locale instead
of localization files.
This commit is contained in:
Erick Pérez Castellanos
2012-12-01 15:28:53 -05:00
committed by Rene A. Viant Moran
parent 1062d3e435
commit cc14e10d36
4 changed files with 52 additions and 17 deletions
+4 -1
View File
@@ -1122,10 +1122,13 @@ gcal_month_view_draw_grid (GcalMonthView *view,
pango_font_description_set_weight (bold_font, PANGO_WEIGHT_SEMIBOLD);
for (i = 0; i < 7; i++)
{
gchar *weekday;
weekday = gcal_get_weekday (i);
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
pango_layout_set_font_description (layout, bold_font);
pango_layout_set_text (layout, gcal_get_weekday (i), -1);
pango_layout_set_text (layout, weekday, -1);
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, &font_width, &font_height);
+41 -14
View File
@@ -20,12 +20,43 @@
#include "gcal-utils.h"
#include <libedataserver/libedataserver.h>
#include <libedataserverui/libedataserverui.h>
#include <glib/gi18n.h>
#include <langinfo.h>
#include <string.h>
#include <libedataserver/libedataserver.h>
#include <libedataserverui/libedataserverui.h>
static const gint
ab_day[7] =
{
ABDAY_1,
ABDAY_2,
ABDAY_3,
ABDAY_4,
ABDAY_5,
ABDAY_6,
ABDAY_7,
};
static const gint
month_item[12] =
{
MON_1,
MON_2,
MON_3,
MON_4,
MON_5,
MON_6,
MON_7,
MON_8,
MON_9,
MON_10,
MON_11,
MON_12
};
G_DEFINE_BOXED_TYPE (icaltimetype, icaltime, gcal_dup_icaltime, g_free)
@@ -188,20 +219,16 @@ gcal_get_source_uid (GtkTreeModel *model,
return uid;
}
const gchar*
gchar*
gcal_get_weekday (gint i)
{
static const char* weekdays [] =
{
N_("Sun"),
N_("Mon"),
N_("Tue"),
N_("Wed"),
N_("Thu"),
N_("Fri"),
N_("Sat")
};
return _(weekdays[i]);
return nl_langinfo (ab_day[i]);
}
gchar*
gcal_get_month_name (gint i)
{
return nl_langinfo (month_item[i + 1]);
}
GdkPixbuf*
+3 -1
View File
@@ -75,7 +75,9 @@ gchar* gcal_get_source_name (GtkTreeModel
gchar* gcal_get_source_uid (GtkTreeModel *model,
const gchar *name);
const gchar* gcal_get_weekday (gint i);
gchar* gcal_get_weekday (gint i);
gchar* gcal_get_month_name (gint i);
GdkPixbuf* gcal_get_pixbuf_from_color (GdkColor *color);
+4 -1
View File
@@ -1176,13 +1176,16 @@ gcal_week_view_draw_header (GcalWeekView *view,
for (i = 0; i < 7; i++)
{
gchar *weekday_header;
gchar *weekday_abv;
gint n_day;
n_day = start_of_week->day + i;
if (n_day > icaltime_days_in_month (start_of_week->month, start_of_week->year))
n_day = n_day - icaltime_days_in_month (start_of_week->month, start_of_week->year);
weekday_header = g_strdup_printf ("%s %d",gcal_get_weekday (i), n_day);
weekday_abv = gcal_get_weekday (i);
weekday_header = g_strdup_printf ("%s %d",weekday_abv, n_day);
pango_layout_set_text (layout, weekday_header, -1);
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, NULL, &font_height);