Add support for freeze suspend state

pull/2/head
Slávek Banko 11 years ago
parent 19b9183489
commit 7d335195a0

@ -714,6 +714,7 @@ void DevicePropertiesDialog::populateDeviceInformation() {
base->comboSystemHibernationMethod->setCurrentItem(m_hibernationComboMap[rdevice->hibernationMethod()]);
base->labelSystemUserCanStandby->setText((rdevice->canStandby())?i18n("Yes"):i18n("No"));
base->labelSystemUserCanFreeze->setText((rdevice->canFreeze())?i18n("Yes"):i18n("No"));
base->labelSystemUserCanSuspend->setText((rdevice->canSuspend())?i18n("Yes"):i18n("No"));
base->labelSystemUserCanHibernate->setText((rdevice->canHibernate())?i18n("Yes"):i18n("No"));
base->labelSystemUserCanPowerOff->setText((rdevice->canPowerOff())?i18n("Yes"):i18n("No"));

@ -1385,12 +1385,12 @@
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>User Can Request Suspend</string>
<string>User Can Request Freeze</string>
</property>
</widget>
<widget class="TQLabel" row="4" column="1" colspan="1">
<property name="name">
<cstring>labelSystemUserCanSuspend</cstring>
<cstring>labelSystemUserCanFreeze</cstring>
</property>
</widget>
<widget class="TQLabel" row="5" column="0" colspan="1">
@ -1398,12 +1398,12 @@
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>User Can Request Hibernation</string>
<string>User Can Request Suspend</string>
</property>
</widget>
<widget class="TQLabel" row="5" column="1" colspan="1">
<property name="name">
<cstring>labelSystemUserCanHibernate</cstring>
<cstring>labelSystemUserCanSuspend</cstring>
</property>
</widget>
<widget class="TQLabel" row="6" column="0" colspan="1">
@ -1411,10 +1411,23 @@
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>User Can Request Shutdown</string>
<string>User Can Request Hibernation</string>
</property>
</widget>
<widget class="TQLabel" row="6" column="1" colspan="1">
<property name="name">
<cstring>labelSystemUserCanHibernate</cstring>
</property>
</widget>
<widget class="TQLabel" row="7" column="0" colspan="1">
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="text">
<string>User Can Request Shutdown</string>
</property>
</widget>
<widget class="TQLabel" row="7" column="1" colspan="1">
<property name="name">
<cstring>labelSystemUserCanPowerOff</cstring>
</property>

@ -1,5 +1,5 @@
[Desktop Entry]
Exec=tdecmshell kwmanager
Exec=tdecmshell hwmanager
Icon=background
Type=Application
DocPath=kcontrol/hwmanager/index.html

@ -2674,17 +2674,18 @@ void KMenu::slotStartURL(const TQString& u)
kapp->dcopClient()->send("ksmserver", "default", "logoutTimed(int,int,TQString)", params);
}
#ifdef COMPILE_HALBACKEND
else if ( u == "kicker:/suspend_disk" ) {
slotSuspend( 1 );
}
else if ( u == "kicker:/suspend_ram" ) {
slotSuspend( 2 );
}
else if ( u == "kicker:/suspend_freeze" ) {
slotSuspend( 4 );
}
else if ( u == "kicker:/standby" ) {
slotSuspend( 3 );
}
#endif
else if ( u == "kicker:/savesession" ) {
TQByteArray data;
kapp->dcopClient()->send( "ksmserver", "default",
@ -3745,6 +3746,7 @@ int KMenu::max_items(int category) const
void KMenu::insertSuspendOption( int &nId, int &index )
{
bool suspend_ram = false;
bool suspend_freeze = false;
bool standby = false;
bool suspend_disk = false;
#ifdef COMPILE_HALBACKEND
@ -3766,12 +3768,18 @@ void KMenu::insertSuspendOption( int &nId, int &index )
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) {
suspend_ram = rootDevice->canSuspend();
suspend_freeze = rootDevice->canFreeze();
standby = rootDevice->canStandby();
suspend_disk = rootDevice->canHibernate();
}
#endif
if ( suspend_disk ) {
// respect disable suspend/hibernate settings from power-manager
TDEConfig config("power-managerrc");
bool disableSuspend = config.readBoolEntry("disableSuspend", false);
bool disableHibernate = config.readBoolEntry("disableHibernate", false);
if ( suspend_disk && !disableHibernate ) {
m_exitView->leftView()->insertItem(
"suspend2disk",
i18n( "Suspend to Disk" ),
@ -3779,7 +3787,7 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"kicker:/suspend_disk", nId++, index++ );
}
if ( suspend_ram ) {
if ( suspend_ram && !disableSuspend ) {
m_exitView->leftView()->insertItem(
"suspend2ram",
i18n( "Suspend to RAM" ),
@ -3787,7 +3795,15 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"kicker:/suspend_ram", nId++, index++ );
}
if ( standby ) {
if ( suspend_freeze && !disableSuspend ) {
m_exitView->leftView()->insertItem(
"suspend2ram",
i18n( "Freeze" ),
i18n( "Pause without logging out" ),
"kicker:/suspend_freeze", nId++, index++ );
}
if ( standby && !disableSuspend ) {
m_exitView->leftView()->insertItem(
"player_pause",
i18n( "Standby" ),
@ -3799,6 +3815,16 @@ void KMenu::insertSuspendOption( int &nId, int &index )
void KMenu::slotSuspend(int id)
{
bool error = true;
// respect lock on resume settings from power-manager
TDEConfig config("power-managerrc");
bool lockOnResume = config.readBoolEntry("lockOnResume", true);
if (lockOnResume) {
// Block here until lock is complete
// If this is not done the desktop of the locked session will be shown after suspend/hibernate until the lock fully engages!
DCOPRef("kdesktop", "KScreensaverIface").call("lock()");
}
#ifdef COMPILE_HALBACKEND
DBusMessage* msg = NULL;
@ -3841,6 +3867,8 @@ void KMenu::slotSuspend(int id)
error = !rootDevice->setPowerState(TDESystemPowerState::Suspend);
} else if (id == 3) {
error = !rootDevice->setPowerState(TDESystemPowerState::Standby);
} else if (id == 4) {
error = !rootDevice->setPowerState(TDESystemPowerState::Freeze);
} else {
return;
}

@ -247,6 +247,9 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm,
if (selection == 2) { // Hibernate
rootDevice->setPowerState(TDESystemPowerState::Hibernate);
}
if (selection == 3) { // Freeze
rootDevice->setPowerState(TDESystemPowerState::Freeze);
}
}
}
}

@ -798,6 +798,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
bool disableHibernate = config.readBoolEntry("disableHibernate", false);
m_lockOnResume = config.readBoolEntry("lockOnResume", true);
bool canFreeze = false;
bool canSuspend = false;
bool canHibernate = false;
@ -859,10 +860,12 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
#else // COMPILE_HALBACKEND
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) {
canFreeze = rootDevice->canFreeze();
canSuspend = rootDevice->canSuspend();
canHibernate = rootDevice->canHibernate();
}
else {
canFreeze = false;
canSuspend = false;
canHibernate = false;
}
@ -870,6 +873,18 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if(doUbuntuLogout) {
if (canFreeze && !disableSuspend)
{
// Freeze
FlatButton* btnFreeze = new FlatButton( frame );
btnFreeze->setTextLabel( i18n("&Freeze"), false );
btnFreeze->setPixmap( DesktopIcon( "suspend") );
int i = btnFreeze->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
btnFreeze->setAccel( "ALT+" + btnFreeze->textLabel().lower()[i+1] ) ;
hbuttonbox->addWidget ( btnFreeze);
connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze()));
}
if (canSuspend && !disableSuspend)
{
// Suspend
@ -1016,6 +1031,14 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
}
}
if (canFreeze && !disableSuspend)
{
KPushButton* btnFreeze = new KPushButton( KGuiItem( i18n("&Freeze Computer"), "suspend"), frame );
btnFreeze->setFont( btnFont );
buttonlay->addWidget( btnFreeze );
connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze()));
}
if (canSuspend && !disableSuspend)
{
KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Suspend Computer"), "suspend"), frame );
@ -1125,9 +1148,9 @@ void KSMShutdownDlg::slotHalt()
void KSMShutdownDlg::slotSuspend()
{
#ifndef COMPILE_HALBACKEND
*m_selection = 1; // Suspend
#ifdef COMPILE_HALBACKEND
#else
if (m_dbusConn)
{
DBusMessage *msg = dbus_message_new_method_call(
@ -1149,9 +1172,9 @@ void KSMShutdownDlg::slotSuspend()
void KSMShutdownDlg::slotHibernate()
{
#ifndef COMPILE_HALBACKEND
*m_selection = 2; // Hibernate
#ifdef COMPILE_HALBACKEND
#else
if (m_dbusConn)
{
DBusMessage *msg = dbus_message_new_method_call(
@ -1168,6 +1191,12 @@ void KSMShutdownDlg::slotHibernate()
reject(); // continue on resume
}
void KSMShutdownDlg::slotFreeze()
{
*m_selection = 3; // Freeze
reject();
}
bool KSMShutdownDlg::confirmShutdown( bool maysd, bool mayrb, TDEApplication::ShutdownType& sdtype, TQString& bootOption, int* selection )
{
kapp->enableStyles();

@ -141,6 +141,7 @@ public slots:
void slotReboot(int);
void slotSuspend();
void slotHibernate();
void slotFreeze();
protected:
~KSMShutdownDlg();

Loading…
Cancel
Save