[gtranslator] search-bar: error style when not found



commit 5dc6c2beb92a5b626db52c2228c33a08509165bf
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Mon Jun 8 08:30:45 2020 +0200

    search-bar: error style when not found

 src/gtr-actions-search.c |  2 ++
 src/gtr-search-bar.c     | 12 +++++++++++-
 src/gtr-search-bar.h     |  2 ++
 3 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/gtr-actions-search.c b/src/gtr-actions-search.c
index 16c84efe..5f7e3292 100644
--- a/src/gtr-actions-search.c
+++ b/src/gtr-actions-search.c
@@ -307,6 +307,8 @@ do_find (GtrSearchBar * dialog, GtrWindow * window, gboolean search_backwards)
 
   if (!found && current_msg)
     gtr_tab_message_go_to (tab, current_msg->data, FALSE, GTR_TAB_MOVE_NONE);
+
+  gtr_search_bar_set_found (dialog, found);
 }
 
 static void
diff --git a/src/gtr-search-bar.c b/src/gtr-search-bar.c
index 6057ab99..f42fd7ea 100644
--- a/src/gtr-search-bar.c
+++ b/src/gtr-search-bar.c
@@ -833,5 +833,15 @@ gtr_search_bar_set_search (GtrSearchBar *self,
     }
 }
 
-
+void
+gtr_search_bar_set_found (GtrSearchBar *self,
+                          gboolean found)
+{
+  GtkStyleContext *context = gtk_widget_get_style_context (
+    GTK_WIDGET (self->search_entry));
+  if (found)
+    gtk_style_context_remove_class (context, "error");
+  else
+    gtk_style_context_add_class (context, "error");
+}
 
diff --git a/src/gtr-search-bar.h b/src/gtr-search-bar.h
index 32d3d26e..329fe913 100644
--- a/src/gtr-search-bar.h
+++ b/src/gtr-search-bar.h
@@ -94,5 +94,7 @@ void             gtr_search_bar_present_with_time (GtrSearchBar * dialog,
 void             gtr_search_bar_find_next (GtrSearchBar *self);
 void             gtr_search_bar_find_prev (GtrSearchBar *self);
 
+void             gtr_search_bar_set_found (GtrSearchBar *self, gboolean found);
+
 G_END_DECLS
 


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