142
xfpm_backlight_composited_changed_cb (XfpmBacklight *backlight)
144
xfpm_backlight_destroy_popup (backlight);
145
xfpm_backlight_create_popup (backlight);
127
149
xfpm_backlight_show_notification (XfpmBacklight *backlight, gfloat value)
131
/* create the notification on demand */
153
static const char *display_icon_name[] =
155
"notification-display-brightness-off",
156
"notification-display-brightness-low",
157
"notification-display-brightness-medium",
158
"notification-display-brightness-high",
159
"notification-display-brightness-full",
132
163
if ( backlight->priv->n == NULL )
134
backlight->priv->n = xfpm_notify_new_notification (backlight->priv->notify,
137
"xfpm-brightness-lcd",
165
backlight->priv->n = xfpm_notify_new_notification (backlight->priv->notify,
139
170
XFPM_NOTIFY_NORMAL,
143
/* generate a human-readable summary for the notification */
144
summary = g_strdup_printf (_("Brightness: %.0f percent"), value);
145
notify_notification_update (backlight->priv->n, summary, NULL, NULL);
148
/* add the brightness value to the notification */
149
notify_notification_set_hint_int32 (backlight->priv->n, "value", value);
151
/* show the notification */
174
i = (gint)value / 25;
176
if ( i > 4 || i < 0 )
179
notify_notification_set_hint_int32 (backlight->priv->n,
183
notify_notification_set_hint_string (backlight->priv->n,
184
"x-canonical-private-synchronous",
187
notify_notification_update (backlight->priv->n,
190
display_icon_name[i]);
152
192
notify_notification_show (backlight->priv->n, NULL);
196
xfpm_backlight_create_popup (XfpmBacklight *backlight)
198
if ( backlight->priv->osd != NULL )
201
backlight->priv->osd = gsd_media_keys_window_new ();
202
gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->osd),
203
XFPM_DISPLAY_BRIGHTNESS_ICON,
205
gtk_window_set_position (GTK_WINDOW (backlight->priv->osd), GTK_WIN_POS_CENTER);
207
g_signal_connect_swapped (backlight->priv->osd, "composited-changed",
208
G_CALLBACK (xfpm_backlight_composited_changed_cb), backlight);
156
213
xfpm_backlight_show (XfpmBacklight *backlight, gint level)
216
gboolean sync_notify;
160
219
XFPM_DEBUG ("Level %u", level);
221
g_object_get (G_OBJECT (backlight->priv->conf),
222
SHOW_BRIGHTNESS_POPUP, &show_popup,
228
g_object_get (G_OBJECT (backlight->priv->notify),
229
"sync", &sync_notify,
162
232
value = (gfloat) 100 * level / backlight->priv->max_level;
163
xfpm_backlight_show_notification (backlight, value);
234
if ( !sync_notify ) /*Notification server doesn't support sync notifications*/
236
xfpm_backlight_create_popup (backlight);
237
gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->osd),
239
if ( !GTK_WIDGET_VISIBLE (backlight->priv->osd))
240
gtk_window_present (GTK_WINDOW (backlight->priv->osd));
244
xfpm_backlight_show_notification (backlight, value);
247
if ( backlight->priv->destroy_id != 0 )
249
g_source_remove (backlight->priv->destroy_id);
250
backlight->priv->destroy_id = 0;
254
/* Release the memory after 60 seconds */
255
backlight->priv->destroy_id = g_timeout_add_seconds (60, (GSourceFunc) xfpm_backlight_destroy_popup, backlight);