Merge lp:~azzar1/unity/scale-eject-notification into lp:unity

Proposed by Andrea Azzarone on 2016-07-21
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2016-07-25
Approved revision: 4154
Merged at revision: 4157
Proposed branch: lp:~azzar1/unity/scale-eject-notification
Merge into: lp:unity
Diff against target: 140 lines (+10/-32)
6 files modified
launcher/DeviceNotificationDisplay.h (+1/-1)
launcher/DeviceNotificationDisplayImp.cpp (+4/-26)
launcher/DeviceNotificationDisplayImp.h (+1/-1)
launcher/VolumeLauncherIcon.cpp (+1/-1)
tests/test_mock_devices.h (+1/-1)
tests/test_volume_launcher_icon.cpp (+2/-2)
To merge this branch: bzr merge lp:~azzar1/unity/scale-eject-notification
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2016-07-21 Approve on 2016-07-25
Review via email: mp+300757@code.launchpad.net

Commit message

Use the standard notification-device-eject in the "device eject" notification. This allows us to scale it properly on high-dpi setups.

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

not a code review but you have a typo in the commit message "notificaiton"

Marco Trevisan (Treviño) (3v1n0) wrote :

Yeah, better one.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/DeviceNotificationDisplay.h'
2--- launcher/DeviceNotificationDisplay.h 2012-08-22 09:03:25 +0000
3+++ launcher/DeviceNotificationDisplay.h 2016-07-21 12:39:12 +0000
4@@ -36,7 +36,7 @@
5
6 virtual ~DeviceNotificationDisplay() {}
7
8- virtual void Display(std::string const& icon_name, std::string const& volume_name) = 0;
9+ virtual void Display(std::string const& volume_name) = 0;
10 };
11
12 }
13
14=== modified file 'launcher/DeviceNotificationDisplayImp.cpp'
15--- launcher/DeviceNotificationDisplayImp.cpp 2015-04-22 23:54:26 +0000
16+++ launcher/DeviceNotificationDisplayImp.cpp 2016-07-21 12:39:12 +0000
17@@ -20,49 +20,27 @@
18 #include "config.h"
19 #include <glib/gi18n-lib.h>
20 #include <libnotify/notify.h>
21-#include <sigc++/sigc++.h>
22 #include <UnityCore/GLibWrapper.h>
23
24 #include "DeviceNotificationDisplayImp.h"
25-#include "unity-shared/IconLoader.h"
26
27 namespace unity
28 {
29 namespace launcher
30 {
31
32-namespace
33-{
34-const unsigned icon_size = 48;
35-}
36-
37 //
38 // Start private implementation
39 //
40 class DeviceNotificationDisplayImp::Impl
41 {
42 public:
43- void Show(std::string const& icon_name, std::string const& volume_name)
44- {
45- IconLoader::GetDefault().LoadFromGIconString(icon_name, -1, icon_size,
46- sigc::bind(sigc::mem_fun(this, &Impl::ShowNotificationWhenIconIsReady), volume_name));
47- }
48-
49- void ShowNotificationWhenIconIsReady(std::string const& icon_name,
50- int max_width,
51- int max_height,
52- glib::Object<GdkPixbuf> const& pixbuf,
53- std::string const& volume_name)
54+ void Show(std::string const& volume_name)
55 {
56 glib::Object<NotifyNotification> notification(notify_notification_new(volume_name.c_str(),
57 _("The drive has been successfully ejected"),
58- nullptr));
59-
60+ "notification-device-eject"));
61 notify_notification_set_hint(notification, "x-canonical-private-synchronous", g_variant_new_boolean(TRUE));
62-
63- if (pixbuf)
64- notify_notification_set_image_from_pixbuf(notification, pixbuf);
65-
66 notify_notification_show(notification, nullptr);
67 }
68 };
69@@ -78,9 +56,9 @@
70 DeviceNotificationDisplayImp::~DeviceNotificationDisplayImp()
71 {}
72
73-void DeviceNotificationDisplayImp::Display(std::string const& icon_name, std::string const& volume_name)
74+void DeviceNotificationDisplayImp::Display(std::string const& volume_name)
75 {
76- pimpl->Show(icon_name, volume_name);
77+ pimpl->Show(volume_name);
78 }
79
80 }
81
82=== modified file 'launcher/DeviceNotificationDisplayImp.h'
83--- launcher/DeviceNotificationDisplayImp.h 2012-08-22 09:03:25 +0000
84+++ launcher/DeviceNotificationDisplayImp.h 2016-07-21 12:39:12 +0000
85@@ -33,7 +33,7 @@
86 DeviceNotificationDisplayImp();
87 virtual ~DeviceNotificationDisplayImp();
88
89- virtual void Display(std::string const& icon_name, std::string const& volume_name);
90+ virtual void Display(std::string const& volume_name);
91
92 private:
93 class Impl;
94
95=== modified file 'launcher/VolumeLauncherIcon.cpp'
96--- launcher/VolumeLauncherIcon.cpp 2016-02-25 13:42:10 +0000
97+++ launcher/VolumeLauncherIcon.cpp 2016-07-21 12:39:12 +0000
98@@ -108,7 +108,7 @@
99
100 auto conn = std::make_shared<sigc::connection>();
101 *conn = volume_->ejected.connect([this, conn] {
102- notification_->Display(volume_->GetIconName(), volume_->GetName());
103+ notification_->Display(volume_->GetName());
104 conn->disconnect();
105 });
106 connections_.Add(*conn);
107
108=== modified file 'tests/test_mock_devices.h'
109--- tests/test_mock_devices.h 2016-01-24 14:35:49 +0000
110+++ tests/test_mock_devices.h 2016-07-21 12:39:12 +0000
111@@ -101,7 +101,7 @@
112 typedef std::shared_ptr<MockDeviceNotificationDisplay> Ptr;
113 typedef testing::NiceMock<MockDeviceNotificationDisplay> Nice;
114
115- MOCK_METHOD2(Display, void(std::string const& icon_name, std::string const& volume_name));
116+ MOCK_METHOD1(Display, void(std::string const& volume_name));
117 };
118
119 } // anonymous namespace
120
121=== modified file 'tests/test_volume_launcher_icon.cpp'
122--- tests/test_volume_launcher_icon.cpp 2016-01-24 14:35:49 +0000
123+++ tests/test_volume_launcher_icon.cpp 2016-07-21 12:39:12 +0000
124@@ -481,7 +481,7 @@
125 auto menuitem = GetMenuItemAtIndex(5);
126
127 EXPECT_CALL(*volume_, Eject());
128- EXPECT_CALL(*notifications_, Display(volume_->GetIconName(), volume_->GetName()));
129+ EXPECT_CALL(*notifications_, Display(volume_->GetName()));
130
131 ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Eject");
132 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
133@@ -573,7 +573,7 @@
134 .WillRepeatedly(Return(true));
135
136 EXPECT_CALL(*volume_, Eject());
137- EXPECT_CALL(*notifications_, Display(volume_->GetIconName(), volume_->GetName()));
138+ EXPECT_CALL(*notifications_, Display(volume_->GetName()));
139 icon_->EjectAndShowNotification();
140 }
141