Merge lp:~azzar1/unity/fix-764905 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 1276
Proposed branch: lp:~azzar1/unity/fix-764905
Merge into: lp:unity
Diff against target: 177 lines (+56/-12)
5 files modified
CMakeLists.txt (+1/-1)
plugins/unityshell/src/DeviceLauncherIcon.cpp (+24/-3)
plugins/unityshell/src/DeviceLauncherIcon.h (+2/-1)
plugins/unityshell/src/LauncherController.cpp (+24/-7)
plugins/unityshell/src/unityshell.cpp (+5/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-764905
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+67457@code.launchpad.net

Description of the change

Ejects a usb pen drive using the drag and drop to the trash. Shows a osd notification too.

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

The strings used for the notification need to be translated. Using these hard-coded strings makes this impossible. Please fix it by using the typical _("") macro.

review: Needs Fixing
Revision history for this message
Mirco Müller (macslow) wrote :

Despite the needed fix the patch looks ok, works and will be approved once the requested update is committed.

Revision history for this message
Mirco Müller (macslow) wrote :

Sweet, thanks... approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-07-08 10:49:42 +0000
3+++ CMakeLists.txt 2011-07-12 16:27:38 +0000
4@@ -118,7 +118,7 @@
5 #
6 # Compiz Plugins
7 #
8-set (UNITY_PLUGIN_DEPS "compiz;nux-1.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4;atk;unity-misc >= 0.4.0;gconf-2.0;libutouch-geis;gtk+-3.0;sigc++-2.0")
9+set (UNITY_PLUGIN_DEPS "compiz;nux-1.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4;atk;unity-misc >= 0.4.0;gconf-2.0;libutouch-geis;gtk+-3.0;sigc++-2.0;libnotify")
10
11 find_package (Compiz REQUIRED)
12 include (CompizPlugin)
13
14=== modified file 'plugins/unityshell/src/DeviceLauncherIcon.cpp'
15--- plugins/unityshell/src/DeviceLauncherIcon.cpp 2011-05-25 08:22:35 +0000
16+++ plugins/unityshell/src/DeviceLauncherIcon.cpp 2011-07-12 16:27:38 +0000
17@@ -23,6 +23,7 @@
18 #include "UBusMessages.h"
19
20 #include <glib/gi18n-lib.h>
21+#include <libnotify/notify.h>
22
23 #define DEFAULT_ICON "drive-removable-media"
24
25@@ -77,7 +78,7 @@
26
27 icon = g_volume_get_icon (_volume);
28 icon_string = g_icon_to_string (icon);
29-
30+
31 SetIconName (icon_string);
32
33 g_object_unref (icon);
34@@ -101,6 +102,12 @@
35 return nux::Color (0xFF333333);
36 }
37
38+bool
39+DeviceLauncherIcon::CanEject ()
40+{
41+ return g_volume_can_eject (_volume);
42+}
43+
44 std::list<DbusmenuMenuitem *>
45 DeviceLauncherIcon::GetMenus ()
46 {
47@@ -257,6 +264,8 @@
48 name,
49 error ? error->message : "Mount operation failed");
50 g_error_free (error);
51+
52+ g_free (name);
53 }
54 }
55
56@@ -264,8 +273,20 @@
57 DeviceLauncherIcon::OnEjectReady (GObject *object,
58 GAsyncResult *result,
59 DeviceLauncherIcon *self)
60-{
61- g_volume_eject_with_operation_finish (self->_volume, result, NULL);
62+{
63+ if (g_volume_eject_with_operation_finish (self->_volume, result, NULL))
64+ {
65+ NotifyNotification* notification;
66+ gchar *name = g_volume_get_name (self->_volume);
67+
68+ notification = notify_notification_new (name,
69+ _("The drive has been successfully ejected"),
70+ "drive-removable-media-usb");
71+
72+ notify_notification_show (notification, NULL);
73+
74+ g_free (name);
75+ }
76 }
77
78 void
79
80=== modified file 'plugins/unityshell/src/DeviceLauncherIcon.h'
81--- plugins/unityshell/src/DeviceLauncherIcon.h 2011-05-17 06:23:36 +0000
82+++ plugins/unityshell/src/DeviceLauncherIcon.h 2011-07-12 16:27:38 +0000
83@@ -35,6 +35,8 @@
84 virtual nux::Color BackgroundColor ();
85 virtual nux::Color GlowColor ();
86 void UpdateVisibility ();
87+ bool CanEject ();
88+ void Eject ();
89
90 protected:
91 std::list<DbusmenuMenuitem *> GetMenus ();
92@@ -43,7 +45,6 @@
93 private:
94 void ActivateLauncherIcon ();
95 void ShowMount (GMount *mount);
96- void Eject ();
97 void Unmount ();
98 void StopDrive ();
99 static void OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);
100
101=== modified file 'plugins/unityshell/src/LauncherController.cpp'
102--- plugins/unityshell/src/LauncherController.cpp 2011-07-10 09:53:43 +0000
103+++ plugins/unityshell/src/LauncherController.cpp 2011-07-12 16:27:38 +0000
104@@ -17,6 +17,7 @@
105 * Authored by: Jason Smith <jason.smith@canonical.com>
106 */
107
108+#include "DeviceLauncherIcon.h"
109 #include "FavoriteStore.h"
110 #include "LauncherController.h"
111 #include "LauncherIcon.h"
112@@ -150,13 +151,29 @@
113 void
114 LauncherController::OnLauncherRemoveRequest (LauncherIcon *icon)
115 {
116- BamfLauncherIcon *bamf_icon = dynamic_cast<BamfLauncherIcon *> (icon);
117-
118- // we only handle bamf Icon removal request for now.
119- if (!bamf_icon)
120- return;
121-
122- bamf_icon->UnStick ();
123+ switch (icon->Type ())
124+ {
125+ case LauncherIcon::TYPE_APPLICATION:
126+ {
127+ BamfLauncherIcon *bamf_icon = dynamic_cast<BamfLauncherIcon *> (icon);
128+
129+ if (bamf_icon)
130+ bamf_icon->UnStick ();
131+
132+ break;
133+ }
134+ case LauncherIcon::TYPE_DEVICE:
135+ {
136+ DeviceLauncherIcon *device_icon = dynamic_cast<DeviceLauncherIcon *> (icon);
137+
138+ if (device_icon && device_icon->CanEject ())
139+ device_icon->Eject ();
140+
141+ break;
142+ }
143+ default:
144+ break;
145+ }
146 }
147
148 void
149
150=== modified file 'plugins/unityshell/src/unityshell.cpp'
151--- plugins/unityshell/src/unityshell.cpp 2011-07-01 11:31:40 +0000
152+++ plugins/unityshell/src/unityshell.cpp 2011-07-12 16:27:38 +0000
153@@ -40,6 +40,7 @@
154 #include <glib/gi18n-lib.h>
155 #include <gtk/gtk.h>
156 #include <gdk/gdk.h>
157+#include <libnotify/notify.h>
158
159 #include <core/atoms.h>
160
161@@ -91,6 +92,8 @@
162 int (*old_handler) (Display *, XErrorEvent *);
163 old_handler = XSetErrorHandler (NULL);
164
165+ notify_init ("unityshell");
166+
167 g_thread_init (NULL);
168 dbus_g_thread_init ();
169
170@@ -187,6 +190,8 @@
171 delete controller;
172 launcher->UnReference ();
173 launcherWindow->UnReference ();
174+
175+ notify_uninit ();
176
177 unity_a11y_finalize ();
178