Commit Graph

119 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
760406002f search: Ignore search provider results metas if search is cancelled
When a search has been cancelled, it is expected that providers don't
return the requested number of results, so don't log a warning in that
case.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/205
2018-09-04 01:00:52 +02:00
Marco Trevisan (Treviño)
c47a740c83 search: Cancel search provider operations on clear
Ensure that the search provider operations (just getResultMetas requests
in the current implementation) in progress are properly cancelled when we
clear the UI, otherwise returned results might still be added when not
needed.

This is triggered for each provider by the SearchResults reset.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/205
2018-09-04 01:00:52 +02:00
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Florian Müllner
093b73b616 viewSelector: Open context for highlighted search result
To make search more efficient, users don't need to move the actual
keyboard focus away from the search entry to activate the first
result. However the shift+f10 shortcut to pop up the context menu
via keyboard still acts on the actually focused widget, which is
the entry. It makes more sense to open the context menu of the
selected result instead, as that's what's highlighted and responds
to keyboard activation.

https://bugzilla.gnome.org/show_bug.cgi?id=675315
2017-08-17 16:58:17 +02:00
Marek Cernocky
11e71845d2 Changed _ to ngettext for message '%d more' 2017-08-11 03:06:10 +02:00
Florian Müllner
033277b68f Define externally accessible contants with 'var' instead of 'const'
Just as we did with classes, define other constants that are (or
may be) used from other modules with 'var' to cut down on warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Rares Visalom
69a9c222d0 search: Disable multiline descriptions
Having descriptions with multiple lines will clutter
the view and make it more confusing for the user. Apart
from that, it also makes the search result a lot bigger,
potentially losing general vertical alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
b3d74bdb0f search: Highlight search terms in description
The classes extending the SearchResult can now connect
to the 'terms-changed' signal emitted by the SearchResult
class. This signal enables each object to update its
internal description in order to apply the bold style
onto strings that match the search terms.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
77e0c38d82 search: Propagate searchResults down the hierarchy
In order to prepare for applying the bold style to the part
of the description that matches the search terms, we need
to listen for the signal that announces the fact that the
search terms have changed. Given the fact that the
SearchResults class is aware of the changes regarding the
search terms, the classes that extent SearchResult need
to have a reference to it in order to listen for the
to-be-implemented 'terms-changed' signal.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
150252391f search: Increase maximum number of visible list search results
Since results are now much more concise and take up less
space, we can use the 'saved' space to provide the user
with more search results for each provider.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
9d77fa8341 search: Replace the gradient separator with a simple line
The current separator uses a gradient effect as a separator
between search results. As the mockups suggest, the gradient
separator is no longer needed, in favor of a more simple one,
which is a thin semitransparent line.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
0a8d81c095 search: Tweak the sizes of search results icons
Just a small tweak of icon sizes, in order to make
them look like in the mockup.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
faa0ddafff search: Refactor providerIcon into providerInfo
In order to match the current mockups, the providerIcon
class needed to include both the name of the provider
and the label that informs the user about how many more
search results are available for that specific provider.
The latter replaces the plus sign icon that has been
used so far.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Rares Visalom
a426295168 search: Make the results take more horizontal space
In order to make gnome-shell search functionality fit on
smaller screens, like those of devices, search results
need to take advantage of more horizontal space so that
any extra space can be used efficiently.

In order to do so, change the layout of the ListSearchResult
class from a vertical one, to a horizontal one and also
decrease the padding of the list-search-result-content css
class.

https://bugzilla.gnome.org/show_bug.cgi?id=749957
2017-07-14 22:40:25 +02:00
Daiki Ueno
0142fae742 search: copy result to clipboard if requested
Some search providers such as GNOME Characters want to copy search
results to clipboard.  However, on Wayland, clipboards are only
accessible from applications that have a visible surface on display.

This patch allows a search provider to request the shell to copy a
search result to clipboard when 'clipboardText' is included in the meta
of the result.

https://bugzilla.gnome.org/show_bug.cgi?id=775099
2017-05-11 11:11:22 +02:00
Giovanni Campagna
048a14f1f3 Search: use the same settings object for loading search providers
In recent glib, change notifications don't actually happen unless all
keys have been read, in an effort to reduce unnecessary dbus
traffic for shortlived GSettings object and avoid AddMatch calls.
But we care about changes here, so we need to make sure we're
subscribed, and an easy way to do so is to reuse the same object
to watch for changes and to load the active providers at startup.

https://bugzilla.gnome.org/show_bug.cgi?id=746509
2015-03-27 13:11:22 -07:00
Giovanni Campagna
fd6ef482f0 Search: watch for changes to enabled as well
When introducing support for "default disabled" search providers
this part was overlooked, so enabling a default disabled provider
would be ignored until the next login.

https://bugzilla.gnome.org/show_bug.cgi?id=746509
2015-03-27 13:11:22 -07:00
Giovanni Campagna
8b5a44e119 Search: be resilient against buggy search providers
If a search provider returns a meta without a name, don't crash
constructing the actor.

https://bugzilla.gnome.org/show_bug.cgi?id=745861
2015-03-11 13:47:48 -07:00
Cosimo Cecchi
8345fe006e search: remove redundant check
We check for (metasNeeded.length == 0) at the beginning of the function,
which is only ever called when when a non-zero number of results is
received back from the provider. Effectively, this means that
(metas.length != metasNeeded.length) will also catch (metas.length == 0)
and print a nicer message to the log.
2015-01-07 15:26:21 -08:00
Cosimo Cecchi
67a807e849 search: improve log message when metas length mismatch
Log also the name of the provider and the expected/received metas.
2015-01-07 15:26:21 -08:00
Cosimo Cecchi
cea946e745 search: don't forget to notify caller when failing to ensure actors
The updateSearch() function is called in SearchResults every time new
search hits are available from a search provider; SearchResults will
wait for updateSearch() to complete in a callaback, to update the
overall progress of the search operation.

updateSearch() will call _ensureResultActors(), which will in turn call
getResultMetas() on the search provider, which is an operation that can
fail arbitrarily or return inconsistent data, as it's entirely in the
hands of the search provider.

In case _ensureResultActors() returns a failure, updateSearch() is
currently failing to notify the passed-in callback, which might leave
SearchResults in an inconsistent state: make sure the asynchronous flow
always ends up with a notification to the updateSearch() callback.
2015-01-07 15:26:21 -08:00
Patrick Ward
72b0a3d78f search: Change order of duplicate search check
Checks for a duplicate search before setting the current search
to true and before cancelling the current search. This ensures that
if a duplicate search occurs while the previous search is still active,
the duplicate search will not incorrectly cancel or change the state
of the previous search.
2014-10-01 07:32:06 -06:00
Jasper St. Pierre
e6cd112379 search: Reset the search display when there's no search terms
Destroy the previous search view when there's no search terms, to make
sure old search items don't show up.
2014-09-30 00:55:01 -06:00
Jasper St. Pierre
2cefc8be27 search: Match an empty array, not a null one
When the terms are missing, we pass an empty array, not a null one.
2014-09-30 00:55:01 -06:00
Jasper St. Pierre
991179835e search: Factor out a function 2014-09-30 00:55:01 -06:00
Cosimo Cecchi
778ef365d9 search: hide provider actors when they're created
When the overview is created, search is populated with one actor for
each provider. As they're not hidden though, they will contribute to the
overall size request of the search page, which will shift upwards the
overview grid.

Reviewed-By: Jasper St. Pierre <jstpierre@mecheye.net>
2014-09-29 22:42:25 -07:00
Florian Müllner
aa7b0a285b search: Do not use deprecated GSettings:schema 2014-09-12 23:56:56 +02:00
Jasper St. Pierre
c49f2e1384 search: Only queue an immediate search if we don't have one queued 2014-09-11 18:01:23 -06:00
Jasper St. Pierre
9208473e59 search: Be a bit more careful in _doSearch about timeouts 2014-09-11 17:51:12 -06:00
Jasper St. Pierre
08ece4c186 search: Fix timeout ordering 2014-09-11 17:50:56 -06:00
Jasper St. Pierre
99c29366ee search: Make sure to clear the timeout 2014-09-11 17:40:00 -06:00
Jasper St. Pierre
7a11964dfb search: Fix indentation 2014-09-11 17:14:54 -06:00
Jasper St. Pierre
c4922f6624 search: Move the timeout for searching into setTerms
This lets us considerably clean up the event flow here and change how
things are structured. It also makes sure that we never show "No
Results" -- search.js not being aware of the timeout means that it might
not think that any work was being done when we show the page.
2014-09-11 17:10:26 -06:00
Jasper St. Pierre
4f2070a7c6 search: Track search status more accurately
Keep a flag depending on whether a provider is in-flight, and use that
to determine what status label to show.

This ensures that we only show "No Results" when we're done searching
and we're sure that all providers have returned results back to us.
2014-09-11 17:10:26 -06:00
Jasper St. Pierre
03177dc474 search: Merge SearchSystem with SearchResults
The complexities of tracking these two things separately, with the
display on one half, and the searching on the other half, is difficult
to manage. Squash it all together.
2014-09-11 17:10:26 -06:00
Jasper St. Pierre
b9b4886a6f search: Don't bother clearing the result display twice
It's just extra work, and breaks our hide/show hack to prevent the
flashing on search results.
2014-09-11 17:10:25 -06:00
Florian Müllner
3981b27d8f search: Remove DND code from GridSearchResult
Providers that need drag-and-drop behavior can implement this via the
createResultObject() hook (as the app search provider already does), no
need to duplicate that code in the generic result objects
(ListSearchResult already does not implement DND).

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-02 00:07:32 +02:00
Carlos Soriano
62786c09a8 appDisplay: Animate appIcon for new window of apps
Following design mockups, animate the icons on AllView, FrequentView,
Dash and Search to zoom out when opening a new window of the app or when
the app is not running and the user execute it.

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-02 00:07:32 +02:00
Florian Müllner
67c216a6fe search: Allow providers to return the complete result object
This makes the existing createResultObject() match its name better
 and avoids oddities like nested StButtons in app search results.

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-02 00:07:32 +02:00
Carlos Soriano
1c0c38574d search: Remove unused function 2014-08-20 18:41:18 +02:00
Florian Müllner
62bfde45aa search: Fix default drag actor source
Another unnoticed fallout from commit 792b963bda ...
2014-08-19 20:34:08 +02:00
Florian Müllner
d5aa276c41 search: Fix custom drag actor source
The existing code broke when commit 792b963bda changed the custom
result actor hook to return an object instead of an actor - stop
trying to go through a _delegate to make it work again.
2014-08-19 19:12:02 +02:00
Florian Müllner
d0fe1211f2 search: Fix visibility of "more" icon
Since commit 19749bb37f, the icon is always visible - ooops.
2014-08-19 18:13:40 +02:00
Giovanni Campagna
926177785d search: add support for default disabled search providers
Search providers that should be disabled by default come with
a DefaultDisabled=true key in their keyfile, and are enabled
with the "enabled" whitelist, not with the "disabled" blacklist.

https://bugzilla.gnome.org/show_bug.cgi?id=734110
2014-08-19 15:29:22 +02:00
Carlos Soriano
9970671bb1 Search: Don't use IconGrid width for maxDisplayedResults
Currently to know how many results we could show for GridResults
we use the width of the bin containing those results. Since it's
expanding it shouldn't be a problem. But it becomes a problem when
no results are displayed, thus the container becomes hidden and
it losts its allocation.
In the next introduction of terms in search we call again
maxDisplayedResults but it doesn't have allocation yet, and therefore no
results are displayed (currently a bug on IconGrid makes the min size =
one icon, so actually we show one and only one icon in this case).

To solve that use the parent container which contains the search results
of all providers or the text label with not displayed results, so it
always have the real available width to calculate maxDisplayedResults.

Thanks Alban Browaeys for the debugging footwork.

https://bugzilla.gnome.org/show_bug.cgi?id=732416
2014-07-19 18:12:43 +02:00
Jasper St. Pierre
83cb26d70e js: Adapt to GSettings API change
The 'schema' property has been deprecated for a long time. Even though
this will likely be reverted in glib, let's stop using it.
2014-06-24 15:17:09 -04:00
Jasper St. Pierre
a83b9ed6d7 search: Make sure to destroy old provider displays when we unregister
When we unregistered providers, like when we refreshed the list of
active remote providers, we would forget to destroy the old provider
display after the fact. This left an empty "skeleton" provider display
still in the search results that would never be filled in. Make sure
to destroy it properly.

https://bugzilla.gnome.org/show_bug.cgi?id=728597
2014-04-21 23:36:52 -04:00