Advertisement
Guest User

16_use_synchronous_notifications.patch

a guest
Apr 3rd, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.01 KB | None | 0 0
  1. Description: Use synchronous notifications when they are supported
  2. Author: ?
  3.  
  4. Index: gnome-settings-daemon-2.30.0/plugins/common/gsd-osd-notification.c
  5. ===================================================================
  6. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  7. +++ gnome-settings-daemon-2.30.0/plugins/common/gsd-osd-notification.c 2010-04-23 17:05:08.862133020 +0100
  8. @@ -0,0 +1,296 @@
  9. +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
  10. +/*
  11. + * gsd-osd-notification.c
  12. + * Copyright (C) 2010 Chris Coulson <chrisccoulson@ubuntu.com>
  13. + * Copyright (C) 2009 Canonical Ltd
  14. + *
  15. + * gsd-osd-notification.c is free software: you can redistribute it and/or modify it
  16. + * under the terms of the GNU General Public License as published by the
  17. + * Free Software Foundation, either version 3 of the License, or
  18. + * (at your option) any later version.
  19. + *
  20. + * gsd-osd-notification.c is distributed in the hope that it will be useful, but
  21. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  22. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. + * See the GNU General Public License for more details.
  24. + *
  25. + * You should have received a copy of the GNU General Public License along
  26. + * with this program. If not, see <http://www.gnu.org/licenses/>.
  27. + */
  28. +
  29. +#include <libnotify/notify.h>
  30. +#include "gsd-osd-notification.h"
  31. +
  32. +struct _GsdOsdNotificationPrivate
  33. +{
  34. + NotifyNotification *notification;
  35. + char **icon_names;
  36. + char *hint;
  37. + guint icon_array_size;
  38. +};
  39. +
  40. +#define GSD_OSD_NOTIFICATION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotificationPrivate))
  41. +
  42. +enum
  43. +{
  44. + PROP_0,
  45. + PROP_ICON_NAMES,
  46. + PROP_HINT
  47. +};
  48. +
  49. +static NotifyNotification *icon_only_notification = NULL;
  50. +static gulong handler_id;
  51. +
  52. +#define NOTIFY_CAP_PRIVATE_SYNCHRONOUS "x-canonical-private-synchronous"
  53. +#define NOTIFY_CAP_PRIVATE_ICON_ONLY "x-canonical-private-icon-only"
  54. +#define NOTIFY_HINT_TRUE "true"
  55. +
  56. +G_DEFINE_TYPE (GsdOsdNotification, gsd_osd_notification, G_TYPE_OBJECT);
  57. +
  58. +static const char*
  59. +_calculate_icon (GsdOsdNotification *notifier, guint value, gboolean muted)
  60. +{
  61. + guint s;
  62. +
  63. + s = (notifier->priv->icon_array_size -1) * value / 100 + 1;
  64. + s = MAX (s, 1);
  65. + s = MIN (s, notifier->priv->icon_array_size -1);
  66. + if (value <= 0)
  67. + s = 0;
  68. +
  69. + return muted ? notifier->priv->icon_names[0] : notifier->priv->icon_names[s];
  70. +}
  71. +
  72. +void
  73. +gsd_osd_notification_set_icon_array (GsdOsdNotification *notifier, const char **icon_names)
  74. +{
  75. + g_return_if_fail (GSD_IS_OSD_NOTIFICATION (notifier));
  76. +
  77. + g_strfreev (notifier->priv->icon_names);
  78. + notifier->priv->icon_names = g_strdupv ((gchar **) icon_names);
  79. +
  80. + notifier->priv->icon_array_size = g_strv_length ((gchar **) icon_names);
  81. +}
  82. +
  83. +void
  84. +gsd_osd_notification_set_hint (GsdOsdNotification *notifier, const char *hint)
  85. +{
  86. + g_return_if_fail (GSD_IS_OSD_NOTIFICATION (notifier));
  87. +
  88. + g_free (notifier->priv->hint);
  89. + notifier->priv->hint = g_strdup (hint);
  90. +}
  91. +
  92. +gboolean
  93. +gsd_osd_notification_is_supported (void)
  94. +{
  95. + GList *caps;
  96. + gboolean has_cap;
  97. +
  98. + caps = notify_get_server_caps ();
  99. + has_cap = (g_list_find_custom (caps, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, (GCompareFunc) g_strcmp0) != NULL);
  100. + g_list_foreach (caps, (GFunc) g_free, NULL);
  101. + g_list_free (caps);
  102. +
  103. + return has_cap;
  104. +}
  105. +
  106. +static void
  107. +notification_closed_cb (NotifyNotification *notification,
  108. + gpointer data)
  109. +{
  110. + g_signal_handler_disconnect (icon_only_notification, handler_id);
  111. + g_object_unref (icon_only_notification);
  112. + icon_only_notification = NULL;
  113. +}
  114. +
  115. +gboolean
  116. +gsd_osd_notification_show_icon_only (const char *icon, const char *hint)
  117. +{
  118. + g_return_val_if_fail (icon != NULL, FALSE);
  119. + g_return_val_if_fail (hint != NULL, FALSE);
  120. +
  121. + if (!gsd_osd_notification_is_supported ())
  122. + return FALSE;
  123. +
  124. + if (icon_only_notification == NULL) {
  125. + icon_only_notification = notify_notification_new (" ", "", icon);
  126. + notify_notification_set_hint_string (icon_only_notification, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, hint);
  127. + notify_notification_set_hint_string (icon_only_notification, NOTIFY_CAP_PRIVATE_ICON_ONLY, NOTIFY_HINT_TRUE);
  128. + handler_id = g_signal_connect (icon_only_notification, "closed", G_CALLBACK (notification_closed_cb), NULL);
  129. + } else {
  130. + notify_notification_set_hint_string (icon_only_notification, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, hint);
  131. + notify_notification_update (icon_only_notification, " ", "", icon);
  132. + }
  133. +
  134. + if (!notify_notification_show (icon_only_notification, NULL)) {
  135. + g_signal_handler_disconnect (icon_only_notification, handler_id);
  136. + g_object_unref (icon_only_notification);
  137. + icon_only_notification = NULL;
  138. + return FALSE;
  139. + }
  140. +
  141. + return TRUE;
  142. +}
  143. +
  144. +gboolean
  145. +gsd_osd_notification_show_value (GsdOsdNotification *notifier, gint value, gboolean muted)
  146. +{
  147. + const char *icon;
  148. +
  149. + g_return_val_if_fail (GSD_IS_OSD_NOTIFICATION (notifier), FALSE);
  150. + g_return_val_if_fail (notifier->priv->icon_names != NULL, FALSE);
  151. + g_return_val_if_fail (notifier->priv->hint != NULL, FALSE);
  152. +
  153. + if (!gsd_osd_notification_is_supported ())
  154. + return FALSE;
  155. +
  156. + if (notifier->priv->notification == NULL) {
  157. + notifier->priv->notification = notify_notification_new (" ", "", NULL);
  158. + notify_notification_set_hint_string (notifier->priv->notification, NOTIFY_CAP_PRIVATE_SYNCHRONOUS, notifier->priv->hint);
  159. +}
  160. + if (notifier->priv->notification != NULL) {
  161. + value = MIN (value, 101);
  162. + value = MAX (value, -1);
  163. + icon = _calculate_icon (notifier, value, muted);
  164. + notify_notification_set_hint_int32(notifier->priv->notification, "value", (muted && value > 0) ? 0 : value);
  165. + notify_notification_update (notifier->priv->notification, " ", "", icon);
  166. + } else {
  167. + return FALSE;
  168. + }
  169. +
  170. + if (!notify_notification_show (notifier->priv->notification, NULL))
  171. + return FALSE;
  172. +
  173. + return TRUE;
  174. +}
  175. +
  176. +gboolean
  177. +gsd_osd_notification_show_overshoot (GsdOsdNotification *notifier, GsdOsdNotifierOvershootType type)
  178. +{
  179. + gint value;
  180. + gboolean muted;
  181. +
  182. + g_return_val_if_fail (type == GSD_OSD_NOTIFICATION_UNDERSHOOT || type == GSD_OSD_NOTIFICATION_OVERSHOOT, FALSE);
  183. +
  184. + switch (type)
  185. + {
  186. + case GSD_OSD_NOTIFICATION_UNDERSHOOT:
  187. + value = -1;
  188. + muted = TRUE;
  189. + break;
  190. + case GSD_OSD_NOTIFICATION_OVERSHOOT:
  191. + value = 101;
  192. + muted = FALSE;
  193. + break;
  194. + default:
  195. + g_assert_not_reached ();
  196. + break;
  197. + }
  198. +
  199. + return gsd_osd_notification_show_value (notifier, value, muted);
  200. +}
  201. +
  202. +GsdOsdNotification*
  203. +gsd_osd_notification_new (const char **icon_names, const char *hint)
  204. +{
  205. + return (GsdOsdNotification *) g_object_new (GSD_TYPE_OSD_NOTIFICATION,
  206. + "icon-names", icon_names,
  207. + "hint", hint,
  208. + NULL);
  209. +}
  210. +
  211. +static void
  212. +gsd_osd_notification_init (GsdOsdNotification *object)
  213. +{
  214. + object->priv = GSD_OSD_NOTIFICATION_PRIVATE (object);
  215. +
  216. + if (!notify_is_initted ())
  217. + notify_init (g_get_application_name ());
  218. +
  219. + object->priv->hint = NULL;
  220. + object->priv->icon_names = NULL;
  221. + object->priv->notification = NULL;
  222. +}
  223. +
  224. +static void
  225. +gsd_osd_notification_finalize (GObject *object)
  226. +{
  227. + GsdOsdNotification *notifier = GSD_OSD_NOTIFICATION (object);
  228. +
  229. + g_strfreev (notifier->priv->icon_names);
  230. + g_free (notifier->priv->hint);
  231. +
  232. + if (notifier->priv->notification)
  233. + g_object_unref (notifier->priv->notification);
  234. +
  235. + G_OBJECT_CLASS (gsd_osd_notification_parent_class)->finalize (object);
  236. +}
  237. +
  238. +static void
  239. +gsd_osd_notification_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
  240. +{
  241. + g_return_if_fail (GSD_IS_OSD_NOTIFICATION (object));
  242. + GsdOsdNotification *notifier = GSD_OSD_NOTIFICATION (object);
  243. +
  244. + switch (prop_id)
  245. + {
  246. + case PROP_ICON_NAMES:
  247. + gsd_osd_notification_set_icon_array (notifier, (const char**) g_value_get_boxed (value));
  248. + break;
  249. + case PROP_HINT:
  250. + gsd_osd_notification_set_hint (notifier, g_value_get_string (value));
  251. + break;
  252. + default:
  253. + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  254. + break;
  255. + }
  256. +}
  257. +
  258. +static void
  259. +gsd_osd_notification_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
  260. +{
  261. + g_return_if_fail (GSD_IS_OSD_NOTIFICATION (object));
  262. + GsdOsdNotification *notifier = GSD_OSD_NOTIFICATION (object);
  263. +
  264. + switch (prop_id)
  265. + {
  266. + case PROP_ICON_NAMES:
  267. + g_value_set_boxed (value, notifier->priv->icon_names);
  268. + break;
  269. + case PROP_HINT:
  270. + g_value_set_string (value, notifier->priv->hint);
  271. + break;
  272. + default:
  273. + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  274. + break;
  275. + }
  276. +}
  277. +
  278. +static void
  279. +gsd_osd_notification_class_init (GsdOsdNotificationClass *klass)
  280. +{
  281. + GObjectClass* object_class = G_OBJECT_CLASS (klass);
  282. +
  283. + object_class->finalize = gsd_osd_notification_finalize;
  284. + object_class->set_property = gsd_osd_notification_set_property;
  285. + object_class->get_property = gsd_osd_notification_get_property;
  286. +
  287. + g_object_class_install_property (object_class,
  288. + PROP_ICON_NAMES,
  289. + g_param_spec_boxed ("icon-names",
  290. + "Icon name array",
  291. + "An array of icon names for the notification",
  292. + G_TYPE_STRV,
  293. + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  294. +
  295. + g_object_class_install_property (object_class,
  296. + PROP_HINT,
  297. + g_param_spec_string ("hint",
  298. + "Notification hint",
  299. + "Hint for the notification",
  300. + NULL,
  301. + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  302. +
  303. + g_type_class_add_private (klass, sizeof (GsdOsdNotificationPrivate));
  304. +}
  305. Index: gnome-settings-daemon-2.30.0/plugins/common/gsd-osd-notification.h
  306. ===================================================================
  307. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  308. +++ gnome-settings-daemon-2.30.0/plugins/common/gsd-osd-notification.h 2010-04-23 17:05:08.862133020 +0100
  309. @@ -0,0 +1,75 @@
  310. +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
  311. +/*
  312. + * gsd-osd-notification.c
  313. + * Copyright (C) 2010 Chris Coulson <chrisccoulson@ubuntu.com>
  314. + * Copyright (C) 2009 Canonical Ltd
  315. + *
  316. + * gsd-osd-notification.c is free software: you can redistribute it and/or modify it
  317. + * under the terms of the GNU General Public License as published by the
  318. + * Free Software Foundation, either version 3 of the License, or
  319. + * (at your option) any later version.
  320. + *
  321. + * gsd-osd-notification.c is distributed in the hope that it will be useful, but
  322. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  323. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  324. + * See the GNU General Public License for more details.
  325. + *
  326. + * You should have received a copy of the GNU General Public License along
  327. + * with this program. If not, see <http://www.gnu.org/licenses/>.
  328. + */
  329. +
  330. +#ifndef _GSD_OSD_NOTIFICATION_H_
  331. +#define _GSD_OSD_NOTIFICATION_H_
  332. +
  333. +#include <glib-object.h>
  334. +
  335. +G_BEGIN_DECLS
  336. +
  337. +#define GSD_TYPE_OSD_NOTIFICATION (gsd_osd_notification_get_type ())
  338. +#define GSD_OSD_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotification))
  339. +#define GSD_OSD_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotificationClass))
  340. +#define GSD_IS_OSD_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_OSD_NOTIFICATION))
  341. +#define GSD_IS_OSD_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSD_TYPE_OSD_NOTIFICATION))
  342. +#define GSD_OSD_NOTIFICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSD_TYPE_OSD_NOTIFICATION, GsdOsdNotificationClass))
  343. +
  344. +typedef struct _GsdOsdNotificationClass GsdOsdNotificationClass;
  345. +typedef struct _GsdOsdNotification GsdOsdNotification;
  346. +typedef struct _GsdOsdNotificationPrivate GsdOsdNotificationPrivate;
  347. +
  348. +struct _GsdOsdNotificationClass
  349. +{
  350. + GObjectClass parent_class;
  351. +};
  352. +
  353. +struct _GsdOsdNotification
  354. +{
  355. + GObject parent_instance;
  356. +
  357. + GsdOsdNotificationPrivate *priv;
  358. +};
  359. +
  360. +typedef enum {
  361. + GSD_OSD_NOTIFICATION_NO_OVERSHOOT = 0,
  362. + GSD_OSD_NOTIFICATION_UNDERSHOOT,
  363. + GSD_OSD_NOTIFICATION_OVERSHOOT,
  364. +} GsdOsdNotifierOvershootType;
  365. +
  366. +GType gsd_osd_notification_get_type (void) G_GNUC_CONST;
  367. +GsdOsdNotification* gsd_osd_notification_new (const char **icon_names,
  368. + const char *hint);
  369. +void gsd_osd_notification_set_icon_array (GsdOsdNotification *notifier,
  370. + const char **icon_names);
  371. +void gsd_osd_notification_set_hint (GsdOsdNotification *notifier,
  372. + const char *hint);
  373. +gboolean gsd_osd_notification_is_supported (void);
  374. +gboolean gsd_osd_notification_show_value (GsdOsdNotification *notifier,
  375. + gint value,
  376. + gboolean muted);
  377. +gboolean gsd_osd_notification_show_overshoot (GsdOsdNotification *notifier,
  378. + GsdOsdNotifierOvershootType type);
  379. +gboolean gsd_osd_notification_show_icon_only (const char *icon,
  380. + const char *hint);
  381. +
  382. +G_END_DECLS
  383. +
  384. +#endif /* _GSD_OSD_NOTIFICATION_H_ */
  385. Index: gnome-settings-daemon-2.30.0/plugins/media-keys/gsd-media-keys-manager.c
  386. ===================================================================
  387. --- gnome-settings-daemon-2.30.0.orig/plugins/media-keys/gsd-media-keys-manager.c 2010-03-29 09:15:04.000000000 +0100
  388. +++ gnome-settings-daemon-2.30.0/plugins/media-keys/gsd-media-keys-manager.c 2010-04-23 17:05:08.862133020 +0100
  389. @@ -49,6 +49,7 @@
  390. #include "eggaccelerators.h"
  391. #include "acme.h"
  392. #include "gsd-media-keys-window.h"
  393. +#include "gsd-osd-notification.h"
  394.  
  395. #ifdef HAVE_PULSE
  396. #include <canberra-gtk.h>
  397. @@ -82,6 +83,7 @@
  398. GtkWidget *dialog;
  399. GConfClient *conf_client;
  400. GVolumeMonitor *volume_monitor;
  401. + GsdOsdNotification *notifier;
  402.  
  403. /* Multihead stuff */
  404. GdkScreen *current_screen;
  405. @@ -108,6 +110,13 @@
  406.  
  407. static gpointer manager_object = NULL;
  408.  
  409. +static const char *volume_icons[] = {
  410. + "notification-audio-volume-muted",
  411. + "notification-audio-volume-low",
  412. + "notification-audio-volume-medium",
  413. + "notification-audio-volume-high",
  414. + NULL
  415. +};
  416.  
  417. static void
  418. init_screens (GsdMediaKeysManager *manager)
  419. @@ -612,11 +621,13 @@
  420. }
  421.  
  422. /* Show the dialogue */
  423. - dialog_init (manager);
  424. - gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
  425. - "media-eject",
  426. - FALSE);
  427. - dialog_show (manager);
  428. + if (!gsd_osd_notification_show_icon_only ("notification-device-eject", "Eject")) {
  429. + dialog_init (manager);
  430. + gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
  431. + "media-eject",
  432. + FALSE);
  433. + dialog_show (manager);
  434. + }
  435.  
  436. /* Clean up the drive selection and exit if no suitable
  437. * drives are found */
  438. @@ -641,23 +652,44 @@
  439. GConfClient *client = manager->priv->conf_client;
  440. gboolean state = gconf_client_get_bool (client, TOUCHPAD_ENABLED_KEY, NULL);
  441.  
  442. - dialog_init (manager);
  443. - gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
  444. - (!state) ? "touchpad-enabled" : "touchpad-disabled",
  445. - FALSE);
  446. - dialog_show (manager);
  447. + if (!gsd_osd_notification_show_icon_only ((!state) ? "touchpad-enabled" : "touchpad-disabled", "Touchpad")) {
  448. + dialog_init (manager);
  449. + gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
  450. + (!state) ? "touchpad-enabled" : "touchpad-disabled",
  451. + FALSE);
  452. + dialog_show (manager);
  453. + }
  454.  
  455. gconf_client_set_bool (client, TOUCHPAD_ENABLED_KEY, !state, NULL);
  456. }
  457.  
  458. #ifdef HAVE_PULSE
  459. +play_volume_event_sound (GtkWidget *widget)
  460. +{
  461. + ca_gtk_play_for_widget (widget, 0,
  462. + CA_PROP_EVENT_ID, "audio-volume-change",
  463. + CA_PROP_EVENT_DESCRIPTION, "volume changed hrough key press",
  464. + CA_PROP_APPLICATION_ID, "org.gnome.VolumeControl",
  465. + NULL);
  466. +}
  467. +
  468. static void
  469. update_dialog (GsdMediaKeysManager *manager,
  470. guint vol,
  471. gboolean muted,
  472. - gboolean sound_changed)
  473. + gboolean sound_changed,
  474. + GsdOsdNotifierOvershootType overshoot)
  475. {
  476. + GtkWidget *window;
  477. +
  478. vol = (int) (100 * (double) vol / PA_VOLUME_NORM);
  479. + if (overshoot != GSD_OSD_NOTIFICATION_NO_OVERSHOOT) {
  480. + if (gsd_osd_notification_show_overshoot (manager->priv->notifier, overshoot))
  481. + goto done;
  482. + } else {
  483. + if (gsd_osd_notification_show_value (manager->priv->notifier, vol, muted))
  484. + goto done;
  485. + }
  486. vol = CLAMP (vol, 0, 100);
  487.  
  488. dialog_init (manager);
  489. @@ -668,12 +700,18 @@
  490. GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
  491. dialog_show (manager);
  492.  
  493. - if (sound_changed != FALSE && muted == FALSE)
  494. - ca_gtk_play_for_widget (manager->priv->dialog, 0,
  495. - CA_PROP_EVENT_ID, "audio-volume-change",
  496. - CA_PROP_EVENT_DESCRIPTION, "volume changed through key press",
  497. - CA_PROP_APPLICATION_ID, "org.gnome.VolumeControl",
  498. - NULL);
  499. +done:
  500. + if (sound_changed != FALSE && muted == FALSE) {
  501. + if (manager->priv->dialog == NULL) {
  502. + window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  503. + gtk_window_set_screen (GTK_WINDOW (window), manager->priv->current_screen);
  504. + gtk_widget_realize (window);
  505. + play_volume_event_sound (window);
  506. + gtk_widget_destroy (window);
  507. + } else {
  508. + play_volume_event_sound (manager->priv->dialog);
  509. + }
  510. + }
  511. }
  512.  
  513. static void
  514. @@ -683,6 +721,7 @@
  515. gboolean muted;
  516. guint vol, norm_vol_step;
  517. int vol_step;
  518. + GsdOsdNotifierOvershootType overshoot = GSD_OSD_NOTIFICATION_NO_OVERSHOOT;
  519. gboolean sound_changed;
  520.  
  521. if (manager->priv->stream == NULL)
  522. @@ -722,7 +761,10 @@
  523. if (gvc_mixer_stream_set_volume (manager->priv->stream, vol) != FALSE) {
  524. gvc_mixer_stream_push_volume (manager->priv->stream);
  525. sound_changed = TRUE;
  526. + gvc_mixer_stream_push_volume (manager->priv->stream);
  527. }
  528. + } else {
  529. + overshoot = GSD_OSD_NOTIFICATION_UNDERSHOOT;
  530. }
  531. break;
  532. case VOLUME_UP_KEY:
  533. @@ -750,12 +792,14 @@
  534. gvc_mixer_stream_push_volume (manager->priv->stream);
  535. sound_changed = TRUE;
  536. }
  537. + } else {
  538. + overshoot = GSD_OSD_NOTIFICATION_OVERSHOOT;
  539. }
  540. }
  541. break;
  542. }
  543.  
  544. - update_dialog (manager, vol, muted, sound_changed);
  545. + update_dialog (manager, vol, muted, sound_changed, overshoot);
  546. }
  547.  
  548. static void
  549. @@ -900,8 +944,11 @@
  550.  
  551. static gboolean
  552. do_multimedia_player_action (GsdMediaKeysManager *manager,
  553. + const char *icon,
  554. const char *key)
  555. {
  556. + if (icon != NULL)
  557. + gsd_osd_notification_show_icon_only (icon, key);
  558. return gsd_media_player_key_pressed (manager, key);
  559. }
  560.  
  561. @@ -972,19 +1019,19 @@
  562. execute (manager, "gcalctool", FALSE, FALSE);
  563. break;
  564. case PLAY_KEY:
  565. - return do_multimedia_player_action (manager, "Play");
  566. + return do_multimedia_player_action (manager, NULL, "Play");
  567. break;
  568. case PAUSE_KEY:
  569. - return do_multimedia_player_action (manager, "Pause");
  570. + return do_multimedia_player_action (manager, NULL, "Pause");
  571. break;
  572. case STOP_KEY:
  573. - return do_multimedia_player_action (manager, "Stop");
  574. + return do_multimedia_player_action (manager, NULL, "Stop");
  575. break;
  576. case PREVIOUS_KEY:
  577. - return do_multimedia_player_action (manager, "Previous");
  578. + return do_multimedia_player_action (manager, NULL, "Previous");
  579. break;
  580. case NEXT_KEY:
  581. - return do_multimedia_player_action (manager, "Next");
  582. + return do_multimedia_player_action (manager, NULL, "Next");
  583. break;
  584. default:
  585. g_assert_not_reached ();
  586. @@ -1121,6 +1168,8 @@
  587.  
  588. gvc_mixer_control_open (manager->priv->volume);
  589.  
  590. + manager->priv->notifier = gsd_osd_notification_new (volume_icons, "volume");
  591. +
  592. gnome_settings_profile_end ("gvc_mixer_control_new");
  593. #endif /* HAVE_PULSE */
  594. g_idle_add ((GSourceFunc) start_media_keys_idle_cb, manager);
  595. @@ -1218,6 +1267,9 @@
  596. }
  597. g_list_free (priv->media_players);
  598. priv->media_players = NULL;
  599. +
  600. + if (manager->priv->notifier != NULL)
  601. + g_object_unref (manager->priv->notifier);
  602. }
  603.  
  604. static void
  605. Index: gnome-settings-daemon-2.30.0/plugins/common/Makefile.am
  606. ===================================================================
  607. --- gnome-settings-daemon-2.30.0.orig/plugins/common/Makefile.am 2010-03-10 11:59:38.000000000 +0000
  608. +++ gnome-settings-daemon-2.30.0/plugins/common/Makefile.am 2010-04-23 17:10:43.209632216 +0100
  609. @@ -7,17 +7,21 @@
  610. gsd-keygrab.c \
  611. gsd-keygrab.h \
  612. gsd-osd-window.c \
  613. - gsd-osd-window.h
  614. + gsd-osd-window.h \
  615. + gsd-osd-notification.c \
  616. + gsd-osd-notification.h
  617.  
  618. libcommon_la_CPPFLAGS = \
  619. $(AM_CPPFLAGS)
  620.  
  621. libcommon_la_CFLAGS = \
  622. $(SETTINGS_PLUGIN_CFLAGS) \
  623. + $(LIBNOTIFY_CFLAGS) \
  624. $(AM_CFLAGS)
  625.  
  626. libcommon_la_LDFLAGS = \
  627. $(GSD_PLUGIN_LDFLAGS) $(X11_LIBS)
  628.  
  629. libcommon_la_LIBADD = \
  630. - $(SETTINGS_PLUGIN_LIBS)
  631. + $(SETTINGS_PLUGIN_LIBS) \
  632. + $(LIBNOTIFY_LIBS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement