After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720993 - Use Gtk.SearchEntry's "search-changed" signal
Use Gtk.SearchEntry's "search-changed" signal
Status: RESOLVED FIXED
Product: geary
Classification: Other
Component: ux
master
Other Linux
: Normal normal
: 0.12.0
Assigned To: Geary Maintainers
Geary Maintainers
Depends on: 764812
Blocks:
 
 
Reported: 2013-12-23 22:26 UTC by Jim Nelson
Modified: 2016-07-04 15:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use the "search-changed" signal (3.67 KB, patch)
2016-07-03 20:18 UTC, Oskar Viljasaar
none Details | Review
Use built-in GTK signals for the search bar (4.65 KB, patch)
2016-07-04 14:08 UTC, Oskar Viljasaar
none Details | Review
Use built-in GTK signals for the search bar (4.92 KB, patch)
2016-07-04 15:03 UTC, Oskar Viljasaar
none Details | Review

Description Jim Nelson 2013-12-23 22:26:26 UTC
Introduced in 3.10, the "search-changed" signal is fired after the user has stopped typing for 150ms.  Using this means we can rip out our own timer code in GearyController.
Comment 1 Oskar Viljasaar 2016-07-03 20:18:37 UTC
Created attachment 330819 [details] [review]
Use the "search-changed" signal

Hello, does this work? I'm not so sure myself but it seems correct to me.
Comment 2 Michael Gratton 2016-07-04 02:08:16 UTC
Review of attachment 330819 [details] [review]:

This looks good, thanks for the patch. Just a few things to tidy up.

In general I don't mind that the timeout has dropped down to 150ms, since that will be more consistent with the desktop. Let's run it for a bit and see if anyone complains.

Also, if you are interested in tidying this up a bit more, the SearchBar::on_search_key_press method should probably be replaced with two handlers: One for "activate" instead of looking for a Return key press, and one for "stop-search" instead of looking for an Esc key press.

::: src/client/application/geary-controller.vala
@@ +2797,1 @@
         do_search(main_window.search_bar.search_text);

Since search text is passed in as a param here, that should be used instead of retreiving it again from the search_bar.

::: src/client/components/search-bar.vala
@@ +25,3 @@
         search_entry.tooltip_text = _("Search all mail in account for keywords (Ctrl+S)");
         search_entry.changed.connect(on_search_entry_changed);
+        search_entry.search_changed.connect(on_search_entry_search_changed);

Since the on_search_entry_changed method is a single line, I would use a lambda expression here instead and remove the separate method.

@@ +56,3 @@
     }
     
     private void on_search_entry_changed() {

This method can be removed altogether, since GTK handles showing/hiding the clear button itself.
Comment 3 Oskar Viljasaar 2016-07-04 14:08:50 UTC
Created attachment 330846 [details] [review]
Use built-in GTK signals for the search bar
Comment 4 Michael Gratton 2016-07-04 14:57:22 UTC
Review of attachment 330846 [details] [review]:

Looks good - just two small things to look at and I'll be happy to commit this.

::: src/client/components/search-bar.vala
@@ +27,3 @@
+            search_text_changed(search_entry.text);
+        });
+        // Handle user pressing Enter to search and canceling it.

This comment is a bit confusing since it applies to both of the next two signals, but only talks about pressing Enter. Maybe just drop it since it's pretty obvious what is going on?

@@ -59,3 @@
-        // Enable/disable clear button.
-        search_entry.secondary_icon_name = search_entry.text != "" ?
-            (get_direction() == Gtk.TextDirection.RTL ? ICON_CLEAR_RTL_NAME : ICON_CLEAR_NAME) : null;

Do ICON_CLEAR_RTL_NAME and ICON_CLEAR_NAME get used anywhere else in this file? If not then their declarations up the top should be removed.
Comment 5 Oskar Viljasaar 2016-07-04 15:03:28 UTC
Created attachment 330849 [details] [review]
Use built-in GTK signals for the search bar
Comment 6 Michael Gratton 2016-07-04 15:11:42 UTC
Pushed to master as f80f52f. Thanks again!