Merge lp:~mhr3/unity/fix-987781 into lp:unity

Proposed by Michal Hruby
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 2338
Proposed branch: lp:~mhr3/unity/fix-987781
Merge into: lp:unity
Diff against target: 111 lines (+12/-26)
3 files modified
plugins/unityshell/src/HudController.cpp (+5/-14)
plugins/unityshell/src/HudView.cpp (+6/-12)
plugins/unityshell/src/HudView.h (+1/-0)
To merge this branch: bzr merge lp:~mhr3/unity/fix-987781
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+103262@code.launchpad.net

Commit message

Make sure hud's spinner stops spinning after hud service returns reply

Description of the change

Hud's spinner keeps spinning even after the service returns reply.

Call SearchBar's SearchFinished() to signal it to stop spinning. Also get rid of some code from HudView that SearchBar handles internally. This makes it more consistent to the way it's used in DashView and therefore easier to maintain.

No new tests.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

LGTM.

review: Approve
Revision history for this message
Gord Allott (gordallott) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/HudController.cpp'
--- plugins/unityshell/src/HudController.cpp 2012-04-23 00:24:52 +0000
+++ plugins/unityshell/src/HudController.cpp 2012-04-24 11:41:26 +0000
@@ -467,22 +467,12 @@
467467
468void Controller::OnSearchChanged(std::string search_string)468void Controller::OnSearchChanged(std::string search_string)
469{469{
470 //FIXME!! - when the service is smart enough to not fall over if you send many requests, this should be removed470 // we're using live_search_reached, so this is called 40ms after the text
471 // is input in the search bar
471 LOG_DEBUG(logger) << "Search Changed";472 LOG_DEBUG(logger) << "Search Changed";
472 auto on_search_changed_timeout_lambda = [] (gpointer data) -> gboolean {473
473 Controller* self = static_cast<Controller*>(data);
474 self->hud_service_.RequestQuery(self->last_search_);
475 self->type_wait_handle_ = 0;
476 return FALSE;
477 };
478
479 last_search_ = search_string;474 last_search_ = search_string;
480 475 hud_service_.RequestQuery(last_search_);
481 if (type_wait_handle_)
482 {
483 g_source_remove(type_wait_handle_);
484 }
485 type_wait_handle_ = g_timeout_add(100, on_search_changed_timeout_lambda, this);
486}476}
487477
488void Controller::OnSearchActivated(std::string search_string)478void Controller::OnSearchActivated(std::string search_string)
@@ -520,6 +510,7 @@
520 }510 }
521511
522 SetIcon(icon_name);512 SetIcon(icon_name);
513 view_->SearchFinished();
523}514}
524515
525// Introspectable516// Introspectable
526517
=== modified file 'plugins/unityshell/src/HudView.cpp'
--- plugins/unityshell/src/HudView.cpp 2012-04-23 02:03:25 +0000
+++ plugins/unityshell/src/HudView.cpp 2012-04-24 11:41:26 +0000
@@ -371,7 +371,7 @@
371 search_bar_->SetMinimumHeight(style.GetSearchBarHeight());371 search_bar_->SetMinimumHeight(style.GetSearchBarHeight());
372 search_bar_->SetMaximumHeight(style.GetSearchBarHeight());372 search_bar_->SetMaximumHeight(style.GetSearchBarHeight());
373 search_bar_->search_hint = _("Type your command");373 search_bar_->search_hint = _("Type your command");
374 search_bar_->search_changed.connect(sigc::mem_fun(this, &View::OnSearchChanged));374 search_bar_->live_search_reached.connect(sigc::mem_fun(this, &View::OnSearchChanged));
375 AddChild(search_bar_.GetPointer());375 AddChild(search_bar_.GetPointer());
376 content_layout_->AddView(search_bar_.GetPointer(), 0, nux::MINOR_POSITION_LEFT);376 content_layout_->AddView(search_bar_.GetPointer(), 0, nux::MINOR_POSITION_LEFT);
377377
@@ -392,14 +392,6 @@
392{392{
393 LOG_DEBUG(logger) << "got search change";393 LOG_DEBUG(logger) << "got search change";
394 search_changed.emit(search_string);394 search_changed.emit(search_string);
395 if (search_string.empty())
396 {
397 search_bar_->search_hint = _("Type your command");
398 }
399 else
400 {
401 search_bar_->search_hint = "";
402 }
403395
404 std::list<HudButton::Ptr>::iterator it;396 std::list<HudButton::Ptr>::iterator it;
405 for(it = buttons_.begin(); it != buttons_.end(); ++it)397 for(it = buttons_.begin(); it != buttons_.end(); ++it)
@@ -511,13 +503,17 @@
511 else503 else
512 {504 {
513 search_bar_->search_string = "";505 search_bar_->search_string = "";
514 search_bar_->search_hint = _("Type your command");
515 }506 }
516 return true;507 return true;
517 }508 }
518 return false;509 return false;
519}510}
520511
512void View::SearchFinished()
513{
514 search_bar_->SearchFinished();
515}
516
521void View::OnSearchbarActivated()517void View::OnSearchbarActivated()
522{518{
523 // The "Enter" key has been received and the text entry has the key focus.519 // The "Enter" key has been received and the text entry has the key focus.
@@ -581,13 +577,11 @@
581577
582 if (search_bar_->search_string == "")578 if (search_bar_->search_string == "")
583 {579 {
584 search_bar_->search_hint = _("Type your command");
585 ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);580 ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);
586 }581 }
587 else582 else
588 {583 {
589 search_bar_->search_string = "";584 search_bar_->search_string = "";
590 search_bar_->search_hint = _("Type your command");
591 return search_bar_->text_entry();585 return search_bar_->text_entry();
592 }586 }
593 return NULL;587 return NULL;
594588
=== modified file 'plugins/unityshell/src/HudView.h'
--- plugins/unityshell/src/HudView.h 2012-04-22 19:09:00 +0000
+++ plugins/unityshell/src/HudView.h 2012-04-24 11:41:26 +0000
@@ -55,6 +55,7 @@
55 void SetQueries(Hud::Queries queries);55 void SetQueries(Hud::Queries queries);
56 void SetIcon(std::string icon_name, unsigned int tile_size, unsigned int size, unsigned int padding);56 void SetIcon(std::string icon_name, unsigned int tile_size, unsigned int size, unsigned int padding);
57 void ShowEmbeddedIcon(bool show);57 void ShowEmbeddedIcon(bool show);
58 void SearchFinished();
5859
59 void AboutToShow();60 void AboutToShow();
60 void AboutToHide();61 void AboutToHide();