aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2007-12-06 04:50:15 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-12-06 04:50:15 +0800
commit7fef4ba1e95a25b78600434b2a71ce0762db47f1 (patch)
tree37ff545517f4afe21db534a1bff3c2fbe59643f0 /calendar
parentdbc59d48bea9da7292c7a30e37f2f086adb76c2d (diff)
downloadgsoc2013-evolution-7fef4ba1e95a25b78600434b2a71ce0762db47f1.tar.gz
gsoc2013-evolution-7fef4ba1e95a25b78600434b2a71ce0762db47f1.tar.zst
gsoc2013-evolution-7fef4ba1e95a25b78600434b2a71ce0762db47f1.zip
** Fixes bug #392747 (extra cleanup work)
2007-12-05 Matthew Barnes <mbarnes@redhat.com> ** Fixes bug #392747 (extra cleanup work) * calendar/gui/e-day-view.c (e_day_view_style_set): * calendar/gui/e-week-view-titles-item.c (e_week_view_titles_item_draw): * calendar/gui/e-week-view.c (e_week_view_style_set): * calendar/gui/print.c (print_month_summary): * calendar/gui/e-meeting-time-sel.c (e_meeting_time_selector_recalc_date_form): Call e_get_month_name() or e_get_weekday_name() instead of e_utf8_strftime() or g_date_strftime(). e_utf8_strftime() or g_date_strftime(). * widgets/misc/e-calendar-item.c (e_calendar_item_show_popup_menu): Call e_get_month_name() instead of e_utf8_strftime(). svn path=/trunk/; revision=34659
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/gui/e-day-view.c66
-rw-r--r--calendar/gui/e-meeting-time-sel.c18
-rw-r--r--calendar/gui/e-week-view-titles-item.c43
-rw-r--r--calendar/gui/e-week-view.c26
-rw-r--r--calendar/gui/print.c22
6 files changed, 75 insertions, 112 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 7f4035f554..4e801a8f97 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,15 @@
+2007-12-05 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #392747 (extra cleanup work)
+
+ * gui/e-day-view.c (e_day_view_style_set):
+ * gui/e-week-view-titles-item.c (e_week_view_titles_item_draw):
+ * gui/e-week-view.c (e_week_view_style_set):
+ * gui/print.c (print_month_summary):
+ * gui/e-meeting-time-sel.c (e_meeting_time_selector_recalc_date_form):
+ Call e_get_month_name() or e_get_weekday_name() instead of
+ e_utf8_strftime() or g_date_strftime().
+
2007-12-05 Milan Crha <mcrha@redhat.com>
** Fix for bug #501474
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 45de0472f5..cb5743e3b3 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1687,8 +1687,8 @@ e_day_view_style_set (GtkWidget *widget,
gint month, day, width;
gint longest_month_width, longest_abbreviated_month_width;
gint longest_weekday_width, longest_abbreviated_weekday_width;
- struct tm date_tm;
gchar buffer[128];
+ const gchar *name;
gint times_width;
PangoFontDescription *font_desc;
PangoContext *pango_context;
@@ -1775,18 +1775,11 @@ e_day_view_style_set (GtkWidget *widget,
e_day_view_update_top_scroll (day_view, TRUE);
/* Find the longest full & abbreviated month names. */
- memset (&date_tm, 0, sizeof (date_tm));
- date_tm.tm_year = 100;
- date_tm.tm_mday = 1;
- date_tm.tm_isdst = -1;
-
longest_month_width = 0;
longest_abbreviated_month_width = 0;
for (month = 0; month < 12; month++) {
- date_tm.tm_mon = month;
-
- e_utf8_strftime (buffer, sizeof (buffer), "%B", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_month_name (month + 1, FALSE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_month_width) {
@@ -1794,8 +1787,8 @@ e_day_view_style_set (GtkWidget *widget,
day_view->longest_month_name = month;
}
- e_utf8_strftime (buffer, sizeof (buffer), "%b", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_month_name (month + 1, TRUE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_abbreviated_month_width) {
@@ -1805,19 +1798,11 @@ e_day_view_style_set (GtkWidget *widget,
}
/* Find the longest full & abbreviated weekday names. */
- memset (&date_tm, 0, sizeof (date_tm));
- date_tm.tm_year = 100;
- date_tm.tm_mon = 0;
- date_tm.tm_isdst = -1;
-
longest_weekday_width = 0;
longest_abbreviated_weekday_width = 0;
for (day = 0; day < 7; day++) {
- date_tm.tm_mday = 2 + day;
- date_tm.tm_wday = day;
-
- e_utf8_strftime (buffer, sizeof (buffer), "%A", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_weekday_name (day + 1, FALSE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_weekday_width) {
@@ -1825,8 +1810,8 @@ e_day_view_style_set (GtkWidget *widget,
day_view->longest_weekday_name = day;
}
- e_utf8_strftime (buffer, sizeof (buffer), "%a", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_weekday_name (day + 1, TRUE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_abbreviated_weekday_width) {
@@ -1888,8 +1873,8 @@ e_day_view_style_set (GtkWidget *widget,
gint month, day, width;
gint longest_month_width, longest_abbreviated_month_width;
gint longest_weekday_width, longest_abbreviated_weekday_width;
- struct tm date_tm;
gchar buffer[128];
+ const gchar *name;
gint times_width;
PangoFontDescription *font_desc;
PangoContext *pango_context;
@@ -1969,18 +1954,11 @@ e_day_view_style_set (GtkWidget *widget,
e_day_view_update_top_scroll (day_view, TRUE);
/* Find the longest full & abbreviated month names. */
- memset (&date_tm, 0, sizeof (date_tm));
- date_tm.tm_year = 100;
- date_tm.tm_mday = 1;
- date_tm.tm_isdst = -1;
-
longest_month_width = 0;
longest_abbreviated_month_width = 0;
for (month = 0; month < 12; month++) {
- date_tm.tm_mon = month;
-
- e_utf8_strftime (buffer, sizeof (buffer), "%B", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_month_name (month + 1, FALSE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_month_width) {
@@ -1988,8 +1966,8 @@ e_day_view_style_set (GtkWidget *widget,
day_view->longest_month_name = month;
}
- e_utf8_strftime (buffer, sizeof (buffer), "%b", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_month_name (month + 1, TRUE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_abbreviated_month_width) {
@@ -1999,19 +1977,11 @@ e_day_view_style_set (GtkWidget *widget,
}
/* Find the longest full & abbreviated weekday names. */
- memset (&date_tm, 0, sizeof (date_tm));
- date_tm.tm_year = 100;
- date_tm.tm_mon = 0;
- date_tm.tm_isdst = -1;
-
longest_weekday_width = 0;
longest_abbreviated_weekday_width = 0;
for (day = 0; day < 7; day++) {
- date_tm.tm_mday = 2 + day;
- date_tm.tm_wday = day;
-
- e_utf8_strftime (buffer, sizeof (buffer), "%A", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_weekday_name (day + 1, FALSE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_weekday_width) {
@@ -2019,8 +1989,8 @@ e_day_view_style_set (GtkWidget *widget,
day_view->longest_weekday_name = day;
}
- e_utf8_strftime (buffer, sizeof (buffer), "%a", &date_tm);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_weekday_name (day + 1, TRUE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_abbreviated_weekday_width) {
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 5367cd3335..013fa338f9 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -60,6 +60,7 @@
#include <misc/e-dateedit.h>
#include <e-util/e-gui-utils.h>
#include <e-util/e-cursor.h>
+#include <e-util/e-util.h>
#include "calendar-component.h"
#include "calendar-config.h"
@@ -2064,6 +2065,7 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
gint max_date_width, longest_weekday_width, longest_month_width, width;
gint day, longest_weekday, month, longest_month;
gchar buffer[128];
+ const gchar *name;
PangoContext *pango_context;
PangoLayout *layout;
@@ -2081,23 +2083,21 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
longest_weekday_width = 0;
longest_weekday = G_DATE_MONDAY;
for (day = G_DATE_MONDAY; day <= G_DATE_SUNDAY; day++) {
- g_date_strftime (buffer, sizeof (buffer), "%A", &date);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_weekday_name (day, FALSE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_weekday_width) {
longest_weekday = day;
longest_weekday_width = width;
}
- g_date_add_days (&date, 1);
}
/* Now find the biggest month name. */
longest_month_width = 0;
longest_month = G_DATE_JANUARY;
for (month = G_DATE_JANUARY; month <= G_DATE_DECEMBER; month++) {
- g_date_set_month (&date, month);
- g_date_strftime (buffer, sizeof (buffer), "%B", &date);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_month_name (month, FALSE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_month_width) {
longest_month = month;
@@ -2130,16 +2130,14 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
/* Now try it with abbreviated weekday names. */
longest_weekday_width = 0;
longest_weekday = G_DATE_MONDAY;
- g_date_set_dmy (&date, 3, 1, 2000); /* Monday 3rd Jan 2000. */
for (day = G_DATE_MONDAY; day <= G_DATE_SUNDAY; day++) {
- g_date_strftime (buffer, sizeof (buffer), "%a", &date);
- pango_layout_set_text (layout, buffer, -1);
+ name = e_get_weekday_name (day, TRUE);
+ pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width > longest_weekday_width) {
longest_weekday = day;
longest_weekday_width = width;
}
- g_date_add_days (&date, 1);
}
g_date_set_dmy (&date, days[longest_month - 1] + longest_weekday,
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index 08f401e599..ec8edcc780 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -31,6 +31,7 @@
#endif
#include <string.h>
+#include <e-util/e-util.h>
#include "e-week-view-titles-item.h"
static void e_week_view_titles_item_set_arg (GtkObject *o,
@@ -139,10 +140,9 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
GtkStyle *style;
GdkGC *fg_gc, *light_gc, *dark_gc;
gint canvas_width, canvas_height, col_width, col, date_width, date_x;
- gchar buffer[128], *date_format;
- GDate date;
+ gchar buffer[128];
GdkRectangle clip_rect;
- gboolean long_format;
+ gboolean abbreviated;
gint weekday;
PangoLayout *layout;
@@ -177,13 +177,7 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
/* Determine the format to use. */
col_width = canvas_width / week_view->columns;
- if (col_width > week_view->max_day_width + 2) {
- date_format = "%A";
- long_format = TRUE;
- } else {
- date_format = "%a";
- long_format = FALSE;
- }
+ abbreviated = (week_view->max_day_width + 2 >= col_width);
/* Shift right one pixel to account for the shadow around the main
canvas. */
@@ -191,20 +185,17 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
/* Draw the date. Set a clipping rectangle so we don't draw over the
next day. */
- g_date_clear (&date, 1);
- /* Note that 20th March 2000 is a Monday. We only care about the
- weekday. */
weekday = week_view->display_start_day;
- g_date_set_dmy (&date, 20 + weekday, 3, 2000);
for (col = 0; col < week_view->columns; col++) {
- if (weekday == 5 && week_view->compress_weekend) {
- g_date_strftime (buffer, 128, "%a/", &date);
- g_date_add_days (&date, 1);
- g_date_strftime (buffer + strlen (buffer), 100,
- "%a", &date);
- } else {
- g_date_strftime (buffer, 128, date_format, &date);
- }
+ if (weekday == 5 && week_view->compress_weekend)
+ g_snprintf (
+ buffer, sizeof (buffer), "%s/%s",
+ e_get_weekday_name (G_DATE_SATURDAY, TRUE),
+ e_get_weekday_name (G_DATE_SUNDAY, TRUE));
+ else
+ g_snprintf (
+ buffer, sizeof (buffer), "%s",
+ e_get_weekday_name (weekday + 1, abbreviated));
clip_rect.x = week_view->col_offsets[col] - x;
clip_rect.y = 2 - y;
@@ -216,10 +207,10 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
date_width = week_view->abbr_day_widths[5]
+ week_view->slash_width
+ week_view->abbr_day_widths[6];
- else if (long_format)
- date_width = week_view->day_widths[weekday];
- else
+ else if (abbreviated)
date_width = week_view->abbr_day_widths[weekday];
+ else
+ date_width = week_view->day_widths[weekday];
date_x = week_view->col_offsets[col]
+ (week_view->col_widths[col] - date_width) / 2;
@@ -263,8 +254,6 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
weekday++;
weekday = weekday % 7;
-
- g_date_add_days (&date, 1);
}
g_object_unref (layout);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 47a939a4de..0c3ca360ad 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -52,6 +52,7 @@
#include <misc/e-unicode.h>
#include <e-util/e-categories-config.h>
#include <e-util/e-dialog-utils.h>
+#include <e-util/e-util.h>
#include "dialogs/delete-comp.h"
#include "dialogs/delete-error.h"
#include "dialogs/send-comp.h"
@@ -815,8 +816,7 @@ e_week_view_style_set (GtkWidget *widget,
gint day, day_width, max_day_width, max_abbr_day_width;
gint month, month_width, max_month_width, max_abbr_month_width;
gint span_num;
- GDate date;
- gchar buffer[128];
+ const gchar *name;
PangoFontDescription *font_desc;
PangoContext *pango_context;
PangoFontMetrics *font_metrics;
@@ -873,37 +873,31 @@ e_week_view_style_set (GtkWidget *widget,
/* Save the sizes of various strings in the font, so we can quickly
decide which date formats to use. */
- g_date_clear (&date, 1);
- g_date_set_dmy (&date, 27, 3, 2000); /* Must be a Monday. */
max_day_width = 0;
max_abbr_day_width = 0;
for (day = 0; day < 7; day++) {
- g_date_strftime (buffer, 128, "%A", &date);
- day_width = get_string_width (layout, buffer);
+ name = e_get_weekday_name (day + 1, FALSE);
+ day_width = get_string_width (layout, name);
week_view->day_widths[day] = day_width;
max_day_width = MAX (max_day_width, day_width);
- g_date_strftime (buffer, 128, "%a", &date);
- day_width = get_string_width (layout, buffer);
+ name = e_get_weekday_name (day + 1, TRUE);
+ day_width = get_string_width (layout, name);
week_view->abbr_day_widths[day] = day_width;
max_abbr_day_width = MAX (max_abbr_day_width, day_width);
-
- g_date_add_days (&date, 1);
}
max_month_width = 0;
max_abbr_month_width = 0;
for (month = 0; month < 12; month++) {
- g_date_set_month (&date, month + 1);
-
- g_date_strftime (buffer, 128, "%B", &date);
- month_width = get_string_width (layout, buffer);
+ name = e_get_month_name (month + 1, FALSE);
+ month_width = get_string_width (layout, name);
week_view->month_widths[month] = month_width;
max_month_width = MAX (max_month_width, month_width);
- g_date_strftime (buffer, 128, "%b", &date);
- month_width = get_string_width (layout, buffer);
+ name = e_get_month_name (month + 1, TRUE);
+ month_width = get_string_width (layout, name);
week_view->abbr_month_widths[month] = month_width;
max_abbr_month_width = MAX (max_abbr_month_width, month_width);
}
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index 855271bb57..1fde0e3495 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -1778,7 +1778,7 @@ print_month_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whenc
char buffer[100];
PangoFontDescription *font;
gboolean compress_weekend;
- int columns, col, weekday, len, month;
+ int columns, col, weekday, month;
double font_size, cell_width, x1, x2, y1, y2;
weekday = calendar_config_get_week_start_day ();
@@ -1815,16 +1815,16 @@ print_month_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whenc
y2 = top + font_size * 1.5;
for (col = 0; col < columns; col++) {
- if (tm.tm_wday == 6 && compress_weekend) {
- e_utf8_strftime (buffer, sizeof (buffer), "%a/", &tm);
- len = strlen (buffer);
- tm.tm_mday++;
- tm.tm_wday = (tm.tm_wday + 1) % 7;
- e_utf8_strftime (buffer + len, sizeof (buffer) - len,
- "%a", &tm);
- } else {
- e_utf8_strftime (buffer, sizeof (buffer), "%A", &tm);
- }
+ if (tm.tm_wday == 6 && compress_weekend)
+ g_snprintf (
+ buffer, sizeof (buffer), "%s/%s",
+ e_get_weekday_name (G_DATE_SATURDAY, TRUE),
+ e_get_weekday_name (G_DATE_SUNDAY, TRUE));
+ else
+ g_snprintf (
+ buffer, sizeof (buffer), "%s",
+ e_get_weekday_name (
+ tm.tm_wday ? tm.tm_wday : 7, FALSE));
x1 = left + cell_width * col;
x2 = x1 + cell_width;