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



This patch for bug#55208 warns user about wrong birthdate and
anniversary giving the correct format and allows him to re-enter valid
date.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1642
diff -u -r1.1642 ChangeLog
--- ChangeLog	9 Apr 2004 19:05:48 -0000	1.1642
+++ ChangeLog	10 Apr 2004 15:41:20 -0000
@@ -1,3 +1,9 @@
+2004-04-09  S N Tejasvi <tejasvi_sn gawab 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-09  Chris Toshok  <toshok ximian com>
 
 	* gui/component/addressbook-migrate.c (addressbook_migrate): bump
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	10 Apr 2004 15:42:47 -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);
@@ -1662,7 +1663,42 @@
 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;
+	gboolean validation_error = FALSE;
+	gint result;
+	GString *errmsg = g_string_new (_("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)))) {
+		g_string_append_printf (errmsg,"%s: %s",
+						e_contact_pretty_name (E_CONTACT_BIRTH_DATE),
+						_("Example: 04/04/2004\n\n"));
+       		validation_error = TRUE;
+	}
+
+	widget = glade_xml_get_widget (ce->gui, "dateedit-anniversary");
+	if(!(e_date_edit_date_is_valid (E_DATE_EDIT (widget)))) {
+                g_string_append_printf (errmsg,"%s: %s",
+                                                e_contact_pretty_name (E_CONTACT_ANNIVERSARY),
+                                                _("Example: 04/04/2004\n\n"));
+		validation_error = TRUE;
+	}
+
+	if(validation_error) {
+		dialog = gtk_message_dialog_new (GTK_WINDOW (ce->app),
+								   0,
+                        	                                   GTK_MESSAGE_INFO,
+								   GTK_BUTTONS_OK,
+								   errmsg->str);
+                               result = gtk_dialog_run (GTK_DIALOG (dialog));
+                               gtk_widget_destroy (dialog);
+				g_string_free (errmsg, TRUE);
+				return FALSE;
+	}
+        	else
+				g_string_free (errmsg, TRUE);
+                               return TRUE;
 }
 



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