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 776082 - Port PhotosSearchbar to GtkSearchBar
Port PhotosSearchbar to GtkSearchBar
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
3.23.x
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-12-14 09:32 UTC by Alessandro Bono
Modified: 2017-05-16 14:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
photos-searchbar: Port to GtkSearchBar (5.27 KB, patch)
2016-12-14 11:02 UTC, Alessandro Bono
none Details | Review
photos-searchbar: Port to GtkSearchBar (8.22 KB, patch)
2017-04-09 21:19 UTC, Alessandro Bono
none Details | Review
searchbar: Stop using gd_entry_focus_hack() (996 bytes, patch)
2017-04-09 21:19 UTC, Alessandro Bono
none Details | Review
searchbar: Enable/disable search action when required (1.55 KB, patch)
2017-04-09 21:19 UTC, Alessandro Bono
reviewed Details | Review
photos-searchbar: Port to GtkSearchBar (9.22 KB, patch)
2017-05-12 15:13 UTC, Debarshi Ray
none Details | Review
photos-searchbar: Port to GtkSearchBar (9.33 KB, patch)
2017-05-12 15:35 UTC, Debarshi Ray
committed Details | Review
overview-searchbar: Stop using gd_entry_focus_hack (1.36 KB, patch)
2017-05-12 15:38 UTC, Debarshi Ray
committed Details | Review
searchbar: Avoid CRITICALs when typing inside the preview (1.46 KB, patch)
2017-05-15 15:45 UTC, Debarshi Ray
committed Details | Review

Description Alessandro Bono 2016-12-14 09:32:46 UTC
Doing so we get the correct theme for the search bar for free.
Comment 1 Alessandro Bono 2016-12-14 11:02:13 UTC
Created attachment 341947 [details] [review]
photos-searchbar: Port to GtkSearchBar
Comment 2 Debarshi Ray 2016-12-14 15:25:00 UTC
Review of attachment 341947 [details] [review]:

Thanks for taking this on!

Can't we delete even more lines of code? eg., here is the corresponding gnome-documents commit:
https://git.gnome.org/browse/gnome-documents/commit/?id=0b3aa6955f22fd105e5dd25fda9653a3628a87ea
Comment 3 Alessandro Bono 2017-04-09 21:19:33 UTC
Created attachment 349571 [details] [review]
photos-searchbar: Port to GtkSearchBar
Comment 4 Alessandro Bono 2017-04-09 21:19:38 UTC
Created attachment 349572 [details] [review]
searchbar: Stop using gd_entry_focus_hack()

It is no more needed.
Comment 5 Alessandro Bono 2017-04-09 21:19:43 UTC
Created attachment 349573 [details] [review]
searchbar: Enable/disable search action when required

Since the key events are now handled by GtkSearchbar, the
searchbar will now show/hide itself when it receives the
appropriate key event. However, a way to enable/disable the
search action is missing. Thus, we need to do it manually when
escape is pressed or when the searchbar has handeled the keyevent
but the search-mode is still not active.
Comment 6 Debarshi Ray 2017-05-12 15:12:45 UTC
Review of attachment 349571 [details] [review]:

Thanks for the updated patch, Alessandro.

I found that if I start typing right after launching the application, the search entry loses focus right after typing the first character. I think that's because the "app.search" GAction's state is getting changed to FALSE right after the first key press when the application switches to the SEARCH mode. Keeping the GAction in sync with the SearchBar::search-mode-enabled seems to address this.

::: src/photos-searchbar.c
@@ +97,2 @@
   if (event_device != NULL)
     gd_entry_focus_hack (priv->search_entry, event_device);

This gd_entry_focus_hack() can be removed.

@@ +146,2 @@
   g_signal_connect_swapped (priv->search_entry,
                             "search-changed",

We should also connect to notify::search-mode-enabled to update the GAction whenever Searchbar::search-mode-enabled changes. This solves the above problem.

::: src/photos-searchbar.h
@@ +37,3 @@
 struct _PhotosSearchbarClass
 {
+  GtkSearchBarClass parent_class;

The G_DECLARE_* line needs to be updated.
Comment 7 Debarshi Ray 2017-05-12 15:13:39 UTC
Created attachment 351732 [details] [review]
photos-searchbar: Port to GtkSearchBar

I took the liberty to make the above changes.
Comment 8 Debarshi Ray 2017-05-12 15:25:38 UTC
Review of attachment 349573 [details] [review]:

Is this really needed? I don't see any similar code in gnome-documents. It seems to already do the right thing. For example, if I press escape after typing the Searchbar is concealed and we are out of the SEARCH mode. I don't know how to get the SearchBar to handle a key press without the "app.search" being TRUE.
Comment 9 Debarshi Ray 2017-05-12 15:30:10 UTC
Review of attachment 349572 [details] [review]:

This is covered by attachment 351732 [details] [review]. See comment 6.

However, we do need to remove gd_entry_focus_hack from photos_overview_searchbar_active_changed. The corresponding gnome-documents commit is https://git.gnome.org/browse/gnome-documents/commit/?id=d5c1f35c1ad7a740fc69024308e80946c0564c25
Comment 10 Debarshi Ray 2017-05-12 15:35:11 UTC
Created attachment 351735 [details] [review]
photos-searchbar: Port to GtkSearchBar

Let's stop #including gd.h.
Comment 11 Debarshi Ray 2017-05-12 15:38:42 UTC
Created attachment 351737 [details] [review]
overview-searchbar: Stop using gd_entry_focus_hack
Comment 12 Debarshi Ray 2017-05-12 15:46:15 UTC
Many thanks for tackling this hairy beast, Alessandro!
Comment 13 Debarshi Ray 2017-05-15 15:45:52 UTC
Created attachment 351894 [details] [review]
searchbar: Avoid CRITICALs when typing inside the preview
Comment 14 Alessandro Bono 2017-05-16 14:08:14 UTC
(In reply to Debarshi Ray from comment #8)
> Review of attachment 349573 [details] [review] [review]:
> 
> Is this really needed? I don't see any similar code in gnome-documents. It
> seems to already do the right thing. For example, if I press escape after
> typing the Searchbar is concealed and we are out of the SEARCH mode. I don't
> know how to get the SearchBar to handle a key press without the "app.search"
> being TRUE.

Probably because the problem has been fixed by keeping the GAction in sync with the SearchBar::search-mode-enabled as you have done in attachment 351732 [details] [review]. My attempt was a workaround because I didn't fully understand the issue.
Comment 15 Debarshi Ray 2017-05-16 14:20:55 UTC
(In reply to Alessandro Bono from comment #14)
> (In reply to Debarshi Ray from comment #8)
> > Review of attachment 349573 [details] [review] [review] [review]:
> > 
> > Is this really needed? I don't see any similar code in gnome-documents. It
> > seems to already do the right thing. For example, if I press escape after
> > typing the Searchbar is concealed and we are out of the SEARCH mode. I don't
> > know how to get the SearchBar to handle a key press without the "app.search"
> > being TRUE.
> 
> Probably because the problem has been fixed by keeping the GAction in sync
> with the SearchBar::search-mode-enabled as you have done in attachment
> 351732 [details] [review]. My attempt was a workaround because I didn't
> fully understand the issue.

Ok, I see. Closing the bug as FIXED.