Hi again, This is a follow up of the patch sent to this mailing list May 28th [1]. I've reworked the patch slightly, as I discovered that the critical alarm sounds should be stopped before aborting the critical power action *if* the power was restored just in time. Please consider the attached patch for inclusion. This new patch replaces the previous patch sent to the mailing list. kind regards, David Sommerseth [1] <http://mail.gnome.org/archives/gnome-power-manager-list/2011-May/msg00003.html>
From c4ba43192409d1290996fcec5765a5aadf2db78b Mon Sep 17 00:00:00 2001 From: David Sommerseth <davids redhat com> Date: Tue, 14 Jun 2011 09:20:35 +0200 Subject: [PATCH v2] Don't complete critical action if power is resumed When the critical warning is displayed, the critical action will be perfomed even if power is restored. This patch adds an extra check to see if power has been restored during those 20 seconds the warning is displayed. If the power is restored in time, abort the critical action. [ This is version 2 of this patch, where this version stops the sound alarm before aborting ] Signed-off-by: David Sommerseth <davids redhat com> --- src/gpm-manager.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 9bb0591..c889c4f 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -1185,7 +1185,19 @@ manager_critical_action_do (GpmManager *manager) if (manager->priv->critical_alert_timeout_id) gpm_manager_play_loop_stop (manager); - gpm_manager_perform_policy (manager, GSD_SETTINGS_ACTION_CRITICAL_BATT, "Battery is critically low."); + /* If power is restored before we reach here, abort */ + if( !manager->priv->on_battery ) { + /* Show an abort notification */ + gpm_manager_notify (manager, &manager->priv->notification_warning_low, + "Power resumed", + "Aborting the previous critical power action", + GPM_MANAGER_NOTIFY_TIMEOUT_SHORT, + NULL, NOTIFY_URGENCY_NORMAL); + } else + /* If still on battery, start the critical action */ + gpm_manager_perform_policy (manager, GSD_SETTINGS_ACTION_CRITICAL_BATT, + "Battery is critically low."); + return FALSE; } -- 1.7.4.4
Attachment:
signature.asc
Description: OpenPGP digital signature