From b6313289303f2263649c70ea477e04aea4a994ec Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 4 Aug 2009 15:04:02 +0200 Subject: Bug #205137 - Configurable date formats in components --- calendar/gui/dialogs/cal-prefs-dialog.c | 8 ++- calendar/gui/dialogs/cal-prefs-dialog.glade | 79 +++++++++++++++++++++++++++++ calendar/gui/e-cal-list-view.c | 6 +++ calendar/gui/e-calendar-table.c | 5 ++ calendar/gui/e-calendar-view.c | 8 +-- calendar/gui/e-cell-date-edit-text.c | 7 +-- calendar/gui/e-memo-table.c | 5 ++ 7 files changed, 106 insertions(+), 12 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 2c19acaadd..2fc17202cc 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -31,6 +31,7 @@ #include "../calendar-config.h" #include "cal-prefs-dialog.h" #include +#include "e-util/e-datetime-format.h" #include #include #include @@ -779,7 +780,7 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs) ECalConfig *ec; ECalConfigTargetPrefs *target; gint i; - GtkWidget *toplevel; + GtkWidget *toplevel, *table; GSList *l; const gchar *working_day_names[] = { "sun_button", @@ -859,6 +860,11 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs) toplevel = e_config_create_widget ((EConfig *)ec); gtk_container_add (GTK_CONTAINER (prefs), toplevel); + /* date/time format */ + table = glade_xml_get_widget (gui, "datetime_format_table"); + e_datetime_format_add_setup_widget (table, 0, "calendar", "table", DTFormatKindDateTime, _("Time and date:")); + e_datetime_format_add_setup_widget (table, 1, "calendar", "table", DTFormatKindDate, _("Date only:")); + show_config (prefs); /* FIXME: weakref? */ setup_changes (prefs); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index 63e9e6092f..984e509b64 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -1024,6 +1024,85 @@ Days 3 + + + + True + <span weight="bold">Date/Time Format</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + 1 + 3 + False + 0 + 0 + + + 0 + True + True + + + + + 0 + True + True + + 1 diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 0081dc1340..1da7f16037 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -40,6 +40,7 @@ #include #include
#include
+#include
#include #include #include @@ -256,6 +257,11 @@ setup_e_table (ECalListView *cal_list_view) e_table_extras_add_compare (extras, "date-compare", date_compare_cb); + + /* set proper format component for a default 'date' cell renderer */ + cell = e_table_extras_get_cell (extras, "date"); + e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); + /* Create table view */ etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 70f347bae3..284922c029 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -42,6 +42,7 @@ #include
#include
#include
+#include
#include #include #include @@ -687,6 +688,10 @@ e_calendar_table_init (ECalendarTable *cal_table) e_table_extras_add_pixbuf(extras, "complete", pixbuf); g_object_unref(pixbuf); + /* set proper format component for a default 'date' cell renderer */ + cell = e_table_extras_get_cell (extras, "date"); + e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); + /* Create the table */ etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index cd42454d64..286db6b5f1 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -2222,16 +2223,11 @@ tooltip_grab (GtkWidget *tooltip, GdkEventKey *event, ECalendarView *view) static gchar * get_label (struct icaltimetype *tt, icaltimezone *f_zone, icaltimezone *t_zone) { - gchar buffer[1000]; struct tm tmp_tm; tmp_tm = icaltimetype_to_tm_with_zone (tt, f_zone, t_zone); - e_time_format_date_and_time (&tmp_tm, - calendar_config_get_24_hour_format (), - FALSE, FALSE, - buffer, 1000); - return g_strdup (buffer); + return e_datetime_format_format_tm ("calendar", "table", DTFormatKindDateTime, &tmp_tm); } void diff --git a/calendar/gui/e-cell-date-edit-text.c b/calendar/gui/e-cell-date-edit-text.c index 64dd48ddf1..5836b8ac66 100644 --- a/calendar/gui/e-cell-date-edit-text.c +++ b/calendar/gui/e-cell-date-edit-text.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "e-cell-date-edit-text.h" @@ -63,7 +64,6 @@ ecd_get_text (ECellText *cell, ETableModel *model, gint col, gint row) ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell); ECellDateEditValue *dv = e_table_model_value_at (model, col, row); struct tm tmp_tm; - gchar buffer[64]; if (!dv) return g_strdup (""); @@ -74,10 +74,7 @@ ecd_get_text (ECellText *cell, ETableModel *model, gint col, gint row) it will be set to the current timezone. See set_value(). */ tmp_tm = icaltimetype_to_tm_with_zone (&dv->tt, dv->zone, ecd->zone); - e_time_format_date_and_time (&tmp_tm, ecd->use_24_hour_format, - !dv->tt.is_date, FALSE, - buffer, sizeof (buffer)); - return g_strdup (buffer); + return e_datetime_format_format_tm ("calendar", "table", dv->tt.is_date ? DTFormatKindDate : DTFormatKindDateTime, &tmp_tm); } static void diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 47b3d4410c..50158899ac 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -41,6 +41,7 @@ #include
#include
#include
+#include
#include #include #include @@ -255,6 +256,10 @@ e_memo_table_init (EMemoTable *memo_table) e_table_extras_add_cell(extras, "icon", cell); e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); + /* set proper format component for a default 'date' cell renderer */ + cell = e_table_extras_get_cell (extras, "date"); + e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); + /* Create the table */ etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, -- cgit v1.2.3