[gtranslator/merge-requests/61: 20/20] screen sharing session fixes



commit 9c2dd6a5a110e425bc692f483a44b93df95b09cc
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Fri Feb 14 10:51:10 2020 +0100

    screen sharing session fixes

 src/gtr-actions-search.c |  14 ++----
 src/gtr-actions.h        |   3 +-
 src/gtr-application.c    |   1 +
 src/gtr-search-bar.c     | 121 ++++++++++-------------------------------------
 4 files changed, 32 insertions(+), 107 deletions(-)
---
diff --git a/src/gtr-actions-search.c b/src/gtr-actions-search.c
index 22b55f3f..e05d57ab 100644
--- a/src/gtr-actions-search.c
+++ b/src/gtr-actions-search.c
@@ -267,7 +267,7 @@ find_in_list (GtrWindow * window,
 }
 
 void
-do_find (GtrSearchBar * dialog, GtrWindow * window)
+do_find (GtrSearchBar * dialog, GtrWindow * window, gboolean search_backwards)
 {
   GtrTab *tab;
   GList *views, *list;
@@ -278,7 +278,6 @@ do_find (GtrSearchBar * dialog, GtrWindow * window)
   gboolean match_case;
   gboolean entire_word;
   gboolean wrap_around;
-  gboolean search_backwards;
   guint flags = 0;
   guint old_flags = 0;
   gboolean found;
@@ -295,7 +294,6 @@ do_find (GtrSearchBar * dialog, GtrWindow * window)
   /* Flags */
   match_case = gtr_search_bar_get_match_case (dialog);
   entire_word = gtr_search_bar_get_entire_word (dialog);
-  search_backwards = gtr_search_bar_get_backwards (dialog);
   wrap_around = gtr_search_bar_get_wrap_around (dialog);
 
   if (!original_text && !translated_text)
@@ -333,10 +331,6 @@ do_find (GtrSearchBar * dialog, GtrWindow * window)
   else
     phrase_not_found (dialog);
 
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                     GTR_SEARCH_BAR_REPLACE_RESPONSE,
-                                     found);
-
   restore_last_searched_data (dialog, tab);
 }
 
@@ -397,7 +391,7 @@ do_replace (GtrSearchBar * dialog, GtrWindow * window)
                                               strlen (unescaped_search_text))
        != 0))
     {
-      do_find (dialog, window);
+      do_find (dialog, window, FALSE);
       g_free (unescaped_search_text);
       g_free (selected_text);
       gtr_tab_find_replace (tab, FALSE);
@@ -414,7 +408,7 @@ do_replace (GtrSearchBar * dialog, GtrWindow * window)
   g_free (selected_text);
   g_free (unescaped_replace_text);
 
-  do_find (dialog, window);
+  do_find (dialog, window, FALSE);
   gtr_tab_find_replace (tab, FALSE);
 }
 
@@ -507,7 +501,7 @@ search_bar_response_cb (GtrSearchBar *dialog,
   switch (response_id)
     {
     case GTR_SEARCH_BAR_FIND_RESPONSE:
-      do_find (dialog, window);
+      do_find (dialog, window, FALSE);
       break;
     case GTR_SEARCH_BAR_REPLACE_RESPONSE:
       do_replace (dialog, window);
diff --git a/src/gtr-actions.h b/src/gtr-actions.h
index dca6a223..4913551c 100644
--- a/src/gtr-actions.h
+++ b/src/gtr-actions.h
@@ -155,7 +155,8 @@ gboolean find_in_list (GtrWindow * window,
 
 
 void do_find (GtrSearchBar * dialog,
-              GtrWindow * window);
+              GtrWindow * window,
+              gboolean search_backwards);
 
 void do_replace (GtrSearchBar * dialog,
                  GtrWindow * window);
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 2b02979d..93704489 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -244,6 +244,7 @@ find_activated (GSimpleAction *action,
 
   //_gtr_actions_search_find (NULL, priv->active_window);
   GtrTab *active_tab = gtr_window_get_active_tab (priv->active_window);
+  g_return_if_fail (active_tab != NULL);
   gtr_tab_show_hide_search_bar (active_tab, priv->search_bar, 0);
 }
 
diff --git a/src/gtr-search-bar.c b/src/gtr-search-bar.c
index 5167604f..f1038165 100644
--- a/src/gtr-search-bar.c
+++ b/src/gtr-search-bar.c
@@ -75,14 +75,6 @@ gtr_search_bar_set_search_text (GtrSearchBar *dialog,
   g_return_if_fail (text != NULL);
 
   gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), text);
-
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                     GTR_SEARCH_BAR_FIND_RESPONSE,
-                                     (*text != '\0'));
-
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                     GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE,
-                                     (*text != '\0'));
 }
 
 /*
@@ -252,7 +244,21 @@ gtr_hide_bar (GtrSearchBar *self)
 
   GtrTab *active_tab = gtr_window_get_active_tab (GTR_WINDOW (window));
 
-  return gtr_tab_show_hide_search_bar (active_tab, self, 0);
+  return gtr_tab_show_hide_search_bar (active_tab, self, 1);
+}
+
+void
+gtr_find_next (GtrSearchBar *self)
+{
+  GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+  do_find (self, GTR_WINDOW (window), FALSE);
+}
+
+void
+gtr_find_prev (GtrSearchBar *self)
+{
+  GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (self));
+  do_find (self, GTR_WINDOW (window), TRUE);
 }
 
 static void
@@ -339,43 +345,6 @@ original_checkbutton_toggled (GtkToggleButton * button,
     }
 }
 
-static void
-response_handler (GtrSearchBar * dialog, gint response_id, gpointer data)
-{
-  const gchar *str;
-
-  switch (response_id)
-    {
-    case GTR_SEARCH_BAR_REPLACE_RESPONSE:
-    case GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE:
-      str = gtk_entry_get_text (GTK_ENTRY (dialog->replace_text_entry));
-      if (*str != '\0')
-        {
-          gchar *text;
-
-          text = gtr_utils_unescape_search_text (str);
-          gtr_history_entry_prepend_text
-            (GTR_HISTORY_ENTRY (dialog->replace_entry), text);
-
-          g_free (text);
-        }
-      /* fall through, so that we also save the find entry */
-    case GTR_SEARCH_BAR_FIND_RESPONSE:
-      str = gtk_entry_get_text (GTK_ENTRY (dialog->search_text_entry));
-      if (*str != '\0')
-        {
-          gchar *text;
-
-          text = gtr_utils_unescape_search_text (str);
-          gtr_history_entry_prepend_text
-            (GTR_HISTORY_ENTRY (dialog->search_entry), text);
-
-          g_free (text);
-        }
-    }
-}
-
-
 /*-----------------------------END OF NEW RE_WRITTEN METHODS-----------------*/
 
 gboolean
@@ -561,28 +530,6 @@ search_entry_changed (GtrSearchBar *dialog,
 
   search_string = gtk_entry_get_text (GTK_ENTRY (entry));
   g_return_if_fail (search_string != NULL);
-
-  if (*search_string != '\0')
-    {
-      gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                         GTR_SEARCH_BAR_FIND_RESPONSE,
-                                         TRUE);
-      gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                         GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE,
-                                         TRUE);
-    }
-  else
-    {
-      gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                         GTR_SEARCH_BAR_FIND_RESPONSE,
-                                         FALSE);
-      gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                         GTR_SEARCH_BAR_REPLACE_RESPONSE,
-                                         FALSE);
-      gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
-                                         GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE,
-                                         FALSE);
-    }
 }
 
 //TODO:
@@ -754,33 +701,8 @@ gtr_search_bar_init (GtrSearchBar *self)
 
   self->search_signals = dzl_signal_group_new (GTK_TYPE_SEARCH_ENTRY);
 
-   gtk_dialog_add_action_widget (GTK_DIALOG (self),
-                                GTK_WIDGET (self->replace_all_button),
-                                GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE);
-
-  gtk_dialog_add_action_widget (GTK_DIALOG (self),
-                                GTK_WIDGET (self->replace_button),
-                                GTR_SEARCH_BAR_REPLACE_RESPONSE);
-
-  gtk_dialog_add_action_widget (GTK_DIALOG (self),
-                                GTK_WIDGET (self->next_button),
-                                GTR_SEARCH_BAR_FIND_RESPONSE);
-
   g_object_set (G_OBJECT (self->next_button), "can-default", TRUE, NULL);
 
-  /* insensitive by default */
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (self),
-                                     GTR_SEARCH_BAR_FIND_RESPONSE, FALSE);
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (self),
-                                     GTR_SEARCH_BAR_REPLACE_RESPONSE,
-                                     FALSE);
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (self),
-                                     GTR_SEARCH_BAR_REPLACE_ALL_RESPONSE,
-                                     FALSE);
-
-  gtk_dialog_set_default_response (GTK_DIALOG (self),
-                                   GTR_SEARCH_BAR_FIND_RESPONSE);
-
 /*  dzl_signal_group_connect_swapped (self->search_signals,
                                     "notify::match-count",
                                     G_CALLBACK (ide_editor_search_bar_notify_match),
@@ -861,6 +783,16 @@ gtr_search_bar_init (GtrSearchBar *self)
                             self);
 
 // TODO:
+  g_signal_connect_swapped (self->next_button,
+                            "clicked",
+                            G_CALLBACK (gtr_find_next),
+                            self);
+
+  g_signal_connect_swapped (self->previous_button,
+                            "clicked",
+                            G_CALLBACK (gtr_find_prev),
+                            self);
+
   g_signal_connect_swapped (self->close_button,
                             "clicked",
                             G_CALLBACK (gtr_hide_bar),
@@ -884,9 +816,6 @@ gtr_search_bar_init (GtrSearchBar *self)
 //                            self);
 
 // _ide_editor_search_bar_init_shortcuts (self);
-
-  g_signal_connect (self, "response", G_CALLBACK (response_handler), NULL);
-
 }
 
 GtkSearchEntry *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]