Merge ~3v1n0/unity:use-upstream-nautilus-features into unity:master

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 69c308e849e04cb89d2b9a99ec27a596c2ab1e92
Merged at revision: 3a1c7e35f69f1bedf72832becbd0fd1e44e18b69
Proposed branch: ~3v1n0/unity:use-upstream-nautilus-features
Merge into: unity:master
Diff against target: 897 lines (+274/-98)
30 files modified
CMakeLists.txt (+1/-1)
dash/ResultRendererTile.cpp (+1/-1)
debian/changelog (+39/-0)
debian/control (+1/-1)
launcher/LauncherController.cpp (+1/-53)
launcher/LauncherControllerPrivateImpl.h (+81/-0)
launcher/MockLauncherIcon.h (+1/-0)
launcher/Volume.h (+1/-0)
launcher/VolumeImp.cpp (+11/-0)
launcher/VolumeImp.h (+1/-0)
launcher/VolumeLauncherIcon.cpp (+3/-0)
tests/dummy-xorg-test-runner.sh (+4/-1)
tests/mock-application.h (+6/-0)
tests/test_gtk_icon_info.cpp (+10/-0)
tests/test_launcher_controller.cpp (+1/-0)
tests/test_mock_devices.h (+1/-0)
tests/test_mock_filemanager.h (+4/-2)
tests/test_result_renderer.cpp (+1/-1)
tests/test_software_center_launcher_icon.cpp (+1/-1)
tests/test_text_input.cpp (+2/-0)
tests/test_trash_launcher_icon.cpp (+1/-1)
tests/test_volume_launcher_icon.cpp (+2/-2)
unity-shared/ApplicationManager.h (+3/-0)
unity-shared/BamfApplicationManager.cpp (+25/-0)
unity-shared/BamfApplicationManager.h (+2/-0)
unity-shared/CompizUtils.cpp (+1/-0)
unity-shared/FileManager.h (+3/-2)
unity-shared/GnomeFileManager.cpp (+64/-29)
unity-shared/GnomeFileManager.h (+2/-2)
unity-shared/IntrospectionData.cpp (+0/-1)
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+403570@code.launchpad.net

Description of the change

Use upstream features for GnomeFileManager, so we can now drop two nautilus patches:

19_unity_open_location_xid.patch
20_add_timestamp_to_operations.patch

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/CMakeLists.txt b/CMakeLists.txt
2index e12a71a..e3abf80 100644
3--- a/CMakeLists.txt
4+++ b/CMakeLists.txt
5@@ -11,7 +11,7 @@ include (GNUInstallDirs)
6 set (PROJECT_NAME "unity")
7 set (UNITY_MAJOR 7)
8 set (UNITY_MINOR 5)
9-set (UNITY_MICRO 0)
10+set (UNITY_MICRO 1)
11 set (UNITY_VERSION "${UNITY_MAJOR}.${UNITY_MINOR}.${UNITY_MICRO}")
12 set (UNITY_API_VERSION "6.0")
13 set (UNITY_COMPONENTS_VERSION "6")
14diff --git a/dash/ResultRendererTile.cpp b/dash/ResultRendererTile.cpp
15index ae0fc22..94a26ff 100644
16--- a/dash/ResultRendererTile.cpp
17+++ b/dash/ResultRendererTile.cpp
18@@ -259,7 +259,7 @@ nux::NBitmapData* ResultRendererTile::GetDndImage(Result const& row) const
19 if (container && container->drag_icon && container->drag_icon.IsType(GDK_TYPE_PIXBUF))
20 {
21 // Need to ref the drag icon because GdkGraphics will unref it.
22- nux::GdkGraphics graphics(GDK_PIXBUF(g_object_ref(container->drag_icon)));
23+ nux::GdkGraphics graphics(g_object_ref(static_cast<GdkPixbuf*>(container->drag_icon)));
24 bitmap = graphics.GetBitmap();
25 }
26 return bitmap ? bitmap : ResultRenderer::GetDndImage(row);
27diff --git a/debian/changelog b/debian/changelog
28index ffea45d..a31fe6c 100644
29--- a/debian/changelog
30+++ b/debian/changelog
31@@ -1,3 +1,42 @@
32+unity (7.5.1) UNRELEASED; urgency=medium
33+
34+ * New upstream release
35+ * IntrospectionData: Keep Get() const as it should be.
36+ The builder is now invalid but unreffing will happne in the destructor
37+ * ResultRendererTile: Use proper casting to GdkPixbuf for drag icon
38+ * CompizUtils: Add missing iostream include
39+ * FileManager: Support timestamps and parent windows and implement for GNOME.
40+ Finally implement org.gnome.Nautilus.FileOperations2 so we can get rid
41+ of using our ubuntu patch in nautilus https://trello.com/c/ZVKL0Loz
42+ * ApplicationManager: Add ability to get window properties.
43+ A simple way to get properties through bamf, so that we don't have
44+ to compute the atom ourselves.
45+ * ApplicationManager: Add function to find a window by an (unique) property.
46+ This is relevant for unique property values, otherwise we'd just return
47+ the firs window matching it.
48+ * GnomeFileManager: Use upstream OpenWindowsWithLocations.
49+ Find nautilus application windows by their unique GTK window object path
50+ using the application manager, in this way we can drop the support to
51+ the ubuntu-only XUbuntuOpenLocationsXids property.
52+ As per this, recommends an higher version of nautilus.
53+ * VolumeLauncherIcons: Hide shadowed mounts
54+ * TestSoftwareCenterLauncherIcon: Expose proper virtual function.
55+ Compiler seems to be confused by using a base class implementation,
56+ so let's just point to the class one and leave it figure out which
57+ implementation to use at runtime.
58+ * TestGtkIconInfo: Ignore icons that gtk can't find.
59+ We still ensure that we've tested various, so the test is still valid
60+ * TestResultRenderer: Use a freedesktop icon for the test.
61+ So we can be sure that a theme will provide it
62+ * tests/dummy-xorg-test-runner.sh: Do not delete log files on failure
63+ * LauncherController: Move GetLastIconPriority into a private impl header.
64+ Being a template it must be defined for all its customers, so expose it
65+ to the test.
66+ Fixes linking issue on s390x.
67+ * tests/test_text_input: Initialize previews style
68+
69+ -- Marco Trevisan (Treviño) <marco@ubuntu.com> Tue, 01 Jun 2021 21:56:27 +0200
70+
71 unity (7.5.0+20.04.20200312-0ubuntu1) focal; urgency=medium
72
73 [ Khurshid Alam ]
74diff --git a/debian/control b/debian/control
75index 945f092..cd3a3bf 100644
76--- a/debian/control
77+++ b/debian/control
78@@ -90,7 +90,7 @@ Depends: ${shlibs:Depends},
79 unity-scope-home,
80 Recommends: unity-control-center,
81 ${unity-default-masterscopes}
82- nautilus,
83+ nautilus (>> 3.37.1),
84 nemo,
85 gnome-disk-utility,
86 hud,
87diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp
88index 5fb2882..3a38b5f 100644
89--- a/launcher/LauncherController.cpp
90+++ b/launcher/LauncherController.cpp
91@@ -36,6 +36,7 @@
92 #include "FileManagerLauncherIcon.h"
93 #include "LauncherController.h"
94 #include "LauncherControllerPrivate.h"
95+#include "LauncherControllerPrivateImpl.h"
96 #include "SoftwareCenterLauncherIcon.h"
97 #include "ExpoLauncherIcon.h"
98 #include "TrashLauncherIcon.h"
99@@ -790,59 +791,6 @@ void Controller::Impl::RegisterIcon(AbstractLauncherIcon::Ptr const& icon, int p
100 }
101 }
102
103-template<typename IconType>
104-int Controller::Impl::GetLastIconPriority(std::string const& favorite_uri, bool sticky)
105-{
106- auto const& icons = model_->GetSublist<IconType>();
107- int icon_prio = std::numeric_limits<int>::min();
108-
109- AbstractLauncherIcon::Ptr last_icon;
110-
111- // Get the last (non)-sticky icon position (if available)
112- for (auto it = icons.rbegin(); it != icons.rend(); ++it)
113- {
114- auto const& icon = *it;
115- bool update_last_icon = ((!last_icon && !sticky) || sticky);
116-
117- if (update_last_icon || icon->IsSticky() == sticky)
118- {
119- last_icon = icon;
120-
121- if (icon->IsSticky() == sticky)
122- break;
123- }
124- }
125-
126- if (last_icon)
127- {
128- icon_prio = last_icon->SortPriority();
129-
130- if (sticky && last_icon->IsSticky() != sticky)
131- icon_prio -= 1;
132- }
133- else if (!favorite_uri.empty())
134- {
135- // If we have no applications opened, we must guess it position by favorites
136- for (auto const& fav : FavoriteStore::Instance().GetFavorites())
137- {
138- if (fav == favorite_uri)
139- {
140- if (icon_prio == std::numeric_limits<int>::min())
141- icon_prio = (*model_->begin())->SortPriority() - 1;
142-
143- break;
144- }
145-
146- auto const& icon = GetIconByUri(fav);
147-
148- if (icon)
149- icon_prio = icon->SortPriority();
150- }
151- }
152-
153- return icon_prio;
154-}
155-
156 void Controller::Impl::OnApplicationStarted(ApplicationPtr const& app)
157 {
158 if (app->sticky() || app->seen())
159diff --git a/launcher/LauncherControllerPrivateImpl.h b/launcher/LauncherControllerPrivateImpl.h
160new file mode 100644
161index 0000000..88b1db8
162--- /dev/null
163+++ b/launcher/LauncherControllerPrivateImpl.h
164@@ -0,0 +1,81 @@
165+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
166+/*
167+ * Copyright (C) 2010-2012 Canonical Ltd
168+ *
169+ * This program is free software: you can redistribute it and/or modify
170+ * it under the terms of the GNU General Public License version 3 as
171+ * published by the Free Software Foundation.
172+ *
173+ * This program is distributed in the hope that it will be useful,
174+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
175+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176+ * GNU General Public License for more details.
177+ *
178+ * You should have received a copy of the GNU General Public License
179+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
180+ *
181+ * Authored by: Jason Smith <jason.smith@canonical.com>
182+ * Tim Penhey <tim.penhey@canonical.com>
183+ * Marco Trevisan <marco.trevisan@canonical.com>
184+ */
185+
186+namespace unity
187+{
188+namespace launcher
189+{
190+
191+template<typename IconType>
192+int Controller::Impl::GetLastIconPriority(std::string const& favorite_uri, bool sticky)
193+{
194+ auto const& icons = model_->GetSublist<IconType>();
195+ int icon_prio = std::numeric_limits<int>::min();
196+
197+ AbstractLauncherIcon::Ptr last_icon;
198+
199+ // Get the last (non)-sticky icon position (if available)
200+ for (auto it = icons.rbegin(); it != icons.rend(); ++it)
201+ {
202+ auto const& icon = *it;
203+ bool update_last_icon = ((!last_icon && !sticky) || sticky);
204+
205+ if (update_last_icon || icon->IsSticky() == sticky)
206+ {
207+ last_icon = icon;
208+
209+ if (icon->IsSticky() == sticky)
210+ break;
211+ }
212+ }
213+
214+ if (last_icon)
215+ {
216+ icon_prio = last_icon->SortPriority();
217+
218+ if (sticky && last_icon->IsSticky() != sticky)
219+ icon_prio -= 1;
220+ }
221+ else if (!favorite_uri.empty())
222+ {
223+ // If we have no applications opened, we must guess it position by favorites
224+ for (auto const& fav : FavoriteStore::Instance().GetFavorites())
225+ {
226+ if (fav == favorite_uri)
227+ {
228+ if (icon_prio == std::numeric_limits<int>::min())
229+ icon_prio = (*model_->begin())->SortPriority() - 1;
230+
231+ break;
232+ }
233+
234+ auto const& icon = GetIconByUri(fav);
235+
236+ if (icon)
237+ icon_prio = icon->SortPriority();
238+ }
239+ }
240+
241+ return icon_prio;
242+}
243+
244+} // namespace launcher
245+} // namespace unity
246diff --git a/launcher/MockLauncherIcon.h b/launcher/MockLauncherIcon.h
247index 550047d..1ceb65c 100644
248--- a/launcher/MockLauncherIcon.h
249+++ b/launcher/MockLauncherIcon.h
250@@ -55,6 +55,7 @@ public:
251 virtual WindowType type() const { return WindowType::UNKNOWN; }
252
253 virtual Window window_id() const { return xid_; }
254+ virtual std::string property(std::string const& name) const { return name; }
255 virtual int monitor() const { return -1; }
256 virtual ApplicationPtr application() const { return ApplicationPtr(); }
257 virtual bool Focus() const { return false; }
258diff --git a/launcher/Volume.h b/launcher/Volume.h
259index b6c03ff..a40aae0 100644
260--- a/launcher/Volume.h
261+++ b/launcher/Volume.h
262@@ -49,6 +49,7 @@ public:
263 virtual std::string GetUri() const = 0;
264 virtual bool HasSiblings() const = 0;
265 virtual bool IsMounted() const = 0;
266+ virtual bool IsShadowed() const = 0;
267
268 virtual void Eject() = 0;
269 virtual void Mount() = 0;
270diff --git a/launcher/VolumeImp.cpp b/launcher/VolumeImp.cpp
271index 7e9957e..e2f272d 100644
272--- a/launcher/VolumeImp.cpp
273+++ b/launcher/VolumeImp.cpp
274@@ -120,6 +120,12 @@ public:
275 return static_cast<bool>(mount);
276 }
277
278+ bool IsShadowed() const
279+ {
280+ glib::Object<GMount> mount(g_volume_get_mount(volume_));
281+ return mount ? g_mount_is_shadowed(mount) : false;
282+ }
283+
284 void Eject()
285 {
286 if (!CanBeEjected())
287@@ -264,6 +270,11 @@ bool VolumeImp::IsMounted() const
288 return pimpl->IsMounted();
289 }
290
291+bool VolumeImp::IsShadowed() const
292+{
293+ return pimpl->IsShadowed();
294+}
295+
296 void VolumeImp::Mount()
297 {
298 pimpl->Mount();
299diff --git a/launcher/VolumeImp.h b/launcher/VolumeImp.h
300index 47a9b0b..363f7dd 100644
301--- a/launcher/VolumeImp.h
302+++ b/launcher/VolumeImp.h
303@@ -51,6 +51,7 @@ public:
304 virtual std::string GetUri() const;
305 virtual bool HasSiblings() const;
306 virtual bool IsMounted() const;
307+ virtual bool IsShadowed() const;
308
309 virtual void Eject();
310 virtual void Mount();
311diff --git a/launcher/VolumeLauncherIcon.cpp b/launcher/VolumeLauncherIcon.cpp
312index 6cbbc5c..d8d0a0f 100644
313--- a/launcher/VolumeLauncherIcon.cpp
314+++ b/launcher/VolumeLauncherIcon.cpp
315@@ -78,6 +78,9 @@ public:
316 if (IsBlackListed() && parent_->GetManagedWindows().empty())
317 return false;
318
319+ if (volume_->IsShadowed())
320+ return false;
321+
322 return true;
323 }
324
325diff --git a/tests/dummy-xorg-test-runner.sh b/tests/dummy-xorg-test-runner.sh
326index 93e5ac6..a4808f8 100755
327--- a/tests/dummy-xorg-test-runner.sh
328+++ b/tests/dummy-xorg-test-runner.sh
329@@ -54,7 +54,10 @@ function do_cleanup()
330 {
331 if [ -n "$x_pid" ] && (kill -0 $x_pid &> /dev/null); then kill $x_pid; fi
332 rm $conffile
333- rm $logfile*
334+
335+ if [[ "$ret_val" == 0 ]]; then
336+ rm $logfile*
337+ fi
338 }
339
340 trap "do_cleanup; exit 1" SIGHUP SIGINT SIGSEGV SIGTERM
341diff --git a/tests/mock-application.h b/tests/mock-application.h
342index 0ee200f..bd00908 100644
343--- a/tests/mock-application.h
344+++ b/tests/mock-application.h
345@@ -55,6 +55,7 @@ struct MockApplicationWindow : unity::ApplicationWindow
346
347 ON_CALL(*this, type()).WillByDefault(Invoke([this] { return type_; }));
348 ON_CALL(*this, window_id()).WillByDefault(Invoke([this] { return xid_; }));
349+ ON_CALL(*this, property(_)).WillByDefault(Return("MockWindowProperty"));
350 ON_CALL(*this, Focus()).WillByDefault(Invoke([this] { return LocalFocus(); }));
351 ON_CALL(*this, application()).WillByDefault(Return(unity::ApplicationPtr()));
352 }
353@@ -71,6 +72,7 @@ struct MockApplicationWindow : unity::ApplicationWindow
354
355 MOCK_CONST_METHOD0(type, unity::WindowType());
356 MOCK_CONST_METHOD0(window_id, Window());
357+ MOCK_CONST_METHOD1(property, std::string(std::string const&));
358 MOCK_CONST_METHOD0(application, unity::ApplicationPtr());
359 MOCK_CONST_METHOD0(Focus, bool());
360 MOCK_CONST_METHOD0(Quit, void());
361@@ -319,6 +321,9 @@ struct MockApplicationManager : public unity::ApplicationManager
362 ON_CALL(*this, GetActiveApplication()).WillByDefault(Invoke([this] { return unity::ApplicationPtr(); } ));
363 ON_CALL(*this, GetWindowsForMonitor(_)).WillByDefault(Invoke([this] (Window) { return unity::WindowList(); } ));
364 ON_CALL(*this, GetWindowForId(_)).WillByDefault(Invoke([this] (int) { return unity::ApplicationWindowPtr(); } ));
365+ ON_CALL(*this, GetWindowForProperty(_, _)).WillByDefault(Invoke([this] (std::string const&, std::string const&) {
366+ return unity::ApplicationWindowPtr();
367+ }));
368 }
369
370 static void StartApp(std::string const& desktop_file)
371@@ -338,6 +343,7 @@ struct MockApplicationManager : public unity::ApplicationManager
372 MOCK_CONST_METHOD0(GetActiveApplication, unity::ApplicationPtr());
373 MOCK_CONST_METHOD1(GetWindowsForMonitor, unity::WindowList(int));
374 MOCK_CONST_METHOD1(GetWindowForId, unity::ApplicationWindowPtr(Window));
375+ MOCK_CONST_METHOD2(GetWindowForProperty, unity::ApplicationWindowPtr(std::string const&, std::string const&));
376 MOCK_CONST_METHOD3(FocusWindowGroup, void(unity::WindowList const&, bool, int));
377
378 unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file)
379diff --git a/tests/test_gtk_icon_info.cpp b/tests/test_gtk_icon_info.cpp
380index bc4d8fb..6aaefd9 100644
381--- a/tests/test_gtk_icon_info.cpp
382+++ b/tests/test_gtk_icon_info.cpp
383@@ -38,17 +38,27 @@ TEST(TestGtkIconInfo, EmptyIconInfo)
384 TEST(TestGtkIconInfo, ValidIconInfo)
385 {
386 GList *icons = gtk_icon_theme_list_icons(gtk_icon_theme_get_default(), "Emblems");
387+ bool found_any = false;
388
389 for (GList *l = icons; l; l = l->next)
390 {
391 auto icon_name = static_cast <const char*>(l->data);
392 GtkIconInfo *ginfo = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), icon_name, 32, GTK_ICON_LOOKUP_FORCE_SIZE);
393 glib::Object<GtkIconInfo> info(ginfo);
394+ if (!ginfo)
395+ {
396+ ASSERT_THAT(info.RawPtr(), IsNull());
397+ continue;
398+ }
399+
400+ found_any = true;
401 ASSERT_THAT(info.RawPtr(), NotNull());
402 ASSERT_TRUE(info);
403 ASSERT_EQ(info, ginfo);
404 }
405
406+ ASSERT_TRUE(found_any);
407+
408 g_list_free_full(icons, g_free);
409 }
410
411diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
412index 6a6df5c..9495dff 100644
413--- a/tests/test_launcher_controller.cpp
414+++ b/tests/test_launcher_controller.cpp
415@@ -22,6 +22,7 @@
416 #include "FavoriteStore.h"
417 #include "LauncherController.h"
418 #include "LauncherControllerPrivate.h"
419+#include "LauncherControllerPrivateImpl.h"
420 #include "ExpoLauncherIcon.h"
421 #include "DesktopLauncherIcon.h"
422 #include "DesktopUtilities.h"
423diff --git a/tests/test_mock_devices.h b/tests/test_mock_devices.h
424index 7dc0fce..d389ba1 100644
425--- a/tests/test_mock_devices.h
426+++ b/tests/test_mock_devices.h
427@@ -89,6 +89,7 @@ struct MockVolume : Volume
428 MOCK_CONST_METHOD0(HasSiblings, bool(void));
429 MOCK_CONST_METHOD0(CanBeEjected, bool(void));
430 MOCK_CONST_METHOD0(IsMounted, bool(void));
431+ MOCK_CONST_METHOD0(IsShadowed, bool(void));
432
433 MOCK_METHOD0(Eject, void());
434 MOCK_METHOD0(Mount, void());
435diff --git a/tests/test_mock_filemanager.h b/tests/test_mock_filemanager.h
436index 1e541eb..8eb7925 100644
437--- a/tests/test_mock_filemanager.h
438+++ b/tests/test_mock_filemanager.h
439@@ -34,8 +34,10 @@ struct MockFileManager : FileManager
440 MOCK_METHOD2(Open, void(std::string const& uri, uint64_t time));
441 MOCK_METHOD1(OpenTrash, void(uint64_t time));
442 MOCK_METHOD1(TrashFile, bool(std::string const& uri));
443- MOCK_METHOD1(EmptyTrash, void(uint64_t time));
444- MOCK_METHOD3(CopyFiles, void(std::set<std::string> const& files, std::string const& dest, uint64_t time));
445+ MOCK_METHOD2(EmptyTrash, void(uint64_t time, Window parent_xid));
446+ MOCK_METHOD4(CopyFiles, void(std::set<std::string> const& files,
447+ std::string const& dest, uint64_t time,
448+ Window parent_xid));
449 MOCK_CONST_METHOD1(WindowsForLocation, WindowList(std::string const&));
450 MOCK_CONST_METHOD1(LocationForWindow, std::string(ApplicationWindowPtr const&));
451
452diff --git a/tests/test_result_renderer.cpp b/tests/test_result_renderer.cpp
453index 9a0b2b0..2f286be 100644
454--- a/tests/test_result_renderer.cpp
455+++ b/tests/test_result_renderer.cpp
456@@ -39,7 +39,7 @@ namespace unity
457 namespace
458 {
459
460-#define DEFAULT_GICON ". GThemedIcon cmake"
461+#define DEFAULT_GICON ". GThemedIcon terminal"
462
463 } // namespace [anonymous]
464
465diff --git a/tests/test_software_center_launcher_icon.cpp b/tests/test_software_center_launcher_icon.cpp
466index 98ef81d..4984cca 100644
467--- a/tests/test_software_center_launcher_icon.cpp
468+++ b/tests/test_software_center_launcher_icon.cpp
469@@ -69,7 +69,7 @@ struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase
470 using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;
471 using SoftwareCenterLauncherIcon::OnFinished;
472 using SoftwareCenterLauncherIcon::OnPropertyChanged;
473- using LauncherIcon::GetRemoteUri;
474+ using SoftwareCenterLauncherIcon::GetRemoteUri;
475 };
476
477 nux::ObjectPtr<Launcher> CreateLauncher()
478diff --git a/tests/test_text_input.cpp b/tests/test_text_input.cpp
479index e37352d..4d3b418 100644
480--- a/tests/test_text_input.cpp
481+++ b/tests/test_text_input.cpp
482@@ -23,6 +23,7 @@
483 #include <gtest/gtest.h>
484
485 #include "unity-shared/DashStyle.h"
486+#include "unity-shared/PreviewStyle.h"
487 #include "unity-shared/StaticCairoText.h"
488 #include "unity-shared/TextInput.h"
489 #include "test_utils.h"
490@@ -55,6 +56,7 @@ class TestTextInput : public ::testing::Test
491 pango_entry = entry->GetPangoEntry();
492 }
493
494+ dash::previews::Style previews_style_;
495 dash::Style dash_style_;
496 nux::ObjectPtr<TextInputMock> entry;
497 StaticCairoText* hint;
498diff --git a/tests/test_trash_launcher_icon.cpp b/tests/test_trash_launcher_icon.cpp
499index 58690c5..f224b0d 100644
500--- a/tests/test_trash_launcher_icon.cpp
501+++ b/tests/test_trash_launcher_icon.cpp
502@@ -76,7 +76,7 @@ TEST_F(TestTrashLauncherIcon, QuicklistEmptyTrash)
503 auto const& empty_trash_menu = menus.front();
504
505 unsigned time = g_random_int();
506- EXPECT_CALL(*fm_, EmptyTrash(time));
507+ EXPECT_CALL(*fm_, EmptyTrash(time, 0));
508 dbusmenu_menuitem_handle_event(empty_trash_menu, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time);
509 }
510
511diff --git a/tests/test_volume_launcher_icon.cpp b/tests/test_volume_launcher_icon.cpp
512index cee0dc9..569cb3c 100644
513--- a/tests/test_volume_launcher_icon.cpp
514+++ b/tests/test_volume_launcher_icon.cpp
515@@ -711,7 +711,7 @@ TEST_F(TestVolumeLauncherIcon, AcceptDropUnmounted)
516 InSequence seq;
517 ON_CALL(*volume_, IsMounted()).WillByDefault(Return(false));
518 EXPECT_CALL(*volume_, Mount());
519- EXPECT_CALL(*file_manager_, CopyFiles(data.Uris(), volume_->GetUri(), time));
520+ EXPECT_CALL(*file_manager_, CopyFiles(data.Uris(), volume_->GetUri(), time, 0));
521 icon_->AcceptDrop(data);
522 }
523
524@@ -725,7 +725,7 @@ TEST_F(TestVolumeLauncherIcon, AcceptDropMounted)
525
526 InSequence seq;
527 EXPECT_CALL(*volume_, Mount()).Times(0);
528- EXPECT_CALL(*file_manager_, CopyFiles(data.Uris(), volume_->GetUri(), time));
529+ EXPECT_CALL(*file_manager_, CopyFiles(data.Uris(), volume_->GetUri(), time, 0));
530 icon_->AcceptDrop(data);
531 }
532
533diff --git a/unity-shared/ApplicationManager.h b/unity-shared/ApplicationManager.h
534index 04f6e59..e60a56f 100644
535--- a/unity-shared/ApplicationManager.h
536+++ b/unity-shared/ApplicationManager.h
537@@ -102,6 +102,8 @@ public:
538 return !(operator==(other));
539 }
540
541+ virtual std::string property(std::string const& name) const = 0;
542+
543 nux::ROProperty<int> monitor;
544
545 nux::ROProperty<std::string> title;
546@@ -225,6 +227,7 @@ public:
547 virtual WindowList GetWindowsForMonitor(int monitor = -1) const = 0;
548 virtual ApplicationPtr GetApplicationForWindow(Window xid) const = 0;
549 virtual ApplicationWindowPtr GetWindowForId(Window xid) const = 0;
550+ virtual ApplicationWindowPtr GetWindowForProperty(const std::string& name, const std::string& value) const = 0;
551 virtual void FocusWindowGroup(WindowList const&, bool show_on_visible, int monitor) const = 0;
552
553 sigc::signal<void, ApplicationPtr const&> application_started;
554diff --git a/unity-shared/BamfApplicationManager.cpp b/unity-shared/BamfApplicationManager.cpp
555index b9f56d0..fb580ef 100644
556--- a/unity-shared/BamfApplicationManager.cpp
557+++ b/unity-shared/BamfApplicationManager.cpp
558@@ -209,6 +209,11 @@ Window AppWindow::window_id() const
559 return bamf_window_get_xid(bamf_window_);
560 }
561
562+std::string AppWindow::property(std::string const& property) const
563+{
564+ return glib::String(bamf_window_get_utf8_prop(bamf_window_, property.c_str())).Str();
565+}
566+
567 WindowType AppWindow::type() const
568 {
569 switch (bamf_window_get_window_type(bamf_window_))
570@@ -725,6 +730,26 @@ ApplicationWindowPtr Manager::GetWindowForId(Window xid) const
571 return nullptr;
572 }
573
574+ApplicationWindowPtr Manager::GetWindowForProperty(std::string const& name, std::string const& value) const
575+{
576+ if (name.empty())
577+ return nullptr;
578+
579+ for (auto const& win_pair : pool::wins_)
580+ {
581+ if (win_pair.second->property(name) == value)
582+ return win_pair.second;
583+ }
584+
585+ for (auto const& win : GetWindowsForMonitor())
586+ {
587+ if (win->property(name) == value)
588+ return win;
589+ }
590+
591+ return nullptr;
592+}
593+
594 ApplicationList Manager::GetRunningApplications() const
595 {
596 ApplicationList result;
597diff --git a/unity-shared/BamfApplicationManager.h b/unity-shared/BamfApplicationManager.h
598index 214b383..eac6d25 100644
599--- a/unity-shared/BamfApplicationManager.h
600+++ b/unity-shared/BamfApplicationManager.h
601@@ -81,6 +81,7 @@ public:
602
603 WindowType type() const override;
604 Window window_id() const override;
605+ std::string property(std::string const& name) const override;
606 ApplicationPtr application() const override;
607 void Quit() const override;
608
609@@ -172,6 +173,7 @@ public:
610 WindowList GetWindowsForMonitor(int monitor = -1) const override;
611 ApplicationPtr GetApplicationForWindow(Window xid) const override;
612 ApplicationWindowPtr GetWindowForId(Window xid) const override;
613+ ApplicationWindowPtr GetWindowForProperty(const std::string& name, const std::string& value) const override;
614
615 ApplicationPtr EnsureApplication(BamfView*) const;
616 ApplicationWindowPtr EnsureWindow(BamfView*) const;
617diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp
618index 643dfd1..bbc9ae9 100644
619--- a/unity-shared/CompizUtils.cpp
620+++ b/unity-shared/CompizUtils.cpp
621@@ -21,6 +21,7 @@
622 #include <cairo-xlib.h>
623 #include <cairo-xlib-xrender.h>
624 #include <core/screen.h>
625+#include <iostream>
626
627 namespace unity
628 {
629diff --git a/unity-shared/FileManager.h b/unity-shared/FileManager.h
630index 15dc1d9..d3f7c46 100644
631--- a/unity-shared/FileManager.h
632+++ b/unity-shared/FileManager.h
633@@ -43,9 +43,10 @@ public:
634
635 virtual void Open(std::string const& uri, uint64_t timestamp = 0) = 0;
636 virtual void OpenTrash(uint64_t timestamp) = 0;
637- virtual void CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp = 0) = 0;
638+ virtual void CopyFiles(std::set<std::string> const& uris, std::string const& dest,
639+ uint64_t timestamp = 0, Window parent_xid = 0) = 0;
640 virtual bool TrashFile(std::string const& uri) = 0;
641- virtual void EmptyTrash(uint64_t timestamp = 0) = 0;
642+ virtual void EmptyTrash(uint64_t timestamp = 0, Window parent_xid = 0) = 0;
643 virtual WindowList WindowsForLocation(std::string const& location) const = 0;
644 virtual std::string LocationForWindow(ApplicationWindowPtr const&) const = 0;
645
646diff --git a/unity-shared/GnomeFileManager.cpp b/unity-shared/GnomeFileManager.cpp
647index df35347..bd2a051 100644
648--- a/unity-shared/GnomeFileManager.cpp
649+++ b/unity-shared/GnomeFileManager.cpp
650@@ -38,7 +38,9 @@ const std::string TRASH_URI = "trash:///";
651 const std::string FILE_SCHEMA = "file://";
652
653 const std::string NAUTILUS_NAME = "org.gnome.Nautilus";
654-const std::string NAUTILUS_PATH = "/org/gnome/Nautilus";
655+const std::string NAUTILUS_FILE_OPS_PATH = "/org/gnome/Nautilus/FileOperations2";
656+
657+const std::string GTK_WINDOW_PATH_PROPERTY = "_GTK_WINDOW_OBJECT_PATH";
658 }
659
660 struct GnomeFileManager::Impl
661@@ -47,22 +49,22 @@ struct GnomeFileManager::Impl
662 : parent_(parent)
663 , filemanager_proxy_("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS)
664 {
665- auto callback = sigc::mem_fun(this, &Impl::OnOpenLocationsXidsUpdated);
666- filemanager_proxy_.GetProperty("XUbuntuOpenLocationsXids", callback);
667- filemanager_proxy_.ConnectProperty("XUbuntuOpenLocationsXids", callback);
668+ auto callback = sigc::mem_fun(this, &Impl::OnOpenWindowsWithLocationsChanged);
669+ filemanager_proxy_.GetProperty("OpenWindowsWithLocations", callback);
670+ filemanager_proxy_.ConnectProperty("OpenWindowsWithLocations", callback);
671 }
672
673 glib::DBusProxy::Ptr NautilusOperationsProxy() const
674 {
675 auto flags = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
676- return std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_PATH,
677- "org.gnome.Nautilus.FileOperations",
678+ return std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_FILE_OPS_PATH,
679+ "org.gnome.Nautilus.FileOperations2",
680 G_BUS_TYPE_SESSION, flags);
681 }
682
683- void OnOpenLocationsXidsUpdated(GVariant* value)
684+ void OnOpenWindowsWithLocationsChanged(GVariant* value)
685 {
686- opened_location_for_xid_.clear();
687+ opened_location_for_window_.clear();
688
689 if (!value)
690 {
691@@ -71,7 +73,7 @@ struct GnomeFileManager::Impl
692 return;
693 }
694
695- if (!g_variant_is_of_type(value, G_VARIANT_TYPE("a{uas}")))
696+ if (!g_variant_is_of_type(value, G_VARIANT_TYPE("a{sas}")))
697 {
698 LOG_ERROR(logger) << "Locations value type is not matching the expected one!";
699 parent_->locations_changed.emit();
700@@ -81,39 +83,46 @@ struct GnomeFileManager::Impl
701 GVariantIter iter;
702 GVariantIter *str_iter;
703 const char *loc;
704- guint32 xid;
705+ const char *window_path;
706+ std::map<std::string, std::string> opened_locations_for_path;
707
708 g_variant_iter_init(&iter, value);
709
710- while (g_variant_iter_loop(&iter, "{uas}", &xid, &str_iter))
711+ while (g_variant_iter_loop(&iter, "{&sas}", &window_path, &str_iter))
712 {
713 while (g_variant_iter_loop(str_iter, "s", &loc))
714 {
715 /* We only care about the first mentioned location as per our "standard"
716 * it's the active one */
717- LOG_DEBUG(logger) << xid << ": Opened location " << loc;
718- opened_location_for_xid_[xid] = loc;
719+ LOG_DEBUG(logger) << window_path << ": Opened location " << loc;
720+ opened_locations_for_path[window_path] = loc;
721 break;
722 }
723 }
724
725 // We must ensure that we emit the locations_changed signal only when all
726 // the parent windows have been registered on the app-manager
727- auto app_manager_not_synced = [this]
728+ auto app_manager_not_synced = [this, opened_locations_for_path]
729 {
730 auto& app_manager = ApplicationManager::Default();
731 bool synced = true;
732
733- for (auto const& pair : opened_location_for_xid_)
734+ for (auto const& pair : opened_locations_for_path)
735 {
736- synced = (app_manager.GetWindowForId(pair.first) != nullptr);
737+ auto win = app_manager.GetWindowForProperty(GTK_WINDOW_PATH_PROPERTY, pair.first);
738+ synced = (win != nullptr);
739
740 if (!synced)
741 break;
742+
743+ LOG_DEBUG(logger) << win->window_id() << ": Opened location " << pair.second;
744+ opened_location_for_window_[win] = pair.second;
745 }
746
747 if (synced)
748 parent_->locations_changed.emit();
749+ else
750+ opened_location_for_window_.clear();
751
752 return !synced;
753 };
754@@ -122,10 +131,31 @@ struct GnomeFileManager::Impl
755 idle_.reset(new glib::Idle(app_manager_not_synced));
756 }
757
758+ GVariant *GetPlatformData(uint64_t timestamp, Window parent_xid)
759+ {
760+ GVariantBuilder builder;
761+ char *parent_handle;
762+
763+ g_variant_builder_init(&builder, G_VARIANT_TYPE ("a{sv}"));
764+
765+ parent_handle = g_strdup_printf("x11:%lx", parent_xid);
766+
767+ g_variant_builder_add(&builder, "{sv}", "parent-handle",
768+ g_variant_new_take_string(parent_handle));
769+
770+ g_variant_builder_add(&builder, "{sv}", "timestamp",
771+ g_variant_new_uint32(timestamp));
772+
773+ g_variant_builder_add(&builder, "{sv}", "window-position",
774+ g_variant_new_string("center"));
775+
776+ return g_variant_builder_end(&builder);
777+ }
778+
779 GnomeFileManager* parent_;
780 glib::DBusProxy filemanager_proxy_;
781 glib::Source::UniquePtr idle_;
782- std::map<Window, std::string> opened_location_for_xid_;
783+ std::map<ApplicationWindowPtr, std::string> opened_location_for_window_;
784 };
785
786
787@@ -184,22 +214,29 @@ bool GnomeFileManager::TrashFile(std::string const& uri)
788 return false;
789 }
790
791-void GnomeFileManager::EmptyTrash(uint64_t timestamp)
792+void GnomeFileManager::EmptyTrash(uint64_t timestamp, Window parent_xid)
793 {
794 auto const& proxy = impl_->NautilusOperationsProxy();
795+ const bool ask_confirmation = true;
796+
797+ GVariantBuilder b;
798+ g_variant_builder_init(&b, G_VARIANT_TYPE("(ba{sv})"));
799+ g_variant_builder_add(&b, "b", ask_confirmation);
800+ g_variant_builder_add_value(&b, impl_->GetPlatformData(timestamp, parent_xid));
801+ glib::Variant parameters(g_variant_builder_end(&b));
802
803 // Passing the proxy to the lambda we ensure that it will be destroyed when needed
804- proxy->CallBegin("EmptyTrashWithTimestamp", g_variant_new("(u)", timestamp), [proxy] (GVariant*, glib::Error const&) {});
805+ proxy->CallBegin("EmptyTrash", parameters, [proxy] (GVariant*, glib::Error const&) {});
806 }
807
808-void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp)
809+void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp, Window parent_xid)
810 {
811 if (uris.empty() || dest.empty())
812 return;
813
814 bool found_valid = false;
815 GVariantBuilder b;
816- g_variant_builder_init(&b, G_VARIANT_TYPE("(assu)"));
817+ g_variant_builder_init(&b, G_VARIANT_TYPE("(assa{sv})"));
818 g_variant_builder_open(&b, G_VARIANT_TYPE("as"));
819
820 for (auto const& uri : uris)
821@@ -213,25 +250,23 @@ void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string
822
823 g_variant_builder_close(&b);
824 g_variant_builder_add(&b, "s", dest.c_str());
825- g_variant_builder_add(&b, "u", timestamp);
826+ g_variant_builder_add_value(&b, impl_->GetPlatformData(timestamp, parent_xid));
827 glib::Variant parameters(g_variant_builder_end(&b));
828
829 if (found_valid)
830 {
831 // Passing the proxy to the lambda we ensure that it will be destroyed when needed
832 auto const& proxy = impl_->NautilusOperationsProxy();
833- proxy->CallBegin("CopyURIsWithTimestamp", parameters, [proxy] (GVariant*, glib::Error const&) {});
834+ proxy->CallBegin("CopyURIs", parameters, [proxy] (GVariant*, glib::Error const&) {});
835 }
836 }
837
838 WindowList GnomeFileManager::WindowsForLocation(std::string const& location) const
839 {
840 std::vector<ApplicationWindowPtr> windows;
841- auto& app_manager = ApplicationManager::Default();
842-
843 glib::Object<GFile> location_file(g_file_new_for_uri(location.c_str()));
844
845- for (auto const& pair : impl_->opened_location_for_xid_)
846+ for (auto const& pair : impl_->opened_location_for_window_)
847 {
848 auto const& loc = pair.second;
849 bool matches = (loc == location);
850@@ -245,7 +280,7 @@ WindowList GnomeFileManager::WindowsForLocation(std::string const& location) con
851
852 if (matches)
853 {
854- auto const& win = app_manager.GetWindowForId(pair.first);
855+ auto const& win = pair.first;
856
857 if (win && std::find(windows.rbegin(), windows.rend(), win) == windows.rend())
858 windows.push_back(win);
859@@ -259,9 +294,9 @@ std::string GnomeFileManager::LocationForWindow(ApplicationWindowPtr const& win)
860 {
861 if (win)
862 {
863- auto it = impl_->opened_location_for_xid_.find(win->window_id());
864+ auto it = impl_->opened_location_for_window_.find(win);
865
866- if (it != end(impl_->opened_location_for_xid_))
867+ if (it != end(impl_->opened_location_for_window_))
868 return it->second;
869 }
870
871diff --git a/unity-shared/GnomeFileManager.h b/unity-shared/GnomeFileManager.h
872index 8f3b3c3..b9c3dd8 100644
873--- a/unity-shared/GnomeFileManager.h
874+++ b/unity-shared/GnomeFileManager.h
875@@ -35,9 +35,9 @@ public:
876 void Open(std::string const& uri, uint64_t timestamp);
877 void OpenTrash(uint64_t timestamp);
878
879- void CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp);
880+ void CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp, Window parent_xid);
881 bool TrashFile(std::string const& uri);
882- void EmptyTrash(uint64_t timestamp);
883+ void EmptyTrash(uint64_t timestamp, Window parent_xid);
884
885 WindowList WindowsForLocation(std::string const& location) const;
886 std::string LocationForWindow(ApplicationWindowPtr const&) const;
887diff --git a/unity-shared/IntrospectionData.cpp b/unity-shared/IntrospectionData.cpp
888index 2dbb393..495e175 100644
889--- a/unity-shared/IntrospectionData.cpp
890+++ b/unity-shared/IntrospectionData.cpp
891@@ -55,7 +55,6 @@ IntrospectionData::~IntrospectionData()
892 GVariant* IntrospectionData::Get() const
893 {
894 GVariant* data = g_variant_builder_end(builder_);
895- g_clear_pointer(&builder_, g_variant_builder_unref);
896 return data;
897 }
898

Subscribers

People subscribed via source and target branches