diff options
| -rw-r--r-- | src/DeviceLauncherIcon.cpp | 59 | ||||
| -rw-r--r-- | src/DeviceLauncherIcon.h | 3 | ||||
| -rw-r--r-- | src/Launcher.cpp | 2 | ||||
| -rw-r--r-- | src/unityshell.cpp | 28 | ||||
| -rw-r--r-- | src/unityshell.h | 2 |
5 files changed, 77 insertions, 17 deletions
diff --git a/src/DeviceLauncherIcon.cpp b/src/DeviceLauncherIcon.cpp index 13e4b154b..f95863d8c 100644 --- a/src/DeviceLauncherIcon.cpp +++ b/src/DeviceLauncherIcon.cpp @@ -104,6 +104,7 @@ DeviceLauncherIcon::GetMenus () { std::list<DbusmenuMenuitem *> result; DbusmenuMenuitem *menu_item; + GDrive *drive; menu_item = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Open")); @@ -124,6 +125,19 @@ DeviceLauncherIcon::GetMenus () result.push_back (menu_item); } + drive = g_volume_get_drive (_volume); + if (drive && g_drive_can_stop (drive)) + { + menu_item = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Safely Remove")); + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); + g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (&DeviceLauncherIcon::OnDriveStop), this); + result.push_back (menu_item); + g_object_unref (drive); + } + return result; } @@ -233,14 +247,18 @@ DeviceLauncherIcon::OnEjectReady (GObject *object, void DeviceLauncherIcon::Eject () { - g_debug ("%s", G_STRLOC); + GMountOperation *mount_op; + + mount_op = gtk_mount_operation_new(NULL); + g_volume_eject_with_operation (_volume, (GMountUnmountFlags)0, - NULL, + mount_op, NULL, (GAsyncReadyCallback)OnEjectReady, this); - g_debug ("%s", G_STRLOC); + + g_object_unref(mount_op); } void @@ -252,9 +270,7 @@ DeviceLauncherIcon::OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon void DeviceLauncherIcon::OnEject (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self) { - g_debug ("%s", G_STRLOC); self->Eject (); - g_debug ("%s", G_STRLOC); } void @@ -262,3 +278,36 @@ DeviceLauncherIcon::OnRemoved (GVolume *volume, DeviceLauncherIcon *self) { self->Remove (); } + +void +DeviceLauncherIcon::OnDriveStop (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self) +{ + self->StopDrive (); +} + +void +DeviceLauncherIcon::StopDrive () +{ + GDrive *drive; + + drive = g_volume_get_drive (_volume); + g_drive_stop (drive, + (GMountUnmountFlags)0, + NULL, + NULL, + (GAsyncReadyCallback)OnStopDriveReady, + this); + g_object_unref (drive); +} + +void +DeviceLauncherIcon::OnStopDriveReady (GObject *object, + GAsyncResult *result, + DeviceLauncherIcon *self) +{ + GDrive *drive; + + drive = g_volume_get_drive (self->_volume); + g_drive_stop_finish (drive, result, NULL); + g_object_unref (drive); +} diff --git a/src/DeviceLauncherIcon.h b/src/DeviceLauncherIcon.h index d966699a3..ae31943d0 100644 --- a/src/DeviceLauncherIcon.h +++ b/src/DeviceLauncherIcon.h @@ -43,11 +43,14 @@ private: void ActivateLauncherIcon (); void ShowMount (GMount *mount); void Eject (); + void StopDrive (); static void OnOpen (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self); static void OnEject (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self); static void OnRemoved (GVolume *volume, DeviceLauncherIcon *self); static void OnMountReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self); static void OnEjectReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self); + static void OnDriveStop (DbusmenuMenuitem *item, int time, DeviceLauncherIcon *self); + static void OnStopDriveReady (GObject *object, GAsyncResult *result, DeviceLauncherIcon *self); private: GVolume *_volume; diff --git a/src/Launcher.cpp b/src/Launcher.cpp index 1e5b12e21..dec84f8c5 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -2739,7 +2739,7 @@ Launcher::RecvKeyPressed (unsigned int key_sym, // down (move selection down and unfold launcher if needed) case NUX_VK_DOWN: - if (_current_icon_index < _model->Size ()) + if (_current_icon_index < _model->Size () - 1) { _current_icon_index++; NeedRedraw (); diff --git a/src/unityshell.cpp b/src/unityshell.cpp index c7ba1bc9f..799fa3222 100644 --- a/src/unityshell.cpp +++ b/src/unityshell.cpp @@ -570,6 +570,12 @@ UnityScreen::NeedsRelayout () } void +UnityScreen::ScheduleRelayout (guint timeout) +{ + g_timeout_add (timeout, &UnityScreen::RelayoutTimeout, this); +} + +void UnityScreen::Relayout () { GdkScreen *scr; @@ -669,7 +675,7 @@ OnMonitorChanged (GdkScreen* screen, gpointer data) { UnityScreen* uscreen = (UnityScreen*) data; - uscreen->NeedsRelayout (); + uscreen->ScheduleRelayout (500); } void @@ -677,7 +683,7 @@ OnSizeChanged (GdkScreen* screen, gpointer data) { UnityScreen* uscreen = (UnityScreen*) data; - uscreen->NeedsRelayout (); + uscreen->ScheduleRelayout (500); } UnityScreen::UnityScreen (CompScreen *screen) : @@ -764,14 +770,14 @@ UnityScreen::UnityScreen (CompScreen *screen) : g_timeout_add (0, &UnityScreen::initPluginActions, this); g_timeout_add (5000, (GSourceFunc) write_logger_data_to_disk, NULL); - g_signal_connect_swapped (gdk_screen_get_default (), - "monitors-changed", - G_CALLBACK (OnMonitorChanged), - this); - g_signal_connect_swapped (gdk_screen_get_default (), - "size-changed", - G_CALLBACK (OnSizeChanged), - this); + g_signal_connect (gdk_screen_get_default (), + "monitors-changed", + G_CALLBACK (OnMonitorChanged), + this); + g_signal_connect (gdk_screen_get_default (), + "size-changed", + G_CALLBACK (OnSizeChanged), + this); END_FUNCTION (); } @@ -871,7 +877,7 @@ void UnityScreen::initLauncher (nux::NThread* thread, void* InitData) self->launcher->SetHideMode (Launcher::LAUNCHER_HIDE_DODGE_WINDOWS); self->launcher->SetLaunchAnimation (Launcher::LAUNCH_ANIMATION_PULSE); self->launcher->SetUrgentAnimation (Launcher::URGENT_ANIMATION_WIGGLE); - g_timeout_add (2000, &UnityScreen::RelayoutTimeout, self); + self->ScheduleRelayout (2000); g_timeout_add (2000, &UnityScreen::strutHackTimeout, self); END_FUNCTION (); diff --git a/src/unityshell.h b/src/unityshell.h index fce0b04a9..9dade73c4 100644 --- a/src/unityshell.h +++ b/src/unityshell.h @@ -130,6 +130,8 @@ class UnityScreen : void NeedsRelayout (); + void ScheduleRelayout (guint timeout); + protected: const gchar* GetName (); |
