evolution r34774 - in trunk: addressbook addressbook/gui/contact-editor widgets/misc



Author: mcrha
Date: Mon Jan  7 11:42:51 2008
New Revision: 34774
URL: http://svn.gnome.org/viewvc/evolution?rev=34774&view=rev

Log:
2008-01-07  Milan Crha  <mcrha redhat com>

	** Fix for bug #339813

	* addressbook/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.

	* widgets/misc/e-dateedit.h: (e_date_edit_get_twodigit_year_can_future),
	(e_date_edit_set_twodigit_year_can_future):
	Added new option for component.
	* widgets/misc/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.
	* widgets/misc/e-dateedit.c: (on_date_entry_focus_out):
	Always repaint value on focus out.
	* widgets/misc/e-dateedit.c: (e_date_edit_update_date_entry):
	Forced to always show 4-digit year.

Note: Be sure you updated EDS too (revision 8343 and above)


Modified:
   trunk/addressbook/ChangeLog
   trunk/addressbook/gui/contact-editor/e-contact-editor.c
   trunk/widgets/misc/ChangeLog
   trunk/widgets/misc/e-dateedit.c
   trunk/widgets/misc/e-dateedit.h

Modified: trunk/addressbook/ChangeLog
==============================================================================
--- trunk/addressbook/ChangeLog	(original)
+++ trunk/addressbook/ChangeLog	Mon Jan  7 11:42:51 2008
@@ -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

Modified: trunk/addressbook/gui/contact-editor/e-contact-editor.c
==============================================================================
--- trunk/addressbook/gui/contact-editor/e-contact-editor.c	(original)
+++ trunk/addressbook/gui/contact-editor/e-contact-editor.c	Mon Jan  7 11:42:51 2008
@@ -3786,6 +3786,7 @@
 					   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) {

Modified: trunk/widgets/misc/ChangeLog
==============================================================================
--- trunk/widgets/misc/ChangeLog	(original)
+++ trunk/widgets/misc/ChangeLog	Mon Jan  7 11:42:51 2008
@@ -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

Modified: trunk/widgets/misc/e-dateedit.c
==============================================================================
--- trunk/widgets/misc/e-dateedit.c	(original)
+++ trunk/widgets/misc/e-dateedit.c	Mon Jan  7 11:42:51 2008
@@ -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 @@
 	EDateEditGetTimeCallback time_callback;
 	gpointer time_callback_data;
 	GtkDestroyNotify time_callback_destroy;
+
+	gboolean twodigit_year_can_future;
 };
 
 enum {
@@ -296,6 +296,8 @@
 	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 @@
 			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 @@
 		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 @@
 	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 @@
 	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 @@
 
 	return GTK_WIDGET(priv->date_entry);
 }
-

Modified: trunk/widgets/misc/e-dateedit.h
==============================================================================
--- trunk/widgets/misc/e-dateedit.h	(original)
+++ trunk/widgets/misc/e-dateedit.h	Mon Jan  7 11:42:51 2008
@@ -169,6 +169,10 @@
 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]