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 743586 - Startup applications: Quick search when adding an application
Startup applications: Quick search when adding an application
Status: RESOLVED FIXED
Product: gnome-tweak-tool
Classification: Applications
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: GNOME Tweak Tool maintainer(s)
GNOME Tweak Tool maintainer(s)
: 739932 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-01-27 15:29 UTC by Isaac Lenton
Modified: 2015-02-23 10:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (3.09 KB, patch)
2015-01-30 12:00 UTC, Isaac Lenton
needs-work Details | Review
Updated patch (3.22 KB, patch)
2015-02-15 10:39 UTC, Isaac Lenton
needs-work Details | Review
Updated patch (3.56 KB, patch)
2015-02-16 01:30 UTC, Isaac Lenton
committed Details | Review

Description Isaac Lenton 2015-01-27 15:29:24 UTC
Currently when adding an application for startup using the gui there is no search functionality (at least not that I am aware of).  It would be nice to have either a search bar or just filter when the user starts typing.

I might add a patch fixing this if get time.
Comment 1 Isaac Lenton 2015-01-30 12:00:57 UTC
Created attachment 295798 [details] [review]
Proposed patch
Comment 2 Rui Matos 2015-02-14 23:32:50 UTC
Review of attachment 295798 [details] [review]:

Thanks

::: gtweak/tweaks/tweak_group_startup.py
@@ +38,3 @@
         self._all = {}
 
+        self.entry = Gtk.SearchEntry(placeholder_text=_("Search Tweaks..."))

certainly not "Tweaks"

@@ +39,3 @@
 
+        self.entry = Gtk.SearchEntry(placeholder_text=_("Search Tweaks..."))
+        self.entry.set_size_request(300, -1)

set_width_chars() is better for this purpose

@@ +125,3 @@
         return row
 
+    def _list_filter_func(self, row, user_data):

please use a better name than user_data here, e.g. txt is ok

@@ +130,3 @@
+          if type(sib) == Gtk.Label:
+              if user_data in sib.get_text().lower():
+                  return row

return True

@@ +131,3 @@
+              if user_data in sib.get_text().lower():
+                  return row
+              return None

return False

@@ +134,3 @@
+
+    def _on_search(self, entry):
+      txt = entry.get_text().decode("utf-8", "ignore").lower()

the decode() call isn't needed

@@ +137,3 @@
+      self.listbox.set_filter_func(self._list_filter_func, txt)
+
+    def _on_key_press(self, widget, event):

There should be a searchbar.handle_event() here. Also, please add return True/False appropriately on all code paths.
Comment 3 Isaac Lenton 2015-02-15 10:39:01 UTC
Created attachment 296867 [details] [review]
Updated patch

Fixed.  Also removed _search_cb and replaced it with a lambda (I hadn't realized about the invalidate_filter() method of ListBox).

I didn't known about `searchbar.handle_event` until tonight, I'm still unfamiliar with many of the Gtk methods.

Thanks,

Isaac
Comment 4 Isaac Lenton 2015-02-15 10:41:36 UTC
On second thought, is it OK to use lambda there because it will always return None (False)?
Comment 5 Rui Matos 2015-02-15 16:16:53 UTC
Review of attachment 296867 [details] [review]:

(In reply to Isaac Lenton from comment #4)
> On second thought, is it OK to use lambda there because it will always
> return None (False)?

That's fine since the search-changed signal handler doesn't need to return anything.

::: gtweak/tweaks/tweak_group_startup.py
@@ +144,3 @@
+          elif self.searchbar.get_search_mode():
+              self.entry.grab_focus()
+          return True

You should return True on both branches and then here return False, otherwise you can't ever cancel the dialog with escape
Comment 6 Isaac Lenton 2015-02-16 01:30:49 UTC
Created attachment 296901 [details] [review]
Updated patch

Updated the patch with ability to cancel the dialog using escape.

I also added code for the searchentry to capture focus when visible and something else has focus.  I feel adding this additional code is a little redundant, should I file a bug against Gtk requesting the desired functionality?
Comment 7 Rui Matos 2015-02-16 12:54:47 UTC
Review of attachment 296901 [details] [review]:

looks fine
Comment 8 Rui Matos 2015-02-16 12:56:32 UTC
(In reply to Isaac Lenton from comment #6)
> I also added code for the searchentry to capture focus when visible and
> something else has focus.  I feel adding this additional code is a little
> redundant, should I file a bug against Gtk requesting the desired
> functionality?

Yes, GtkSearchBar/GtkSearchEntry could probably do a better job here. Please do
Comment 9 Rui Matos 2015-02-23 10:58:25 UTC
*** Bug 739932 has been marked as a duplicate of this bug. ***