[gnome-calendar/gnome-3-24] search-view: no show search view if field is empty



commit 0c6884a0d994929773fe42bcd6a5f6ee6748d9fb
Author: Kevin Lopez <kevin kevlopez com>
Date:   Thu Mar 16 12:49:09 2017 +0100

    search-view: no show search view if field is empty
    
    When the search field is empty is not needed show the result drop down.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747962

 data/ui/window.ui |    1 -
 src/gcal-window.c |   18 +++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 085c84d..a7d9267 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -291,7 +291,6 @@
     </child>
   </template>
   <object class="GcalSearchView" id="search_view">
-    <property name="visible" bind-source="search_bar" bind-property="search-mode-enabled" 
bind-flags="default | sync-create" />
     <property name="relative_to">search_entry</property>
     <property name="position">bottom</property>
     <signal name="event-activated" handler="search_event_selected" object="GcalWindow" swapped="no"/>
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 0800f40..3233c82 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -1197,12 +1197,24 @@ search_changed (GtkEditable *editable,
                 gpointer     user_data)
 {
   GcalWindow *window = GCAL_WINDOW (user_data);
+  gint search_length;
 
   if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (window->search_bar)))
     {
-      /* perform the search */
-      gcal_search_view_search (GCAL_SEARCH_VIEW (window->search_view),
-                               "summary", gtk_entry_get_text (GTK_ENTRY (window->search_entry)));
+      /* perform the search or hide when the field is empty */
+
+      search_length = gtk_entry_get_text_length (GTK_ENTRY (window->search_entry));
+
+      if (search_length)
+        {
+          gtk_popover_popup (GTK_POPOVER (window->search_view));
+          gcal_search_view_search (GCAL_SEARCH_VIEW (window->search_view),
+                                   "summary", gtk_entry_get_text (GTK_ENTRY (window->search_entry)));
+        }
+      else
+        {
+          gtk_popover_popdown (GTK_POPOVER (window->search_view));
+        }
     }
 }
 


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