Merge lp:~vanvugt/unity/fix-773946 into lp:unity

Proposed by Daniel van Vugt
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 1233
Proposed branch: lp:~vanvugt/unity/fix-773946
Merge into: lp:unity
Diff against target: 98 lines (+60/-0)
2 files modified
src/DeviceLauncherIcon.cpp (+57/-0)
src/DeviceLauncherIcon.h (+3/-0)
To merge this branch: bzr merge lp:~vanvugt/unity/fix-773946
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Sam Spilsbury (community) Needs Information
Review via email: mp+61206@code.launchpad.net

Commit message

Added missing Unmount option to devices in the Launcher which don't have Eject or Remove options (LP: #773946)

Description of the change

Added missing Unmount option to devices in the Launcher. This is especially important for eSATA mounts which don't have Eject or Remove options (LP: #773946)

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

The code for this branch looks fine.

Random question: It looks as though this would add an "unmount" option to every single drive that was in the launcher. That might need some design feedback. I understand that "unmount" is relevant to eSATA, but it's not relevant to other external mass storage devices where "unmount" and "eject" basically do the same thing for the user.

Might be worth adding a check for whether or not the drive can eject, and if not, whether or not it can unmount.

Revision history for this message
Sam Spilsbury (smspillaz) :
review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I thought exactly the same thing Sam and predicted that response :)

Then I realized Unmount without eject was actually useful for other drives like USB. At least useful to power-users who want to do things like unmount an auto-mounted filesystem to repartition/reformat. Then again, Disk Utility already has a button for that.

But there is the design argument that users should not be confused by being given so many options. That's understandable and I expected to be questioned on that.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hid the Unmount option in cases where Eject is available.

Avoids confusing users and makes the menu options identical to those in Nautilus.

Revision history for this message
Gord Allott (gordallott) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/DeviceLauncherIcon.cpp'
2--- src/DeviceLauncherIcon.cpp 2011-04-11 08:40:32 +0000
3+++ src/DeviceLauncherIcon.cpp 2011-05-25 08:25:59 +0000
4@@ -137,9 +137,31 @@
5 g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
6 G_CALLBACK (&DeviceLauncherIcon::OnDriveStop), this);
7 result.push_back (menu_item);
8+ }
9+ if (drive)
10+ {
11 g_object_unref (drive);
12 }
13
14+ if (!g_volume_can_eject (_volume)) // Don't need Unmount if can Eject
15+ {
16+ GMount *mount = g_volume_get_mount (_volume);
17+ if (mount && g_mount_can_unmount (mount))
18+ {
19+ menu_item = dbusmenu_menuitem_new ();
20+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Unmount"));
21+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
22+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
23+ g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
24+ G_CALLBACK (&DeviceLauncherIcon::OnUnmount), this);
25+ result.push_back (menu_item);
26+ }
27+ if (mount)
28+ {
29+ g_object_unref (mount);
30+ }
31+ }
32+
33 return result;
34 }
35
36@@ -276,6 +298,41 @@
37 }
38
39 void
40+DeviceLauncherIcon::OnUnmountReady (GObject *object,
41+ GAsyncResult *result,
42+ DeviceLauncherIcon *self)
43+{
44+ if (G_IS_MOUNT (object))
45+ {
46+ g_mount_unmount_with_operation_finish (G_MOUNT(object), result, NULL);
47+ }
48+}
49+
50+void
51+DeviceLauncherIcon::Unmount ()
52+{
53+ GMount *mount = g_volume_get_mount (_volume);
54+ if (mount)
55+ {
56+ GMountOperation *op = gtk_mount_operation_new (NULL);
57+ g_mount_unmount_with_operation (mount,
58+ (GMountUnmountFlags)0,
59+ op,
60+ NULL,
61+ (GAsyncReadyCallback)OnUnmountReady,
62+ this);
63+ g_object_unref (op);
64+ g_object_unref (mount);
65+ }
66+}
67+
68+void
69+DeviceLauncherIcon::OnUnmount (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self)
70+{
71+ self->Unmount ();
72+}
73+
74+void
75 DeviceLauncherIcon::OnRemoved (GVolume *volume, DeviceLauncherIcon *self)
76 {
77 self->_volume = NULL;
78
79=== modified file 'src/DeviceLauncherIcon.h'
80--- src/DeviceLauncherIcon.h 2011-04-09 23:40:50 +0000
81+++ src/DeviceLauncherIcon.h 2011-05-25 08:25:59 +0000
82@@ -44,13 +44,16 @@
83 void ActivateLauncherIcon ();
84 void ShowMount (GMount *mount);
85 void Eject ();
86+ void Unmount ();
87 void StopDrive ();
88 static void OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);
89 static void OnEject (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);
90+ static void OnUnmount (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);
91 static void OnRemoved (GVolume *volume, DeviceLauncherIcon *self);
92 static void OnChanged (GVolume *volume, DeviceLauncherIcon *self);
93 static void OnMountReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self);
94 static void OnEjectReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self);
95+ static void OnUnmountReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self);
96 static void OnDriveStop (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self);
97 static void OnStopDriveReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self);
98 void OnSettingsChanged (DevicesSettings *settings);