~ubuntu-branches/ubuntu/lucid/gnome-power-manager/lucid-updates

« back to all changes in this revision

Viewing changes to src/gpm-idle.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-02-05 13:28:09 UTC
  • mfrom: (2.1.49 upstream)
  • Revision ID: james.westby@ubuntu.com-20100205132809-jfmqtr00ri6flcv2
Tags: 2.29.2-0ubuntu1
* New upstream release:
  - Move the power management preferences into the hardware section of the
    control center.
  - Use the name of 'Power' for the power management preferences capplet
  - Don't rely on the cached value of the lid status, to fix a double
    suspend issue (LP: #425411)
  - Add a flag to inhibit consolekit events just after we resumed
  - Don't automatically suspend if there are suspend inhibits
  - Do not exit if hal is not available
  - Only connect to HAL if there is no xrandr backlight hardware
  - Fix compile when using an ld that defaults to --as-needed
  - Enable the help action in gnome-power-statistics. Fixes #607005
  - Ensure the window is realized before we invalidate it. Fixes #604918
  - Don't show the user a sleep failed link pointing to the quirk site
  - Show the device name even when using UPower
  - Translation updates.
* Drop patches accepted upstream: 
  + 03-run-without-hal.patch
  + 04-dont-connect-to-hal-with-xrandr.patch
  + 09-fix-double-suspend.patch
* Regenerate 90-autotools.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *
18
18
 * You should have received a copy of the GNU General Public License
19
19
 * along with this program; if not, write to the Free Software
20
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
21
 */
22
22
 
23
23
#include "config.h"
203
203
gpm_idle_evaluate (GpmIdle *idle)
204
204
{
205
205
        gboolean is_idle;
206
 
        gboolean is_inhibited;
 
206
        gboolean is_idle_inhibited;
 
207
        gboolean is_suspend_inhibited;
207
208
        gchar *tooltip;
208
209
        gchar *what_to_do;
209
210
        gchar *nag_message;
210
211
 
211
212
        is_idle = gpm_session_get_idle (idle->priv->session);
212
 
        is_inhibited = gpm_session_get_inhibited (idle->priv->session);
213
 
        egg_debug ("session_idle=%i, session_inhibited=%i, x_idle=%i", is_idle, is_inhibited, idle->priv->x_idle);
 
213
        is_idle_inhibited = gpm_session_get_idle_inhibited (idle->priv->session);
 
214
        is_suspend_inhibited = gpm_session_get_suspend_inhibited (idle->priv->session);
 
215
        egg_debug ("session_idle=%i, idle_inhibited=%i, suspend_inhibited=%i, x_idle=%i", is_idle, is_idle_inhibited, is_suspend_inhibited, idle->priv->x_idle);
214
216
 
215
217
        /* TRANSLATORS: this is what the user should read for more information about the blanking problem (%s is a URL) */
216
218
        what_to_do = g_strdup_printf (_("Please see %s for more information."),
221
223
                                       what_to_do);
222
224
 
223
225
        /* debug */
224
 
        tooltip = g_strdup_printf ("%s, %s, %s.\n%s",
 
226
        tooltip = g_strdup_printf ("%s, %s, %s, %s.\n%s",
225
227
                                   /* TRANSLATORS: this is for debugging, if the session is idle */
226
228
                                   is_idle ? _("Session idle") : _("Session active"),
227
 
                                   /* TRANSLATORS: has something inhibited the session */
228
 
                                   is_inhibited ? _("inhibited") : _("not inhibited"),
 
229
                                   /* TRANSLATORS: has something inhibited the session from going idle */
 
230
                                   is_idle_inhibited ? _("idle inhibited") : _("idle not inhibited"),
 
231
                                   /* TRANSLATORS: has something inhibited the system from being suspended */
 
232
                                   is_suspend_inhibited ? _("suspend inhibited") : _("suspend not inhibited"),
229
233
                                   /* TRANSLATORS: is the screen idle or awake */
230
234
                                   idle->priv->x_idle ? _("screen idle") : _("screen awake"),
231
235
                                   nag_message);
247
251
                goto out;
248
252
        }
249
253
 
250
 
        /* are we inhibited */
251
 
        if (is_inhibited) {
 
254
        /* are we inhibited from going idle */
 
255
        if (is_idle_inhibited) {
252
256
                egg_debug ("inhibited, so using normal state");
253
257
                gpm_idle_set_mode (idle, GPM_IDLE_MODE_NORMAL);
254
258
                if (idle->priv->timeout_blank_id != 0) {
276
280
                idle->priv->timeout_blank_id = g_timeout_add_seconds (idle->priv->timeout_blank, (GSourceFunc) gpm_idle_blank_cb, idle);
277
281
        }
278
282
 
279
 
        /* only do the sleep timeout when the session is idle */
280
 
        if (is_idle) {
 
283
        /* are we inhibited from sleeping */
 
284
        if (is_suspend_inhibited) {
 
285
                egg_debug ("suspend inhibited");
 
286
                if (idle->priv->timeout_sleep_id != 0) {
 
287
                        g_source_remove (idle->priv->timeout_sleep_id);
 
288
                        idle->priv->timeout_sleep_id = 0;
 
289
                }
 
290
        } else if (is_idle) {
 
291
        /* only do the sleep timeout when the session is idle and we aren't inhibited from sleeping */
281
292
                if (idle->priv->timeout_sleep_id == 0 &&
282
293
                    idle->priv->timeout_sleep != 0) {
283
294
                        egg_debug ("setting up sleep callback %is", idle->priv->timeout_sleep);
362
373
 * gpm_idle_session_inhibited_changed_cb:
363
374
 **/
364
375
static void
365
 
gpm_idle_session_inhibited_changed_cb (GpmSession *session, gboolean is_inhibited, GpmIdle *idle)
 
376
gpm_idle_session_inhibited_changed_cb (GpmSession *session, gboolean is_idle_inhibited, gboolean is_suspend_inhibited, GpmIdle *idle)
366
377
{
367
 
        egg_debug ("Received gnome session inhibited changed: %i", is_inhibited);
 
378
        egg_debug ("Received gnome session inhibited changed: idle=(%i), suspend=(%i)", is_idle_inhibited, is_suspend_inhibited);
368
379
        gpm_idle_evaluate (idle);
369
380
}
370
381