Kickoff menu: Allow suspend features using tdehw library

pull/2/head
Slávek Banko 11 years ago
parent bbdb95ed64
commit 7a982ffaa1

@ -52,6 +52,7 @@
#include <kdebug.h>
#include <tdeglobal.h>
#include <tdeglobalsettings.h>
#include <tdehardwaredevices.h>
#include <kiconloader.h>
#include <klineedit.h>
#include <tdelocale.h>
@ -3761,6 +3762,13 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"/org/freedesktop/Hal/devices/computer",
"power_management.can_hibernate",
NULL);
#else // COMPILE_HALBACKEND
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) {
suspend_ram = rootDevice->canSuspend();
standby = rootDevice->canStandby();
suspend_disk = rootDevice->canHibernate();
}
#endif
if ( suspend_disk ) {
@ -3824,6 +3832,19 @@ void KMenu::slotSuspend(int id)
}
dbus_message_unref(msg);
}
#else // COMPILE_HALBACKEND
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) {
if (id == 1) {
error = !rootDevice->setPowerState(TDESystemPowerState::Hibernate);
} else if (id == 2) {
error = !rootDevice->setPowerState(TDESystemPowerState::Suspend);
} else if (id == 3) {
error = !rootDevice->setPowerState(TDESystemPowerState::Standby);
} else {
return;
}
}
#endif
if (error)
KMessageBox::error(this, i18n("Suspend failed"));

Loading…
Cancel
Save