~ubuntu-branches/ubuntu/saucy/gnome-control-center/saucy-proposed

« back to all changes in this revision

Viewing changes to panels/sound-nua/gvc-applet.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Sebastien Bacher, Robert Ancell, Iain Lane, Edward Donovan, Rico Tzschichholz, Jeremy Bicha, David Henningsson
  • Date: 2012-11-21 19:32:45 UTC
  • mfrom: (1.1.63)
  • Revision ID: package-import@ubuntu.com-20121121193245-mj61nzz1z4fk3z25
Tags: 1:3.6.3-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in: recommends libcanberra-pulse (lp: #1004973)
* debian/patches/58_ubuntu_icon_views_redesign.patch:
  - drop most of the changes, keep the different grid size though
    to fit on screen with our extra icons
* debian/patches/91_dont_show_in_unity.patch:
  - dropped, show the upstream printer panel and the layout tab
* debian/patches/revert_git_keyboard_gsettings.patch,
  debian/patches/revert_git_stop_using_gconf.patch:
  - dropped the gconf->gsettings reverts

[ Robert Ancell ]
* New upstream release (LP: #1010317)
* debian/control:
  - Bump build-depends on libgnome-desktop-3-dev, libwacom-dev
  - Add build-depends on libclutter-1.0-dev, libclutter-gtk-1.0-dev,
    libpwquality-dev
  - Drop build-depends on libgnomekbd-dev
* debian/patches/60_ubuntu_nav_bar.patch:
  - Disabled for now, doesn't apply
* debian/patches/revert_ua_gsettings.patch:
  - We can use GSettings for universal access now
* debian/patches/00git_online_accounts_gtkgrid.patch:
* debian/patches/00git_online_accounts_layout.part:
* debian/patches/git_wacom_translations.patch:
  - Applied upstream

[ Iain Lane ]
* Add Build-Depends on libxkbfile-dev
* New upstream release.
* Refresh all patches to apply cleanly.

[ Edward Donovan ]
* debian/source_gnome-control-center.py: Fix for Python 3. (LP: #1013171)

[ Rico Tzschichholz ]
* debian/control.in:
  - Build-depend on gtk-doc-tools instead of docbook directly
  - Bump minimum glib-2.0, gnome-desktop3, gnome-settings-daemon
     and gsettings-desktop-schemas

[ Jeremy Bicha ]
* Dropped more patches applied in new version:
  - git_unmute_sound_event.patch
  - git_fix_big_editable_labels.patch
  - 96_sound_nua_panel.patch
* debian/patches/04_new_appearance_settings.patch:
  - Dropped, this is now packaged separately as gnome-control-center-unity
* debian/patches/10_keyboard_layout_on_unity.patch:
  - Don't change the keyboard panel name when not running Unity
* debian/patches/52_ubuntu_language_list_mods.patch:
  - Don't disable adding current language to the list. While this
    fix shows the current language twice, at least it avoids the
    "Ubuntu suddenly in Chinese" bug (LP: #1035219)
* debian/patches/53_use_ubuntu_help.patch:
  - Only show Ubuntu help when running Unity
* debian/patches/58_hide_gdm_notifications.patch:
  - Hide "Show notifications when locked" settings when running Unity
    since it's a GNOME Shell-specific feature
* debian/patches/63_normal_scrollbar_in_a11y.patch:
  - Drop, overlay-scrollbars should handle this instead
* debian/patches/91_dont_show_in_unity.patch:
  - Hide Printers & Region panels in Unity until we're ready to switch
    to them.
* debian/patches/fix-crash-on-user-panel.patch:
  - Dropped, GNOME says it's obsolete
* debian/rules:
  - Build with -z,defs again
  - Explicitly disable ibus support since ibus 1.4 isn't supported in
    this version
* debian/control.in:
  - Drop ubuntu-docs and gnome-user-guide from recommends to suggests
  - Don't recommend indicators; let's leave that to Unity

[ David Henningsson ]
* sound_nua_panel.patch: Rebase to gnome 3.6 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2
 
 *
3
 
 * Copyright (C) 2008 Red Hat, Inc.
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 "config.h"
22
 
 
23
 
#include <stdlib.h>
24
 
#include <stdio.h>
25
 
#include <fcntl.h>
26
 
#include <unistd.h>
27
 
#include <string.h>
28
 
#include <errno.h>
29
 
 
30
 
#include <glib.h>
31
 
#include <glib/gi18n.h>
32
 
#include <gtk/gtk.h>
33
 
#include <pulse/pulseaudio.h>
34
 
 
35
 
#include "gvc-applet.h"
36
 
#include "gvc-mixer-control.h"
37
 
#include "gvc-stream-status-icon.h"
38
 
 
39
 
#define GVC_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_APPLET, GvcAppletPrivate))
40
 
 
41
 
#define SCALE_SIZE 128
42
 
 
43
 
static const char *output_icon_names[] = {
44
 
        "audio-volume-muted-symbolic",
45
 
        "audio-volume-low-symbolic",
46
 
        "audio-volume-medium-symbolic",
47
 
        "audio-volume-high-symbolic",
48
 
        NULL
49
 
};
50
 
 
51
 
static const char *input_icon_names[] = {
52
 
        "audio-input-microphone-muted-symbolic",
53
 
        "audio-input-microphone-low-symbolic",
54
 
        "audio-input-microphone-medium-symbolic",
55
 
        "audio-input-microphone-high-symbolic",
56
 
        NULL
57
 
};
58
 
 
59
 
struct GvcAppletPrivate
60
 
{
61
 
        GvcStreamStatusIcon *input_status_icon;
62
 
        GvcStreamStatusIcon *output_status_icon;
63
 
        GvcMixerControl     *control;
64
 
};
65
 
 
66
 
static void     gvc_applet_class_init (GvcAppletClass *klass);
67
 
static void     gvc_applet_init       (GvcApplet      *applet);
68
 
static void     gvc_applet_finalize   (GObject        *object);
69
 
 
70
 
G_DEFINE_TYPE (GvcApplet, gvc_applet, G_TYPE_OBJECT)
71
 
 
72
 
static void
73
 
maybe_show_status_icons (GvcApplet *applet)
74
 
{
75
 
        gboolean        show;
76
 
        GvcMixerStream *stream;
77
 
        GSList         *source_outputs, *l;
78
 
 
79
 
        show = TRUE;
80
 
        stream = gvc_mixer_control_get_default_sink (applet->priv->control);
81
 
        if (stream == NULL) {
82
 
                show = FALSE;
83
 
        }
84
 
        gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->output_status_icon), show);
85
 
 
86
 
 
87
 
        show = FALSE;
88
 
        stream = gvc_mixer_control_get_default_source (applet->priv->control);
89
 
        source_outputs = gvc_mixer_control_get_source_outputs (applet->priv->control);
90
 
        if (stream != NULL && source_outputs != NULL) {
91
 
                /* Check that we're not trying to add the peak detector
92
 
                 * as an application doing recording */
93
 
                for (l = source_outputs ; l ; l = l->next) {
94
 
                        GvcMixerStream *s = l->data;
95
 
                        const char *id;
96
 
 
97
 
                        id = gvc_mixer_stream_get_application_id (s);
98
 
                        if (id == NULL) {
99
 
                                show = TRUE;
100
 
                                break;
101
 
                        }
102
 
 
103
 
                        if (!g_str_equal (id, "org.gnome.VolumeControl") &&
104
 
                            !g_str_equal (id, "org.PulseAudio.pavucontrol")) {
105
 
                                show = TRUE;
106
 
                                break;
107
 
                        }
108
 
                }
109
 
        }
110
 
        gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->input_status_icon), show);
111
 
 
112
 
        g_slist_free (source_outputs);
113
 
}
114
 
 
115
 
void
116
 
gvc_applet_start (GvcApplet *applet)
117
 
{
118
 
        g_return_if_fail (GVC_IS_APPLET (applet));
119
 
 
120
 
        maybe_show_status_icons (applet);
121
 
}
122
 
 
123
 
static void
124
 
gvc_applet_dispose (GObject *object)
125
 
{
126
 
        GvcApplet *applet = GVC_APPLET (object);
127
 
 
128
 
        if (applet->priv->control != NULL) {
129
 
                g_object_unref (applet->priv->control);
130
 
                applet->priv->control = NULL;
131
 
        }
132
 
 
133
 
        G_OBJECT_CLASS (gvc_applet_parent_class)->dispose (object);
134
 
}
135
 
 
136
 
static void
137
 
update_default_source (GvcApplet *applet)
138
 
{
139
 
        GvcMixerStream *stream;
140
 
 
141
 
        stream = gvc_mixer_control_get_default_source (applet->priv->control);
142
 
        if (stream != NULL) {
143
 
                gvc_stream_status_icon_set_mixer_stream (applet->priv->input_status_icon,
144
 
                                                         stream);
145
 
                maybe_show_status_icons(applet);
146
 
        } else {
147
 
                g_debug ("Unable to get default source, or no source available");
148
 
        }
149
 
}
150
 
 
151
 
static void
152
 
update_default_sink (GvcApplet *applet)
153
 
{
154
 
        GvcMixerStream *stream;
155
 
 
156
 
        stream = gvc_mixer_control_get_default_sink (applet->priv->control);
157
 
        if (stream != NULL) {
158
 
                gvc_stream_status_icon_set_mixer_stream (applet->priv->output_status_icon,
159
 
                                                         stream);
160
 
                maybe_show_status_icons(applet);
161
 
        } else {
162
 
                g_warning ("Unable to get default sink");
163
 
        }
164
 
}
165
 
 
166
 
static void
167
 
on_control_state_changed (GvcMixerControl      *control,
168
 
                          GvcMixerControlState  new_state,
169
 
                          GvcApplet            *applet)
170
 
{
171
 
        if (new_state == GVC_STATE_READY)  {
172
 
                update_default_sink (applet);
173
 
                update_default_source (applet);
174
 
        } else if (new_state == GVC_STATE_CONNECTING) {
175
 
                g_debug ("Connecting...");
176
 
        }
177
 
}
178
 
 
179
 
static void
180
 
on_control_default_sink_changed (GvcMixerControl *control,
181
 
                                 guint            id,
182
 
                                 GvcApplet       *applet)
183
 
{
184
 
        update_default_sink (applet);
185
 
}
186
 
 
187
 
static void
188
 
on_control_default_source_changed (GvcMixerControl *control,
189
 
                                   guint            id,
190
 
                                   GvcApplet       *applet)
191
 
{
192
 
        update_default_source (applet);
193
 
}
194
 
 
195
 
static void
196
 
on_control_stream_removed (GvcMixerControl *control,
197
 
                           guint            id,
198
 
                           GvcApplet       *applet)
199
 
{
200
 
        maybe_show_status_icons (applet);
201
 
}
202
 
 
203
 
static void
204
 
on_control_stream_added (GvcMixerControl *control,
205
 
                         guint            id,
206
 
                         GvcApplet       *applet)
207
 
{
208
 
        maybe_show_status_icons (applet);
209
 
}
210
 
 
211
 
static GObject *
212
 
gvc_applet_constructor (GType                  type,
213
 
                        guint                  n_construct_properties,
214
 
                        GObjectConstructParam *construct_params)
215
 
{
216
 
        GObject   *object;
217
 
        GvcApplet *self;
218
 
 
219
 
        object = G_OBJECT_CLASS (gvc_applet_parent_class)->constructor (type, n_construct_properties, construct_params);
220
 
 
221
 
        self = GVC_APPLET (object);
222
 
 
223
 
        self->priv->control = gvc_mixer_control_new ("GNOME Volume Control Applet");
224
 
        g_signal_connect (self->priv->control,
225
 
                          "state-changed",
226
 
                          G_CALLBACK (on_control_state_changed),
227
 
                          self);
228
 
        g_signal_connect (self->priv->control,
229
 
                          "default-sink-changed",
230
 
                          G_CALLBACK (on_control_default_sink_changed),
231
 
                          self);
232
 
        g_signal_connect (self->priv->control,
233
 
                          "default-source-changed",
234
 
                          G_CALLBACK (on_control_default_source_changed),
235
 
                          self);
236
 
        g_signal_connect (self->priv->control,
237
 
                          "stream-added",
238
 
                          G_CALLBACK (on_control_stream_added),
239
 
                          self);
240
 
        g_signal_connect (self->priv->control,
241
 
                          "stream-removed",
242
 
                          G_CALLBACK (on_control_stream_removed),
243
 
                          self);
244
 
 
245
 
        gvc_mixer_control_open (self->priv->control);
246
 
 
247
 
        return object;
248
 
}
249
 
 
250
 
static void
251
 
gvc_applet_class_init (GvcAppletClass *klass)
252
 
{
253
 
        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
254
 
 
255
 
        object_class->finalize = gvc_applet_finalize;
256
 
        object_class->dispose = gvc_applet_dispose;
257
 
        object_class->constructor = gvc_applet_constructor;
258
 
 
259
 
        g_type_class_add_private (klass, sizeof (GvcAppletPrivate));
260
 
}
261
 
 
262
 
static void
263
 
gvc_applet_init (GvcApplet *applet)
264
 
{
265
 
        applet->priv = GVC_APPLET_GET_PRIVATE (applet);
266
 
 
267
 
        applet->priv->output_status_icon = gvc_stream_status_icon_new (NULL,
268
 
                                                                       output_icon_names);
269
 
        gvc_stream_status_icon_set_display_name (applet->priv->output_status_icon,
270
 
                                                 _("Output"));
271
 
        gtk_status_icon_set_title (GTK_STATUS_ICON (applet->priv->output_status_icon),
272
 
                                   _("Sound Output Volume"));
273
 
        applet->priv->input_status_icon = gvc_stream_status_icon_new (NULL,
274
 
                                                                      input_icon_names);
275
 
        gvc_stream_status_icon_set_display_name (applet->priv->input_status_icon,
276
 
                                                 _("Input"));
277
 
        gtk_status_icon_set_title (GTK_STATUS_ICON (applet->priv->input_status_icon),
278
 
                                   _("Microphone Volume"));
279
 
}
280
 
 
281
 
static void
282
 
gvc_applet_finalize (GObject *object)
283
 
{
284
 
        GvcApplet *applet;
285
 
 
286
 
        g_return_if_fail (object != NULL);
287
 
        g_return_if_fail (GVC_IS_APPLET (object));
288
 
 
289
 
        applet = GVC_APPLET (object);
290
 
 
291
 
        g_return_if_fail (applet->priv != NULL);
292
 
 
293
 
 
294
 
        G_OBJECT_CLASS (gvc_applet_parent_class)->finalize (object);
295
 
}
296
 
 
297
 
GvcApplet *
298
 
gvc_applet_new (void)
299
 
{
300
 
        GObject *applet;
301
 
 
302
 
        applet = g_object_new (GVC_TYPE_APPLET, NULL);
303
 
 
304
 
        return GVC_APPLET (applet);
305
 
}