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

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
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) Approve
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.
Revision history for this message
Sebastien Bacher (seb128) wrote :

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

Revision history for this message
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
=== modified file 'launcher/DeviceNotificationDisplay.h'
--- launcher/DeviceNotificationDisplay.h 2012-08-22 09:03:25 +0000
+++ launcher/DeviceNotificationDisplay.h 2016-07-21 12:39:12 +0000
@@ -36,7 +36,7 @@
3636
37 virtual ~DeviceNotificationDisplay() {}37 virtual ~DeviceNotificationDisplay() {}
3838
39 virtual void Display(std::string const& icon_name, std::string const& volume_name) = 0;39 virtual void Display(std::string const& volume_name) = 0;
40};40};
4141
42}42}
4343
=== modified file 'launcher/DeviceNotificationDisplayImp.cpp'
--- launcher/DeviceNotificationDisplayImp.cpp 2015-04-22 23:54:26 +0000
+++ launcher/DeviceNotificationDisplayImp.cpp 2016-07-21 12:39:12 +0000
@@ -20,49 +20,27 @@
20#include "config.h"20#include "config.h"
21#include <glib/gi18n-lib.h>21#include <glib/gi18n-lib.h>
22#include <libnotify/notify.h>22#include <libnotify/notify.h>
23#include <sigc++/sigc++.h>
24#include <UnityCore/GLibWrapper.h>23#include <UnityCore/GLibWrapper.h>
2524
26#include "DeviceNotificationDisplayImp.h"25#include "DeviceNotificationDisplayImp.h"
27#include "unity-shared/IconLoader.h"
2826
29namespace unity27namespace unity
30{28{
31namespace launcher29namespace launcher
32{30{
3331
34namespace
35{
36const unsigned icon_size = 48;
37}
38
39//32//
40// Start private implementation33// Start private implementation
41//34//
42class DeviceNotificationDisplayImp::Impl35class DeviceNotificationDisplayImp::Impl
43{36{
44public:37public:
45 void Show(std::string const& icon_name, std::string const& volume_name)38 void Show(std::string const& volume_name)
46 {
47 IconLoader::GetDefault().LoadFromGIconString(icon_name, -1, icon_size,
48 sigc::bind(sigc::mem_fun(this, &Impl::ShowNotificationWhenIconIsReady), volume_name));
49 }
50
51 void ShowNotificationWhenIconIsReady(std::string const& icon_name,
52 int max_width,
53 int max_height,
54 glib::Object<GdkPixbuf> const& pixbuf,
55 std::string const& volume_name)
56 {39 {
57 glib::Object<NotifyNotification> notification(notify_notification_new(volume_name.c_str(),40 glib::Object<NotifyNotification> notification(notify_notification_new(volume_name.c_str(),
58 _("The drive has been successfully ejected"),41 _("The drive has been successfully ejected"),
59 nullptr));42 "notification-device-eject"));
60
61 notify_notification_set_hint(notification, "x-canonical-private-synchronous", g_variant_new_boolean(TRUE));43 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);44 notify_notification_show(notification, nullptr);
67 }45 }
68};46};
@@ -78,9 +56,9 @@
78DeviceNotificationDisplayImp::~DeviceNotificationDisplayImp()56DeviceNotificationDisplayImp::~DeviceNotificationDisplayImp()
79{}57{}
8058
81void DeviceNotificationDisplayImp::Display(std::string const& icon_name, std::string const& volume_name)59void DeviceNotificationDisplayImp::Display(std::string const& volume_name)
82{60{
83 pimpl->Show(icon_name, volume_name);61 pimpl->Show(volume_name);
84}62}
8563
86}64}
8765
=== modified file 'launcher/DeviceNotificationDisplayImp.h'
--- launcher/DeviceNotificationDisplayImp.h 2012-08-22 09:03:25 +0000
+++ launcher/DeviceNotificationDisplayImp.h 2016-07-21 12:39:12 +0000
@@ -33,7 +33,7 @@
33 DeviceNotificationDisplayImp();33 DeviceNotificationDisplayImp();
34 virtual ~DeviceNotificationDisplayImp();34 virtual ~DeviceNotificationDisplayImp();
3535
36 virtual void Display(std::string const& icon_name, std::string const& volume_name);36 virtual void Display(std::string const& volume_name);
3737
38private:38private:
39 class Impl;39 class Impl;
4040
=== modified file 'launcher/VolumeLauncherIcon.cpp'
--- launcher/VolumeLauncherIcon.cpp 2016-02-25 13:42:10 +0000
+++ launcher/VolumeLauncherIcon.cpp 2016-07-21 12:39:12 +0000
@@ -108,7 +108,7 @@
108108
109 auto conn = std::make_shared<sigc::connection>();109 auto conn = std::make_shared<sigc::connection>();
110 *conn = volume_->ejected.connect([this, conn] {110 *conn = volume_->ejected.connect([this, conn] {
111 notification_->Display(volume_->GetIconName(), volume_->GetName());111 notification_->Display(volume_->GetName());
112 conn->disconnect();112 conn->disconnect();
113 });113 });
114 connections_.Add(*conn);114 connections_.Add(*conn);
115115
=== modified file 'tests/test_mock_devices.h'
--- tests/test_mock_devices.h 2016-01-24 14:35:49 +0000
+++ tests/test_mock_devices.h 2016-07-21 12:39:12 +0000
@@ -101,7 +101,7 @@
101 typedef std::shared_ptr<MockDeviceNotificationDisplay> Ptr;101 typedef std::shared_ptr<MockDeviceNotificationDisplay> Ptr;
102 typedef testing::NiceMock<MockDeviceNotificationDisplay> Nice;102 typedef testing::NiceMock<MockDeviceNotificationDisplay> Nice;
103103
104 MOCK_METHOD2(Display, void(std::string const& icon_name, std::string const& volume_name));104 MOCK_METHOD1(Display, void(std::string const& volume_name));
105};105};
106106
107} // anonymous namespace107} // anonymous namespace
108108
=== modified file 'tests/test_volume_launcher_icon.cpp'
--- tests/test_volume_launcher_icon.cpp 2016-01-24 14:35:49 +0000
+++ tests/test_volume_launcher_icon.cpp 2016-07-21 12:39:12 +0000
@@ -481,7 +481,7 @@
481 auto menuitem = GetMenuItemAtIndex(5);481 auto menuitem = GetMenuItemAtIndex(5);
482482
483 EXPECT_CALL(*volume_, Eject());483 EXPECT_CALL(*volume_, Eject());
484 EXPECT_CALL(*notifications_, Display(volume_->GetIconName(), volume_->GetName()));484 EXPECT_CALL(*notifications_, Display(volume_->GetName()));
485485
486 ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Eject");486 ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Eject");
487 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));487 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
@@ -573,7 +573,7 @@
573 .WillRepeatedly(Return(true));573 .WillRepeatedly(Return(true));
574574
575 EXPECT_CALL(*volume_, Eject());575 EXPECT_CALL(*volume_, Eject());
576 EXPECT_CALL(*notifications_, Display(volume_->GetIconName(), volume_->GetName()));576 EXPECT_CALL(*notifications_, Display(volume_->GetName()));
577 icon_->EjectAndShowNotification();577 icon_->EjectAndShowNotification();
578}578}
579579