Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 320697 | Differences between
and this patch

Collapse All | Expand All

(-)notifications/configure.ac (+1 lines)
Lines 69-74 Link Here
69
        gio-2.0 >= $GIO_REQUIRED_VERSION
69
        gio-2.0 >= $GIO_REQUIRED_VERSION
70
        libglade-2.0 >= 2.0.0
70
        libglade-2.0 >= 2.0.0
71
        dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
71
        dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
72
	libnotify >= $LIBNOTIFY_REQUIRED_VERSION
72
)
73
)
73
74
74
GSD_PLUGIN_LDFLAGS="-export_dynamic -module -avoid-version -no-undefined"
75
GSD_PLUGIN_LDFLAGS="-export_dynamic -module -avoid-version -no-undefined"
(-)notifications/plugins/media-keys/gsd-media-keys-manager.c (+15 lines)
Lines 51-56 Link Here
51
#include "actions/acme-volume.h"
51
#include "actions/acme-volume.h"
52
#include "gsd-media-keys-window.h"
52
#include "gsd-media-keys-window.h"
53
53
54
/* HACK: fwd declaration */
55
gboolean
56
gsd_media_keys_notification_volume (int value, gboolean muted);
57
58
gboolean
59
gsd_media_keys_notification_eject (void);
60
61
54
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
62
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
55
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
63
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
56
#define GSD_MEDIA_KEYS_DBUS_PATH GSD_DBUS_PATH "/MediaKeys"
64
#define GSD_MEDIA_KEYS_DBUS_PATH GSD_DBUS_PATH "/MediaKeys"
Lines 586-595 Link Here
586
{
594
{
587
        char *command;
595
        char *command;
588
596
597
        if (! gsd_media_keys_notification_eject ())
598
        {
589
        dialog_init (manager);
599
        dialog_init (manager);
590
        gsd_media_keys_window_set_action (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
600
        gsd_media_keys_window_set_action (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
591
                                          GSD_MEDIA_KEYS_WINDOW_ACTION_EJECT);
601
                                          GSD_MEDIA_KEYS_WINDOW_ACTION_EJECT);
592
        dialog_show (manager);
602
        dialog_show (manager);
603
        }
593
604
594
        command = gconf_client_get_string (manager->priv->conf_client,
605
        command = gconf_client_get_string (manager->priv->conf_client,
595
                                           GCONF_MISC_DIR "/eject_command",
606
                                           GCONF_MISC_DIR "/eject_command",
Lines 661-666 Link Here
661
        muted = acme_volume_get_mute (manager->priv->volume);
672
        muted = acme_volume_get_mute (manager->priv->volume);
662
        vol = acme_volume_get_volume (manager->priv->volume);
673
        vol = acme_volume_get_volume (manager->priv->volume);
663
674
675
        /* try to use the new notification service, if available */
676
        if (gsd_media_keys_notification_volume (vol, muted))
677
                return;
678
664
        /* FIXME: AcmeVolume should probably emit signals
679
        /* FIXME: AcmeVolume should probably emit signals
665
           instead of doing it like this */
680
           instead of doing it like this */
666
        dialog_init (manager);
681
        dialog_init (manager);
(-)notifications/plugins/media-keys/gsd-media-keys-notification.c (+132 lines)
Line 0 Link Here
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2
 *
3
 * Copyright (C) 2009 Canonical Ltd
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 *
19
 */
20
21
#include <libnotify/notify.h>
22
#include <glib/gi18n.h>
23
24
gboolean
25
gsd_media_keys_notification_check_service (void)
26
{
27
        GList * caps = NULL;
28
	gchar *name = NULL, *vendor = NULL, *version = NULL, *specver = NULL;
29
        gboolean compat = FALSE;
30
31
        if (! notify_is_initted())
32
                notify_init ("gnome-settings-daemon");
33
34
	if (! notify_get_server_info (&name, &vendor, &version, &specver))
35
	{
36
		g_debug ("unable to reach notification service");
37
		return FALSE;
38
	}
39
40
        caps = notify_get_server_caps();
41
        if (g_list_find_custom (caps,
42
                                "private-synchronous",
43
                                (GCompareFunc) g_strcmp0) != NULL)
44
                compat = TRUE;
45
46
        g_list_foreach(caps, (GFunc)g_free, NULL);
47
        g_list_free(caps);
48
49
        if (! compat)
50
                g_debug ("the service does not support the 'synchronous' capability");
51
52
        g_free (name); g_free (vendor); g_free (version); g_free (specver);
53
54
	return compat;
55
}
56
57
static const char *icon_name[] = {
58
        "notification-audio-volume-muted",
59
        /* "notification-audio-volume-off", */
60
        "notification-audio-volume-low",
61
        "notification-audio-volume-medium",
62
        "notification-audio-volume-high",
63
        NULL
64
};
65
66
67
gboolean
68
gsd_media_keys_notification_volume (int value, gboolean muted)
69
{
70
        static NotifyNotification *n = NULL;
71
        int s;
72
73
	if (! gsd_media_keys_notification_check_service ())
74
		return FALSE;
75
76
	if (n == NULL)
77
		n = notify_notification_new (_("Volume"),
78
					     "",
79
					     NULL,
80
					     NULL);
81
        if (value < 0)
82
        {
83
                value = 0; /* notify-osd doesn't like -1 */
84
                s = 0; /* off, ie with the undershoot effect */
85
        } else {
86
                s = 3 * value / 100 + 1;
87
                if (s < 1)
88
                        s = 1;
89
                if (s > 3)
90
                        s = 3;
91
        }
92
93
        if (muted)
94
                s = 0;
95
96
        notify_notification_update (n,
97
                                    _("Volume"),
98
                                    "",
99
                                    icon_name[s]);
100
		
101
	notify_notification_set_hint_int32(n, "value", value);
102
	notify_notification_set_hint_string(n, "synchronous", "volume");
103
104
	notify_notification_show (n, NULL);
105
106
        return TRUE;
107
}
108
109
gboolean
110
gsd_media_keys_notification_eject (void)
111
{
112
        static NotifyNotification *n = NULL;
113
114
	if (! gsd_media_keys_notification_check_service ())
115
		return FALSE;
116
117
	if (n == NULL)
118
        {
119
		n = notify_notification_new ("Eject",
120
					     "",
121
					     "notification-device-eject",
122
                                             NULL);
123
                notify_notification_set_hint_string(n, "synchronous", "eject");
124
                notify_notification_set_hint_string (n,
125
                                                     "icon-only",
126
                                                     "allowed");
127
        }
128
129
	notify_notification_show (n, NULL);
130
131
        return TRUE;
132
}
(-)notifications/plugins/media-keys/Makefile.am (+4 lines)
Lines 29-34 Link Here
29
	gsd-media-keys-window.h		\
29
	gsd-media-keys-window.h		\
30
	gsd-media-keys-window.c		\
30
	gsd-media-keys-window.c		\
31
	gsd-media-keys-notification.c	\
31
	$(BUILT_SOURCES)		\
32
	$(BUILT_SOURCES)		\
32
	$(NULL)
33
	$(NULL)
33
34
Lines 42-51 Link Here
42
	$(AM_CPPFLAGS)
43
	$(AM_CPPFLAGS)
43
44
44
libmedia_keys_la_CFLAGS = \
45
libmedia_keys_la_CFLAGS = \
46
	$(LIBNOTIFY_CFLAGS)		\
45
	$(SETTINGS_PLUGIN_CFLAGS)	\
47
	$(SETTINGS_PLUGIN_CFLAGS)	\
46
	$(AM_CFLAGS)
48
	$(AM_CFLAGS)
47
49
48
libmedia_keys_la_LDFLAGS = 		\
50
libmedia_keys_la_LDFLAGS = 		\
51
	$(LIBNOTIFY_LDFLAGS)		\
49
	$(GSD_PLUGIN_LDFLAGS)
52
	$(GSD_PLUGIN_LDFLAGS)
50
53
51
libmedia_keys_la_LIBADD  = 		\
54
libmedia_keys_la_LIBADD  = 		\
Lines 92-97 Link Here
92
test_media_keys_SOURCES =			\
95
test_media_keys_SOURCES =			\
93
	gsd-media-keys-manager.c		\
96
	gsd-media-keys-manager.c		\
94
	gsd-media-keys-manager.h		\
97
	gsd-media-keys-manager.h		\
98
	gsd-media-keys-notification.c		\
95
	gsd-media-keys-window.h			\
99
	gsd-media-keys-window.h			\
96
	gsd-media-keys-window.c			\
100
	gsd-media-keys-window.c			\
97
	test-media-keys.c			\
101
	test-media-keys.c			\

Return to bug 320697