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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2011-07-08 10:49:42 +0000
+++ CMakeLists.txt 2011-07-12 16:27:38 +0000
@@ -118,7 +118,7 @@
118#118#
119# Compiz Plugins119# Compiz Plugins
120#120#
121set (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")121set (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")
122122
123find_package (Compiz REQUIRED)123find_package (Compiz REQUIRED)
124include (CompizPlugin)124include (CompizPlugin)
125125
=== modified file 'plugins/unityshell/src/DeviceLauncherIcon.cpp'
--- plugins/unityshell/src/DeviceLauncherIcon.cpp 2011-05-25 08:22:35 +0000
+++ plugins/unityshell/src/DeviceLauncherIcon.cpp 2011-07-12 16:27:38 +0000
@@ -23,6 +23,7 @@
23#include "UBusMessages.h"23#include "UBusMessages.h"
2424
25#include <glib/gi18n-lib.h>25#include <glib/gi18n-lib.h>
26#include <libnotify/notify.h>
2627
27#define DEFAULT_ICON "drive-removable-media"28#define DEFAULT_ICON "drive-removable-media"
2829
@@ -77,7 +78,7 @@
7778
78 icon = g_volume_get_icon (_volume);79 icon = g_volume_get_icon (_volume);
79 icon_string = g_icon_to_string (icon);80 icon_string = g_icon_to_string (icon);
8081
81 SetIconName (icon_string);82 SetIconName (icon_string);
8283
83 g_object_unref (icon);84 g_object_unref (icon);
@@ -101,6 +102,12 @@
101 return nux::Color (0xFF333333);102 return nux::Color (0xFF333333);
102}103}
103104
105bool
106DeviceLauncherIcon::CanEject ()
107{
108 return g_volume_can_eject (_volume);
109}
110
104std::list<DbusmenuMenuitem *>111std::list<DbusmenuMenuitem *>
105DeviceLauncherIcon::GetMenus ()112DeviceLauncherIcon::GetMenus ()
106{113{
@@ -257,6 +264,8 @@
257 name,264 name,
258 error ? error->message : "Mount operation failed");265 error ? error->message : "Mount operation failed");
259 g_error_free (error);266 g_error_free (error);
267
268 g_free (name);
260 }269 }
261}270}
262271
@@ -264,8 +273,20 @@
264DeviceLauncherIcon::OnEjectReady (GObject *object,273DeviceLauncherIcon::OnEjectReady (GObject *object,
265 GAsyncResult *result,274 GAsyncResult *result,
266 DeviceLauncherIcon *self)275 DeviceLauncherIcon *self)
267{276{
268 g_volume_eject_with_operation_finish (self->_volume, result, NULL);277 if (g_volume_eject_with_operation_finish (self->_volume, result, NULL))
278 {
279 NotifyNotification* notification;
280 gchar *name = g_volume_get_name (self->_volume);
281
282 notification = notify_notification_new (name,
283 _("The drive has been successfully ejected"),
284 "drive-removable-media-usb");
285
286 notify_notification_show (notification, NULL);
287
288 g_free (name);
289 }
269}290}
270291
271void292void
272293
=== modified file 'plugins/unityshell/src/DeviceLauncherIcon.h'
--- plugins/unityshell/src/DeviceLauncherIcon.h 2011-05-17 06:23:36 +0000
+++ plugins/unityshell/src/DeviceLauncherIcon.h 2011-07-12 16:27:38 +0000
@@ -35,6 +35,8 @@
35 virtual nux::Color BackgroundColor ();35 virtual nux::Color BackgroundColor ();
36 virtual nux::Color GlowColor ();36 virtual nux::Color GlowColor ();
37 void UpdateVisibility ();37 void UpdateVisibility ();
38 bool CanEject ();
39 void Eject ();
3840
39protected:41protected:
40 std::list<DbusmenuMenuitem *> GetMenus ();42 std::list<DbusmenuMenuitem *> GetMenus ();
@@ -43,7 +45,6 @@
43private:45private:
44 void ActivateLauncherIcon ();46 void ActivateLauncherIcon ();
45 void ShowMount (GMount *mount);47 void ShowMount (GMount *mount);
46 void Eject ();
47 void Unmount ();48 void Unmount ();
48 void StopDrive ();49 void StopDrive ();
49 static void OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);50 static void OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);
5051
=== modified file 'plugins/unityshell/src/LauncherController.cpp'
--- plugins/unityshell/src/LauncherController.cpp 2011-07-10 09:53:43 +0000
+++ plugins/unityshell/src/LauncherController.cpp 2011-07-12 16:27:38 +0000
@@ -17,6 +17,7 @@
17 * Authored by: Jason Smith <jason.smith@canonical.com>17 * Authored by: Jason Smith <jason.smith@canonical.com>
18 */18 */
1919
20#include "DeviceLauncherIcon.h"
20#include "FavoriteStore.h"21#include "FavoriteStore.h"
21#include "LauncherController.h"22#include "LauncherController.h"
22#include "LauncherIcon.h"23#include "LauncherIcon.h"
@@ -150,13 +151,29 @@
150void151void
151LauncherController::OnLauncherRemoveRequest (LauncherIcon *icon)152LauncherController::OnLauncherRemoveRequest (LauncherIcon *icon)
152{153{
153 BamfLauncherIcon *bamf_icon = dynamic_cast<BamfLauncherIcon *> (icon);154 switch (icon->Type ())
154 155 {
155 // we only handle bamf Icon removal request for now.156 case LauncherIcon::TYPE_APPLICATION:
156 if (!bamf_icon)157 {
157 return;158 BamfLauncherIcon *bamf_icon = dynamic_cast<BamfLauncherIcon *> (icon);
158 159
159 bamf_icon->UnStick ();160 if (bamf_icon)
161 bamf_icon->UnStick ();
162
163 break;
164 }
165 case LauncherIcon::TYPE_DEVICE:
166 {
167 DeviceLauncherIcon *device_icon = dynamic_cast<DeviceLauncherIcon *> (icon);
168
169 if (device_icon && device_icon->CanEject ())
170 device_icon->Eject ();
171
172 break;
173 }
174 default:
175 break;
176 }
160}177}
161178
162void179void
163180
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2011-07-01 11:31:40 +0000
+++ plugins/unityshell/src/unityshell.cpp 2011-07-12 16:27:38 +0000
@@ -40,6 +40,7 @@
40#include <glib/gi18n-lib.h>40#include <glib/gi18n-lib.h>
41#include <gtk/gtk.h>41#include <gtk/gtk.h>
42#include <gdk/gdk.h>42#include <gdk/gdk.h>
43#include <libnotify/notify.h>
4344
44#include <core/atoms.h>45#include <core/atoms.h>
4546
@@ -91,6 +92,8 @@
91 int (*old_handler) (Display *, XErrorEvent *);92 int (*old_handler) (Display *, XErrorEvent *);
92 old_handler = XSetErrorHandler (NULL);93 old_handler = XSetErrorHandler (NULL);
9394
95 notify_init ("unityshell");
96
94 g_thread_init (NULL);97 g_thread_init (NULL);
95 dbus_g_thread_init ();98 dbus_g_thread_init ();
9699
@@ -187,6 +190,8 @@
187 delete controller;190 delete controller;
188 launcher->UnReference ();191 launcher->UnReference ();
189 launcherWindow->UnReference ();192 launcherWindow->UnReference ();
193
194 notify_uninit ();
190195
191 unity_a11y_finalize ();196 unity_a11y_finalize ();
192197