Merge lp:~3v1n0/unity/dash-files-open into lp:unity/7.0

Proposed by Marco Trevisan (Treviño)
Status: Work in progress
Proposed branch: lp:~3v1n0/unity/dash-files-open
Merge into: lp:unity/7.0
Diff against target: 596 lines (+172/-76)
12 files modified
UnityCore/Lens.cpp (+10/-2)
dash/DashController.cpp (+1/-2)
dash/DashView.cpp (+26/-12)
dash/DashView.h (+5/-1)
dash/StandaloneDash.cpp (+1/-3)
tests/test_dash_view.cpp (+17/-3)
tests/test_lens.cpp (+28/-10)
tests/test_mock_filemanager.h (+4/-3)
tests/test_service_lens.cpp (+14/-7)
unity-shared/FileManager.h (+7/-3)
unity-shared/GnomeFileManager.cpp (+51/-26)
unity-shared/GnomeFileManager.h (+8/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/dash-files-open
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+162008@code.launchpad.net

Commit message

Lens: if a lens returns a "goto-uri" parameter, activate that instead of the activated uri

DashView: use FileManager to launch an activated location, in case opening it.

Description of the change

We use the "goto-uri" parameter that a Lens can return to activate the lens-parsed location, using FileManager with correct timestamp to open or launch files.

This depends on lp:~3v1n0/unity-lens-files/delegate-activation/+merge/162007

To post a comment you must log in.
lp:~3v1n0/unity/dash-files-open updated
3318. By Marco Trevisan (Treviño)

TestDashView: use our beloved beef

3319. By Marco Trevisan (Treviño)

TestLensService: update to support goto-uri redirection

3320. By Marco Trevisan (Treviño)

TestLens: add activation redirection test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

3320. By Marco Trevisan (Treviño)

TestLens: add activation redirection test

3319. By Marco Trevisan (Treviño)

TestLensService: update to support goto-uri redirection

3318. By Marco Trevisan (Treviño)

TestDashView: use our beloved beef

3317. By Marco Trevisan (Treviño)

TestDashView: add tests for Filemanager Launch and Opening

3316. By Marco Trevisan (Treviño)

DashView: use FileManager to launch an activated location, in case opening it.

3315. By Marco Trevisan (Treviño)

Lens: if a lens returns a "goto-uri" parameter, activate that instead of the activated uri

3314. By Marco Trevisan (Treviño)

GnomeFileManager: add Launch Implementation, to launch a file with default handler

3313. By Marco Trevisan (Treviño)

GnomeFileManager: add Utility function to get the Launch Context

3312. By Marco Trevisan (Treviño)

GnomeFileManager: If the requested location is not mounted, we open the file-manager

If the requested position is not mounted, we open the file-manager waiting it to mount
the requested location.

3311. By Marco Trevisan (Treviño)

FileManager: return a bool on Open methods.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UnityCore/Lens.cpp'
--- UnityCore/Lens.cpp 2013-03-21 19:11:44 +0000
+++ UnityCore/Lens.cpp 2013-05-02 01:34:26 +0000
@@ -509,7 +509,7 @@
509 guint32 handled;509 guint32 handled;
510 GVariant* hints_variant;510 GVariant* hints_variant;
511 Hints hints;511 Hints hints;
512 512
513 g_variant_get(parameters, "((su@a{sv}))", &uri, &handled, &hints_variant);513 g_variant_get(parameters, "((su@a{sv}))", &uri, &handled, &hints_variant);
514514
515 glib::Variant dict (hints_variant, glib::StealRef());515 glib::Variant dict (hints_variant, glib::StealRef());
@@ -536,7 +536,15 @@
536 }536 }
537 else537 else
538 {538 {
539 owner_->activated.emit(uri.Str(), static_cast<HandledType>(handled), hints);539 auto activated_uri = uri.Str();
540
541 auto iter = hints.find("goto-uri");
542 if (iter != hints.end())
543 {
544 activated_uri = "goto-uri:" + iter->second.GetString();
545 }
546
547 owner_->activated.emit(activated_uri, static_cast<HandledType>(handled), hints);
540 }548 }
541}549}
542550
543551
=== modified file 'dash/DashController.cpp'
--- dash/DashController.cpp 2013-04-10 20:59:51 +0000
+++ dash/DashController.cpp 2013-05-02 01:34:26 +0000
@@ -23,7 +23,6 @@
23#include <Nux/HLayout.h>23#include <Nux/HLayout.h>
24#include <UnityCore/GLibWrapper.h>24#include <UnityCore/GLibWrapper.h>
2525
26#include "ApplicationStarterImp.h"
27#include "unity-shared/DashStyle.h"26#include "unity-shared/DashStyle.h"
28#include "unity-shared/PanelStyle.h"27#include "unity-shared/PanelStyle.h"
29#include "unity-shared/UBusMessages.h"28#include "unity-shared/UBusMessages.h"
@@ -140,7 +139,7 @@
140139
141void Controller::SetupDashView()140void Controller::SetupDashView()
142{141{
143 view_ = new DashView(std::make_shared<FilesystemLenses>(), std::make_shared<ApplicationStarterImp>());142 view_ = new DashView(std::make_shared<FilesystemLenses>());
144 AddChild(view_);143 AddChild(view_);
145144
146 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);145 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
147146
=== modified file 'dash/DashView.cpp'
--- dash/DashView.cpp 2013-04-12 16:01:19 +0000
+++ dash/DashView.cpp 2013-05-02 01:34:26 +0000
@@ -20,6 +20,7 @@
2020
21#include "DashView.h"21#include "DashView.h"
22#include "DashViewPrivate.h"22#include "DashViewPrivate.h"
23#include "ApplicationStarterImp.h"
23#include "FilterExpanderLabel.h"24#include "FilterExpanderLabel.h"
2425
25#include <math.h>26#include <math.h>
@@ -31,6 +32,7 @@
31#include <UnityCore/GLibWrapper.h>32#include <UnityCore/GLibWrapper.h>
32#include <UnityCore/RadioOptionFilter.h>33#include <UnityCore/RadioOptionFilter.h>
3334
35#include "unity-shared/GnomeFileManager.h"
34#include "unity-shared/DashStyle.h"36#include "unity-shared/DashStyle.h"
35#include "unity-shared/KeyboardUtil.h"37#include "unity-shared/KeyboardUtil.h"
36#include "unity-shared/PreviewStyle.h"38#include "unity-shared/PreviewStyle.h"
@@ -56,6 +58,10 @@
56const int GROUP_HEADING_HEIGHT = 24;58const int GROUP_HEADING_HEIGHT = 24;
5759
58const int PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10;60const int PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10;
61
62const std::string RESULT_APPLICATION_PREFIX = "application://";
63const std::string RESULT_RUNNER_PREFIX = "unity-runner://";
64const std::string RESULT_DIRECTORY_PREFIX = "directory://";
59}65}
6066
61// This is so we can access some protected members in nux::VLayout and67// This is so we can access some protected members in nux::VLayout and
@@ -109,11 +115,12 @@
109115
110NUX_IMPLEMENT_OBJECT_TYPE(DashView);116NUX_IMPLEMENT_OBJECT_TYPE(DashView);
111117
112DashView::DashView(Lenses::Ptr const& lenses, ApplicationStarter::Ptr const& application_starter)118DashView::DashView(Lenses::Ptr const& lenses, ApplicationStarter::Ptr const& application_starter, FileManager::Ptr const& file_manager)
113 : nux::View(NUX_TRACKER_LOCATION)119 : nux::View(NUX_TRACKER_LOCATION)
114 , lenses_(lenses)120 , lenses_(lenses)
115 , home_lens_(new HomeLens(_("Home"), _("Home screen"), _("Search your computer and online sources")))121 , home_lens_(new HomeLens(_("Home"), _("Home screen"), _("Search your computer and online sources")))
116 , application_starter_(application_starter)122 , application_starter_(application_starter ? application_starter : std::make_shared<ApplicationStarterImp>())
123 , file_manager_(file_manager ? file_manager : GnomeFileManager::Get())
117 , preview_container_(nullptr)124 , preview_container_(nullptr)
118 , preview_displaying_(false)125 , preview_displaying_(false)
119 , preview_navigation_mode_(previews::Navigation::NONE)126 , preview_navigation_mode_(previews::Navigation::NONE)
@@ -1380,18 +1387,25 @@
13801387
1381 LOG_DEBUG(logger) << "Fallback activating " << uri;1388 LOG_DEBUG(logger) << "Fallback activating " << uri;
13821389
1383 if (g_str_has_prefix(uri.c_str(), "application://"))1390 if (uri.find(RESULT_APPLICATION_PREFIX) == 0)
1384 {1391 {
1385 std::string const& appname = uri.substr(14);1392 std::string const& appname = uri.substr(RESULT_APPLICATION_PREFIX.size());
1386 return application_starter_->Launch(appname, last_activated_timestamp_);1393 return application_starter_->Launch(appname, last_activated_timestamp_);
1387 }1394 }
1388 else if (g_str_has_prefix(uri.c_str(), "unity-runner://"))1395 else if (uri.find(RESULT_RUNNER_PREFIX) == 0)
1389 {1396 {
1390 std::string const& appname = uri.substr(15);1397 std::string const& appname = uri.substr(RESULT_RUNNER_PREFIX.size());
1391 return application_starter_->Launch(appname, last_activated_timestamp_);1398 return application_starter_->Launch(appname, last_activated_timestamp_);
1399 }
1400 else if (uri.find(RESULT_DIRECTORY_PREFIX) == 0)
1401 {
1402 std::string const& directory = uri.substr(RESULT_DIRECTORY_PREFIX.size());
1403 return file_manager_->Open(directory, last_activated_timestamp_);
1392 }1404 }
1393 else1405 else
1394 return gtk_show_uri(NULL, uri.c_str(), last_activated_timestamp_, NULL);1406 {
1407 return file_manager_->Launch(uri, last_activated_timestamp_);
1408 }
13951409
1396 return false;1410 return false;
1397}1411}
13981412
=== modified file 'dash/DashView.h'
--- dash/DashView.h 2013-04-10 18:26:42 +0000
+++ dash/DashView.h 2013-05-02 01:34:26 +0000
@@ -37,6 +37,7 @@
3737
38#include "unity-shared/BackgroundEffectHelper.h"38#include "unity-shared/BackgroundEffectHelper.h"
39#include "unity-shared/BGHash.h"39#include "unity-shared/BGHash.h"
40#include "unity-shared/FileManager.h"
40#include "unity-shared/Introspectable.h"41#include "unity-shared/Introspectable.h"
41#include "unity-shared/OverlayRenderer.h"42#include "unity-shared/OverlayRenderer.h"
42#include "unity-shared/SearchBar.h"43#include "unity-shared/SearchBar.h"
@@ -59,7 +60,9 @@
59 typedef std::map<std::string, nux::ObjectPtr<LensView>> LensViews;60 typedef std::map<std::string, nux::ObjectPtr<LensView>> LensViews;
6061
61public:62public:
62 DashView(Lenses::Ptr const& lenses, ApplicationStarter::Ptr const& application_starter);63 DashView(Lenses::Ptr const& lenses,
64 ApplicationStarter::Ptr const& application_starter = nullptr,
65 FileManager::Ptr const& file_manager = nullptr);
63 ~DashView();66 ~DashView();
6467
65 void AboutToShow();68 void AboutToShow();
@@ -139,6 +142,7 @@
139 LensViews lens_views_;142 LensViews lens_views_;
140143
141 ApplicationStarter::Ptr application_starter_;144 ApplicationStarter::Ptr application_starter_;
145 FileManager::Ptr file_manager_;
142146
143 // View related147 // View related
144 PreviewStateMachine preview_state_machine_;148 PreviewStateMachine preview_state_machine_;
145149
=== modified file 'dash/StandaloneDash.cpp'
--- dash/StandaloneDash.cpp 2013-03-12 15:21:19 +0000
+++ dash/StandaloneDash.cpp 2013-05-02 01:34:26 +0000
@@ -28,7 +28,6 @@
28#include <NuxCore/AnimationController.h>28#include <NuxCore/AnimationController.h>
29#include <NuxCore/Logger.h>29#include <NuxCore/Logger.h>
3030
31#include "ApplicationStarterImp.h"
32#include "unity-shared/BGHash.h"31#include "unity-shared/BGHash.h"
33#include "unity-shared/FontSettings.h"32#include "unity-shared/FontSettings.h"
34#include "DashView.h"33#include "DashView.h"
@@ -65,8 +64,7 @@
65{64{
66 layout = new nux::HLayout(NUX_TRACKER_LOCATION);65 layout = new nux::HLayout(NUX_TRACKER_LOCATION);
6766
68 DashView* view = new DashView(std::make_shared<unity::dash::FilesystemLenses>(), 67 DashView* view = new DashView(std::make_shared<unity::dash::FilesystemLenses>());
69 std::make_shared<unity::ApplicationStarterImp>());
70 view->DisableBlur();68 view->DisableBlur();
71 view->SetMinMaxSize(WIDTH, HEIGHT);69 view->SetMinMaxSize(WIDTH, HEIGHT);
72 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);70 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
7371
=== modified file 'tests/test_dash_view.cpp'
--- tests/test_dash_view.cpp 2013-03-12 21:45:58 +0000
+++ tests/test_dash_view.cpp 2013-05-02 01:34:26 +0000
@@ -20,11 +20,11 @@
2020
21#include <UnityCore/Lenses.h>21#include <UnityCore/Lenses.h>
2222
23#include "ApplicationStarter.h"
24#include "DashView.h"23#include "DashView.h"
25#include "unity-shared/DashStyle.h"24#include "unity-shared/DashStyle.h"
26#include "unity-shared/PanelStyle.h"25#include "unity-shared/PanelStyle.h"
27#include "unity-shared/UnitySettings.h"26#include "unity-shared/UnitySettings.h"
27#include "test_mock_filemanager.h"
2828
29#include "mock-lenses.h"29#include "mock-lenses.h"
3030
@@ -43,7 +43,8 @@
43 TestDashView()43 TestDashView()
44 : lenses_(std::make_shared<testmocks::ThreeMockTestLenses>())44 : lenses_(std::make_shared<testmocks::ThreeMockTestLenses>())
45 , application_starter_(std::make_shared<MockApplicationStarter>())45 , application_starter_(std::make_shared<MockApplicationStarter>())
46 , dash_view_(new DashView(lenses_, application_starter_))46 , file_manager_(std::make_shared<NiceMock<unity::MockFileManager>>())
47 , dash_view_(new DashView(lenses_, application_starter_, file_manager_))
47 {}48 {}
4849
49 unity::Settings unity_settings_;50 unity::Settings unity_settings_;
@@ -51,11 +52,12 @@
51 unity::panel::Style panel_style;52 unity::panel::Style panel_style;
52 Lenses::Ptr lenses_;53 Lenses::Ptr lenses_;
53 MockApplicationStarter::Ptr application_starter_;54 MockApplicationStarter::Ptr application_starter_;
55 unity::MockFileManager::Ptr file_manager_;
54 nux::ObjectPtr<DashView> dash_view_;56 nux::ObjectPtr<DashView> dash_view_;
55};57};
5658
5759
58TEST_F(TestDashView, LensActivatedSignal)60TEST_F(TestDashView, LensActivatedApplication)
59{61{
60 EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1);62 EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1);
61 lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:application://uri", NOT_HANDLED, Lens::Hints());63 lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:application://uri", NOT_HANDLED, Lens::Hints());
@@ -64,4 +66,16 @@
64 lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:unity-runner://uri", NOT_HANDLED, Lens::Hints());66 lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:unity-runner://uri", NOT_HANDLED, Lens::Hints());
65}67}
6668
69TEST_F(TestDashView, LensActivatedDirectory)
70{
71 EXPECT_CALL(*file_manager_, Open("file:///dir/file.ext", _));
72 lenses_->GetLensAtIndex(0)->activated.emit("goto-uri:directory://file:///dir/file.ext", NOT_HANDLED, Lens::Hints());
73}
74
75TEST_F(TestDashView, LensActivatedAny)
76{
77 EXPECT_CALL(*file_manager_, Launch("file:///dir/file.ext", _));
78 lenses_->GetLensAtIndex(0)->activated.emit("0xdeadbeef:file:///dir/file.ext", NOT_HANDLED, Lens::Hints());
79}
80
67}81}
6882
=== modified file 'tests/test_lens.cpp'
--- tests/test_lens.cpp 2013-03-04 11:31:36 +0000
+++ tests/test_lens.cpp 2013-05-02 01:34:26 +0000
@@ -1,4 +1,3 @@
1#include <boost/lexical_cast.hpp>
2#include <gtest/gtest.h>1#include <gtest/gtest.h>
3#include <glib-object.h>2#include <glib-object.h>
43
@@ -66,13 +65,13 @@
66 ASSERT_EQ(model->count(), n_rows);65 ASSERT_EQ(model->count(), n_rows);
67 }66 }
6867
69 std::string PopulateAndGetFirstResultURI()68 std::string PopulateAndGetFirstResultURI(bool redirect = false)
70 {69 {
71 Results::Ptr results = lens_->results;70 Results::Ptr results = lens_->results;
7271
73 lens_->Search("Test Search String", nullptr);72 lens_->Search(redirect ? "redirect" : "Test Search String", nullptr);
74 WaitForModel<Result>(results.get(), 5);73 WaitForModel<Result>(results.get(), 5);
75 74
76 Result result = results->RowAtIndex(0);75 Result result = results->RowAtIndex(0);
77 return result.uri;76 return result.uri;
78 }77 }
@@ -134,18 +133,18 @@
134133
135 for (unsigned int i = 0; i < 5; i++)134 for (unsigned int i = 0; i < 5; i++)
136 {135 {
137 std::string name("Test Search String" + boost::lexical_cast<std::string>(i));136 std::string name("Test Search String" + std::to_string(i));
138137
139 Result result = results->RowAtIndex(i);138 Result result = results->RowAtIndex(i);
140 139
141 std::string uri = result.uri;140 std::string uri = result.uri;
142 EXPECT_TRUE(uri.find("file:///test"));141 EXPECT_TRUE(uri.find("file:///test/"+std::to_string(i)));
143 EXPECT_EQ(result.icon_hint, "gtk-apply");142 EXPECT_EQ(result.icon_hint, "gtk-apply");
144 EXPECT_EQ(result.category_index, i);143 EXPECT_EQ(result.category_index, i);
145 EXPECT_EQ(result.mimetype, "text/html");144 EXPECT_EQ(result.mimetype, "text/html");
146 EXPECT_EQ(result.name, name);145 EXPECT_EQ(result.name, name);
147 EXPECT_EQ(result.comment, "kamstrup likes ponies");146 EXPECT_EQ(result.comment, "kamstrup likes ponies");
148 EXPECT_EQ(result.dnd_uri, "file:///test");147 EXPECT_EQ(result.dnd_uri, "file:///test/"+std::to_string(i));
149 }148 }
150}149}
151150
@@ -158,18 +157,18 @@
158157
159 for (unsigned int i = 0; i < 10; i++)158 for (unsigned int i = 0; i < 10; i++)
160 {159 {
161 std::string name("Test Global Search String" + boost::lexical_cast<std::string>(i));160 std::string name("Test Global Search String" + std::to_string(i));
162161
163 Result result = results->RowAtIndex(i);162 Result result = results->RowAtIndex(i);
164163
165 std::string uri = result.uri;164 std::string uri = result.uri;
166 EXPECT_TRUE(uri.find("file:///test"));165 EXPECT_TRUE(uri.find("file:///test/"+std::to_string(i)));
167 EXPECT_EQ(result.icon_hint, "gtk-apply");166 EXPECT_EQ(result.icon_hint, "gtk-apply");
168 EXPECT_EQ(result.category_index, i);167 EXPECT_EQ(result.category_index, i);
169 EXPECT_EQ(result.mimetype, "text/html");168 EXPECT_EQ(result.mimetype, "text/html");
170 EXPECT_EQ(result.name, name);169 EXPECT_EQ(result.name, name);
171 EXPECT_EQ(result.comment, "kamstrup likes ponies");170 EXPECT_EQ(result.comment, "kamstrup likes ponies");
172 EXPECT_EQ(result.dnd_uri, "file:///test");171 EXPECT_EQ(result.dnd_uri, "file:///test/"+std::to_string(i));
173 }172 }
174}173}
175174
@@ -193,6 +192,25 @@
193 Utils::WaitUntil(activated);192 Utils::WaitUntil(activated);
194}193}
195194
195TEST_F(TestLens, TestActivationRedirect)
196{
197 std::string uri = PopulateAndGetFirstResultURI(true);
198
199 bool activated = false;
200 auto activated_cb = [&activated, &uri] (std::string const& uri_,
201 HandledType handled,
202 Lens::Hints const& hints)
203 {
204 EXPECT_EQ(uri_, "goto-uri:"+uri.substr(uri.find(":")+1));
205 EXPECT_EQ(handled, HandledType::HIDE_DASH);
206 activated = true;
207 };
208 lens_->activated.connect(activated_cb);
209
210 lens_->Activate(uri);
211 Utils::WaitUntil(activated);
212}
213
196TEST_F(TestLens, TestPreview)214TEST_F(TestLens, TestPreview)
197{215{
198 std::string uri = PopulateAndGetFirstResultURI();216 std::string uri = PopulateAndGetFirstResultURI();
199217
=== modified file 'tests/test_mock_filemanager.h'
--- tests/test_mock_filemanager.h 2013-03-29 17:44:12 +0000
+++ tests/test_mock_filemanager.h 2013-05-02 01:34:26 +0000
@@ -29,9 +29,10 @@
29{29{
30 typedef std::shared_ptr<MockFileManager> Ptr;30 typedef std::shared_ptr<MockFileManager> Ptr;
3131
32 MOCK_METHOD2(Open, void(std::string const& uri, unsigned long long time));32 MOCK_METHOD2(Open, bool(std::string const& uri, unsigned long long time));
33 MOCK_METHOD2(OpenActiveChild, void(std::string const& uri, unsigned long long time));33 MOCK_METHOD2(OpenActiveChild, bool(std::string const& uri, unsigned long long time));
34 MOCK_METHOD1(OpenTrash, void(unsigned long long time));34 MOCK_METHOD1(OpenTrash, bool(unsigned long long time));
35 MOCK_METHOD2(Launch, bool(std::string const& uri, unsigned long long time));
35 MOCK_METHOD1(EmptyTrash, void(unsigned long long time));36 MOCK_METHOD1(EmptyTrash, void(unsigned long long time));
36 MOCK_CONST_METHOD0(OpenedLocations, std::vector<std::string>());37 MOCK_CONST_METHOD0(OpenedLocations, std::vector<std::string>());
37 MOCK_CONST_METHOD1(IsPrefixOpened, bool(std::string const& uri));38 MOCK_CONST_METHOD1(IsPrefixOpened, bool(std::string const& uri));
3839
=== modified file 'tests/test_service_lens.cpp'
--- tests/test_service_lens.cpp 2013-03-04 11:31:36 +0000
+++ tests/test_service_lens.cpp 2013-05-02 01:34:26 +0000
@@ -118,21 +118,22 @@
118 int num_items = search_type == UNITY_SEARCH_TYPE_GLOBAL ? 10 : 5;118 int num_items = search_type == UNITY_SEARCH_TYPE_GLOBAL ? 10 : 5;
119119
120 DeeModel* model = (DeeModel*)unity_lens_search_get_results_model(search);120 DeeModel* model = (DeeModel*)unity_lens_search_get_results_model(search);
121 bool redirect = (g_strcmp0(unity_lens_search_get_search_string(search), "redirect") == 0);
122
123 dee_model_clear(model);
121124
122 for (i = 0; i < num_items; i++)125 for (i = 0; i < num_items; i++)
123 {126 {
124 gchar* name = g_strdup_printf("%s%d",127 std::string name = unity_lens_search_get_search_string(search) + std::to_string(i);
125 unity_lens_search_get_search_string(search),128 std::string uri = (redirect ? "file:///test/redirect/" : "file:///test/") + std::to_string(i);
126 i);
127 dee_model_append(model,129 dee_model_append(model,
128 "file:///test",130 uri.c_str(),
129 "gtk-apply",131 "gtk-apply",
130 i,132 i,
131 "text/html",133 "text/html",
132 name,134 name.c_str(),
133 "kamstrup likes ponies",135 "kamstrup likes ponies",
134 "file:///test");136 uri.c_str());
135 g_free(name);
136 }137 }
137138
138 unity_lens_search_finished (search);139 unity_lens_search_finished (search);
@@ -140,11 +141,17 @@
140141
141static UnityActivationResponse* on_activate_uri(UnityScope* scope, const char* uri, Lens* self)142static UnityActivationResponse* on_activate_uri(UnityScope* scope, const char* uri, Lens* self)
142{143{
144 if (strstr(uri, "/redirect/"))
145 return unity_activation_response_new(UNITY_HANDLED_TYPE_HIDE_DASH, uri);
146
143 return unity_activation_response_new(UNITY_HANDLED_TYPE_HIDE_DASH, "");147 return unity_activation_response_new(UNITY_HANDLED_TYPE_HIDE_DASH, "");
144}148}
145149
146static UnityActivationResponse* preview_action_activated(UnityPreviewAction* action, const char* uri)150static UnityActivationResponse* preview_action_activated(UnityPreviewAction* action, const char* uri)
147{151{
152 if (strstr(uri, "/redirect/"))
153 return unity_activation_response_new(UNITY_HANDLED_TYPE_HIDE_DASH, uri);
154
148 return unity_activation_response_new(UNITY_HANDLED_TYPE_SHOW_DASH, "");155 return unity_activation_response_new(UNITY_HANDLED_TYPE_SHOW_DASH, "");
149}156}
150157
151158
=== modified file 'unity-shared/FileManager.h'
--- unity-shared/FileManager.h 2013-04-10 22:13:44 +0000
+++ unity-shared/FileManager.h 2013-05-02 01:34:26 +0000
@@ -37,13 +37,17 @@
37 FileManager() = default;37 FileManager() = default;
38 virtual ~FileManager() {}38 virtual ~FileManager() {}
3939
40 virtual void Open(std::string const& uri, unsigned long long timestamp = 0) = 0;40 virtual bool Open(std::string const& uri, unsigned long long timestamp = 0) = 0;
41 virtual void OpenActiveChild(std::string const& uri, unsigned long long timestamp = 0) = 0;41 virtual bool OpenActiveChild(std::string const& uri, unsigned long long timestamp = 0) = 0;
42 virtual void OpenTrash(unsigned long long timestamp) = 0;42 virtual bool OpenTrash(unsigned long long timestamp) = 0;
43
44 virtual bool Launch(std::string const& uri, unsigned long long timestamp = 0) = 0;
45
43 virtual std::vector<std::string> OpenedLocations() const = 0;46 virtual std::vector<std::string> OpenedLocations() const = 0;
44 virtual bool IsPrefixOpened(std::string const& uri) const = 0;47 virtual bool IsPrefixOpened(std::string const& uri) const = 0;
45 virtual bool IsTrashOpened() const = 0;48 virtual bool IsTrashOpened() const = 0;
46 virtual bool IsDeviceOpened() const = 0;49 virtual bool IsDeviceOpened() const = 0;
50
47 virtual void EmptyTrash(unsigned long long timestamp = 0) = 0;51 virtual void EmptyTrash(unsigned long long timestamp = 0) = 0;
4852
49 sigc::signal<void> locations_changed;53 sigc::signal<void> locations_changed;
5054
=== modified file 'unity-shared/GnomeFileManager.cpp'
--- unity-shared/GnomeFileManager.cpp 2013-03-29 17:44:12 +0000
+++ unity-shared/GnomeFileManager.cpp 2013-05-02 01:34:26 +0000
@@ -36,6 +36,7 @@
36const std::string TRASH_URI = "trash:";36const std::string TRASH_URI = "trash:";
37const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserDataDirectory() + "/Trash/files";37const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserDataDirectory() + "/Trash/files";
38const std::string DEVICES_PREFIX = "file:///media/" + std::string(g_get_user_name());38const std::string DEVICES_PREFIX = "file:///media/" + std::string(g_get_user_name());
39const std::string FOLDER_TYPE = "inode/directory";
39}40}
4041
41struct GnomeFileManager::Impl42struct GnomeFileManager::Impl
@@ -93,6 +94,15 @@
93 return "";94 return "";
94 }95 }
9596
97 static glib::Object<GAppLaunchContext> GetLaunchContext(long long timestamp)
98 {
99 GdkDisplay* display = gdk_display_get_default();
100 glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
101 gdk_app_launch_context_set_timestamp(context, timestamp);
102
103 return glib::object_cast<GAppLaunchContext>(context);
104 }
105
96 GnomeFileManager* parent_;106 GnomeFileManager* parent_;
97 glib::DBusProxy filemanager_proxy_;107 glib::DBusProxy filemanager_proxy_;
98 std::vector<std::string> opened_locations_;108 std::vector<std::string> opened_locations_;
@@ -112,46 +122,67 @@
112GnomeFileManager::~GnomeFileManager()122GnomeFileManager::~GnomeFileManager()
113{}123{}
114124
115void GnomeFileManager::Open(std::string const& uri, unsigned long long timestamp)125bool GnomeFileManager::Launch(std::string const& uri, unsigned long long timestamp)
116{126{
117 if (uri.empty())127 if (uri.empty())
118 {128 {
119 LOG_ERROR(logger) << "Impossible to open an empty location";129 LOG_ERROR(logger) << "Impossible to launch the application for an empty location";
120 return;130 return false;
121 }131 }
122132
123 glib::Error error;133 glib::Error error;
124 GdkDisplay* display = gdk_display_get_default();134 auto const& gcontext = Impl::GetLaunchContext(timestamp);
125 glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
126
127 if (timestamp > 0)
128 gdk_app_launch_context_set_timestamp(context, timestamp);
129
130 auto const& gcontext = glib::object_cast<GAppLaunchContext>(context);
131 g_app_info_launch_default_for_uri(uri.c_str(), gcontext, &error);135 g_app_info_launch_default_for_uri(uri.c_str(), gcontext, &error);
132136
133 if (error)137 if (error)
134 {138 {
135 LOG_ERROR(logger) << "Impossible to open the location: " << error.Message();139 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED))
136 }140 {
137}141 /* If the location is not mounted, then we open the file-manager to make
138142 * it mount the requested position */
139void GnomeFileManager::OpenActiveChild(std::string const& uri, unsigned long long timestamp)143 return Open(uri, timestamp);
144 }
145
146 LOG_ERROR(logger) << "Impossible to launch the location: " << error;
147 return false;
148 }
149
150 return true;
151}
152
153bool GnomeFileManager::Open(std::string const& uri, unsigned long long timestamp)
154{
155 glib::Error error;
156 glib::Object<GAppInfo> app_info(g_app_info_get_default_for_type(FOLDER_TYPE.c_str(), TRUE));
157 std::shared_ptr<GList> uris(g_list_append(nullptr, const_cast<char*>(uri.c_str())), g_list_free);
158
159 g_app_info_launch_uris(app_info, uris.get(), Impl::GetLaunchContext(timestamp), &error);
160
161 if (error)
162 {
163 LOG_ERROR(logger) << "Impossible to open the location: " << error;
164 return false;
165 }
166
167 return true;
168}
169
170bool GnomeFileManager::OpenActiveChild(std::string const& uri, unsigned long long timestamp)
140{171{
141 auto const& opened = impl_->GetOpenedPrefix(uri);172 auto const& opened = impl_->GetOpenedPrefix(uri);
142173
143 Open(opened.empty() ? uri : opened, timestamp);174 return Open(opened.empty() ? uri : opened, timestamp);
144}175}
145176
146void GnomeFileManager::OpenTrash(unsigned long long timestamp)177bool GnomeFileManager::OpenTrash(unsigned long long timestamp)
147{178{
148 if (IsPrefixOpened(TRASH_PATH))179 if (IsPrefixOpened(TRASH_PATH))
149 {180 {
150 OpenActiveChild(TRASH_PATH, timestamp);181 return OpenActiveChild(TRASH_PATH, timestamp);
151 }182 }
152 else183 else
153 {184 {
154 OpenActiveChild(TRASH_URI, timestamp);185 return OpenActiveChild(TRASH_URI, timestamp);
155 }186 }
156}187}
157188
@@ -163,17 +194,11 @@
163194
164 if (app_info)195 if (app_info)
165 {196 {
166 GdkDisplay* display = gdk_display_get_default();
167 glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
168
169 if (timestamp > 0)
170 gdk_app_launch_context_set_timestamp(context, timestamp);
171
172 auto const& gcontext = glib::object_cast<GAppLaunchContext>(context);
173 auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.NautilusApplication",197 auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.NautilusApplication",
174 "/org/gnome/NautilusApplication",198 "/org/gnome/NautilusApplication",
175 "org.gtk.Application");199 "org.gtk.Application");
176200
201 auto const& gcontext = Impl::GetLaunchContext(timestamp);
177 glib::String context_string(g_app_launch_context_get_startup_notify_id(gcontext, app_info, nullptr));202 glib::String context_string(g_app_launch_context_get_startup_notify_id(gcontext, app_info, nullptr));
178203
179 if (context_string && g_utf8_validate(context_string, -1, nullptr))204 if (context_string && g_utf8_validate(context_string, -1, nullptr))
180205
=== modified file 'unity-shared/GnomeFileManager.h'
--- unity-shared/GnomeFileManager.h 2013-03-29 17:44:12 +0000
+++ unity-shared/GnomeFileManager.h 2013-05-02 01:34:26 +0000
@@ -32,15 +32,19 @@
32 static FileManager::Ptr Get();32 static FileManager::Ptr Get();
33 ~GnomeFileManager();33 ~GnomeFileManager();
3434
35 void Open(std::string const& uri, unsigned long long timestamp);35 bool Open(std::string const& uri, unsigned long long timestamp);
36 void OpenActiveChild(std::string const& uri, unsigned long long timestamp);36 bool OpenActiveChild(std::string const& uri, unsigned long long timestamp);
37 void OpenTrash(unsigned long long timestamp);37 bool OpenTrash(unsigned long long timestamp);
38 void EmptyTrash(unsigned long long timestamp);38
39 bool Launch(std::string const& uri, unsigned long long timestamp);
40
39 std::vector<std::string> OpenedLocations() const;41 std::vector<std::string> OpenedLocations() const;
40 bool IsPrefixOpened(std::string const& uri) const;42 bool IsPrefixOpened(std::string const& uri) const;
41 bool IsTrashOpened() const;43 bool IsTrashOpened() const;
42 bool IsDeviceOpened() const;44 bool IsDeviceOpened() const;
4345
46 void EmptyTrash(unsigned long long timestamp);
47
44private:48private:
45 GnomeFileManager();49 GnomeFileManager();
46 void Activate(unsigned long long timestamp);50 void Activate(unsigned long long timestamp);

Subscribers

People subscribed via source and target branches