[gnome-calendar] Get month names and weekdays from locale.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] Get month names and weekdays from locale.
- Date: Sat, 1 Dec 2012 20:33:25 +0000 (UTC)
commit cc14e10d3681a92a8c1e3dfc95688f1d0405753f
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Wed Nov 21 15:50:44 2012 -0500
Get month names and weekdays from locale.
Added modification to extract month names from locale instead
of localization files.
src/gcal-month-view.c | 5 +++-
src/gcal-utils.c | 55 ++++++++++++++++++++++++++++++++++++------------
src/gcal-utils.h | 4 ++-
src/gcal-week-view.c | 5 +++-
4 files changed, 52 insertions(+), 17 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index f2ec2f7..4b9d606 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -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);
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index 3046dc1..dc4c514 100644
--- a/src/gcal-utils.c
+++ b/src/gcal-utils.c
@@ -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*
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
index ee78c75..5e18835 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -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);
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index f0a6bea..15c1ef9 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]