[gtranslator/gtk4] Fix search entry, disable search on text change
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/gtk4] Fix search entry, disable search on text change
- Date: Mon, 12 Sep 2022 16:32:04 +0000 (UTC)
commit 4ca43196f5501da2c7db8e24334de4bb6b0468ba
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Mon Sep 12 18:30:54 2022 +0200
Fix search entry, disable search on text change
The search on text change was causing problems with the search
selection, triggering a search for each word and making it difficult to
change the focus on the text field.
src/gtr-actions-search.c | 22 +++++++++++-----------
src/gtr-search-bar.c | 8 +++-----
src/gtr-tab.c | 27 ++++++++++-----------------
3 files changed, 24 insertions(+), 33 deletions(-)
---
diff --git a/src/gtr-actions-search.c b/src/gtr-actions-search.c
index f8b76616..95637e1d 100644
--- a/src/gtr-actions-search.c
+++ b/src/gtr-actions-search.c
@@ -204,7 +204,7 @@ find_in_list (GtrWindow * window,
found = run_search (GTR_VIEW (viewsaux->data), found);
if (found)
{
- gtr_tab_message_go_to (tab, l->data, TRUE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, l->data, FALSE, GTR_TAB_MOVE_NONE);
run_search (GTR_VIEW (viewsaux->data), aux);
return TRUE;
}
@@ -232,7 +232,7 @@ find_in_list (GtrWindow * window,
else
l = l->prev;
}
- gtr_tab_message_go_to (tab, l->data, TRUE, GTR_TAB_MOVE_NONE);
+ gtr_tab_message_go_to (tab, l->data, FALSE, GTR_TAB_MOVE_NONE);
viewsaux = views;
}
while (l != current);
@@ -241,7 +241,7 @@ find_in_list (GtrWindow * window,
}
void
-do_find (GtrSearchBar * dialog, GtrWindow * window, gboolean search_backwards)
+do_find (GtrSearchBar * searchbar, GtrWindow * window, gboolean search_backwards)
{
GtrTab *tab;
GList *views, *list, *current_msg;
@@ -259,16 +259,16 @@ do_find (GtrSearchBar * dialog, GtrWindow * window, gboolean search_backwards)
/* Used to store search options */
tab = gtr_window_get_active_tab (window);
- entry_text = gtr_search_bar_get_search_text (dialog);
+ entry_text = gtr_search_bar_get_search_text (searchbar);
/* Views where find */
- original_text = gtr_search_bar_get_original_text (dialog);
- translated_text = gtr_search_bar_get_translated_text (dialog);
+ original_text = gtr_search_bar_get_original_text (searchbar);
+ translated_text = gtr_search_bar_get_translated_text (searchbar);
/* Flags */
- match_case = gtr_search_bar_get_match_case (dialog);
- entire_word = gtr_search_bar_get_entire_word (dialog);
- wrap_around = gtr_search_bar_get_wrap_around (dialog);
+ match_case = gtr_search_bar_get_match_case (searchbar);
+ entire_word = gtr_search_bar_get_entire_word (searchbar);
+ wrap_around = gtr_search_bar_get_wrap_around (searchbar);
if (!original_text && !translated_text)
return;
@@ -300,12 +300,12 @@ do_find (GtrSearchBar * dialog, GtrWindow * window, gboolean search_backwards)
current_msg = gtr_po_get_current_message (gtr_tab_get_po (tab));
found = find_in_list (window, views, wrap_around, search_backwards);
- restore_last_searched_data (dialog, tab);
+ restore_last_searched_data (searchbar, tab);
if (!found && current_msg)
gtr_tab_message_go_to (tab, current_msg->data, TRUE, GTR_TAB_MOVE_NONE);
- gtr_search_bar_set_found (dialog, found);
+ gtr_search_bar_set_found (searchbar, found);
}
static void
diff --git a/src/gtr-search-bar.c b/src/gtr-search-bar.c
index 29479bad..7aaa86d5 100644
--- a/src/gtr-search-bar.c
+++ b/src/gtr-search-bar.c
@@ -262,16 +262,14 @@ gtr_hide_bar (GtrSearchBar *self)
void
gtr_search_bar_find_next (GtrSearchBar *self)
{
- //GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
- GtkWindow *window = GTK_WINDOW(gtk_widget_get_root (GTK_WIDGET (self)));
+ GtkWindow *window = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self)));
do_find (self, GTR_WINDOW (window), FALSE);
}
void
gtr_search_bar_find_prev (GtrSearchBar *self)
{
- //GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
- GtkWindow *window = GTK_WINDOW(gtk_widget_get_root (GTK_WIDGET (self)));
+ GtkWindow *window = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self)));
do_find (self, GTR_WINDOW (window), TRUE);
}
@@ -717,7 +715,7 @@ gtr_search_bar_init (GtrSearchBar *self)
"insert_text", G_CALLBACK (insert_text_handler), NULL);
g_signal_connect_swapped (self->search_entry,
- "changed",
+ "activate",
G_CALLBACK (gtr_search_bar_find_next),
self);
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index b5f8d3cf..68eca9b0 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -68,7 +68,7 @@ typedef struct
GSettings *editor_settings;
GSettings *state_settings;
- GtkWidget *progress_gesture_click;
+ GtkGesture *progress_gesture_click;
GtkWidget *progress_box;
GtkWidget *progress_revealer;
GtkWidget *progress_percentage;
@@ -853,13 +853,9 @@ sort_by_translated_cb (GtkWidget *checkbutton, GtrTab* tab)
static void
gtr_tab_init (GtrTab * tab)
{
- GtrTabPrivate *priv;
-
- priv = gtr_tab_get_instance_private (tab);
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
- g_printf("creating tab widget from template \n");
gtk_widget_init_template (GTK_WIDGET (tab));
- g_printf("created tab widget from template \n");
priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
@@ -884,9 +880,11 @@ gtr_tab_init (GtrTab * tab)
priv->find_replace_flag = FALSE;
priv->progress = gtr_progress_new ();
- priv->progress_gesture_click = gtk_gesture_click_new();
+ priv->progress_gesture_click = gtk_gesture_click_new ();
gtk_widget_show (GTK_WIDGET (priv->progress));
- gtk_widget_add_controller(priv->progress_box, priv->progress_gesture_click);
+
+ gtk_widget_add_controller (priv->progress_box,
+ GTK_EVENT_CONTROLLER (priv->progress_gesture_click));
gtk_box_append (GTK_BOX (priv->progress_box), GTK_WIDGET (priv->progress));
g_signal_connect (priv->progress_gesture_click, "pressed",
@@ -904,7 +902,7 @@ gtr_tab_init (GtrTab * tab)
G_CALLBACK(sort_by_msgid_cb), tab);
g_signal_connect (priv->sort_translated, "toggled",
G_CALLBACK(sort_by_translated_cb), tab);
- gtk_check_button_set_active (priv->sort_id, TRUE);
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (priv->sort_id), TRUE);
}
static void
@@ -1225,7 +1223,6 @@ gtr_tab_new (GtrPo * po,
manager = gtr_profile_manager_get_default();
tab = g_object_new (GTR_TYPE_TAB, NULL);
- g_printf("tab created\n");
priv = gtr_tab_get_instance_private (tab);
gtr_context_init_tm (GTR_CONTEXT_PANEL (priv->context),
@@ -1390,12 +1387,7 @@ gtr_tab_message_go_to (GtrTab * tab,
GtrTabMove move)
{
static gboolean first_msg = TRUE;
- GtrTabPrivate *priv;
-
- g_return_if_fail (tab != NULL);
- g_return_if_fail (GTR_IS_MSG (to_go));
-
- priv = gtr_tab_get_instance_private (tab);
+ GtrTabPrivate *priv = gtr_tab_get_instance_private (tab);
if (!priv->blocking || first_msg)
{
@@ -1463,10 +1455,11 @@ gtr_tab_message_go_to (GtrTab * tab,
g_signal_emit (G_OBJECT (tab), signals[SHOWED_MESSAGE], 0,
GTR_MSG (to_go));
+
// Grabbing the focus in the GtrView to edit the message
// This is done in the idle add to avoid the focus grab from the
// message-table
- g_idle_add((GSourceFunc)msg_grab_focus, tab);
+ g_idle_add ((GSourceFunc)msg_grab_focus, tab);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]