search-button: React to 'stop-search' signal
Quit the search entry state when the search entry emits stop-search, usually that's when Escape is pressed when the search entry is focused. Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/830
This commit is contained in:
@@ -76,6 +76,18 @@ hide_suggestions (GcalSearchButton *self)
|
|||||||
gtk_revealer_set_reveal_child (self->results_revealer, FALSE);
|
gtk_revealer_set_reveal_child (self->results_revealer, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
quit_search_entry (GcalSearchButton *self)
|
||||||
|
{
|
||||||
|
gtk_editable_set_width_chars (self->entry, 0);
|
||||||
|
gtk_editable_set_max_width_chars (self->entry, 0);
|
||||||
|
gtk_stack_set_visible_child_name (self->stack, "button");
|
||||||
|
|
||||||
|
hide_suggestions (self);
|
||||||
|
|
||||||
|
gtk_editable_set_text (self->entry, "");
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_widget_func (gpointer item,
|
create_widget_func (gpointer item,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -130,13 +142,7 @@ static void
|
|||||||
on_focus_controller_leave_cb (GtkEventControllerFocus *focus_controller,
|
on_focus_controller_leave_cb (GtkEventControllerFocus *focus_controller,
|
||||||
GcalSearchButton *self)
|
GcalSearchButton *self)
|
||||||
{
|
{
|
||||||
gtk_editable_set_width_chars (self->entry, 0);
|
quit_search_entry (self);
|
||||||
gtk_editable_set_max_width_chars (self->entry, 0);
|
|
||||||
gtk_stack_set_visible_child_name (self->stack, "button");
|
|
||||||
|
|
||||||
hide_suggestions (self);
|
|
||||||
|
|
||||||
gtk_editable_set_text (self->entry, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -190,6 +196,13 @@ on_entry_search_changed_cb (GtkSearchEntry *entry,
|
|||||||
GCAL_EXIT;
|
GCAL_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_entry_stop_search_cb (GtkSearchEntry *search_entry,
|
||||||
|
GcalSearchButton *self)
|
||||||
|
{
|
||||||
|
quit_search_entry (self);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_results_listbox_row_activated_cb (GtkListBox *listbox,
|
on_results_listbox_row_activated_cb (GtkListBox *listbox,
|
||||||
GcalSearchHitRow *row,
|
GcalSearchHitRow *row,
|
||||||
@@ -344,6 +357,7 @@ gcal_search_button_class_init (GcalSearchButtonClass *klass)
|
|||||||
gtk_widget_class_bind_template_callback (widget_class, on_button_clicked_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_button_clicked_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_focus_controller_leave_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_focus_controller_leave_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_entry_search_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_entry_search_changed_cb);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, on_entry_stop_search_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_results_listbox_row_activated_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_results_listbox_row_activated_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_results_revealer_child_reveal_state_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_results_revealer_child_reveal_state_changed_cb);
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
<property name="max-width-chars">0</property>
|
<property name="max-width-chars">0</property>
|
||||||
<property name="width-chars">0</property>
|
<property name="width-chars">0</property>
|
||||||
<signal name="search-changed" handler="on_entry_search_changed_cb" object="GcalSearchButton" swapped="no" />
|
<signal name="search-changed" handler="on_entry_search_changed_cb" object="GcalSearchButton" swapped="no" />
|
||||||
|
<signal name="stop-search" handler="on_entry_stop_search_cb" object="GcalSearchButton" swapped="no" />
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class='GtkShortcutController'>
|
<object class='GtkShortcutController'>
|
||||||
|
|||||||
Reference in New Issue
Block a user