[gtranslator: 8/10] search-bar: Create a stop-search signal
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator: 8/10] search-bar: Create a stop-search signal
- Date: Mon, 21 Mar 2022 07:03:15 +0000 (UTC)
commit 8805a5548b87bfc541507271c5822e1c47442024
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Wed Mar 16 01:12:17 2022 +0100
search-bar: Create a stop-search signal
Which will be used to hide the search bar. The app global keybinding for
Escape was disabled as its scope was bigger than necessary and could
cause undesirable behavior.
gtr_page_stop_search already handled this signal.
src/gtr-application.c | 13 -------------
src/gtr-search-bar.c | 43 +++++++++++++++----------------------------
2 files changed, 15 insertions(+), 41 deletions(-)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 25f24ba1..99c8aa5a 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -295,17 +295,6 @@ find_prev_activated (GSimpleAction *action,
gtr_tab_find_prev (active_tab);
}
-static void
-find_unactivated (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- GtrApplication *app = GTR_APPLICATION (user_data);
-
- GtrApplicationPrivate *priv = gtr_application_get_instance_private (app);
- gtr_window_show_search_bar (priv->active_window, FALSE);
-}
-
static void
find_and_replace_activated (GSimpleAction *action,
GVariant *parameter,
@@ -642,7 +631,6 @@ static GActionEntry app_entries[] = {
{ "find_and_replace", find_and_replace_activated, NULL, NULL, NULL },
{ "findtoggle", find_toggle_activated, NULL, NULL, NULL },
{ "find", find_activated, NULL, NULL, NULL },
- { "find-off", find_unactivated, NULL, NULL, NULL},
{ "find-next", find_next_activated, NULL, NULL, NULL },
{ "find-prev", find_prev_activated, NULL, NULL, NULL },
{ "new_window", new_window_activated, NULL, NULL, NULL },
@@ -710,7 +698,6 @@ gtr_application_startup (GApplication *application)
set_kb (application, "app.fuzzy", "<Ctrl>u");
set_kb (application, "app.find", "<Ctrl>f");
- set_kb (application, "app.find-off", "Escape");
set_kb (application, "app.find_and_replace", "<Ctrl>h");
set_kb (application, "app.find-next", "<Ctrl>g");
set_kb (application, "app.find-prev", "<Ctrl><Shift>g");
diff --git a/src/gtr-search-bar.c b/src/gtr-search-bar.c
index 5926d9f3..b7fc38bc 100644
--- a/src/gtr-search-bar.c
+++ b/src/gtr-search-bar.c
@@ -442,22 +442,6 @@ search_entry_populate_popup (GtrSearchBar *self,
}
}
-static void
-gtr_search_bar_real_stop_search (GtrSearchBar *self)
-{
- g_assert (GTR_IS_SEARCH_BAR (self));
-}
-
-static void
-search_entry_stop_search (GtrSearchBar *self,
- GtkEntry *entry)
-{
- g_assert (GTR_IS_SEARCH_BAR (self));
- g_assert (GTK_IS_ENTRY (entry));
-
- g_signal_emit (self, signals [STOP_SEARCH], 0);
-}
-
static void
gtr_search_bar_destroy (GtkWidget *widget)
{
@@ -613,6 +597,7 @@ gtr_search_bar_class_init (GtrSearchBarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkBindingSet *binding_set;
object_class->get_property = gtr_search_bar_get_property;
object_class->set_property = gtr_search_bar_set_property;
@@ -651,13 +636,12 @@ gtr_search_bar_class_init (GtrSearchBarClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
signals [STOP_SEARCH] =
- g_signal_new_class_handler ("stop-search",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_CALLBACK (gtr_search_bar_real_stop_search),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("stop-search",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/translator/gtr-search-bar.ui");
gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, replace_all_button);
@@ -670,6 +654,14 @@ gtr_search_bar_class_init (GtrSearchBarClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtrSearchBar, search_text_error);
gtk_widget_class_set_css_name (widget_class, "gtrsearchbar");
+
+ /* Replace by gtk_widget_class_add_binding_signal in gtk 4. */
+ /* Also add gtk_widget_class_add_binding for next-match and previous-match as
+ * in gtksearchentry.c, which are already in the app as app.find-next and
+ * app.find-prev */
+ binding_set = gtk_binding_set_by_class (klass);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
+ "stop-search", 0);
}
static void
@@ -735,11 +727,6 @@ gtr_search_bar_init (GtrSearchBar *self)
G_CALLBACK (gtr_do_replace_all),
self);
- g_signal_connect_swapped (self->search_entry,
- "stop-search",
- G_CALLBACK (search_entry_stop_search),
- self);
-
add_actions (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]