@@ -33,12 +33,14 @@
3333#include <QQmlEngine>
3434
3535#include <UnityCore/Variant.h>
36+#include <UnityCore/GLibWrapper.h>
3637
3738#include <libintl.h>
3839#include <glib.h>
3940
4041Scope::Scope(QObject *parent) : QObject(parent)
4142 , m_formFactor("phone")
43+ , m_searchInProgress(false)
4244{
4345 m_categories.reset(new Categories(this));
4446}
@@ -68,6 +70,11 @@ QString Scope::searchHint() const
6870 return QString::fromStdString(m_unityScope->search_hint());
6971}
7072
73+bool Scope::searchInProgress() const
74+{
75+ return m_searchInProgress;
76+}
77+
7178bool Scope::visible() const
7279{
7380 return m_unityScope->visible();
@@ -115,10 +122,15 @@ void Scope::setSearchQuery(const QString& search_query)
115122 string ("") and m_searchQuery is the null string,
116123 search_query != m_searchQuery is still true.
117124 */
125+ using namespace std::placeholders;
126+
118127 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
119128 m_searchQuery = search_query;
120− m_unityScope->Search(search_query.toStdString(), sigc::mem_fun(this, &Scope::searchFinished));
129+ m_cancellable.Renew();
130+ m_searchInProgress = true;
131+ m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
121132 Q_EMIT searchQueryChanged();
133+ Q_EMIT searchInProgressChanged();
122134 }
123135}
124136
@@ -294,8 +306,6 @@ void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
294306 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
295307 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
296308 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
297− /* Signals forwarding */
298− connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
299309
300310 /* FIXME: signal should be forwarded instead of calling the handler directly */
301311 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
@@ -316,18 +326,33 @@ unity::dash::Scope::Ptr Scope::unityScope() const
316326
317327void Scope::synchronizeStates()
318328{
329+ using namespace std::placeholders;
330+
319331 if (connected()) {
320332 /* Forward local states to m_unityScope */
321333 if (!m_searchQuery.isNull()) {
322− m_unityScope->Search(m_searchQuery.toStdString());
334+ m_cancellable.Renew();
335+ m_searchInProgress = true;
336+ m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
337+ Q_EMIT searchInProgressChanged();
323338 }
324339 }
325340}
326341
327−void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints)
342+void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
328343{
329344 QString hint;
330345
346+ GError* error = const_cast<unity::glib::Error&>(err);
347+
348+ if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
349+ m_searchInProgress = false;
350+ Q_EMIT searchInProgressChanged();
351+ } else {
352+ // no need to check the results hint, we're still searching
353+ return;
354+ }
355+
331356 if (!m_unityScope->results()->count()) {
332357 unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
333358 if (it != hints.end()) {