Want more features on Pastebin? Sign Up, it's FREE!
Guest

notify-osd-support.patch

By: a guest on Apr 9th, 2010  |  syntax: Diff  |  size: 19.87 KB  |  views: 306  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Description: Add support for synchronous brightness notifications using notify-osd.
  2.  The patch is based around gsd-osd-notification.[ch] which is shared with gsd
  3. Author: Chris Coulson <chris.coulson@canonical.com>
  4. Forwarded: no
  5.  
  6. Index: gnome-power-manager-2.29.2/src/Makefile.am
  7. ===================================================================
  8. --- gnome-power-manager-2.29.2.orig/src/Makefile.am     2010-01-27 16:24:51.000000000 +0000
  9. +++ gnome-power-manager-2.29.2/src/Makefile.am  2010-02-23 19:03:10.519523228 +0000
  10. @@ -168,6 +168,8 @@
  11.         gsd-media-keys-window.c                         \
  12.         gpm-engine.h                                    \
  13.         gpm-engine.c                                    \
  14. +       gsd-osd-notification.h                  \
  15. +       gsd-osd-notification.c                  \
  16.         $(NULL)
  17.  
  18.  if HAVE_HAL
  19. Index: gnome-power-manager-2.29.2/src/gsd-osd-notification.c
  20. ===================================================================
  21. --- /dev/null   1970-01-01 00:00:00.000000000 +0000
  22. +++ gnome-power-manager-2.29.2/src/gsd-osd-notification.c       2010-02-23 19:03:37.929522263 +0000
  23. @@ -0,0 +1,286 @@
  24. +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
  25. +/*
  26. + * gsd-osd-notification.c
  27. + * Copyright (C) 2010 Chris Coulson <chrisccoulson@ubuntu.com>
  28. + * Copyright (C) 2009 Canonical Ltd
  29. + *
  30. + * gsd-osd-notification.c is free software: you can redistribute it and/or modify it
  31. + * under the terms of the GNU General Public License as published by the
  32. + * Free Software Foundation, either version 3 of the License, or
  33. + * (at your option) any later version.
  34. + *
  35. + * gsd-osd-notification.c is distributed in the hope that it will be useful, but
  36. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  37. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  38. + * See the GNU General Public License for more details.
  39. + *
  40. + * You should have received a copy of the GNU General Public License along
  41. + * with this program.  If not, see <http://www.gnu.org/licenses/>.
  42. + */
  43. +
  44. +#include <libnotify/notify.h>
  45. +#include "gsd-osd-notification.h"
  46. +
  47. +struct _GsdOsdNotificationPrivate
  48. +{
  49. +        NotifyNotification *notification;
  50. +        char **icon_names;
  51. +        char *hint;
  52. +        guint icon_array_size;
  53. +};
  54. +
  55. +#define GSD_OSD_NOTIFICATION_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotificationPrivate))
  56. +
  57. +enum
  58. +{
  59. +       PROP_0,
  60. +       PROP_ICON_NAMES,
  61. +        PROP_HINT
  62. +};
  63. +
  64. +#define NOTIFY_CAP_PRIVATE_SYNCHRONOUS "x-canonical-private-synchronous"
  65. +#define NOTIFY_CAP_PRIVATE_ICON_ONLY "x-canonical-private-icon-only"
  66. +#define NOTIFY_HINT_TRUE "true"
  67. +
  68. +G_DEFINE_TYPE (GsdOsdNotification, gsd_osd_notification, G_TYPE_OBJECT);
  69. +
  70. +static const char*
  71. +_calculate_icon (GsdOsdNotification *notifier, guint value, gboolean muted)
  72. +{
  73. +        guint s;
  74. +
  75. +        s = (notifier->priv->icon_array_size -1) * value / 100 + 1;
  76. +        s = MAX (s, 1);
  77. +        s = MIN (s, notifier->priv->icon_array_size -1);
  78. +        if (value <= 0)
  79. +                s = 0;
  80. +
  81. +        return muted ? notifier->priv->icon_names[0] : notifier->priv->icon_names[s];
  82. +}
  83. +
  84. +void
  85. +gsd_osd_notification_set_icon_array (GsdOsdNotification *notifier, const char **icon_names)
  86. +{
  87. +        g_return_if_fail (GSD_IS_OSD_NOTIFICATION (notifier));
  88. +
  89. +        g_strfreev (notifier->priv->icon_names);
  90. +        notifier->priv->icon_names = g_strdupv ((gchar **) icon_names);
  91. +
  92. +        notifier->priv->icon_array_size = g_strv_length ((gchar **) icon_names);
  93. +}
  94. +
  95. +void
  96. +gsd_osd_notification_set_hint (GsdOsdNotification *notifier, const char *hint)
  97. +{
  98. +        g_return_if_fail (GSD_IS_OSD_NOTIFICATION (notifier));
  99. +
  100. +        g_free (notifier->priv->hint);
  101. +        notifier->priv->hint = g_strdup (hint);
  102. +}
  103. +
  104. +gboolean
  105. +gsd_osd_notification_is_supported (void)
  106. +{
  107. +        GList *caps;
  108. +        gboolean has_cap;
  109. +
  110. +        caps = notify_get_server_caps ();
  111. +        has_cap = (g_list_find_custom (caps, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, (GCompareFunc) g_strcmp0) != NULL);
  112. +        g_list_foreach (caps, (GFunc) g_free, NULL);
  113. +        g_list_free (caps);
  114. +
  115. +        return has_cap;
  116. +}
  117. +
  118. +gboolean
  119. +gsd_osd_notification_show_icon_only (const char *icon, const char *hint)
  120. +{
  121. +        NotifyNotification *notification;
  122. +
  123. +        g_return_val_if_fail (icon != NULL, FALSE);
  124. +        g_return_val_if_fail (hint != NULL, FALSE);
  125. +
  126. +        if (!gsd_osd_notification_is_supported ())
  127. +                return FALSE;
  128. +
  129. +        notification = notify_notification_new (" ", "", NULL, NULL);
  130. +
  131. +        if (notification != NULL) {
  132. +                notify_notification_set_hint_string (notification, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, hint);
  133. +                notify_notification_set_hint_string (notification, NOTIFY_CAP_PRIVATE_ICON_ONLY, NOTIFY_HINT_TRUE);
  134. +                notify_notification_update (notification, " ", "", icon);
  135. +        } else {
  136. +                return FALSE;
  137. +        }
  138. +
  139. +        if (!notify_notification_show (notification, NULL)) {
  140. +                g_object_unref (notification);
  141. +                return FALSE;
  142. +        }
  143. +
  144. +        g_object_unref (notification);
  145. +
  146. +        return TRUE;
  147. +}
  148. +
  149. +gboolean
  150. +gsd_osd_notification_show_value (GsdOsdNotification *notifier, gint value, gboolean muted)
  151. +{
  152. +        const char *icon;
  153. +
  154. +        g_return_val_if_fail (GSD_IS_OSD_NOTIFICATION (notifier), FALSE);
  155. +        g_return_val_if_fail (notifier->priv->icon_names != NULL, FALSE);
  156. +        g_return_val_if_fail (notifier->priv->hint != NULL, FALSE);
  157. +
  158. +        if (!gsd_osd_notification_is_supported ())
  159. +                return FALSE;
  160. +
  161. +        if (notifier->priv->notification == NULL) {
  162. +                notifier->priv->notification = notify_notification_new (" ", "", NULL, NULL);
  163. +                notify_notification_set_hint_string (notifier->priv->notification, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, notifier->priv->hint);
  164. +}
  165. +        if (notifier->priv->notification != NULL) {
  166. +                value = MIN (value, 101);
  167. +                value = MAX (value, -1);
  168. +                icon = _calculate_icon (notifier, value, muted);
  169. +                notify_notification_set_hint_int32(notifier->priv->notification, "value", (muted && value > 0) ? 0 : value);
  170. +                notify_notification_update (notifier->priv->notification, " ", "", icon);
  171. +        } else {
  172. +                return FALSE;
  173. +        }
  174. +
  175. +        if (!notify_notification_show (notifier->priv->notification, NULL))
  176. +                return FALSE;
  177. +
  178. +        return TRUE;
  179. +}
  180. +
  181. +gboolean
  182. +gsd_osd_notification_show_overshoot (GsdOsdNotification *notifier, GsdOsdNotifierOvershootType type)
  183. +{
  184. +        gint value;
  185. +        gboolean muted;
  186. +
  187. +        g_return_val_if_fail (type == GSD_OSD_NOTIFICATION_UNDERSHOOT || type == GSD_OSD_NOTIFICATION_OVERSHOOT, FALSE);
  188. +
  189. +        switch (type)
  190. +        {
  191. +        case GSD_OSD_NOTIFICATION_UNDERSHOOT:
  192. +                value = -1;
  193. +                muted = TRUE;
  194. +                break;
  195. +        case GSD_OSD_NOTIFICATION_OVERSHOOT:
  196. +                value = 101;
  197. +                muted = FALSE;
  198. +                break;
  199. +        default:
  200. +                g_assert_not_reached ();
  201. +                break;
  202. +        }
  203. +
  204. +        return gsd_osd_notification_show_value (notifier, value, muted);
  205. +}
  206. +
  207. +GsdOsdNotification*
  208. +gsd_osd_notification_new (const char **icon_names, const char *hint)
  209. +{
  210. +        return (GsdOsdNotification *) g_object_new (GSD_TYPE_OSD_NOTIFICATION,
  211. +                                                    "icon-names", icon_names,
  212. +                                                    "hint", hint,
  213. +                                                    NULL);
  214. +}
  215. +
  216. +static void
  217. +gsd_osd_notification_init (GsdOsdNotification *object)
  218. +{
  219. +        object->priv = GSD_OSD_NOTIFICATION_PRIVATE (object);
  220. +
  221. +        if (!notify_is_initted ())
  222. +                notify_init (g_get_application_name ());
  223. +
  224. +        object->priv->hint = NULL;
  225. +        object->priv->icon_names = NULL;
  226. +        object->priv->notification = NULL;
  227. +}
  228. +
  229. +static void
  230. +gsd_osd_notification_finalize (GObject *object)
  231. +{
  232. +        GsdOsdNotification *notifier = GSD_OSD_NOTIFICATION (object);
  233. +
  234. +        g_strfreev (notifier->priv->icon_names);
  235. +        g_free (notifier->priv->hint);
  236. +
  237. +        if (notifier->priv->notification)
  238. +                g_object_unref (notifier->priv->notification);
  239. +
  240. +        G_OBJECT_CLASS (gsd_osd_notification_parent_class)->finalize (object);
  241. +}
  242. +
  243. +static void
  244. +gsd_osd_notification_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
  245. +{
  246. +       g_return_if_fail (GSD_IS_OSD_NOTIFICATION (object));
  247. +        GsdOsdNotification *notifier = GSD_OSD_NOTIFICATION (object);
  248. +
  249. +       switch (prop_id)
  250. +       {
  251. +       case PROP_ICON_NAMES:
  252. +               gsd_osd_notification_set_icon_array (notifier, (const char**) g_value_get_boxed (value));
  253. +               break;
  254. +        case PROP_HINT:
  255. +                gsd_osd_notification_set_hint (notifier, (char**) g_value_get_string (value));
  256. +                break;
  257. +       default:
  258. +               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  259. +               break;
  260. +       }
  261. +}
  262. +
  263. +static void
  264. +gsd_osd_notification_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
  265. +{
  266. +       g_return_if_fail (GSD_IS_OSD_NOTIFICATION (object));
  267. +        GsdOsdNotification *notifier = GSD_OSD_NOTIFICATION (object);
  268. +
  269. +       switch (prop_id)
  270. +       {
  271. +       case PROP_ICON_NAMES:
  272. +               g_value_set_boxed (value, notifier->priv->icon_names);
  273. +               break;
  274. +        case PROP_HINT:
  275. +                g_value_set_string (value, notifier->priv->hint);
  276. +                break;
  277. +       default:
  278. +               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  279. +               break;
  280. +       }
  281. +}
  282. +
  283. +static void
  284. +gsd_osd_notification_class_init (GsdOsdNotificationClass *klass)
  285. +{
  286. +        GObjectClass* object_class = G_OBJECT_CLASS (klass);
  287. +
  288. +        object_class->finalize = gsd_osd_notification_finalize;
  289. +       object_class->set_property = gsd_osd_notification_set_property;
  290. +       object_class->get_property = gsd_osd_notification_get_property;
  291. +
  292. +       g_object_class_install_property (object_class,
  293. +                                        PROP_ICON_NAMES,
  294. +                                        g_param_spec_boxed ("icon-names",
  295. +                                                            "Icon name array",
  296. +                                                            "An array of icon names for the notification",
  297. +                                                            G_TYPE_STRV,
  298. +                                                            G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  299. +
  300. +        g_object_class_install_property (object_class,
  301. +                                        PROP_HINT,
  302. +                                        g_param_spec_string ("hint",
  303. +                                                            "Notification hint",
  304. +                                                            "Hint for the notification",
  305. +                                                            NULL,
  306. +                                                            G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  307. +
  308. +        g_type_class_add_private (klass, sizeof (GsdOsdNotificationPrivate));
  309. +}
  310. Index: gnome-power-manager-2.29.2/src/gsd-osd-notification.h
  311. ===================================================================
  312. --- /dev/null   1970-01-01 00:00:00.000000000 +0000
  313. +++ gnome-power-manager-2.29.2/src/gsd-osd-notification.h       2010-02-23 19:03:10.529523032 +0000
  314. @@ -0,0 +1,75 @@
  315. +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
  316. +/*
  317. + * gsd-osd-notification.c
  318. + * Copyright (C) 2010 Chris Coulson <chrisccoulson@ubuntu.com>
  319. + * Copyright (C) 2009 Canonical Ltd
  320. + *
  321. + * gsd-osd-notification.c is free software: you can redistribute it and/or modify it
  322. + * under the terms of the GNU General Public License as published by the
  323. + * Free Software Foundation, either version 3 of the License, or
  324. + * (at your option) any later version.
  325. + *
  326. + * gsd-osd-notification.c is distributed in the hope that it will be useful, but
  327. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  328. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  329. + * See the GNU General Public License for more details.
  330. + *
  331. + * You should have received a copy of the GNU General Public License along
  332. + * with this program.  If not, see <http://www.gnu.org/licenses/>.
  333. + */
  334. +
  335. +#ifndef _GSD_OSD_NOTIFICATION_H_
  336. +#define _GSD_OSD_NOTIFICATION_H_
  337. +
  338. +#include <glib-object.h>
  339. +
  340. +G_BEGIN_DECLS
  341. +
  342. +#define GSD_TYPE_OSD_NOTIFICATION             (gsd_osd_notification_get_type ())
  343. +#define GSD_OSD_NOTIFICATION(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotification))
  344. +#define GSD_OSD_NOTIFICATION_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotificationClass))
  345. +#define GSD_IS_OSD_NOTIFICATION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_OSD_NOTIFICATION))
  346. +#define GSD_IS_OSD_NOTIFICATION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GSD_TYPE_OSD_NOTIFICATION))
  347. +#define GSD_OSD_NOTIFICATION_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotificationClass))
  348. +
  349. +typedef struct _GsdOsdNotificationClass GsdOsdNotificationClass;
  350. +typedef struct _GsdOsdNotification GsdOsdNotification;
  351. +typedef struct _GsdOsdNotificationPrivate GsdOsdNotificationPrivate;
  352. +
  353. +struct _GsdOsdNotificationClass
  354. +{
  355. +        GObjectClass parent_class;
  356. +};
  357. +
  358. +struct _GsdOsdNotification
  359. +{
  360. +        GObject parent_instance;
  361. +
  362. +        GsdOsdNotificationPrivate *priv;
  363. +};
  364. +
  365. +typedef enum {
  366. +        GSD_OSD_NOTIFICATION_NO_OVERSHOOT = 0,
  367. +        GSD_OSD_NOTIFICATION_UNDERSHOOT,
  368. +        GSD_OSD_NOTIFICATION_OVERSHOOT,
  369. +} GsdOsdNotifierOvershootType;
  370. +
  371. +GType                   gsd_osd_notification_get_type           (void) G_GNUC_CONST;
  372. +GsdOsdNotification*     gsd_osd_notification_new                (const char                 **icon_names,
  373. +                                                                 const char                  *hint);
  374. +void                    gsd_osd_notification_set_icon_array     (GsdOsdNotification          *notifier,
  375. +                                                                 const char                 **icon_names);
  376. +void                    gsd_osd_notification_set_hint           (GsdOsdNotification          *notifier,
  377. +                                                                 const char                  *hint);
  378. +gboolean                gsd_osd_notification_is_supported       (void);
  379. +gboolean                gsd_osd_notification_show_value         (GsdOsdNotification          *notifier,
  380. +                                                                 gint                        value,
  381. +                                                                 gboolean                     muted);
  382. +gboolean                gsd_osd_notification_show_overshoot     (GsdOsdNotification          *notifier,
  383. +                                                                 GsdOsdNotifierOvershootType  type);
  384. +gboolean                gsd_osd_notification_show_icon_only     (const char                  *icon,
  385. +                                                                 const char                  *hint);
  386. +
  387. +G_END_DECLS
  388. +
  389. +#endif /* _GSD_OSD_NOTIFICATION_H_ */
  390. Index: gnome-power-manager-2.29.2/src/gpm-backlight.c
  391. ===================================================================
  392. --- gnome-power-manager-2.29.2.orig/src/gpm-backlight.c 2010-01-27 16:24:52.000000000 +0000
  393. +++ gnome-power-manager-2.29.2/src/gpm-backlight.c      2010-02-23 19:03:10.529523032 +0000
  394. @@ -54,6 +54,7 @@
  395.  #include "gpm-marshal.h"
  396.  #include "gpm-stock-icons.h"
  397.  #include "gpm-prefs-server.h"
  398. +#include "gsd-osd-notification.h"
  399.  
  400.  #define GPM_BACKLIGHT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_BACKLIGHT, GpmBacklightPrivate))
  401.  
  402. @@ -67,6 +68,7 @@
  403.         GpmControl              *control;
  404.         GpmDpms                 *dpms;
  405.         GpmIdle                 *idle;
  406. +       GsdOsdNotification      *notifier;
  407.         gboolean                 can_dim;
  408.         gboolean                 system_is_idle;
  409.         GTimer                  *idle_timer;
  410. @@ -81,6 +83,15 @@
  411.  
  412.  static guint signals [LAST_SIGNAL] = { 0 };
  413.  
  414. +static const char *backlight_icons[] = {
  415. +        "notification-display-brightness-off",
  416. +       "notification-display-brightness-low",
  417. +       "notification-display-brightness-medium",
  418. +       "notification-display-brightness-high",
  419. +       "notification-display-brightness-full",
  420. +       NULL
  421. +};
  422. +
  423.  G_DEFINE_TYPE (GpmBacklight, gpm_backlight, G_TYPE_OBJECT)
  424.  
  425.  /**
  426. @@ -347,10 +358,12 @@
  427.  
  428.         /* only show dialog if interactive */
  429.         if (interactive) {
  430. -               gpm_backlight_dialog_init (backlight);
  431. -               gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
  432. -                                                       round (brightness));
  433. -               gpm_backlight_dialog_show (backlight);
  434. +               if (!gsd_osd_notification_show_value (backlight->priv->notifier, round (brightness), FALSE)) {
  435. +                       gpm_backlight_dialog_init (backlight);
  436. +                       gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
  437. +                                                               round (brightness));
  438. +                       gpm_backlight_dialog_show (backlight);
  439. +               }
  440.         }
  441.  
  442.         ret = gpm_brightness_set (backlight->priv->brightness, value, &hw_changed);
  443. @@ -431,8 +444,14 @@
  444.         GError *error = NULL;
  445.         guint percentage;
  446.         gboolean hw_changed;
  447. +       gboolean brightness_at_0;
  448. +       gboolean brightness_at_100;
  449.         egg_debug ("Button press event type=%s", type);
  450.  
  451. +       gpm_brightness_get (backlight->priv->brightness, &percentage);
  452. +       brightness_at_100 = percentage == 100 ? TRUE : FALSE;
  453. +       brightness_at_0 = percentage == 0 ? TRUE : FALSE;
  454. +
  455.         if (strcmp (type, GPM_BUTTON_BRIGHT_UP) == 0) {
  456.                 /* go up one step */
  457.                 ret = gpm_brightness_up (backlight->priv->brightness, &hw_changed);
  458. @@ -440,10 +459,17 @@
  459.                 /* show the new value */
  460.                 if (ret) {
  461.                         gpm_brightness_get (backlight->priv->brightness, &percentage);
  462. -                       gpm_backlight_dialog_init (backlight);
  463. -                       gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
  464. -                                                               percentage);
  465. -                       gpm_backlight_dialog_show (backlight);
  466. +                       if (brightness_at_100) {
  467. +                               ret = gsd_osd_notification_show_overshoot (backlight->priv->notifier, GSD_OSD_NOTIFICATION_OVERSHOOT);         
  468. +                       } else {
  469. +                               ret = gsd_osd_notification_show_value (backlight->priv->notifier, percentage, FALSE);                  
  470. +                       }
  471. +                       if (!ret) {
  472. +                               gpm_backlight_dialog_init (backlight);
  473. +                               gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
  474. +                                                                       percentage);
  475. +                               gpm_backlight_dialog_show (backlight);
  476. +                       }
  477.                         /* save the new percentage */
  478.                         backlight->priv->master_percentage = percentage;
  479.                 }
  480. @@ -459,10 +485,17 @@
  481.                 /* show the new value */
  482.                 if (ret) {
  483.                         gpm_brightness_get (backlight->priv->brightness, &percentage);
  484. -                       gpm_backlight_dialog_init (backlight);
  485. -                       gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
  486. -                                                               percentage);
  487. -                       gpm_backlight_dialog_show (backlight);
  488. +                       if (brightness_at_0) {
  489. +                               ret = gsd_osd_notification_show_overshoot (backlight->priv->notifier, GSD_OSD_NOTIFICATION_UNDERSHOOT);        
  490. +                       } else {
  491. +                               ret = gsd_osd_notification_show_value (backlight->priv->notifier, percentage, FALSE);                  
  492. +                       }
  493. +                       if (!ret) {
  494. +                               gpm_backlight_dialog_init (backlight);
  495. +                               gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
  496. +                                                                       percentage);
  497. +                               gpm_backlight_dialog_show (backlight);
  498. +                       }
  499.                         /* save the new percentage */
  500.                         backlight->priv->master_percentage = percentage;
  501.                 }
  502. @@ -678,6 +711,7 @@
  503.         g_object_unref (backlight->priv->button);
  504.         g_object_unref (backlight->priv->idle);
  505.         g_object_unref (backlight->priv->brightness);
  506. +       g_object_unref (backlight->priv->notifier);
  507.  
  508.         g_return_if_fail (backlight->priv != NULL);
  509.         G_OBJECT_CLASS (gpm_backlight_parent_class)->finalize (object);
  510. @@ -786,6 +820,8 @@
  511.                                                  TRUE);
  512.          gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
  513.  
  514. +       backlight->priv->notifier = gsd_osd_notification_new (backlight_icons, "brightness");
  515. +
  516.         /* DPMS mode poll class */
  517.         backlight->priv->dpms = gpm_dpms_new ();
clone this paste RAW Paste Data