~ubuntu-branches/ubuntu/maverick/gnome-power-manager/maverick-proposed

« back to all changes in this revision

Viewing changes to src/gpm-idle.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-03-29 14:34:27 UTC
  • mfrom: (2.1.51 upstream)
  • Revision ID: james.westby@ubuntu.com-20100329143427-tp37w17rfeibdppi
Tags: 2.30.0-0ubuntu1
* New upstream release:
 - Check for libpanel only if building the applets
 - Check for XRR* functions using library version instead of proto version
 - Use pkg-config instead of autoconf macros to find X libs and protos
 - Declare GError in gpm_brightness_hal_init to fix build failure
 - Do not set a charge warning if the device is on AC
 - Do not use EggDbusProxy in GpmScreensaver
 - Don't query the capabilities of the notification daemon
 - Ensure we close any 'battery low' notifications when we switch to being
   on AC
 - Fix a problem where the critical action is not done in the case of a UPS
 - Fix a race condition where we can miss the idle reset alarm
 - Fix up a translation using ngettext rather than assuming the plural.
 - Fix wrong suspends with docked laptops
 - If a battery charge is low but not critical don't play the sound meant
   for a critical charge event
 - Play a sound loop if the charge of a laptop battery/ups reaches a
   critical level.
 - Remove the pointy-finger status icon when the idletime code fails to work
   correctly
 - Replace devkit-power call with upower in gnome-power-bugreport.sh
* Drop patches which went upstream:
 - 01-suspend-on-vt-change.patch
 - 10-proxy-by-name.patch
 - 13-dont-query-notify-caps.patch
 - 14-critical-message-timeout.patch
 - 15-declare-gerror.patch
 - 16-upower-bugreport.patch
 - 18-fix-idletime-reset-race.patch
* Drop 06-bugreport-debian.patch: It's actually wrong for Ubuntu, we use
  lsb_release, not /etc/debian_version.
* 90-autotools.patch: Regenerate.
* 08-desktop-bugreport-path.patch, 12-add-appindicators.patch: Update to
  current patch tagging guidelines.
* debian/control.in: Set Maintainer from "Ted Gould" to "Ubuntu Developers".
* Synchronize with Debian:
  - Build/binary dependency cleanup/shuffling.
  - Bump Standards-Version to 3.8.4.
  - Add debian/preinst for upgrade conffile cleanup.
  - Drop obsolete debian/README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
struct GpmIdlePrivate
56
56
{
57
 
        GtkStatusIcon   *status_icon;
58
57
        EggIdletime     *idletime;
59
58
        GpmLoad         *load;
60
59
        GpmSession      *session;
96
95
}
97
96
 
98
97
/**
99
 
 * gpm_idle_mode_to_icon_name:
100
 
 **/
101
 
static const gchar *
102
 
gpm_idle_mode_to_icon_name (GpmIdleMode mode)
103
 
{
104
 
        if (mode == GPM_IDLE_MODE_BLANK)
105
 
                return "view-fullscreen";
106
 
        if (mode == GPM_IDLE_MODE_SLEEP)
107
 
                return "system-log-out";
108
 
        return NULL;
109
 
}
110
 
 
111
 
/**
112
98
 * gpm_idle_set_mode:
113
99
 * @mode: The new mode, e.g. GPM_IDLE_MODE_SLEEP
114
100
 **/
115
101
static void
116
102
gpm_idle_set_mode (GpmIdle *idle, GpmIdleMode mode)
117
103
{
118
 
        const gchar *icon_name;
119
 
 
120
104
        g_return_if_fail (GPM_IS_IDLE (idle));
121
105
 
122
 
        /* debug */
123
 
        icon_name = gpm_idle_mode_to_icon_name (mode);
124
 
        if (icon_name != NULL) {
125
 
                gtk_status_icon_set_from_icon_name (idle->priv->status_icon, icon_name);
126
 
                gtk_status_icon_set_visible (idle->priv->status_icon, TRUE);
127
 
        } else {
128
 
                gtk_status_icon_set_visible (idle->priv->status_icon, FALSE);
129
 
        }
130
 
 
131
106
        if (mode != idle->priv->mode) {
132
107
                idle->priv->mode = mode;
133
108
                egg_debug ("Doing a state transition: %s", gpm_idle_mode_to_text (mode));
205
180
        gboolean is_idle;
206
181
        gboolean is_idle_inhibited;
207
182
        gboolean is_suspend_inhibited;
208
 
        gchar *tooltip;
209
 
        gchar *what_to_do;
210
 
        gchar *nag_message;
211
183
 
212
184
        is_idle = gpm_session_get_idle (idle->priv->session);
213
185
        is_idle_inhibited = gpm_session_get_idle_inhibited (idle->priv->session);
214
186
        is_suspend_inhibited = gpm_session_get_suspend_inhibited (idle->priv->session);
215
187
        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);
216
188
 
217
 
        /* TRANSLATORS: this is what the user should read for more information about the blanking problem (%s is a URL) */
218
 
        what_to_do = g_strdup_printf (_("Please see %s for more information."),
219
 
                                      "http://blogs.gnome.org/hughsie/2009/08/17/gnome-power-manager-and-blanking-removal-of-bodges/");
220
 
 
221
 
        /* TRANSLATORS: this is telling the user that thier X server is broken, and needs to be fixed */
222
 
        nag_message = g_strdup_printf ("%s\n%s", _("If you can see this text, your display server is broken and you should notify your distributor."),
223
 
                                       what_to_do);
224
 
 
225
 
        /* debug */
226
 
        tooltip = g_strdup_printf ("%s, %s, %s, %s.\n%s",
227
 
                                   /* TRANSLATORS: this is for debugging, if the session is idle */
228
 
                                   is_idle ? _("Session idle") : _("Session active"),
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"),
233
 
                                   /* TRANSLATORS: is the screen idle or awake */
234
 
                                   idle->priv->x_idle ? _("screen idle") : _("screen awake"),
235
 
                                   nag_message);
236
 
        gtk_status_icon_set_tooltip_text (idle->priv->status_icon, tooltip);
237
 
        g_free (tooltip);
238
 
 
239
189
        /* check we are really idle */
240
190
        if (!idle->priv->x_idle) {
241
191
                gpm_idle_set_mode (idle, GPM_IDLE_MODE_NORMAL);
296
246
                }
297
247
        }
298
248
out:
299
 
        g_free (nag_message);
300
 
        g_free (what_to_do);
301
249
        return;
302
250
}
303
251
 
429
377
        if (idle->priv->timeout_sleep_id != 0)
430
378
                g_source_remove (idle->priv->timeout_sleep_id);
431
379
 
432
 
        /* for debugging */
433
 
        g_object_unref (idle->priv->status_icon);
434
 
 
435
380
        g_object_unref (idle->priv->load);
436
381
        g_object_unref (idle->priv->session);
437
382
 
490
435
        g_signal_connect (idle->priv->idletime, "reset", G_CALLBACK (gpm_idle_idletime_reset_cb), idle);
491
436
        g_signal_connect (idle->priv->idletime, "alarm-expired", G_CALLBACK (gpm_idle_idletime_alarm_expired_cb), idle);
492
437
 
493
 
        /* only used for debugging */
494
 
        idle->priv->status_icon = gtk_status_icon_new ();
495
 
 
496
438
        gpm_idle_evaluate (idle);
497
439
}
498
440