From 77cf09208aa0fecdc7eaf20adee4ee4125ab5cf5 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Thu, 24 Nov 2005 06:24:01 +0000 Subject: Commiting Johnny Jacob's patch on EDateEdit 2005-11-24 Srinivasa Ragavan * Commiting Johnny Jacob's patch on EDateEdit svn path=/trunk/; revision=30652 --- widgets/misc/e-dateedit.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'widgets/misc/e-dateedit.c') diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c index 258ad5b20e..1cae770ed4 100644 --- a/widgets/misc/e-dateedit.c +++ b/widgets/misc/e-dateedit.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -147,6 +148,9 @@ static void e_date_edit_grab_focus (GtkWidget *widget); static gint on_date_entry_key_press (GtkWidget *widget, GdkEventKey *event, EDateEdit *dedit); +static gint on_date_entry_key_release (GtkWidget *widget, + GdkEventKey *event, + EDateEdit *dedit); static void on_date_button_clicked (GtkWidget *widget, EDateEdit *dedit); static void e_date_edit_show_date_popup (EDateEdit *dedit); @@ -340,6 +344,9 @@ create_children (EDateEdit *dedit) g_signal_connect (priv->date_entry, "key_press_event", G_CALLBACK (on_date_entry_key_press), dedit); + g_signal_connect (priv->date_entry, "key_release_event", + G_CALLBACK (on_date_entry_key_release), + dedit); g_signal_connect_after (priv->date_entry, "focus_out_event", G_CALLBACK (on_date_entry_focus_out), @@ -1586,6 +1593,15 @@ on_time_entry_key_press (GtkWidget *widget, return FALSE; } +static gint +on_date_entry_key_release (GtkWidget *widget, + GdkEventKey *event, + EDateEdit *dedit) +{ + e_date_edit_check_date_changed (dedit); + return TRUE; +} + static gint on_time_entry_key_release (GtkWidget *widget, GdkEventKey *event, @@ -1597,7 +1613,7 @@ on_time_entry_key_release (GtkWidget *widget, e_date_edit_check_time_changed (dedit); return TRUE; } - + e_date_edit_check_time_changed (dedit); return FALSE; } @@ -1607,7 +1623,28 @@ on_date_entry_focus_out (GtkEntry *entry, GdkEventFocus *event, EDateEdit *dedit) { + struct tm tmp_tm; + GtkMessageDialog *msg_dialog; + + tmp_tm.tm_year = 0; + tmp_tm.tm_mon = 0; + tmp_tm.tm_mday = 0; + e_date_edit_check_date_changed (dedit); + + if (!e_date_edit_date_is_valid (dedit)) { + msg_dialog = gtk_message_dialog_new(NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Invalid Date Value"); + gtk_dialog_run (GTK_DIALOG(msg_dialog)); + gtk_widget_destroy (msg_dialog); + 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); + gtk_widget_grab_focus (entry); + return FALSE; + } return FALSE; } @@ -1617,7 +1654,22 @@ on_time_entry_focus_out (GtkEntry *entry, GdkEventFocus *event, EDateEdit *dedit) { + GtkMessageDialog *msg_dialog; + e_date_edit_check_time_changed (dedit); + + if (!e_date_edit_time_is_valid (dedit)) { + msg_dialog=gtk_message_dialog_new(NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Invalid Time Value"); + gtk_dialog_run (GTK_DIALOG(msg_dialog)); + gtk_widget_destroy (msg_dialog); + e_date_edit_set_time (dedit,e_date_edit_get_time(dedit)); + gtk_widget_grab_focus (entry); + return FALSE; + } return FALSE; } -- cgit