[evolution/gnome-3-34] I#681 - Cannot type the date of a meeting ][
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-34] I#681 - Cannot type the date of a meeting ][
- Date: Tue, 3 Dec 2019 14:23:10 +0000 (UTC)
commit 71508e7dbfd596d411177c68f13e494ca6cc70b7
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 3 15:17:54 2019 +0100
I#681 - Cannot type the date of a meeting ][
Extends the initial fix to cover auto-select in GtkEntry and
better report errors with time portion of the date/time.
Closes https://gitlab.gnome.org/GNOME/evolution/issues/681
src/calendar/gui/e-comp-editor-event.c | 6 ++--
src/calendar/gui/e-comp-editor-property-part.c | 21 ++++++++++--
src/calendar/gui/e-comp-editor.c | 14 +++++---
src/e-util/e-dateedit.c | 44 ++++++++++++++++++--------
src/e-util/e-dateedit.h | 2 ++
5 files changed, 64 insertions(+), 23 deletions(-)
---
diff --git a/src/calendar/gui/e-comp-editor-event.c b/src/calendar/gui/e-comp-editor-event.c
index 34ef34bbfd..bac3c84ca7 100644
--- a/src/calendar/gui/e-comp-editor-event.c
+++ b/src/calendar/gui/e-comp-editor-event.c
@@ -67,14 +67,14 @@ ece_event_update_times (ECompEditorEvent *event_editor,
EDateEdit *date_edit,
gboolean change_end_datetime)
{
- GtkWidget *widget;
guint flags;
g_return_if_fail (E_IS_COMP_EDITOR_EVENT (event_editor));
g_return_if_fail (E_IS_DATE_EDIT (date_edit));
- widget = e_date_edit_get_entry (date_edit);
- if (widget && gtk_widget_has_focus (widget))
+ if (e_date_edit_has_focus (date_edit) ||
+ !e_date_edit_date_is_valid (date_edit) ||
+ !e_date_edit_time_is_valid (date_edit))
return;
if (!e_comp_editor_get_updating (E_COMP_EDITOR (event_editor))) {
diff --git a/src/calendar/gui/e-comp-editor-property-part.c b/src/calendar/gui/e-comp-editor-property-part.c
index b9bb326cc6..1cbef9352c 100644
--- a/src/calendar/gui/e-comp-editor-property-part.c
+++ b/src/calendar/gui/e-comp-editor-property-part.c
@@ -668,6 +668,23 @@ ecepp_datetime_get_current_time_cb (EDateEdit *date_edit,
return tm;
}
+static void
+ecepp_datetime_changed_cb (ECompEditorPropertyPart *property_part)
+{
+ GtkWidget *edit_widget;
+
+ g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME (property_part));
+
+ edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
+
+ if (!edit_widget || e_date_edit_has_focus (E_DATE_EDIT (edit_widget)) ||
+ !e_date_edit_date_is_valid (E_DATE_EDIT (edit_widget)) ||
+ !e_date_edit_time_is_valid (E_DATE_EDIT (edit_widget)))
+ return;
+
+ e_comp_editor_property_part_emit_changed (property_part);
+}
+
static void
ecepp_datetime_create_widgets (ECompEditorPropertyPart *property_part,
GtkWidget **out_label_widget,
@@ -700,9 +717,9 @@ ecepp_datetime_create_widgets (ECompEditorPropertyPart *property_part,
e_weak_ref_new (property_part), (GDestroyNotify) e_weak_ref_free);
g_signal_connect_swapped (*out_edit_widget, "changed",
- G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
+ G_CALLBACK (ecepp_datetime_changed_cb), property_part);
g_signal_connect_swapped (*out_edit_widget, "notify::show-time",
- G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
+ G_CALLBACK (ecepp_datetime_changed_cb), property_part);
}
static void
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index 015d66d796..f4c27fde34 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -112,10 +112,10 @@ ece_restore_focus (ECompEditor *comp_editor)
g_return_if_fail (E_IS_COMP_EDITOR (comp_editor));
if (comp_editor->priv->restore_focus) {
- gtk_widget_grab_focus (comp_editor->priv->restore_focus);
-
if (GTK_IS_ENTRY (comp_editor->priv->restore_focus))
- gtk_editable_set_position (GTK_EDITABLE (comp_editor->priv->restore_focus), 0);
+ gtk_entry_grab_focus_without_selecting (GTK_ENTRY (comp_editor->priv->restore_focus));
+ else
+ gtk_widget_grab_focus (comp_editor->priv->restore_focus);
comp_editor->priv->restore_focus = NULL;
}
@@ -2683,8 +2683,12 @@ e_comp_editor_fill_component (ECompEditor *comp_editor,
is_valid = comp_editor_class->fill_component (comp_editor, component);
- if (focused_widget)
- gtk_window_set_focus (GTK_WINDOW (comp_editor), focused_widget);
+ if (focused_widget) {
+ if (GTK_IS_ENTRY (focused_widget))
+ gtk_entry_grab_focus_without_selecting (GTK_ENTRY (focused_widget));
+ else
+ gtk_widget_grab_focus (focused_widget);
+ }
if (is_valid && comp_editor->priv->validation_alert) {
e_alert_response (comp_editor->priv->validation_alert, GTK_RESPONSE_CLOSE);
diff --git a/src/e-util/e-dateedit.c b/src/e-util/e-dateedit.c
index 44abed3bae..0718a47133 100644
--- a/src/e-util/e-dateedit.c
+++ b/src/e-util/e-dateedit.c
@@ -526,6 +526,13 @@ e_date_edit_new (void)
return GTK_WIDGET (dedit);
}
+static void
+on_time_entry_changed_cb (GtkEditable *editable,
+ EDateEdit *dedit)
+{
+ e_date_edit_check_time_changed (dedit);
+}
+
static void
create_children (EDateEdit *dedit)
{
@@ -636,6 +643,9 @@ create_children (EDateEdit *dedit)
g_signal_connect_after (
child, "focus_out_event",
G_CALLBACK (on_time_entry_focus_out), dedit);
+ g_signal_connect (
+ child, "changed",
+ G_CALLBACK (on_time_entry_changed_cb), dedit);
g_signal_connect_after (
priv->time_combo, "changed",
G_CALLBACK (on_date_edit_time_selected), dedit);
@@ -2010,8 +2020,7 @@ on_date_entry_focus_out (GtkEntry *entry,
if (!e_date_edit_date_is_valid (dedit)) {
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning");
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, _("Invalid Date Value"));
- gtk_widget_grab_focus (GTK_WIDGET (entry));
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ gtk_entry_grab_focus_without_selecting (entry);
return FALSE;
} else if (e_date_edit_get_date (
dedit, &tmp_tm.tm_year, &tmp_tm.tm_mon, &tmp_tm.tm_mday)) {
@@ -2044,13 +2053,12 @@ on_time_entry_focus_out (GtkEntry *entry,
e_date_edit_check_time_changed (dedit);
if (!e_date_edit_time_is_valid (dedit)) {
- gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning");
- gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, _("Invalid Time Value"));
- gtk_widget_grab_focus (GTK_WIDGET (entry));
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, "dialog-warning");
+ gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, _("Invalid Time Value"));
+ gtk_entry_grab_focus_without_selecting (entry);
} else {
- gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
- gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
+ gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
+ gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
}
return FALSE;
@@ -2350,7 +2358,7 @@ e_date_edit_check_time_changed (EDateEdit *dedit)
tmp_tm.tm_min);
if (time_changed) {
- e_date_edit_update_time_entry (dedit);
+ /* Do not call e_date_edit_update_time_entry (dedit); let the user correct the value */
g_signal_emit (dedit, signals[CHANGED], 0);
}
}
@@ -2517,11 +2525,11 @@ e_date_edit_set_time_internal (EDateEdit *dedit,
entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dedit->priv->time_combo)));
if (priv->time_is_valid) {
- gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
- gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
+ gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
+ gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
} else {
- gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning");
- gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, _("Invalid Time
Value"));
+ gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, "dialog-warning");
+ gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, _("Invalid Time
Value"));
}
}
@@ -2576,3 +2584,13 @@ e_date_edit_get_entry (EDateEdit *dedit)
return GTK_WIDGET (dedit->priv->date_entry);
}
+
+gboolean
+e_date_edit_has_focus (EDateEdit *dedit)
+{
+ g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
+
+ return gtk_widget_has_focus (GTK_WIDGET (dedit)) ||
+ (dedit->priv->date_entry && gtk_widget_has_focus (dedit->priv->date_entry)) ||
+ (dedit->priv->time_combo && gtk_widget_has_focus (dedit->priv->time_combo));
+}
diff --git a/src/e-util/e-dateedit.h b/src/e-util/e-dateedit.h
index 128270bd51..26fc20993b 100644
--- a/src/e-util/e-dateedit.h
+++ b/src/e-util/e-dateedit.h
@@ -211,6 +211,8 @@ void e_date_edit_set_get_time_callback
GtkWidget * e_date_edit_get_entry (EDateEdit *dedit);
+gboolean e_date_edit_has_focus (EDateEdit *dedit);
+
G_END_DECLS
#endif /* E_DATE_EDIT_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]