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




This patch for bug#55208,warns user about wrong birthdate and
anniversary formats giving him the correct format and allows him to
re-enter the correct dates.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1656
diff -u -r1.1656 ChangeLog
--- ChangeLog	18 Apr 2004 07:01:50 -0000	1.1656
+++ ChangeLog	18 Apr 2004 09:16:28 -0000
@@ -1,3 +1,11 @@
+2004-04-18  S N Tejasvi  <tejasvi_sn gawab com>
+	
+	[ fixes bug #55208 ]
+
+	* 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-18  Chris Toshok  <toshok ximian com>
 
 	* gui/contact-editor/e-contact-editor.c (nonempty): new macro.
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.180
diff -u -r1.180 e-contact-editor.c
--- gui/contact-editor/e-contact-editor.c	18 Apr 2004 07:01:50 -0000	1.180
+++ gui/contact-editor/e-contact-editor.c	18 Apr 2004 09:18:39 -0000
@@ -1421,6 +1421,9 @@
 	if (!ce->target_book)
 		return;
	 
+	if (!e_contact_editor_is_valid (EAB_EDITOR (ce)))
+		return;
+
 	ecs->ce = ce;
 	g_object_ref (ecs->ce);
 
@@ -1460,7 +1463,43 @@
 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;
+       }
 }
 
 static gboolean


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