aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/gui/e-meeting-time-sel-item.c37
-rw-r--r--calendar/gui/e-meeting-time-sel.c49
-rw-r--r--calendar/gui/e-meeting-time-sel.h10
-rw-r--r--e-util/e-datetime-format.c22
-rw-r--r--e-util/e-datetime-format.h1
5 files changed, 71 insertions, 48 deletions
diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c
index 35f3a7d743..ced8414ef9 100644
--- a/calendar/gui/e-meeting-time-sel-item.c
+++ b/calendar/gui/e-meeting-time-sel-item.c
@@ -29,6 +29,9 @@
#include <time.h>
#include <glib/gi18n.h>
+
+#include "e-util/e-datetime-format.h"
+
#include "calendar-config.h"
#include "e-meeting-time-sel-item.h"
#include "e-meeting-time-sel.h"
@@ -389,9 +392,10 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
{
EMeetingTimeSelector *mts;
gint y, grid_x;
- gchar buffer[128], *format;
+ gchar *str;
gint hour, hour_x, hour_y;
PangoLayout *layout;
+ struct tm tm_time;
cairo_save (cr);
@@ -437,29 +441,31 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
cairo_rel_line_to (cr, 0, height);
cairo_stroke (cr);
+ g_date_to_struct_tm (date, &tm_time);
+ str = e_datetime_format_format_tm ("calendar", "table", DTFormatKindDate, &tm_time);
+
+ g_return_if_fail (str != NULL);
+
/* Draw the date. Set a clipping rectangle so we don't draw over the
* next day. */
- if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_FULL)
- /* This is a strftime() format string %A = full weekday name,
- * %B = full month name, %d = month day, %Y = full year. */
- format = _("%A, %B %d, %Y");
- else if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY)
- /* This is a strftime() format string %a = abbreviated weekday
- * name, %m = month number, %d = month day, %Y = full year. */
- format = _("%a %m/%d/%Y");
- else
- /* This is a strftime() format string %m = month number,
- * %d = month day, %Y = full year. */
- format = _("%m/%d/%Y");
+ if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY
+ && !e_datetime_format_includes_day_name ("calendar", "table", DTFormatKindDate)) {
+ gchar buffer[128];
+ gchar *tmp;
+
+ g_date_strftime (buffer, sizeof (buffer), "%a", date);
- g_date_strftime (buffer, sizeof (buffer), format, date);
+ tmp = str;
+ str = g_strconcat (buffer, " ", str, NULL);
+ g_free (tmp);
+ }
cairo_save (cr);
cairo_rectangle (cr, x, -scroll_y, mts->day_width - 2, mts->row_height - 2);
cairo_clip (cr);
- pango_layout_set_text (layout, buffer, -1);
+ pango_layout_set_text (layout, str, -1);
cairo_move_to (cr, x + 2, 4 - scroll_y);
pango_cairo_show_layout (cr, layout);
@@ -484,6 +490,7 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
g_object_unref (layout);
cairo_restore (cr);
+ g_free (str);
}
/* This paints the colored bars representing busy periods for the combined
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 36e7ad7d42..9957be998d 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -41,6 +41,7 @@
#include "misc/e-dateedit.h"
#include "e-util/e-util.h"
+#include "e-util/e-datetime-format.h"
#include "e-meeting-utils.h"
#include "e-meeting-list-view.h"
@@ -2327,10 +2328,11 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
GDate date;
gint max_date_width, longest_weekday_width, longest_month_width, width;
gint day, longest_weekday, month, longest_month;
- gchar buffer[128];
+ gchar buffer[128], *str;
const gchar *name;
PangoContext *pango_context;
PangoLayout *layout;
+ struct tm tm_time;
/* Set up Pango prerequisites */
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (mts));
@@ -2368,28 +2370,6 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
}
}
- /* See if we can use the full date. We want to use a date with a
- * month day > 20 and also the longest weekday. We use a
- * pre-calculated array of days for each month and add on the
- * weekday (which is 1 (Mon) to 7 (Sun). */
- g_date_set_dmy (&date, days[longest_month - 1] + longest_weekday,
- longest_month, 2000);
- /* This is a strftime() format string %A = full weekday name,
- * %B = full month name, %d = month day, %Y = full year. */
- g_date_strftime (buffer, sizeof (buffer), _("%A, %B %d, %Y"), &date);
-
-#if 0
- g_print ("longest_month: %i longest_weekday: %i date: %s\n",
- longest_month, longest_weekday, buffer);
-#endif
-
- pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_pixel_size (layout, &width, NULL);
- if (width < max_date_width) {
- mts->date_format = E_MEETING_TIME_SELECTOR_DATE_FULL;
- return;
- }
-
/* Now try it with abbreviated weekday names. */
longest_weekday_width = 0;
longest_weekday = G_DATE_MONDAY;
@@ -2405,16 +2385,28 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
g_date_set_dmy (&date, days[longest_month - 1] + longest_weekday,
longest_month, 2000);
- /* This is a strftime() format string %a = abbreviated weekday name,
- * %m = month number, %d = month day, %Y = full year. */
- g_date_strftime (buffer, sizeof (buffer), _("%a %m/%d/%Y"), &date);
+
+ g_date_to_struct_tm (&date, &tm_time);
+ str = e_datetime_format_format_tm ("calendar", "table", DTFormatKindDate, &tm_time);
+
+ g_return_if_fail (str != NULL);
+
+ if (!e_datetime_format_includes_day_name ("calendar", "table", DTFormatKindDate)) {
+ gchar *tmp;
+
+ g_date_strftime (buffer, sizeof (buffer), "%a", &date);
+
+ tmp = str;
+ str = g_strconcat (buffer, " ", str, NULL);
+ g_free (tmp);
+ }
#if 0
g_print ("longest_month: %i longest_weekday: %i date: %s\n",
- longest_month, longest_weekday, buffer);
+ longest_month, longest_weekday, str);
#endif
- pango_layout_set_text (layout, buffer, -1);
+ pango_layout_set_text (layout, str, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width < max_date_width)
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY;
@@ -2422,6 +2414,7 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_SHORT;
g_object_unref (layout);
+ g_free (str);
}
/* Turn off the background of the canvas windows. This reduces flicker
diff --git a/calendar/gui/e-meeting-time-sel.h b/calendar/gui/e-meeting-time-sel.h
index 7f45242006..7c3f7c3021 100644
--- a/calendar/gui/e-meeting-time-sel.h
+++ b/calendar/gui/e-meeting-time-sel.h
@@ -68,13 +68,13 @@
G_BEGIN_DECLS
/* This is used to specify the format used when displaying the dates.
- * The full format is like 'Sunday, September 12, 1999'. The abbreviated format
- * is like 'Sun 12/9/99'. The short format is like '12/9/99'. The actual
- * format used is determined in e_meeting_time_selector_style_set (), once we
- * know the font being used. */
+ * The abbreviated format is like 'Sun 12/9/99'.
+ * The short format is like '12/9/99'.
+ * The actual format used is determined in e_meeting_time_selector_style_set (),
+ * once we know the font being used.
+ */
typedef enum
{
- E_MEETING_TIME_SELECTOR_DATE_FULL,
E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY,
E_MEETING_TIME_SELECTOR_DATE_SHORT
} EMeetingTimeSelectorDateFormat;
diff --git a/e-util/e-datetime-format.c b/e-util/e-datetime-format.c
index c21d025794..877b170218 100644
--- a/e-util/e-datetime-format.c
+++ b/e-util/e-datetime-format.c
@@ -662,3 +662,25 @@ e_datetime_format_format_tm (const gchar *component,
return res;
}
+
+gboolean
+e_datetime_format_includes_day_name (const gchar *component, const gchar *part, DTFormatKind kind)
+{
+ gchar *key;
+ const gchar *fmt;
+ gboolean res;
+
+ g_return_val_if_fail (component != NULL, FALSE);
+ g_return_val_if_fail (*component != 0, FALSE);
+
+ key = gen_key (component, part, kind);
+ g_return_val_if_fail (key != NULL, FALSE);
+
+ fmt = get_format_internal (key, kind);
+
+ res = fmt && (strstr (fmt, "%a") != NULL || strstr (fmt, "%A") != NULL);
+
+ g_free (key);
+
+ return res;
+}
diff --git a/e-util/e-datetime-format.h b/e-util/e-datetime-format.h
index 2c19c65133..28eed151b3 100644
--- a/e-util/e-datetime-format.h
+++ b/e-util/e-datetime-format.h
@@ -39,6 +39,7 @@ void e_datetime_format_add_setup_widget (GtkWidget *table, gint row, const gchar
gchar *e_datetime_format_format (const gchar *component, const gchar *part, DTFormatKind kind, time_t value);
gchar *e_datetime_format_format_tm (const gchar *component, const gchar *part, DTFormatKind kind, struct tm *tm_time);
+gboolean e_datetime_format_includes_day_name (const gchar *component, const gchar *part, DTFormatKind kind);
G_END_DECLS