Merge lp://staging/~brandontschaefer/unity/fix-711199 into lp://staging/unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2093
Proposed branch: lp://staging/~brandontschaefer/unity/fix-711199
Merge into: lp://staging/unity
Diff against target: 300 lines (+147/-6)
5 files modified
plugins/unityshell/src/DashView.cpp (+36/-5)
plugins/unityshell/src/DashView.h (+3/-0)
plugins/unityshell/src/LensView.cpp (+58/-1)
plugins/unityshell/src/LensView.h (+5/-0)
tests/autopilot/autopilot/tests/test_dash.py (+45/-0)
To merge this branch: bzr merge lp://staging/~brandontschaefer/unity/fix-711199
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Alex Launi (community) Approve
Michal Hruby (community) Approve
Marco Trevisan (Treviño) Approve
Brandon Schaefer (community) Approve
Review via email: mp+89192@code.staging.launchpad.net

Description of the change

= Problem description =

If no results are returned from a lens there is no message informing the user so.

= The fix =

In DashView::OnSearchFinished a check is made to see if a message should be
shown.

A default message is used if the lens doesn't provide one.

There is also a timer that waits for 150ms then hides the
message, if the search is taking a while.

= Test coverage =

There is an autopilot test for this now!

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) :
review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) :
review: Needs Resubmitting
Revision history for this message
Brandon Schaefer (brandontschaefer) :
review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Need to not use a work around for the start up problem. Looking into removing the call in LensView:
http://bazaar.launchpad.net/~unity-team/unity/trunk/view/head:/plugins/unityshell/src/LensView.cpp#L350

Removing that if statement which calls Search("") and OnSearchFinished is getting emitted with 0 results for ALL lenses, even though they have them. So far testing shows this code can be removed, but want to do more testing by killing the lenses and restarting them.

Revision history for this message
Tim Penhey (thumper) wrote :

Why check for
  if (active_lens_view_->lens())
at the start of DashView::OnSearchFinished?
Small style issue, no space before (hints).

plese use:
  nux::color::White
instead of:
  nux::Color(1.0f,1.0f,1.0f,1.0f)

Instead of using += on a std::string, use a string stream.

#include <sstream>

std::stringstream sout;

sout << "<span size='larger' weight='bold'>";
//...
sout << g_variant_get_string(it->second, NULL);
//...
sout << "Sorry, there is nothing that matches your search.";
//...
sout << "</span>";

LOG_DEBUG(logger) << "The no-result-hint is: " << sout.str();

no_results_->SetText(sout.str());

How does the normal results view get shown again?

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

I was checking active_lens_->lens() because there was a problem before where the active home lens would get passed in with out actually having a lens() which would cause a seg fault. That has now been fix/changed so I remove that! (Tested, now no seg fault yay!)

Fixed style problems (there were other style errors; now fixed!), now using nux::color::White, and now markup uses sstream!

As for the normal results view, it is still getting shown how it normally does. The no-result-message is apart of the same layout so when the results == 0 the layout is empty. Then I change the layouts ContentDistribution to nux::MAJOR_POSITION_CENTER, which draws the text in the middle of the dash. When there are > 0 results I change it back to nux::MAJOR_POSITION_START (default), so the new results get draw back where they should. (Instead of the middle!)

Revision history for this message
Michal Hruby (mhr3) wrote :

89 + markup << g_variant_get_string(it->second, NULL);

Values in the Hints map are instances of unity::glib::Variant (which have a GVariant* operator), please use the GetString method (which is NULL safe).

93 + markup << "Sorry, there is nothing that matches your search.";

This needs to be marked for translation - just use _("Sorry, ...")

review: Needs Fixing
Revision history for this message
Michal Hruby (mhr3) wrote :

Also there could be an issue with hiding the message - currently it's only shown or hidden when the SearchFinishes, which means that this can happen:

If you're searching with a lens/scope that is really slow and is adding results one by one and finishes in let's say 5seconds, you can end up seeing the "Sorry, ..." message for the entire 5 seconds while it's searching and just then the message will disappear.

A solution to this would be to hide the message as soon as the search starts, but that again brings an issue that the search might finish in 10ms with no results, and the message will flicker. A proper solution will probably have to use a timer similar to what the search bar spinner is doing (it starts spinning after ~150ms after the search starts).

Revision history for this message
Brandon Schaefer (brandontschaefer) :
review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I also guess you can easily write an autopilot test to check this. Just add a a value for no_results_active_ to the introspection wrapper, and check it with the AP suite ;)

review: Needs Fixing (missing tests)
Revision history for this message
Michal Hruby (mhr3) wrote :
Revision history for this message
Michal Hruby (mhr3) wrote :

84 + g_source_remove(hide_message_delay_id_);
100 + g_source_remove(hide_message_delay_id_);

You should set the id to 0 after these calls.

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

@Michal opps, I fixed that but forgot to push those changes...like a month ago haha.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Tests are good, maybe instead of just searching for 'a' you could make it look for a real default application, so it will also indirectly test that lens is working :)

review: Approve
Revision history for this message
Michal Hruby (mhr3) wrote :

There is still one/two rare corner cases where the message could be displayed while also results are, but that can be solved in a later merge. Approve from me.

review: Approve
Revision history for this message
Alex Launi (alexlauni) wrote :

AP test looks good.

review: Approve
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.