[evolution-patches] [IMPROVED PATCH]bug#55208:warn user about wrong birthdate and anniversary format in contacts



This patch for bug#55208 warns user about wrong birthdate and
anniversary giving an example of the correct format and allows him to
re-enter valid date.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1638
diff -u -r1.1638 ChangeLog
--- ChangeLog	7 Apr 2004 19:29:34 -0000	1.1638
+++ ChangeLog	8 Apr 2004 12:21:50 -0000
@@ -1,3 +1,9 @@
+2004-04-08 S N Tejasvi <tejasvi_sn rediffmail com>
+
+       * gui/contact-editor/e-contact-editor.c (save_contact):
+       do e_contact_editor_is_valid check to check the birth date and
+	anniversary date format when user wants to save and warn him.
+
2004-04-07  Chris Toshok  <toshok ximian com>
 
 	* util/e-destination.c (e_destination_copy): we don't have an
Index: gui/contact-editor/e-contact-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/e-contact-editor.c,v
retrieving revision 1.177
diff -u -r1.177 e-contact-editor.c
--- gui/contact-editor/e-contact-editor.c	31 Mar 2004 03:36:50 -0000	1.177
+++ gui/contact-editor/e-contact-editor.c	8 Apr 2004 12:25:02 -0000
@@ -1618,14 +1618,15 @@
 save_contact (EContactEditor *ce, gboolean should_close)
 {
 	EditorCloseStruct *ecs = g_new(EditorCloseStruct, 1);
-
 	extract_info (ce);
 	if (!ce->target_book)
 		return;
 
+	if(!e_contact_editor_is_valid(EAB_EDITOR(ce)))
+        	return;
+
 	ecs->ce = ce;
 	g_object_ref (ecs->ce);
-
 	ecs->should_close = should_close;
 
 	gtk_widget_set_sensitive (ce->app, FALSE);
@@ -1661,8 +1662,41 @@
 static gboolean
 e_contact_editor_is_valid (EABEditor *editor)
 {
+
 	/* insert checks here (date format, for instance, etc.) */
-	return TRUE;
+        EContactEditor *ce = E_CONTACT_EDITOR (editor);
+	GtkWidget *dialog,*widget;
+	gint result,err1 = 0,err2 = 0;
+	char *errmsg = _("The following entries are invalid:\n\n");
+
+        widget = glade_xml_get_widget (ce->gui, "dateedit-birthday");
+
+	if(!(e_date_edit_date_is_valid (E_DATE_EDIT (widget))))
+	{		
+		errmsg = g_strconcat (errmsg,"Birthdate:\n  Example: 04/04/2004\n\n",NULL);
+       		err1 = 1;
+	}
+	widget = glade_xml_get_widget (ce->gui, "dateedit-anniversary");
+
+	if(!(e_date_edit_date_is_valid (E_DATE_EDIT (widget))))
+        {
+                errmsg = g_strconcat (errmsg,"Anniversary:\n  Example: 04/04/2004\n",NULL);
+		err2 = 1;
+	}
+
+	if(err1 || err2)
+	{
+				dialog=gtk_message_dialog_new (GTK_WINDOW (ce->app),
+                	                                           0,
+                        	                                   GTK_MESSAGE_INFO,
+                                	                           GTK_BUTTONS_OK,
+                                        	                   errmsg);
+                                result=gtk_dialog_run (GTK_DIALOG (dialog));
+                                gtk_widget_destroy (dialog);
+				return FALSE;
+	}
+        	else
+                                return TRUE;
 }
 



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