aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c1
-rw-r--r--widgets/misc/ChangeLog17
-rw-r--r--widgets/misc/e-dateedit.c48
-rw-r--r--widgets/misc/e-dateedit.h4
5 files changed, 70 insertions, 7 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index e2e91e36e0..3fe5f989ad 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-07 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #339813
+
+ * gui/contact-editor/e-contact-editor.c: (e_contact_editor_create_date):
+ Setting new option 'e_date_edit_set_twodigit_year_can_future' to FALSE.
+
2008-01-06 Michael Monreal <michael.monreal@gmx.net>
** Fix for bug #492188
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 9a78f9c381..3972889d6c 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -3786,6 +3786,7 @@ e_contact_editor_create_date(gchar *name,
TRUE);
e_date_edit_set_show_time (E_DATE_EDIT (widget), FALSE);
e_date_edit_set_time (E_DATE_EDIT (widget), -1);
+ e_date_edit_set_twodigit_year_can_future (E_DATE_EDIT (widget), FALSE);
a11y = gtk_widget_get_accessible (e_date_edit_get_entry (E_DATE_EDIT(widget)));
if (a11y != NULL) {
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index c05701c48a..e40195bdeb 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,20 @@
+2008-01-07 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #339813
+
+ * e-dateedit.h: (e_date_edit_get_twodigit_year_can_future),
+ (e_date_edit_set_twodigit_year_can_future):
+ Added new option for component.
+ * e-dateedit.c: (e_date_edit_get_twodigit_year_can_future),
+ (e_date_edit_set_twodigit_year_can_future),
+ (struct _EDateEditPrivate::twodigit_year_can_future),
+ (e_date_edit_init), (e_date_edit_parse_date):
+ Implementing new option for component.
+ * e-dateedit.c: (on_date_entry_focus_out):
+ Always repaint value on focus out.
+ * e-dateedit.c: (e_date_edit_update_date_entry):
+ Forced to always show 4-digit year.
+
2008-01-04 Milan Crha <mcrha@redhat.com>
* Part of bug #504480
diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c
index 60aa752ceb..1a49bf2bfa 100644
--- a/widgets/misc/e-dateedit.c
+++ b/widgets/misc/e-dateedit.c
@@ -65,8 +65,6 @@
#include <e-util/e-util.h>
#include "e-calendar.h"
-
-
struct _EDateEditPrivate {
GtkWidget *date_entry;
GtkWidget *date_button;
@@ -128,6 +126,8 @@ struct _EDateEditPrivate {
EDateEditGetTimeCallback time_callback;
gpointer time_callback_data;
GtkDestroyNotify time_callback_destroy;
+
+ gboolean twodigit_year_can_future;
};
enum {
@@ -296,6 +296,8 @@ e_date_edit_init (EDateEdit *dedit)
priv->time_callback_data = NULL;
priv->time_callback_destroy = NULL;
+ priv->twodigit_year_can_future = TRUE;
+
create_children (dedit);
/* Set it to the current time. */
@@ -1476,9 +1478,21 @@ e_date_edit_parse_date (EDateEdit *dedit,
const gchar *date_text,
struct tm *date_tm)
{
- if (e_time_parse_date (date_text, date_tm) != E_TIME_PARSE_OK)
+ gboolean twodigit_year = FALSE;
+
+ if (e_time_parse_date_ex (date_text, date_tm, &twodigit_year) != E_TIME_PARSE_OK)
return FALSE;
+ if (twodigit_year && !dedit->priv->twodigit_year_can_future) {
+ time_t t = time (NULL);
+ struct tm *today_tm = localtime (&t);
+
+ /* it was only 2 digit year in dedit and it was interpreted as in the future,
+ but we don't want it as this, so decrease by 100 years to last century */
+ if (date_tm->tm_year > today_tm->tm_year)
+ date_tm->tm_year -= 100;
+ }
+
return TRUE;
}
@@ -1645,6 +1659,9 @@ on_date_entry_focus_out (GtkEntry *entry,
e_date_edit_set_date (dedit,tmp_tm.tm_year,tmp_tm.tm_mon,tmp_tm.tm_mday);
gtk_widget_grab_focus (GTK_WIDGET (entry));
return FALSE;
+ } else {
+ e_date_edit_get_date (dedit,&tmp_tm.tm_year,&tmp_tm.tm_mon,&tmp_tm.tm_mday);
+ e_date_edit_set_date (dedit,tmp_tm.tm_year,tmp_tm.tm_mon,tmp_tm.tm_mday);
}
return FALSE;
}
@@ -1727,14 +1744,18 @@ e_date_edit_update_date_entry (EDateEdit *dedit)
if (priv->date_set_to_none || !priv->date_is_valid) {
gtk_entry_set_text (GTK_ENTRY (priv->date_entry), _("None"));
} else {
+ /* This is a strftime() format for a short date.
+ %x the preferred date representation for the current locale without the time,
+ but has forced to use 4 digit year */
+ char *format = e_time_get_d_fmt_with_4digit_year ();
+
tmp_tm.tm_year = priv->year;
tmp_tm.tm_mon = priv->month;
tmp_tm.tm_mday = priv->day;
tmp_tm.tm_isdst = -1;
- /* This is a strftime() format for a short date.
- %x the preferred date representation for the current locale without the time*/
- e_utf8_strftime (buffer, sizeof (buffer), "%x", &tmp_tm);
+ e_utf8_strftime (buffer, sizeof (buffer), format, &tmp_tm);
+ g_free (format);
gtk_entry_set_text (GTK_ENTRY (priv->date_entry), buffer);
}
@@ -2108,6 +2129,20 @@ e_date_edit_set_time_internal (EDateEdit *dedit,
return time_changed;
}
+gboolean e_date_edit_get_twodigit_year_can_future (EDateEdit *dedit)
+{
+ g_return_val_if_fail (dedit != NULL, FALSE);
+
+ return dedit->priv->twodigit_year_can_future;
+}
+
+void e_date_edit_set_twodigit_year_can_future (EDateEdit *dedit,
+ gboolean value)
+{
+ g_return_if_fail (dedit != NULL);
+
+ dedit->priv->twodigit_year_can_future = value;
+}
/* Sets a callback to use to get the current time. This is useful if the
application needs to use its own timezone data rather than rely on the
@@ -2141,4 +2176,3 @@ e_date_edit_get_entry (EDateEdit *dedit)
return GTK_WIDGET(priv->date_entry);
}
-
diff --git a/widgets/misc/e-dateedit.h b/widgets/misc/e-dateedit.h
index 3f8def7146..29005a575b 100644
--- a/widgets/misc/e-dateedit.h
+++ b/widgets/misc/e-dateedit.h
@@ -169,6 +169,10 @@ gboolean e_date_edit_get_make_time_insensitive(EDateEdit *dedit);
void e_date_edit_set_make_time_insensitive(EDateEdit *dedit,
gboolean make_insensitive);
+/* Whether two-digit years in date could be modified as in future; default is TRUE */
+gboolean e_date_edit_get_twodigit_year_can_future (EDateEdit *dedit);
+void e_date_edit_set_twodigit_year_can_future (EDateEdit *dedit,
+ gboolean value);
/* Sets a callback to use to get the current time. This is useful if the
application needs to use its own timezone data rather than rely on the