diff options
| -rwxr-xr-x | dash/CoverflowResultView.cpp | 2 | ||||
| -rwxr-xr-x | dash/CoverflowResultView.h | 2 | ||||
| -rw-r--r-- | dash/DashView.cpp | 23 | ||||
| -rw-r--r-- | dash/DashView.h | 6 | ||||
| -rwxr-xr-x | dash/LensView.cpp | 22 | ||||
| -rw-r--r-- | dash/LensView.h | 4 | ||||
| -rw-r--r-- | dash/ResultView.h | 2 | ||||
| -rw-r--r-- | dash/ResultViewGrid.cpp | 2 | ||||
| -rw-r--r-- | dash/ResultViewGrid.h | 2 |
9 files changed, 32 insertions, 33 deletions
diff --git a/dash/CoverflowResultView.cpp b/dash/CoverflowResultView.cpp index 53d456faf..7c2d04d23 100755 --- a/dash/CoverflowResultView.cpp +++ b/dash/CoverflowResultView.cpp @@ -316,7 +316,7 @@ void CoverflowResultView::Activate(std::string const& uri, int index, ResultView int row_y = GetRootGeometry().y; int row_height = renderer_->height; - glib::Variant data(g_variant_new("(iiii)", row_y, row_height, left_results, right_results), glib::StealRef()); + glib::Variant data(g_variant_new("(iiii)", row_y, row_height, left_results, right_results)); UriActivated.emit(uri, type, data); } diff --git a/dash/CoverflowResultView.h b/dash/CoverflowResultView.h index d35d20a24..57cc4fa72 100755 --- a/dash/CoverflowResultView.h +++ b/dash/CoverflowResultView.h @@ -40,7 +40,7 @@ public: virtual void AddResult(Result& result); virtual void RemoveResult(Result& result); - void Activate(std::string const& uri, int index, ActivateType type); + virtual void Activate(std::string const& uri, int index, ActivateType type); protected: virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 269f95cf9..6171cc75b 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -202,8 +202,11 @@ void DashView::FadeInCallBack(float const& fade_in_value) } } -void DashView::OnPreviewUriActivated(std::string const& uri, GVariant* data, std::string const& unique_id) +void DashView::OnUriActivated(ResultView::ActivateType type, std::string const& uri, GVariant* data, std::string const& unique_id) { + last_activated_uri_ = uri; + stored_activated_unique_id_ = unique_id; + if (data) { // Update positioning information. @@ -224,12 +227,8 @@ void DashView::OnPreviewUriActivated(std::string const& uri, GVariant* data, std opening_row_height_ = row_height; } - LOG_DEBUG(logger) << "got unique id from preview activation: " << unique_id; - stored_preview_unique_id_ = unique_id; - stored_preview_uri_identifier_ = uri; - // we want immediate preview reaction on first opening. - if (!preview_displaying_) + if (type == ResultView::ActivateType::DIRECT && !preview_displaying_) { BuildPreview(Preview::Ptr(nullptr)); } @@ -278,7 +277,7 @@ void DashView::BuildPreview(Preview::Ptr model) // sends a message to all result views, sending the the uri of the current preview result // and the unique id of the result view that should be handling the results - ubus_manager_.SendMessage(UBUS_DASH_PREVIEW_NAVIGATION_REQUEST, g_variant_new("(iss)", -1, stored_preview_uri_identifier_.c_str(), stored_preview_unique_id_.c_str())); + ubus_manager_.SendMessage(UBUS_DASH_PREVIEW_NAVIGATION_REQUEST, g_variant_new("(iss)", -1, last_activated_uri_.c_str(), stored_activated_unique_id_.c_str())); }); preview_container_->navigate_right.connect([&] () { @@ -286,7 +285,7 @@ void DashView::BuildPreview(Preview::Ptr model) // sends a message to all result views, sending the the uri of the current preview result // and the unique id of the result view that should be handling the results - ubus_manager_.SendMessage(UBUS_DASH_PREVIEW_NAVIGATION_REQUEST, g_variant_new("(iss)", 1, stored_preview_uri_identifier_.c_str(), stored_preview_unique_id_.c_str())); + ubus_manager_.SendMessage(UBUS_DASH_PREVIEW_NAVIGATION_REQUEST, g_variant_new("(iss)", 1, last_activated_uri_.c_str(), stored_activated_unique_id_.c_str())); }); preview_container_->request_close.connect([&] () { ClosePreview(); }); @@ -405,7 +404,7 @@ void DashView::SetupViews() content_layout_->AddView(lenses_layout_, 1, nux::MINOR_POSITION_LEFT); home_view_ = new LensView(home_lens_, nullptr); - home_view_->uri_preview_activated.connect(sigc::mem_fun(this, &DashView::OnPreviewUriActivated)); + home_view_->uri_activated.connect(sigc::mem_fun(this, &DashView::OnUriActivated)); AddChild(home_view_); active_lens_view_ = home_view_; @@ -900,7 +899,6 @@ void DashView::OnLensAdded(Lens::Ptr& lens) AddChild(view); view->SetVisible(false); view->uri_activated.connect(sigc::mem_fun(this, &DashView::OnUriActivated)); - view->uri_preview_activated.connect(sigc::mem_fun(this, &DashView::OnPreviewUriActivated)); lenses_layout_->AddView(view, 1); lens_views_[lens->id] = view; @@ -1020,11 +1018,6 @@ void DashView::OnAppsGlobalSearchFinished(Lens::Hints const& hints) } } -void DashView::OnUriActivated(std::string const& uri) -{ - last_activated_uri_ = uri; -} - void DashView::OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&) { // We don't want to close the dash if there was another activation pending diff --git a/dash/DashView.h b/dash/DashView.h index 6020eb8f4..4653f3e65 100644 --- a/dash/DashView.h +++ b/dash/DashView.h @@ -94,7 +94,6 @@ private: virtual long PostLayoutManagement (long LayoutResult); nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type); - void OnPreviewUriActivated(std::string const& uri, GVariant* data, std::string const& unique_id); void BuildPreview(Preview::Ptr model); void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key); void OnBackgroundColorChanged(GVariant* args); @@ -105,7 +104,7 @@ private: void OnSearchFinished(Lens::Hints const& hints); void OnGlobalSearchFinished(Lens::Hints const& hints); void OnAppsGlobalSearchFinished(Lens::Hints const& hints); - void OnUriActivated(std::string const& uri); + void OnUriActivated(ResultView::ActivateType type, std::string const& uri, GVariant* data, std::string const& unique_id); void OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&); bool DoFallbackActivation(std::string const& uri); bool LaunchApp(std::string const& appname); @@ -131,8 +130,7 @@ private: PreviewStateMachine preview_state_machine_; previews::PreviewContainer::Ptr preview_container_; bool preview_displaying_; - std::string stored_preview_unique_id_; - std::string stored_preview_uri_identifier_; + std::string stored_activated_unique_id_; dash::previews::Navigation preview_navigation_mode_; nux::VLayout* layout_; diff --git a/dash/LensView.cpp b/dash/LensView.cpp index eecc049f3..897bef513 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -346,16 +346,15 @@ void LensView::OnCategoryAdded(Category const& category) group->SetRendererName(renderer_name.c_str()); grid->UriActivated.connect(sigc::bind([&] (std::string const& uri, ResultView::ActivateType type, GVariant* data, std::string const& view_id) { + uri_activated.emit(type, uri, data, view_id); switch (type) { case ResultView::ActivateType::DIRECT: { - uri_activated.emit(uri); lens_->Activate(uri); } break; case ResultView::ActivateType::PREVIEW: { - uri_preview_activated.emit(uri, data, view_id); lens_->Preview(uri); } break; default: break; @@ -452,6 +451,13 @@ ResultViewGrid* LensView::GetGridForCategory(unsigned category_index) return static_cast<ResultViewGrid*>(group->GetChildView()); } +ResultView* LensView::GetResultViewForCategory(unsigned category_index) +{ + if (category_index >= categories_.size()) return nullptr; + PlacesGroup* group = categories_.at(category_index); + return static_cast<ResultView*>(group->GetChildView()); +} + void LensView::OnResultAdded(Result const& result) { try { @@ -720,22 +726,22 @@ void LensView::ActivateFirst() for (unsigned int i = 0; i < category_order.size(); i++) { unsigned cat_index = category_order.at(i); - ResultViewGrid* grid = GetGridForCategory(cat_index); - if (grid == nullptr) continue; - auto it = grid->GetIteratorAtRow(0); + ResultView* result_view = GetResultViewForCategory(cat_index); + if (result_view == nullptr) continue; + auto it = result_view->GetIteratorAtRow(0); if (!it.IsLast()) { Result result(*it); - uri_activated(result.uri); - lens_->Activate(result.uri); + result_view->Activate(result.uri, result_view->GetIndexForUri(result.uri), ResultView::ActivateType::DIRECT); return; } } + // Fallback Result result = results->RowAtIndex(0); if (result.uri != "") { - uri_activated(result.uri); + uri_activated.emit(ResultView::ActivateType::DIRECT, result.uri, nullptr, ""); lens_->Activate(result.uri); } } diff --git a/dash/LensView.h b/dash/LensView.h index 3c2b96ecb..71da4c9df 100644 --- a/dash/LensView.h +++ b/dash/LensView.h @@ -68,8 +68,7 @@ public: nux::Property<ViewType> view_type; nux::Property<bool> can_refine_search; - sigc::signal<void, std::string const&> uri_activated; - sigc::signal<void, std::string const&, GVariant*, std::string const&> uri_preview_activated; + sigc::signal<void, ResultView::ActivateType, std::string const&, GVariant*, std::string const&> uri_activated; void PerformSearch(std::string const& search_query); void CheckNoResults(Lens::Hints const& hints); @@ -95,6 +94,7 @@ private: void OnViewTypeChanged(ViewType view_type); bool ReinitializeFilterModels(); ResultViewGrid* GetGridForCategory(unsigned category_index); + ResultView* GetResultViewForCategory(unsigned category_index); void BuildPreview(std::string const& uri, Preview::Ptr model); diff --git a/dash/ResultView.h b/dash/ResultView.h index a4a3ee697..089095529 100644 --- a/dash/ResultView.h +++ b/dash/ResultView.h @@ -68,6 +68,8 @@ public: void AddProperties(GVariantBuilder* builder); IntrospectableList GetIntrospectableChildren(); + virtual void Activate(std::string const& uri, int index, ActivateType type) = 0; + protected: virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp index 8dc991568..85921007b 100644 --- a/dash/ResultViewGrid.cpp +++ b/dash/ResultViewGrid.cpp @@ -179,7 +179,7 @@ void ResultViewGrid::Activate(std::string const& uri, int index, ResultView::Act row_y += row_index * row_height; } - glib::Variant data(g_variant_new("(iiii)", row_y, row_height, left_results, right_results), glib::StealRef()); + glib::Variant data(g_variant_new("(iiii)", row_y, row_height, left_results, right_results)); UriActivated.emit(uri, type, data); } diff --git a/dash/ResultViewGrid.h b/dash/ResultViewGrid.h index 931d71919..47c543626 100644 --- a/dash/ResultViewGrid.h +++ b/dash/ResultViewGrid.h @@ -53,7 +53,7 @@ public: int GetSelectedIndex(); virtual unsigned GetIndexAtPosition(int x, int y); - void Activate(std::string const& uri, int index, ActivateType type); + virtual void Activate(std::string const& uri, int index, ActivateType type); protected: void MouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
