From c81e771e3bcafa9913f3b01a4f3d000e0933e883 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 5 Nov 2001 20:12:44 +0000 Subject: Based on a patch by Damon Chaplin 2001-11-05 Christopher James Lahey Based on a patch by Damon Chaplin * e-cell-date-edit.c: Connect to the button_press signal on the popup and do the grab correctly so that this dialog behaves properly when the user clicks it away. Also, changed all instances of setting of popup_shown field of ECellPopup to call e_cell_popup_set_shown. Fixes Ximian bug #14016. svn path=/trunk/; revision=14594 --- widgets/misc/ChangeLog | 10 ++++++++++ widgets/misc/e-cell-date-edit.c | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 7 deletions(-) (limited to 'widgets') diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 254cdf9bfb..a9c6d0eacd 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,13 @@ +2001-11-05 Christopher James Lahey + +Based on a patch by Damon Chaplin + + * e-cell-date-edit.c: Connect to the button_press signal on the + popup and do the grab correctly so that this dialog behaves + properly when the user clicks it away. Also, changed all + instances of setting of popup_shown field of ECellPopup to call + e_cell_popup_set_shown. Fixes Ximian bug #14016. + 2001-10-31 * e-filter-bar.c (build_items): Snotty code so we only disconnect diff --git a/widgets/misc/e-cell-date-edit.c b/widgets/misc/e-cell-date-edit.c index 88203d006d..4d775617ea 100644 --- a/widgets/misc/e-cell-date-edit.c +++ b/widgets/misc/e-cell-date-edit.c @@ -77,6 +77,9 @@ static void e_cell_date_edit_rebuild_time_list (ECellDateEdit *ecde); static int e_cell_date_edit_key_press (GtkWidget *popup_window, GdkEventKey *event, ECellDateEdit *ecde); +static int e_cell_date_edit_button_press (GtkWidget *popup_window, + GdkEventButton *event, + ECellDateEdit *ecde); static void e_cell_date_edit_on_ok_clicked (GtkWidget *button, ECellDateEdit *ecde); static void e_cell_date_edit_show_time_invalid_warning (ECellDateEdit *ecde); @@ -92,6 +95,7 @@ static void e_cell_date_edit_on_time_selected (GtkList *list, ECellDateEdit *ecde); static void e_cell_date_edit_hide_popup (ECellDateEdit *ecde); + /* Our arguments. */ enum { ARG_0, @@ -263,6 +267,10 @@ e_cell_date_edit_init (ECellDateEdit *ecde) "key_press_event", GTK_SIGNAL_FUNC (e_cell_date_edit_key_press), ecde); + gtk_signal_connect (GTK_OBJECT (ecde->popup_window), + "button_press_event", + GTK_SIGNAL_FUNC (e_cell_date_edit_button_press), + ecde); } @@ -435,8 +443,12 @@ e_cell_date_edit_do_popup (ECellPopup *ecp, time = event->key.time; } + gdk_keyboard_grab (ecde->popup_window->window, TRUE, time); gtk_grab_add (ecde->popup_window); + /* Set the focus to the first widget. */ + gtk_widget_grab_focus (ecde->time_entry); + return TRUE; } @@ -554,10 +566,7 @@ e_cell_date_edit_show_popup (ECellDateEdit *ecde, gdk_window_resize (ecde->popup_window->window, width, height); gtk_widget_show (ecde->popup_window); - /* Set the focus to the first widget. */ - gtk_widget_grab_focus (ecde->time_entry); - - E_CELL_POPUP (ecde)->popup_shown = TRUE; + e_cell_popup_set_shown (E_CELL_POPUP (ecde), TRUE); } @@ -657,6 +666,25 @@ e_cell_date_edit_key_press (GtkWidget *popup_window, } +/* This handles button press events in the popup window. If the button is + pressed outside the popup, we hide it and do not change the cell contents. +*/ +static int +e_cell_date_edit_button_press (GtkWidget *popup_window, + GdkEventButton *event, + ECellDateEdit *ecde) +{ + GtkWidget *event_widget; + + event_widget = gtk_get_event_widget ((GdkEvent*) event); + if (gtk_widget_get_toplevel (event_widget) != popup_window) { + e_cell_date_edit_hide_popup (ecde); + } + + return TRUE; +} + + /* Clears the time list and rebuilds it using the lower_hour, upper_hour and use_24_hour_format settings. */ static void @@ -891,7 +919,7 @@ e_cell_date_edit_hide_popup (ECellDateEdit *ecde) { gtk_grab_remove (ecde->popup_window); gtk_widget_hide (ecde->popup_window); - E_CELL_POPUP (ecde)->popup_shown = FALSE; + e_cell_popup_set_shown (E_CELL_POPUP (ecde), FALSE); } @@ -939,5 +967,3 @@ e_cell_date_edit_set_get_time_callback (ECellDateEdit *ecde, ecde->time_callback_data = data; ecde->time_callback_destroy = destroy; } - - -- cgit v1.2.3