Merge lp:~diwic/gnome-control-center/sound-nua-rebase into lp:~ubuntu-desktop/gnome-control-center/ubuntu
- sound-nua-rebase
- Merge into ubuntu
Proposed by
David Henningsson
Status: | Merged |
---|---|
Merged at revision: | 509 |
Proposed branch: | lp:~diwic/gnome-control-center/sound-nua-rebase |
Merge into: | lp:~ubuntu-desktop/gnome-control-center/ubuntu |
Diff against target: |
3334 lines (+3310/-1) 3 files modified
debian/changelog (+4/-1) debian/patches/series (+1/-0) debian/patches/sound_nua_panel.patch (+3305/-0) |
To merge this branch: | bzr merge lp:~diwic/gnome-control-center/sound-nua-rebase |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Approve | ||
David Henningsson (community) | Approve | ||
Review via email: mp+134134@code.launchpad.net |
Commit message
Description of the change
Rebase sound-nua against Gnome 3.6 code. Most of the code is now upstreamed, but Gnome wanted to keep their old design, so therefore we still keep the UI pieces as a patch.
The patch is reduced by about 75% compared to the previous size.
To post a comment you must log in.
Revision history for this message
David Henningsson (diwic) : | # |
review:
Needs Fixing
- 513. By David Henningsson
-
changed the version number back again
- 514. By David Henningsson
-
Updated patch comment
Revision history for this message
David Henningsson (diwic) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2012-11-06 04:32:05 +0000 | |||
3 | +++ debian/changelog 2012-11-13 15:56:18 +0000 | |||
4 | @@ -69,7 +69,10 @@ | |||
5 | 69 | - Drop ubuntu-docs and gnome-user-guide from recommends to suggests | 69 | - Drop ubuntu-docs and gnome-user-guide from recommends to suggests |
6 | 70 | - Don't recommend indicators; let's leave that to Unity | 70 | - Don't recommend indicators; let's leave that to Unity |
7 | 71 | 71 | ||
9 | 72 | -- Jeremy Bicha <jbicha@ubuntu.com> Mon, 05 Nov 2012 23:14:29 -0500 | 72 | [ David Henningsson ] |
10 | 73 | * sound_nua_panel.patch: Rebase to gnome 3.6 | ||
11 | 74 | |||
12 | 75 | -- David Henningsson <david.henningsson@canonical.com> Tue, 13 Nov 2012 15:59:40 +0100 | ||
13 | 73 | 76 | ||
14 | 74 | gnome-control-center (1:3.4.2-0ubuntu20) quantal-proposed; urgency=low | 77 | gnome-control-center (1:3.4.2-0ubuntu20) quantal-proposed; urgency=low |
15 | 75 | 78 | ||
16 | 76 | 79 | ||
17 | === modified file 'debian/patches/series' | |||
18 | --- debian/patches/series 2012-11-06 04:32:05 +0000 | |||
19 | +++ debian/patches/series 2012-11-13 15:56:18 +0000 | |||
20 | @@ -29,3 +29,4 @@ | |||
21 | 29 | dont_download_local_image.patch | 29 | dont_download_local_image.patch |
22 | 30 | classic_use_sound_indicator.patch | 30 | classic_use_sound_indicator.patch |
23 | 31 | accounts_fix_unsetting_icon.patch | 31 | accounts_fix_unsetting_icon.patch |
24 | 32 | sound_nua_panel.patch | ||
25 | 32 | 33 | ||
26 | === added file 'debian/patches/sound_nua_panel.patch' | |||
27 | --- debian/patches/sound_nua_panel.patch 1970-01-01 00:00:00 +0000 | |||
28 | +++ debian/patches/sound_nua_panel.patch 2012-11-13 15:56:18 +0000 | |||
29 | @@ -0,0 +1,3305 @@ | |||
30 | 1 | # Description: New design of the sound capplet | ||
31 | 2 | # Most of the code has now been upstreamed to Gnome, but they wanted | ||
32 | 3 | # to keep their old design, so about 25% of the original patch remains. | ||
33 | 4 | === modified file 'configure.ac' | ||
34 | 5 | Index: gnome-control-center-3.6.2/configure.ac | ||
35 | 6 | =================================================================== | ||
36 | 7 | --- gnome-control-center-3.6.2.orig/configure.ac 2012-11-13 16:25:40.665717988 +0100 | ||
37 | 8 | +++ gnome-control-center-3.6.2/configure.ac 2012-11-13 16:25:40.773717987 +0100 | ||
38 | 9 | @@ -435,6 +435,9 @@ | ||
39 | 10 | panels/online-accounts/icons/32x32/Makefile | ||
40 | 11 | panels/online-accounts/icons/48x48/Makefile | ||
41 | 12 | panels/online-accounts/icons/256x256/Makefile | ||
42 | 13 | +panels/sound-nua/Makefile | ||
43 | 14 | +panels/sound-nua/data/Makefile | ||
44 | 15 | +panels/sound-nua/data/gnome-sound-nua-panel.desktop.in | ||
45 | 16 | panels/sound/Makefile | ||
46 | 17 | panels/sound/data/Makefile | ||
47 | 18 | panels/sound/data/gnome-sound-panel.desktop.in | ||
48 | 19 | Index: gnome-control-center-3.6.2/panels/Makefile.am | ||
49 | 20 | =================================================================== | ||
50 | 21 | --- gnome-control-center-3.6.2.orig/panels/Makefile.am 2012-10-01 11:38:59.000000000 +0200 | ||
51 | 22 | +++ gnome-control-center-3.6.2/panels/Makefile.am 2012-11-13 16:25:40.777717988 +0100 | ||
52 | 23 | @@ -10,6 +10,7 @@ | ||
53 | 24 | region \ | ||
54 | 25 | info \ | ||
55 | 26 | sound \ | ||
56 | 27 | + sound-nua \ | ||
57 | 28 | keyboard \ | ||
58 | 29 | universal-access \ | ||
59 | 30 | user-accounts \ | ||
60 | 31 | Index: gnome-control-center-3.6.2/panels/sound-nua/Makefile.am | ||
61 | 32 | =================================================================== | ||
62 | 33 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
63 | 34 | +++ gnome-control-center-3.6.2/panels/sound-nua/Makefile.am 2012-11-13 16:25:40.777717988 +0100 | ||
64 | 35 | @@ -0,0 +1,63 @@ | ||
65 | 36 | +SUBDIRS = data | ||
66 | 37 | + | ||
67 | 38 | +# This is used in PANEL_CFLAGS | ||
68 | 39 | +cappletname = sound | ||
69 | 40 | +NULL = | ||
70 | 41 | + | ||
71 | 42 | +ccpanelsdir = $(PANELS_DIR) | ||
72 | 43 | +ccpanels_LTLIBRARIES = libsoundnua.la | ||
73 | 44 | + | ||
74 | 45 | +AM_CPPFLAGS = \ | ||
75 | 46 | + $(PANEL_CFLAGS) \ | ||
76 | 47 | + $(SOUND_PANEL_CFLAGS) \ | ||
77 | 48 | + -DLOCALE_DIR=\""$(datadir)/locale"\" \ | ||
78 | 49 | + -DLIBEXECDIR=\"$(libexecdir)\" \ | ||
79 | 50 | + -DGLADEDIR=\""$(pkgdatadir)"\" \ | ||
80 | 51 | + -DSOUND_DATA_DIR="\"$(datadir)/sounds\"" \ | ||
81 | 52 | + -DSOUND_SET_DIR="\"$(pkgdatadir)/sounds\"" \ | ||
82 | 53 | + -DICON_DATA_DIR="\"$(pkgdatadir)/icons\"" \ | ||
83 | 54 | + -I../sound \ | ||
84 | 55 | + $(NULL) | ||
85 | 56 | + | ||
86 | 57 | +libsoundnua_la_LIBADD = \ | ||
87 | 58 | + -lm \ | ||
88 | 59 | + ../sound/libgnomevolumecontrol.la \ | ||
89 | 60 | + $(PANEL_LIBS) \ | ||
90 | 61 | + $(SOUND_PANEL_LIBS) \ | ||
91 | 62 | + $(NULL) | ||
92 | 63 | + | ||
93 | 64 | +libsoundnua_la_LDFLAGS = \ | ||
94 | 65 | + $(PANEL_LDFLAGS) \ | ||
95 | 66 | + $(NULL) | ||
96 | 67 | + | ||
97 | 68 | +libsoundnua_la_SOURCES = \ | ||
98 | 69 | + gvc-balance-bar.h \ | ||
99 | 70 | + gvc-balance-bar.c \ | ||
100 | 71 | + gvc-mixer-dialog.h \ | ||
101 | 72 | + gvc-mixer-dialog.c \ | ||
102 | 73 | + ../sound/gvc-level-bar.h \ | ||
103 | 74 | + ../sound/gvc-level-bar.c \ | ||
104 | 75 | + ../sound/gvc-combo-box.h \ | ||
105 | 76 | + ../sound/gvc-combo-box.c \ | ||
106 | 77 | + ../sound/gvc-speaker-test.h \ | ||
107 | 78 | + ../sound/gvc-speaker-test.c \ | ||
108 | 79 | + ../sound/gvc-sound-theme-chooser.c \ | ||
109 | 80 | + ../sound/gvc-sound-theme-chooser.h \ | ||
110 | 81 | + ../sound/sound-theme-file-utils.c \ | ||
111 | 82 | + ../sound/sound-theme-file-utils.h \ | ||
112 | 83 | + cc-sound-panel.c \ | ||
113 | 84 | + cc-sound-panel.h \ | ||
114 | 85 | + $(NULL) | ||
115 | 86 | + | ||
116 | 87 | +BUILT_SOURCES = \ | ||
117 | 88 | + $(NULL) | ||
118 | 89 | + | ||
119 | 90 | +CLEANFILES = \ | ||
120 | 91 | + $(BUILT_SOURCES) \ | ||
121 | 92 | + $(NULL) | ||
122 | 93 | + | ||
123 | 94 | +MAINTAINERCLEANFILES = \ | ||
124 | 95 | + *~ \ | ||
125 | 96 | + Makefile.in | ||
126 | 97 | + | ||
127 | 98 | +-include $(top_srcdir)/git.mk | ||
128 | 99 | Index: gnome-control-center-3.6.2/panels/sound-nua/cc-sound-panel.c | ||
129 | 100 | =================================================================== | ||
130 | 101 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
131 | 102 | +++ gnome-control-center-3.6.2/panels/sound-nua/cc-sound-panel.c 2012-11-13 16:25:40.777717988 +0100 | ||
132 | 103 | @@ -0,0 +1,141 @@ | ||
133 | 104 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
134 | 105 | + * | ||
135 | 106 | + * Copyright (C) 2008 Red Hat, Inc. | ||
136 | 107 | + * | ||
137 | 108 | + * This program is free software; you can redistribute it and/or | ||
138 | 109 | + * modify it under the terms of the GNU General Public License as | ||
139 | 110 | + * published by the Free Software Foundation; either version 2 of the | ||
140 | 111 | + * License, or (at your option) any later version. | ||
141 | 112 | + * | ||
142 | 113 | + * This program is distributed in the hope that it will be useful, but | ||
143 | 114 | + * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
144 | 115 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
145 | 116 | + * Lesser General Public License for more details. | ||
146 | 117 | + * | ||
147 | 118 | + * You should have received a copy of the GNU General Public License | ||
148 | 119 | + * along with this program; if not, write to the Free Software | ||
149 | 120 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
150 | 121 | + * 02111-1307, USA. | ||
151 | 122 | + */ | ||
152 | 123 | + | ||
153 | 124 | +#include "config.h" | ||
154 | 125 | + | ||
155 | 126 | +#include <libintl.h> | ||
156 | 127 | +#include <stdlib.h> | ||
157 | 128 | +#include <string.h> | ||
158 | 129 | +#include <unistd.h> | ||
159 | 130 | +#include <errno.h> | ||
160 | 131 | + | ||
161 | 132 | +#include <glib/gi18n-lib.h> | ||
162 | 133 | +#include <glib.h> | ||
163 | 134 | +#include <gtk/gtk.h> | ||
164 | 135 | +#include <pulse/pulseaudio.h> | ||
165 | 136 | + | ||
166 | 137 | +#include "cc-sound-panel.h" | ||
167 | 138 | +#include "gvc-mixer-dialog.h" | ||
168 | 139 | + | ||
169 | 140 | +G_DEFINE_DYNAMIC_TYPE (CcSoundNuaPanel, cc_sound_panel, CC_TYPE_PANEL) | ||
170 | 141 | + | ||
171 | 142 | +enum { | ||
172 | 143 | + PROP_0, | ||
173 | 144 | + PROP_ARGV | ||
174 | 145 | +}; | ||
175 | 146 | + | ||
176 | 147 | +static void cc_sound_panel_finalize (GObject *object); | ||
177 | 148 | + | ||
178 | 149 | +static void | ||
179 | 150 | +cc_sound_panel_set_property (GObject *object, | ||
180 | 151 | + guint property_id, | ||
181 | 152 | + const GValue *value, | ||
182 | 153 | + GParamSpec *pspec) | ||
183 | 154 | +{ | ||
184 | 155 | + CcSoundNuaPanel *self = CC_SOUND_PANEL (object); | ||
185 | 156 | + | ||
186 | 157 | + switch (property_id) { | ||
187 | 158 | + case PROP_ARGV: { | ||
188 | 159 | + gchar **args; | ||
189 | 160 | + | ||
190 | 161 | + args = g_value_get_boxed (value); | ||
191 | 162 | + | ||
192 | 163 | + if (args && args[0]) { | ||
193 | 164 | + gvc_mixer_dialog_set_page (self->dialog, args[0]); | ||
194 | 165 | + } | ||
195 | 166 | + break; | ||
196 | 167 | + } | ||
197 | 168 | + default: | ||
198 | 169 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
199 | 170 | + } | ||
200 | 171 | +} | ||
201 | 172 | + | ||
202 | 173 | +static void | ||
203 | 174 | +cc_sound_panel_class_init (CcSoundNuaPanelClass *klass) | ||
204 | 175 | +{ | ||
205 | 176 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
206 | 177 | + | ||
207 | 178 | + object_class->finalize = cc_sound_panel_finalize; | ||
208 | 179 | + object_class->set_property = cc_sound_panel_set_property; | ||
209 | 180 | + | ||
210 | 181 | + g_object_class_override_property (object_class, PROP_ARGV, "argv"); | ||
211 | 182 | +} | ||
212 | 183 | + | ||
213 | 184 | +static void | ||
214 | 185 | +cc_sound_panel_class_finalize (CcSoundNuaPanelClass *klass) | ||
215 | 186 | +{ | ||
216 | 187 | +} | ||
217 | 188 | + | ||
218 | 189 | +static void | ||
219 | 190 | +cc_sound_panel_finalize (GObject *object) | ||
220 | 191 | +{ | ||
221 | 192 | + CcSoundNuaPanel *panel = CC_SOUND_PANEL (object); | ||
222 | 193 | + | ||
223 | 194 | + if (panel->dialog != NULL) | ||
224 | 195 | + panel->dialog = NULL; | ||
225 | 196 | + if (panel->connecting_label != NULL) | ||
226 | 197 | + panel->connecting_label = NULL; | ||
227 | 198 | + if (panel->control != NULL) { | ||
228 | 199 | + g_object_unref (panel->control); | ||
229 | 200 | + panel->control = NULL; | ||
230 | 201 | + } | ||
231 | 202 | + | ||
232 | 203 | + G_OBJECT_CLASS (cc_sound_panel_parent_class)->finalize (object); | ||
233 | 204 | +} | ||
234 | 205 | + | ||
235 | 206 | +static void | ||
236 | 207 | +cc_sound_panel_init (CcSoundNuaPanel *self) | ||
237 | 208 | +{ | ||
238 | 209 | + gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), | ||
239 | 210 | + ICON_DATA_DIR); | ||
240 | 211 | + gtk_window_set_default_icon_name ("multimedia-volume-control"); | ||
241 | 212 | + | ||
242 | 213 | + self->control = gvc_mixer_control_new ("GNOME Volume Control Dialog"); | ||
243 | 214 | + gvc_mixer_control_open (self->control); | ||
244 | 215 | + self->dialog = gvc_mixer_dialog_new (self->control); | ||
245 | 216 | + gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->dialog)); | ||
246 | 217 | + gtk_widget_show (GTK_WIDGET (self->dialog)); | ||
247 | 218 | +} | ||
248 | 219 | + | ||
249 | 220 | +void | ||
250 | 221 | +cc_sound_panel_register (GIOModule *module) | ||
251 | 222 | +{ | ||
252 | 223 | + cc_sound_panel_register_type (G_TYPE_MODULE (module)); | ||
253 | 224 | + g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT, | ||
254 | 225 | + CC_TYPE_SOUND_PANEL, | ||
255 | 226 | + "sound-nua", 0); | ||
256 | 227 | +} | ||
257 | 228 | + | ||
258 | 229 | +/* GIO extension stuff */ | ||
259 | 230 | +void | ||
260 | 231 | +g_io_module_load (GIOModule *module) | ||
261 | 232 | +{ | ||
262 | 233 | + bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); | ||
263 | 234 | + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); | ||
264 | 235 | + | ||
265 | 236 | + /* register the panel */ | ||
266 | 237 | + cc_sound_panel_register (module); | ||
267 | 238 | +} | ||
268 | 239 | + | ||
269 | 240 | +void | ||
270 | 241 | +g_io_module_unload (GIOModule *module) | ||
271 | 242 | +{ | ||
272 | 243 | +} | ||
273 | 244 | + | ||
274 | 245 | Index: gnome-control-center-3.6.2/panels/sound-nua/cc-sound-panel.h | ||
275 | 246 | =================================================================== | ||
276 | 247 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
277 | 248 | +++ gnome-control-center-3.6.2/panels/sound-nua/cc-sound-panel.h 2012-11-13 16:25:40.777717988 +0100 | ||
278 | 249 | @@ -0,0 +1,60 @@ | ||
279 | 250 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
280 | 251 | + * | ||
281 | 252 | + * Copyright (C) 2010 Red Hat, Inc. | ||
282 | 253 | + * | ||
283 | 254 | + * This program is free software; you can redistribute it and/or | ||
284 | 255 | + * modify it under the terms of the GNU General Public License as | ||
285 | 256 | + * published by the Free Software Foundation; either version 2 of the | ||
286 | 257 | + * License, or (at your option) any later version. | ||
287 | 258 | + * | ||
288 | 259 | + * This program is distributed in the hope that it will be useful, but | ||
289 | 260 | + * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
290 | 261 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
291 | 262 | + * Lesser General Public License for more details. | ||
292 | 263 | + * | ||
293 | 264 | + * You should have received a copy of the GNU General Public License | ||
294 | 265 | + * along with this program; if not, write to the Free Software | ||
295 | 266 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
296 | 267 | + * 02111-1307, USA. | ||
297 | 268 | + */ | ||
298 | 269 | + | ||
299 | 270 | +#ifndef _CC_SOUND_PANEL_H | ||
300 | 271 | +#define _CC_SOUND_PANEL_H | ||
301 | 272 | + | ||
302 | 273 | +#include <shell/cc-panel.h> | ||
303 | 274 | +#include "gvc-mixer-control.h" | ||
304 | 275 | +#include "gvc-mixer-dialog.h" | ||
305 | 276 | + | ||
306 | 277 | +G_BEGIN_DECLS | ||
307 | 278 | + | ||
308 | 279 | +#define CC_TYPE_SOUND_PANEL cc_sound_panel_get_type() | ||
309 | 280 | +#define CC_SOUND_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_SOUND_PANEL, CcSoundNuaPanel)) | ||
310 | 281 | +#define CC_SOUND_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_SOUND_PANEL, CcSoundNuaPanelClass)) | ||
311 | 282 | +#define CC_IS_SOUND_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_SOUND_PANEL)) | ||
312 | 283 | +#define CC_IS_SOUND_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_SOUND_PANEL)) | ||
313 | 284 | +#define CC_SOUND_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_SOUND_PANEL, CcSoundNuaPanelClass)) | ||
314 | 285 | + | ||
315 | 286 | +typedef struct _CcSoundNuaPanel CcSoundNuaPanel; | ||
316 | 287 | +typedef struct _CcSoundNuaPanelClass CcSoundNuaPanelClass; | ||
317 | 288 | +typedef struct _CcSoundNuaPanelPrivate CcSoundNuaPanelPrivate; | ||
318 | 289 | + | ||
319 | 290 | +struct _CcSoundNuaPanel { | ||
320 | 291 | + CcPanel parent; | ||
321 | 292 | + | ||
322 | 293 | + GvcMixerControl *control; | ||
323 | 294 | + GvcMixerDialog *dialog; | ||
324 | 295 | + GtkWidget *connecting_label; | ||
325 | 296 | +}; | ||
326 | 297 | + | ||
327 | 298 | +struct _CcSoundNuaPanelClass { | ||
328 | 299 | + CcPanelClass parent_class; | ||
329 | 300 | +}; | ||
330 | 301 | + | ||
331 | 302 | +GType cc_sound_panel_get_type (void) G_GNUC_CONST; | ||
332 | 303 | + | ||
333 | 304 | +void cc_sound_panel_register (GIOModule *module); | ||
334 | 305 | + | ||
335 | 306 | +G_END_DECLS | ||
336 | 307 | + | ||
337 | 308 | +#endif /* _CC_SOUND_PANEL_H */ | ||
338 | 309 | + | ||
339 | 310 | Index: gnome-control-center-3.6.2/panels/sound-nua/data/Makefile.am | ||
340 | 311 | =================================================================== | ||
341 | 312 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
342 | 313 | +++ gnome-control-center-3.6.2/panels/sound-nua/data/Makefile.am 2012-11-13 16:25:40.777717988 +0100 | ||
343 | 314 | @@ -0,0 +1,17 @@ | ||
344 | 315 | +NULL = | ||
345 | 316 | + | ||
346 | 317 | +@INTLTOOL_DESKTOP_RULE@ | ||
347 | 318 | + | ||
348 | 319 | +appsdir = $(datadir)/applications | ||
349 | 320 | +apps_in_files = gnome-sound-nua-panel.desktop.in | ||
350 | 321 | +apps_DATA = $(apps_in_files:.desktop.in=.desktop) | ||
351 | 322 | + | ||
352 | 323 | +EXTRA_DIST = \ | ||
353 | 324 | + gnome-sound-nua-panel.desktop.in.in \ | ||
354 | 325 | + $(NULL) | ||
355 | 326 | + | ||
356 | 327 | +CLEANFILES = \ | ||
357 | 328 | + gnome-sound-nua-panel.desktop \ | ||
358 | 329 | + $(NULL) | ||
359 | 330 | + | ||
360 | 331 | +-include $(top_srcdir)/git.mk | ||
361 | 332 | Index: gnome-control-center-3.6.2/panels/sound-nua/data/gnome-sound-nua-panel.desktop.in.in | ||
362 | 333 | =================================================================== | ||
363 | 334 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
364 | 335 | +++ gnome-control-center-3.6.2/panels/sound-nua/data/gnome-sound-nua-panel.desktop.in.in 2012-11-13 16:25:40.781717988 +0100 | ||
365 | 336 | @@ -0,0 +1,17 @@ | ||
366 | 337 | +[Desktop Entry] | ||
367 | 338 | +_Name=Sound | ||
368 | 339 | +_Comment=Change sound volume and sound events | ||
369 | 340 | +Exec=gnome-control-center sound-nua | ||
370 | 341 | +Icon=multimedia-volume-control | ||
371 | 342 | +Terminal=false | ||
372 | 343 | +Type=Application | ||
373 | 344 | +StartupNotify=true | ||
374 | 345 | +Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel; | ||
375 | 346 | +OnlyShowIn=Unity; | ||
376 | 347 | +X-GNOME-Bugzilla-Bugzilla=GNOME | ||
377 | 348 | +X-GNOME-Bugzilla-Product=gnome-control-center | ||
378 | 349 | +X-GNOME-Bugzilla-Component=sound | ||
379 | 350 | +X-GNOME-Bugzilla-Version=@VERSION@ | ||
380 | 351 | +X-GNOME-Settings-Panel=sound-nua | ||
381 | 352 | +# Translators: those are keywords for the sound control-center panel | ||
382 | 353 | +_Keywords=Card;Microphone;Volume;Fade;Balance;Bluetooth;Headset; | ||
383 | 354 | Index: gnome-control-center-3.6.2/panels/sound-nua/gvc-balance-bar.c | ||
384 | 355 | =================================================================== | ||
385 | 356 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
386 | 357 | +++ gnome-control-center-3.6.2/panels/sound-nua/gvc-balance-bar.c 2012-11-13 16:25:40.797717987 +0100 | ||
387 | 358 | @@ -0,0 +1,575 @@ | ||
388 | 359 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
389 | 360 | + * | ||
390 | 361 | + * Copyright (C) 2008 William Jon McCann | ||
391 | 362 | + * | ||
392 | 363 | + * This program is free software; you can redistribute it and/or modify | ||
393 | 364 | + * it under the terms of the GNU General Public License as published by | ||
394 | 365 | + * the Free Software Foundation; either version 2 of the License, or | ||
395 | 366 | + * (at your option) any later version. | ||
396 | 367 | + * | ||
397 | 368 | + * This program is distributed in the hope that it will be useful, | ||
398 | 369 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
399 | 370 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
400 | 371 | + * GNU General Public License for more details. | ||
401 | 372 | + * | ||
402 | 373 | + * You should have received a copy of the GNU General Public License | ||
403 | 374 | + * along with this program; if not, write to the Free Software | ||
404 | 375 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
405 | 376 | + * | ||
406 | 377 | + */ | ||
407 | 378 | + | ||
408 | 379 | +#include "config.h" | ||
409 | 380 | + | ||
410 | 381 | +#include <stdlib.h> | ||
411 | 382 | +#include <stdio.h> | ||
412 | 383 | +#include <unistd.h> | ||
413 | 384 | + | ||
414 | 385 | +#include <glib.h> | ||
415 | 386 | +#include <glib/gi18n-lib.h> | ||
416 | 387 | +#include <gtk/gtk.h> | ||
417 | 388 | +#include <canberra-gtk.h> | ||
418 | 389 | +#include <pulse/pulseaudio.h> | ||
419 | 390 | + | ||
420 | 391 | +#include "gvc-balance-bar.h" | ||
421 | 392 | +#include "gvc-channel-map-private.h" | ||
422 | 393 | + | ||
423 | 394 | +#define SCALE_SIZE 220 | ||
424 | 395 | +#define ADJUSTMENT_MAX_NORMAL 65536.0 /* PA_VOLUME_NORM */ | ||
425 | 396 | + | ||
426 | 397 | +#define GVC_BALANCE_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_BALANCE_BAR, GvcBalanceBarPrivate)) | ||
427 | 398 | + | ||
428 | 399 | +struct GvcBalanceBarPrivate | ||
429 | 400 | +{ | ||
430 | 401 | + GvcChannelMap *channel_map; | ||
431 | 402 | + GvcBalanceType btype; | ||
432 | 403 | + GtkWidget *scale_box; | ||
433 | 404 | + GtkWidget *start_box; | ||
434 | 405 | + GtkWidget *end_box; | ||
435 | 406 | + GtkWidget *label; | ||
436 | 407 | + GtkWidget *scale; | ||
437 | 408 | + GtkAdjustment *adjustment; | ||
438 | 409 | + GtkSizeGroup *size_group; | ||
439 | 410 | + gboolean symmetric; | ||
440 | 411 | + gboolean click_lock; | ||
441 | 412 | +}; | ||
442 | 413 | + | ||
443 | 414 | +enum | ||
444 | 415 | +{ | ||
445 | 416 | + PROP_0, | ||
446 | 417 | + PROP_CHANNEL_MAP, | ||
447 | 418 | + PROP_BALANCE_TYPE, | ||
448 | 419 | +}; | ||
449 | 420 | + | ||
450 | 421 | +static void gvc_balance_bar_class_init (GvcBalanceBarClass *klass); | ||
451 | 422 | +static void gvc_balance_bar_init (GvcBalanceBar *balance_bar); | ||
452 | 423 | +static void gvc_balance_bar_finalize (GObject *object); | ||
453 | 424 | + | ||
454 | 425 | +static gboolean on_scale_button_press_event (GtkWidget *widget, | ||
455 | 426 | + GdkEventButton *event, | ||
456 | 427 | + GvcBalanceBar *bar); | ||
457 | 428 | +static gboolean on_scale_button_release_event (GtkWidget *widget, | ||
458 | 429 | + GdkEventButton *event, | ||
459 | 430 | + GvcBalanceBar *bar); | ||
460 | 431 | +static gboolean on_scale_scroll_event (GtkWidget *widget, | ||
461 | 432 | + GdkEventScroll *event, | ||
462 | 433 | + GvcBalanceBar *bar); | ||
463 | 434 | +static void on_adjustment_value_changed (GtkAdjustment *adjustment, | ||
464 | 435 | + GvcBalanceBar *bar); | ||
465 | 436 | + | ||
466 | 437 | +G_DEFINE_TYPE (GvcBalanceBar, gvc_balance_bar, GTK_TYPE_HBOX) | ||
467 | 438 | + | ||
468 | 439 | +static GtkWidget * | ||
469 | 440 | +_scale_box_new (GvcBalanceBar *bar) | ||
470 | 441 | +{ | ||
471 | 442 | + GvcBalanceBarPrivate *priv = bar->priv; | ||
472 | 443 | + GtkWidget *box; | ||
473 | 444 | + GtkWidget *sbox; | ||
474 | 445 | + GtkWidget *ebox; | ||
475 | 446 | + GtkAdjustment *adjustment = bar->priv->adjustment; | ||
476 | 447 | + char *str_lower, *str_upper; | ||
477 | 448 | + gdouble lower, upper; | ||
478 | 449 | + | ||
479 | 450 | + bar->priv->scale_box = box = gtk_box_new (FALSE, 6); | ||
480 | 451 | + priv->scale = gtk_hscale_new (priv->adjustment); | ||
481 | 452 | + gtk_widget_set_size_request (priv->scale, SCALE_SIZE, -1); | ||
482 | 453 | + gtk_scale_set_has_origin (GTK_SCALE (priv->scale), FALSE); | ||
483 | 454 | + gtk_widget_set_name (priv->scale, "balance-bar-scale"); | ||
484 | 455 | + gtk_rc_parse_string ("style \"balance-bar-scale-style\" {\n" | ||
485 | 456 | + " GtkScale::trough-side-details = 0\n" | ||
486 | 457 | + "}\n" | ||
487 | 458 | + "widget \"*.balance-bar-scale\" style : rc \"balance-bar-scale-style\"\n"); | ||
488 | 459 | + | ||
489 | 460 | + bar->priv->start_box = sbox = gtk_box_new (FALSE, 6); | ||
490 | 461 | + gtk_box_pack_start (GTK_BOX (box), sbox, FALSE, FALSE, 0); | ||
491 | 462 | + | ||
492 | 463 | + gtk_box_pack_start (GTK_BOX (sbox), priv->label, FALSE, FALSE, 0); | ||
493 | 464 | + | ||
494 | 465 | + gtk_box_pack_start (GTK_BOX (box), priv->scale, TRUE, TRUE, 0); | ||
495 | 466 | + | ||
496 | 467 | + switch (bar->priv->btype) { | ||
497 | 468 | + case BALANCE_TYPE_RL: | ||
498 | 469 | + str_lower = g_strdup_printf ("<small>%s</small>", C_("balance", "Left")); | ||
499 | 470 | + str_upper = g_strdup_printf ("<small>%s</small>", C_("balance", "Right")); | ||
500 | 471 | + break; | ||
501 | 472 | + case BALANCE_TYPE_FR: | ||
502 | 473 | + str_lower = g_strdup_printf ("<small>%s</small>", C_("balance", "Rear")); | ||
503 | 474 | + str_upper = g_strdup_printf ("<small>%s</small>", C_("balance", "Front")); | ||
504 | 475 | + break; | ||
505 | 476 | + case BALANCE_TYPE_LFE: | ||
506 | 477 | + str_lower = g_strdup_printf ("<small>%s</small>", C_("balance", "Minimum")); | ||
507 | 478 | + str_upper = g_strdup_printf ("<small>%s</small>", C_("balance", "Maximum")); | ||
508 | 479 | + break; | ||
509 | 480 | + default: | ||
510 | 481 | + g_assert_not_reached (); | ||
511 | 482 | + } | ||
512 | 483 | + | ||
513 | 484 | + lower = gtk_adjustment_get_lower (adjustment); | ||
514 | 485 | + gtk_scale_add_mark (GTK_SCALE (priv->scale), lower, | ||
515 | 486 | + GTK_POS_BOTTOM, str_lower); | ||
516 | 487 | + g_free (str_lower); | ||
517 | 488 | + upper = gtk_adjustment_get_upper (adjustment); | ||
518 | 489 | + gtk_scale_add_mark (GTK_SCALE (priv->scale), upper, | ||
519 | 490 | + GTK_POS_BOTTOM, str_upper); | ||
520 | 491 | + g_free (str_upper); | ||
521 | 492 | + | ||
522 | 493 | + if (bar->priv->btype != BALANCE_TYPE_LFE) { | ||
523 | 494 | + gtk_scale_add_mark (GTK_SCALE (priv->scale), | ||
524 | 495 | + (upper - lower)/2 + lower, | ||
525 | 496 | + GTK_POS_BOTTOM, NULL); | ||
526 | 497 | + } | ||
527 | 498 | + | ||
528 | 499 | + bar->priv->end_box = ebox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); | ||
529 | 500 | + gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, FALSE, 0); | ||
530 | 501 | + | ||
531 | 502 | + ca_gtk_widget_disable_sounds (bar->priv->scale, FALSE); | ||
532 | 503 | + gtk_widget_add_events (bar->priv->scale, GDK_SCROLL_MASK); | ||
533 | 504 | + | ||
534 | 505 | + g_signal_connect (G_OBJECT (bar->priv->scale), "button-press-event", | ||
535 | 506 | + G_CALLBACK (on_scale_button_press_event), bar); | ||
536 | 507 | + g_signal_connect (G_OBJECT (bar->priv->scale), "button-release-event", | ||
537 | 508 | + G_CALLBACK (on_scale_button_release_event), bar); | ||
538 | 509 | + g_signal_connect (G_OBJECT (bar->priv->scale), "scroll-event", | ||
539 | 510 | + G_CALLBACK (on_scale_scroll_event), bar); | ||
540 | 511 | + | ||
541 | 512 | + if (bar->priv->size_group != NULL) { | ||
542 | 513 | + gtk_size_group_add_widget (bar->priv->size_group, sbox); | ||
543 | 514 | + | ||
544 | 515 | + if (bar->priv->symmetric) { | ||
545 | 516 | + gtk_size_group_add_widget (bar->priv->size_group, ebox); | ||
546 | 517 | + } | ||
547 | 518 | + } | ||
548 | 519 | + | ||
549 | 520 | + gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); | ||
550 | 521 | + | ||
551 | 522 | + return box; | ||
552 | 523 | +} | ||
553 | 524 | + | ||
554 | 525 | +void | ||
555 | 526 | +gvc_balance_bar_set_size_group (GvcBalanceBar *bar, | ||
556 | 527 | + GtkSizeGroup *group, | ||
557 | 528 | + gboolean symmetric) | ||
558 | 529 | +{ | ||
559 | 530 | + g_return_if_fail (GVC_IS_BALANCE_BAR (bar)); | ||
560 | 531 | + | ||
561 | 532 | + bar->priv->size_group = group; | ||
562 | 533 | + bar->priv->symmetric = symmetric; | ||
563 | 534 | + | ||
564 | 535 | + if (bar->priv->size_group != NULL) { | ||
565 | 536 | + gtk_size_group_add_widget (bar->priv->size_group, | ||
566 | 537 | + bar->priv->start_box); | ||
567 | 538 | + | ||
568 | 539 | + if (bar->priv->symmetric) { | ||
569 | 540 | + gtk_size_group_add_widget (bar->priv->size_group, | ||
570 | 541 | + bar->priv->end_box); | ||
571 | 542 | + } | ||
572 | 543 | + } | ||
573 | 544 | + gtk_widget_queue_draw (GTK_WIDGET (bar)); | ||
574 | 545 | +} | ||
575 | 546 | + | ||
576 | 547 | +static const char * | ||
577 | 548 | +btype_to_string (guint btype) | ||
578 | 549 | +{ | ||
579 | 550 | + switch (btype) { | ||
580 | 551 | + case BALANCE_TYPE_RL: | ||
581 | 552 | + return "Balance"; | ||
582 | 553 | + case BALANCE_TYPE_FR: | ||
583 | 554 | + return "Fade"; | ||
584 | 555 | + break; | ||
585 | 556 | + case BALANCE_TYPE_LFE: | ||
586 | 557 | + return "LFE"; | ||
587 | 558 | + default: | ||
588 | 559 | + g_assert_not_reached (); | ||
589 | 560 | + } | ||
590 | 561 | + return NULL; | ||
591 | 562 | +} | ||
592 | 563 | + | ||
593 | 564 | +static void | ||
594 | 565 | +update_level_from_map (GvcBalanceBar *bar, | ||
595 | 566 | + GvcChannelMap *map) | ||
596 | 567 | +{ | ||
597 | 568 | + const gdouble *volumes; | ||
598 | 569 | + gdouble val; | ||
599 | 570 | + | ||
600 | 571 | + g_debug ("Volume changed (for %s bar)", btype_to_string (bar->priv->btype)); | ||
601 | 572 | + | ||
602 | 573 | + volumes = gvc_channel_map_get_volume (map); | ||
603 | 574 | + switch (bar->priv->btype) { | ||
604 | 575 | + case BALANCE_TYPE_RL: | ||
605 | 576 | + val = volumes[BALANCE]; | ||
606 | 577 | + break; | ||
607 | 578 | + case BALANCE_TYPE_FR: | ||
608 | 579 | + val = volumes[FADE]; | ||
609 | 580 | + break; | ||
610 | 581 | + case BALANCE_TYPE_LFE: | ||
611 | 582 | + val = volumes[LFE]; | ||
612 | 583 | + break; | ||
613 | 584 | + default: | ||
614 | 585 | + g_assert_not_reached (); | ||
615 | 586 | + } | ||
616 | 587 | + | ||
617 | 588 | + gtk_adjustment_set_value (bar->priv->adjustment, val); | ||
618 | 589 | +} | ||
619 | 590 | + | ||
620 | 591 | +static void | ||
621 | 592 | +on_channel_map_volume_changed (GvcChannelMap *map, | ||
622 | 593 | + gboolean set, | ||
623 | 594 | + GvcBalanceBar *bar) | ||
624 | 595 | +{ | ||
625 | 596 | + update_level_from_map (bar, map); | ||
626 | 597 | +} | ||
627 | 598 | + | ||
628 | 599 | +static void | ||
629 | 600 | +gvc_balance_bar_set_channel_map (GvcBalanceBar *bar, | ||
630 | 601 | + GvcChannelMap *map) | ||
631 | 602 | +{ | ||
632 | 603 | + g_return_if_fail (GVC_BALANCE_BAR (bar)); | ||
633 | 604 | + | ||
634 | 605 | + if (bar->priv->channel_map != NULL) { | ||
635 | 606 | + g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->channel_map), | ||
636 | 607 | + on_channel_map_volume_changed, bar); | ||
637 | 608 | + g_object_unref (bar->priv->channel_map); | ||
638 | 609 | + } | ||
639 | 610 | + bar->priv->channel_map = g_object_ref (map); | ||
640 | 611 | + | ||
641 | 612 | + update_level_from_map (bar, map); | ||
642 | 613 | + | ||
643 | 614 | + g_signal_connect (G_OBJECT (map), "volume-changed", | ||
644 | 615 | + G_CALLBACK (on_channel_map_volume_changed), bar); | ||
645 | 616 | + | ||
646 | 617 | + g_object_notify (G_OBJECT (bar), "channel-map"); | ||
647 | 618 | +} | ||
648 | 619 | + | ||
649 | 620 | +static void | ||
650 | 621 | +gvc_balance_bar_set_balance_type (GvcBalanceBar *bar, | ||
651 | 622 | + GvcBalanceType btype) | ||
652 | 623 | +{ | ||
653 | 624 | + GtkWidget *frame; | ||
654 | 625 | + | ||
655 | 626 | + g_return_if_fail (GVC_BALANCE_BAR (bar)); | ||
656 | 627 | + | ||
657 | 628 | + bar->priv->btype = btype; | ||
658 | 629 | + if (bar->priv->btype != BALANCE_TYPE_LFE) { | ||
659 | 630 | + bar->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, | ||
660 | 631 | + -1.0, | ||
661 | 632 | + 1.0, | ||
662 | 633 | + 0.5, | ||
663 | 634 | + 0.5, | ||
664 | 635 | + 0.0)); | ||
665 | 636 | + } else { | ||
666 | 637 | + bar->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, | ||
667 | 638 | + 0.0, | ||
668 | 639 | + ADJUSTMENT_MAX_NORMAL, | ||
669 | 640 | + ADJUSTMENT_MAX_NORMAL/100.0, | ||
670 | 641 | + ADJUSTMENT_MAX_NORMAL/10.0, | ||
671 | 642 | + 0.0)); | ||
672 | 643 | + } | ||
673 | 644 | + | ||
674 | 645 | + g_object_ref_sink (bar->priv->adjustment); | ||
675 | 646 | + g_signal_connect (bar->priv->adjustment, | ||
676 | 647 | + "value-changed", | ||
677 | 648 | + G_CALLBACK (on_adjustment_value_changed), | ||
678 | 649 | + bar); | ||
679 | 650 | + | ||
680 | 651 | + switch (btype) { | ||
681 | 652 | + case BALANCE_TYPE_RL: | ||
682 | 653 | + bar->priv->label = gtk_label_new_with_mnemonic (_("_Balance:")); | ||
683 | 654 | + break; | ||
684 | 655 | + case BALANCE_TYPE_FR: | ||
685 | 656 | + bar->priv->label = gtk_label_new_with_mnemonic (_("_Fade:")); | ||
686 | 657 | + break; | ||
687 | 658 | + case BALANCE_TYPE_LFE: | ||
688 | 659 | + bar->priv->label = gtk_label_new_with_mnemonic (_("_Subwoofer:")); | ||
689 | 660 | + break; | ||
690 | 661 | + default: | ||
691 | 662 | + g_assert_not_reached (); | ||
692 | 663 | + } | ||
693 | 664 | + gtk_misc_set_alignment (GTK_MISC (bar->priv->label), | ||
694 | 665 | + 0.0, | ||
695 | 666 | + 0.0); | ||
696 | 667 | + /* frame */ | ||
697 | 668 | + frame = gtk_frame_new (NULL); | ||
698 | 669 | + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); | ||
699 | 670 | + gtk_container_add (GTK_CONTAINER (bar), frame); | ||
700 | 671 | + | ||
701 | 672 | + /* box with scale */ | ||
702 | 673 | + bar->priv->scale_box = _scale_box_new (bar); | ||
703 | 674 | + gtk_container_add (GTK_CONTAINER (frame), bar->priv->scale_box); | ||
704 | 675 | + gtk_widget_show_all (frame); | ||
705 | 676 | + | ||
706 | 677 | + gtk_widget_set_direction (bar->priv->scale, GTK_TEXT_DIR_LTR); | ||
707 | 678 | + gtk_label_set_mnemonic_widget (GTK_LABEL (bar->priv->label), | ||
708 | 679 | + bar->priv->scale); | ||
709 | 680 | + | ||
710 | 681 | + g_object_notify (G_OBJECT (bar), "balance-type"); | ||
711 | 682 | +} | ||
712 | 683 | + | ||
713 | 684 | +static void | ||
714 | 685 | +gvc_balance_bar_set_property (GObject *object, | ||
715 | 686 | + guint prop_id, | ||
716 | 687 | + const GValue *value, | ||
717 | 688 | + GParamSpec *pspec) | ||
718 | 689 | +{ | ||
719 | 690 | + GvcBalanceBar *self = GVC_BALANCE_BAR (object); | ||
720 | 691 | + | ||
721 | 692 | + switch (prop_id) { | ||
722 | 693 | + case PROP_CHANNEL_MAP: | ||
723 | 694 | + gvc_balance_bar_set_channel_map (self, g_value_get_object (value)); | ||
724 | 695 | + break; | ||
725 | 696 | + case PROP_BALANCE_TYPE: | ||
726 | 697 | + gvc_balance_bar_set_balance_type (self, g_value_get_int (value)); | ||
727 | 698 | + break; | ||
728 | 699 | + default: | ||
729 | 700 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
730 | 701 | + break; | ||
731 | 702 | + } | ||
732 | 703 | +} | ||
733 | 704 | + | ||
734 | 705 | +static void | ||
735 | 706 | +gvc_balance_bar_get_property (GObject *object, | ||
736 | 707 | + guint prop_id, | ||
737 | 708 | + GValue *value, | ||
738 | 709 | + GParamSpec *pspec) | ||
739 | 710 | +{ | ||
740 | 711 | + GvcBalanceBar *self = GVC_BALANCE_BAR (object); | ||
741 | 712 | + | ||
742 | 713 | + switch (prop_id) { | ||
743 | 714 | + case PROP_CHANNEL_MAP: | ||
744 | 715 | + g_value_set_object (value, self->priv->channel_map); | ||
745 | 716 | + break; | ||
746 | 717 | + default: | ||
747 | 718 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
748 | 719 | + break; | ||
749 | 720 | + } | ||
750 | 721 | +} | ||
751 | 722 | + | ||
752 | 723 | +static GObject * | ||
753 | 724 | +gvc_balance_bar_constructor (GType type, | ||
754 | 725 | + guint n_construct_properties, | ||
755 | 726 | + GObjectConstructParam *construct_params) | ||
756 | 727 | +{ | ||
757 | 728 | + return G_OBJECT_CLASS (gvc_balance_bar_parent_class)->constructor (type, n_construct_properties, construct_params); | ||
758 | 729 | +} | ||
759 | 730 | + | ||
760 | 731 | +static void | ||
761 | 732 | +gvc_balance_bar_class_init (GvcBalanceBarClass *klass) | ||
762 | 733 | +{ | ||
763 | 734 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
764 | 735 | + | ||
765 | 736 | + object_class->constructor = gvc_balance_bar_constructor; | ||
766 | 737 | + object_class->finalize = gvc_balance_bar_finalize; | ||
767 | 738 | + object_class->set_property = gvc_balance_bar_set_property; | ||
768 | 739 | + object_class->get_property = gvc_balance_bar_get_property; | ||
769 | 740 | + | ||
770 | 741 | + g_object_class_install_property (object_class, | ||
771 | 742 | + PROP_CHANNEL_MAP, | ||
772 | 743 | + g_param_spec_object ("channel-map", | ||
773 | 744 | + "channel map", | ||
774 | 745 | + "The channel map", | ||
775 | 746 | + GVC_TYPE_CHANNEL_MAP, | ||
776 | 747 | + G_PARAM_READWRITE)); | ||
777 | 748 | + g_object_class_install_property (object_class, | ||
778 | 749 | + PROP_BALANCE_TYPE, | ||
779 | 750 | + g_param_spec_int ("balance-type", | ||
780 | 751 | + "balance type", | ||
781 | 752 | + "Whether the balance is right-left or front-rear", | ||
782 | 753 | + BALANCE_TYPE_RL, NUM_BALANCE_TYPES - 1, BALANCE_TYPE_RL, | ||
783 | 754 | + G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); | ||
784 | 755 | + | ||
785 | 756 | + g_type_class_add_private (klass, sizeof (GvcBalanceBarPrivate)); | ||
786 | 757 | +} | ||
787 | 758 | + | ||
788 | 759 | + | ||
789 | 760 | +static gboolean | ||
790 | 761 | +on_scale_button_press_event (GtkWidget *widget, | ||
791 | 762 | + GdkEventButton *event, | ||
792 | 763 | + GvcBalanceBar *bar) | ||
793 | 764 | +{ | ||
794 | 765 | + bar->priv->click_lock = TRUE; | ||
795 | 766 | + | ||
796 | 767 | + return FALSE; | ||
797 | 768 | +} | ||
798 | 769 | + | ||
799 | 770 | +static gboolean | ||
800 | 771 | +on_scale_button_release_event (GtkWidget *widget, | ||
801 | 772 | + GdkEventButton *event, | ||
802 | 773 | + GvcBalanceBar *bar) | ||
803 | 774 | +{ | ||
804 | 775 | + bar->priv->click_lock = FALSE; | ||
805 | 776 | + | ||
806 | 777 | + return FALSE; | ||
807 | 778 | +} | ||
808 | 779 | + | ||
809 | 780 | +static gboolean | ||
810 | 781 | +on_scale_scroll_event (GtkWidget *widget, | ||
811 | 782 | + GdkEventScroll *event, | ||
812 | 783 | + GvcBalanceBar *bar) | ||
813 | 784 | +{ | ||
814 | 785 | + gdouble value; | ||
815 | 786 | + gdouble dx, dy; | ||
816 | 787 | + | ||
817 | 788 | + value = gtk_adjustment_get_value (bar->priv->adjustment); | ||
818 | 789 | + | ||
819 | 790 | + if (!gdk_event_get_scroll_deltas ((GdkEvent*)event, &dx, &dy)) { | ||
820 | 791 | + dx = 0.0; | ||
821 | 792 | + dy = 0.0; | ||
822 | 793 | + | ||
823 | 794 | + switch (event->direction) { | ||
824 | 795 | + case GDK_SCROLL_UP: | ||
825 | 796 | + case GDK_SCROLL_RIGHT: | ||
826 | 797 | + dy = 1.0; | ||
827 | 798 | + break; | ||
828 | 799 | + case GDK_SCROLL_DOWN: | ||
829 | 800 | + case GDK_SCROLL_LEFT: | ||
830 | 801 | + dy = -1.0; | ||
831 | 802 | + break; | ||
832 | 803 | + default: | ||
833 | 804 | + ; | ||
834 | 805 | + } | ||
835 | 806 | + } | ||
836 | 807 | + | ||
837 | 808 | + if (bar->priv->btype == BALANCE_TYPE_LFE) { | ||
838 | 809 | + if (dy > 0) { | ||
839 | 810 | + if (value + dy * ADJUSTMENT_MAX_NORMAL/100.0 > ADJUSTMENT_MAX_NORMAL) | ||
840 | 811 | + value = ADJUSTMENT_MAX_NORMAL; | ||
841 | 812 | + else | ||
842 | 813 | + value = value + dy * ADJUSTMENT_MAX_NORMAL/100.0; | ||
843 | 814 | + } else if (dy < 0) { | ||
844 | 815 | + if (value + dy * ADJUSTMENT_MAX_NORMAL/100.0 < 0) | ||
845 | 816 | + value = 0.0; | ||
846 | 817 | + else | ||
847 | 818 | + value = value + dy * ADJUSTMENT_MAX_NORMAL/100.0; | ||
848 | 819 | + } | ||
849 | 820 | + } else { | ||
850 | 821 | + if (dy > 0) { | ||
851 | 822 | + if (value + dy * 0.01 > 1.0) | ||
852 | 823 | + value = 1.0; | ||
853 | 824 | + else | ||
854 | 825 | + value = value + dy * 0.01; | ||
855 | 826 | + } else if (dy < 0) { | ||
856 | 827 | + if (value + dy * 0.01 < -1.0) | ||
857 | 828 | + value = -1.0; | ||
858 | 829 | + else | ||
859 | 830 | + value = value + dy * 0.01; | ||
860 | 831 | + } | ||
861 | 832 | + } | ||
862 | 833 | + gtk_adjustment_set_value (bar->priv->adjustment, value); | ||
863 | 834 | + | ||
864 | 835 | + return TRUE; | ||
865 | 836 | +} | ||
866 | 837 | + | ||
867 | 838 | +/* FIXME remove when we depend on a newer PA */ | ||
868 | 839 | +static pa_cvolume * | ||
869 | 840 | +gvc_pa_cvolume_set_position (pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t, pa_volume_t v) { | ||
870 | 841 | + unsigned c; | ||
871 | 842 | + gboolean good = FALSE; | ||
872 | 843 | + | ||
873 | 844 | + g_assert(cv); | ||
874 | 845 | + g_assert(map); | ||
875 | 846 | + | ||
876 | 847 | + g_return_val_if_fail(pa_cvolume_compatible_with_channel_map(cv, map), NULL); | ||
877 | 848 | + g_return_val_if_fail(t < PA_CHANNEL_POSITION_MAX, NULL); | ||
878 | 849 | + | ||
879 | 850 | + for (c = 0; c < map->channels; c++) | ||
880 | 851 | + if (map->map[c] == t) { | ||
881 | 852 | + cv->values[c] = v; | ||
882 | 853 | + good = TRUE; | ||
883 | 854 | + } | ||
884 | 855 | + | ||
885 | 856 | + return good ? cv : NULL; | ||
886 | 857 | +} | ||
887 | 858 | + | ||
888 | 859 | +static void | ||
889 | 860 | +on_adjustment_value_changed (GtkAdjustment *adjustment, | ||
890 | 861 | + GvcBalanceBar *bar) | ||
891 | 862 | +{ | ||
892 | 863 | + gdouble val; | ||
893 | 864 | + pa_cvolume cv; | ||
894 | 865 | + const pa_channel_map *pa_map; | ||
895 | 866 | + | ||
896 | 867 | + if (bar->priv->channel_map == NULL) | ||
897 | 868 | + return; | ||
898 | 869 | + | ||
899 | 870 | + cv = *gvc_channel_map_get_cvolume (bar->priv->channel_map); | ||
900 | 871 | + val = gtk_adjustment_get_value (adjustment); | ||
901 | 872 | + | ||
902 | 873 | + pa_map = gvc_channel_map_get_pa_channel_map (bar->priv->channel_map); | ||
903 | 874 | + | ||
904 | 875 | + switch (bar->priv->btype) { | ||
905 | 876 | + case BALANCE_TYPE_RL: | ||
906 | 877 | + pa_cvolume_set_balance (&cv, pa_map, val); | ||
907 | 878 | + break; | ||
908 | 879 | + case BALANCE_TYPE_FR: | ||
909 | 880 | + pa_cvolume_set_fade (&cv, pa_map, val); | ||
910 | 881 | + break; | ||
911 | 882 | + case BALANCE_TYPE_LFE: | ||
912 | 883 | + gvc_pa_cvolume_set_position (&cv, pa_map, PA_CHANNEL_POSITION_LFE, val); | ||
913 | 884 | + break; | ||
914 | 885 | + } | ||
915 | 886 | + | ||
916 | 887 | + gvc_channel_map_volume_changed (bar->priv->channel_map, &cv, TRUE); | ||
917 | 888 | +} | ||
918 | 889 | + | ||
919 | 890 | +static void | ||
920 | 891 | +gvc_balance_bar_init (GvcBalanceBar *bar) | ||
921 | 892 | +{ | ||
922 | 893 | + bar->priv = GVC_BALANCE_BAR_GET_PRIVATE (bar); | ||
923 | 894 | +} | ||
924 | 895 | + | ||
925 | 896 | +static void | ||
926 | 897 | +gvc_balance_bar_finalize (GObject *object) | ||
927 | 898 | +{ | ||
928 | 899 | + GvcBalanceBar *bar; | ||
929 | 900 | + | ||
930 | 901 | + g_return_if_fail (object != NULL); | ||
931 | 902 | + g_return_if_fail (GVC_IS_BALANCE_BAR (object)); | ||
932 | 903 | + | ||
933 | 904 | + bar = GVC_BALANCE_BAR (object); | ||
934 | 905 | + | ||
935 | 906 | + g_return_if_fail (bar->priv != NULL); | ||
936 | 907 | + | ||
937 | 908 | + if (bar->priv->channel_map != NULL) { | ||
938 | 909 | + g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->channel_map), | ||
939 | 910 | + on_channel_map_volume_changed, bar); | ||
940 | 911 | + g_object_unref (bar->priv->channel_map); | ||
941 | 912 | + } | ||
942 | 913 | + | ||
943 | 914 | + G_OBJECT_CLASS (gvc_balance_bar_parent_class)->finalize (object); | ||
944 | 915 | +} | ||
945 | 916 | + | ||
946 | 917 | +void | ||
947 | 918 | +gvc_balance_bar_set_map (GvcBalanceBar* self, | ||
948 | 919 | + const GvcChannelMap *channel_map) | ||
949 | 920 | +{ | ||
950 | 921 | + g_object_set (G_OBJECT (self), | ||
951 | 922 | + "channel-map", channel_map, NULL); | ||
952 | 923 | +} | ||
953 | 924 | + | ||
954 | 925 | +GtkWidget * | ||
955 | 926 | +gvc_balance_bar_new (GvcBalanceType btype) | ||
956 | 927 | +{ | ||
957 | 928 | + GObject *bar; | ||
958 | 929 | + bar = g_object_new (GVC_TYPE_BALANCE_BAR, | ||
959 | 930 | + "balance-type", btype, NULL); | ||
960 | 931 | + | ||
961 | 932 | + return GTK_WIDGET (bar); | ||
962 | 933 | +} | ||
963 | 934 | Index: gnome-control-center-3.6.2/panels/sound-nua/gvc-balance-bar.h | ||
964 | 935 | =================================================================== | ||
965 | 936 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
966 | 937 | +++ gnome-control-center-3.6.2/panels/sound-nua/gvc-balance-bar.h 2012-11-13 16:25:40.873717987 +0100 | ||
967 | 938 | @@ -0,0 +1,70 @@ | ||
968 | 939 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
969 | 940 | + * | ||
970 | 941 | + * Copyright (C) 2008 Red Hat, Inc. | ||
971 | 942 | + * | ||
972 | 943 | + * This program is free software; you can redistribute it and/or modify | ||
973 | 944 | + * it under the terms of the GNU General Public License as published by | ||
974 | 945 | + * the Free Software Foundation; either version 2 of the License, or | ||
975 | 946 | + * (at your option) any later version. | ||
976 | 947 | + * | ||
977 | 948 | + * This program is distributed in the hope that it will be useful, | ||
978 | 949 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
979 | 950 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
980 | 951 | + * GNU General Public License for more details. | ||
981 | 952 | + * | ||
982 | 953 | + * You should have received a copy of the GNU General Public License | ||
983 | 954 | + * along with this program; if not, write to the Free Software | ||
984 | 955 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
985 | 956 | + * | ||
986 | 957 | + */ | ||
987 | 958 | + | ||
988 | 959 | +#ifndef __GVC_BALANCE_BAR_H | ||
989 | 960 | +#define __GVC_BALANCE_BAR_H | ||
990 | 961 | + | ||
991 | 962 | +#include <glib-object.h> | ||
992 | 963 | + | ||
993 | 964 | +#include "gvc-channel-map.h" | ||
994 | 965 | + | ||
995 | 966 | +G_BEGIN_DECLS | ||
996 | 967 | + | ||
997 | 968 | +#define GVC_TYPE_BALANCE_BAR (gvc_balance_bar_get_type ()) | ||
998 | 969 | +#define GVC_BALANCE_BAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_BALANCE_BAR, GvcBalanceBar)) | ||
999 | 970 | +#define GVC_BALANCE_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_BALANCE_BAR, GvcBalanceBarClass)) | ||
1000 | 971 | +#define GVC_IS_BALANCE_BAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_BALANCE_BAR)) | ||
1001 | 972 | +#define GVC_IS_BALANCE_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_BALANCE_BAR)) | ||
1002 | 973 | +#define GVC_BALANCE_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_BALANCE_BAR, GvcBalanceBarClass)) | ||
1003 | 974 | + | ||
1004 | 975 | +typedef enum { | ||
1005 | 976 | + BALANCE_TYPE_RL, | ||
1006 | 977 | + BALANCE_TYPE_FR, | ||
1007 | 978 | + BALANCE_TYPE_LFE, | ||
1008 | 979 | +} GvcBalanceType; | ||
1009 | 980 | + | ||
1010 | 981 | +#define NUM_BALANCE_TYPES BALANCE_TYPE_LFE + 1 | ||
1011 | 982 | + | ||
1012 | 983 | +typedef struct GvcBalanceBarPrivate GvcBalanceBarPrivate; | ||
1013 | 984 | + | ||
1014 | 985 | +typedef struct | ||
1015 | 986 | +{ | ||
1016 | 987 | + GtkHBox parent; | ||
1017 | 988 | + GvcBalanceBarPrivate *priv; | ||
1018 | 989 | +} GvcBalanceBar; | ||
1019 | 990 | + | ||
1020 | 991 | +typedef struct | ||
1021 | 992 | +{ | ||
1022 | 993 | + GtkHBoxClass parent_class; | ||
1023 | 994 | +} GvcBalanceBarClass; | ||
1024 | 995 | + | ||
1025 | 996 | +GType gvc_balance_bar_get_type (void); | ||
1026 | 997 | +GtkWidget * gvc_balance_bar_new (GvcBalanceType btype); | ||
1027 | 998 | + | ||
1028 | 999 | +void gvc_balance_bar_set_size_group (GvcBalanceBar *bar, | ||
1029 | 1000 | + GtkSizeGroup *group, | ||
1030 | 1001 | + gboolean symmetric); | ||
1031 | 1002 | + | ||
1032 | 1003 | +void gvc_balance_bar_set_map (GvcBalanceBar *self, | ||
1033 | 1004 | + const GvcChannelMap *channel_map); | ||
1034 | 1005 | + | ||
1035 | 1006 | +G_END_DECLS | ||
1036 | 1007 | + | ||
1037 | 1008 | +#endif /* __GVC_BALANCE_BAR_H */ | ||
1038 | 1009 | Index: gnome-control-center-3.6.2/panels/sound-nua/gvc-mixer-dialog.c | ||
1039 | 1010 | =================================================================== | ||
1040 | 1011 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
1041 | 1012 | +++ gnome-control-center-3.6.2/panels/sound-nua/gvc-mixer-dialog.c 2012-11-13 16:26:26.245717312 +0100 | ||
1042 | 1013 | @@ -0,0 +1,2187 @@ | ||
1043 | 1014 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
1044 | 1015 | + * | ||
1045 | 1016 | + * Copyright (C) 2008 William Jon McCann | ||
1046 | 1017 | + * Copyright (C) 2012 Conor Curran | ||
1047 | 1018 | + * | ||
1048 | 1019 | + * This program is free software; you can redistribute it and/or modify | ||
1049 | 1020 | + * it under the terms of the GNU General Public License as published by | ||
1050 | 1021 | + * the Free Software Foundation; either version 2 of the License, or | ||
1051 | 1022 | + * (at your option) any later version. | ||
1052 | 1023 | + * | ||
1053 | 1024 | + * This program is distributed in the hope that it will be useful, | ||
1054 | 1025 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1055 | 1026 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1056 | 1027 | + * GNU General Public License for more details. | ||
1057 | 1028 | + * | ||
1058 | 1029 | + * You should have received a copy of the GNU General Public License | ||
1059 | 1030 | + * along with this program; if not, write to the Free Software | ||
1060 | 1031 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
1061 | 1032 | + * | ||
1062 | 1033 | + */ | ||
1063 | 1034 | + | ||
1064 | 1035 | +#include "config.h" | ||
1065 | 1036 | + | ||
1066 | 1037 | +#include <stdlib.h> | ||
1067 | 1038 | +#include <stdio.h> | ||
1068 | 1039 | +#include <unistd.h> | ||
1069 | 1040 | +#include <math.h> | ||
1070 | 1041 | + | ||
1071 | 1042 | +#include <glib.h> | ||
1072 | 1043 | +#include <glib/gi18n-lib.h> | ||
1073 | 1044 | +#include <gdk/gdkkeysyms.h> | ||
1074 | 1045 | +#include <gtk/gtk.h> | ||
1075 | 1046 | +#include <pulse/pulseaudio.h> | ||
1076 | 1047 | + | ||
1077 | 1048 | + | ||
1078 | 1049 | +#include "gvc-channel-bar.h" | ||
1079 | 1050 | +#include "gvc-balance-bar.h" | ||
1080 | 1051 | +#include "gvc-combo-box.h" | ||
1081 | 1052 | +#include "gvc-mixer-control.h" | ||
1082 | 1053 | +#include "gvc-mixer-card.h" | ||
1083 | 1054 | +#include "gvc-mixer-ui-device.h" | ||
1084 | 1055 | +#include "gvc-mixer-sink.h" | ||
1085 | 1056 | +#include "gvc-mixer-source.h" | ||
1086 | 1057 | +#include "gvc-mixer-source-output.h" | ||
1087 | 1058 | +#include "gvc-mixer-dialog.h" | ||
1088 | 1059 | +#include "gvc-sound-theme-chooser.h" | ||
1089 | 1060 | +#include "gvc-level-bar.h" | ||
1090 | 1061 | +#include "gvc-speaker-test.h" | ||
1091 | 1062 | +#include "gvc-mixer-control-private.h" | ||
1092 | 1063 | + | ||
1093 | 1064 | +#define SCALE_SIZE 128 | ||
1094 | 1065 | + | ||
1095 | 1066 | +#define GVC_MIXER_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_DIALOG, GvcMixerDialogPrivate)) | ||
1096 | 1067 | + | ||
1097 | 1068 | +struct GvcMixerDialogPrivate | ||
1098 | 1069 | +{ | ||
1099 | 1070 | + GvcMixerControl *mixer_control; | ||
1100 | 1071 | + GHashTable *bars; | ||
1101 | 1072 | + GtkWidget *notebook; | ||
1102 | 1073 | + GtkWidget *output_bar; | ||
1103 | 1074 | + GtkWidget *input_bar; | ||
1104 | 1075 | + GtkWidget *input_level_bar; | ||
1105 | 1076 | + GtkWidget *effects_bar; | ||
1106 | 1077 | + GtkWidget *output_stream_box; | ||
1107 | 1078 | + GtkWidget *sound_effects_box; | ||
1108 | 1079 | + GtkWidget *hw_box; | ||
1109 | 1080 | + GtkWidget *hw_treeview; | ||
1110 | 1081 | + GtkWidget *hw_settings_box; | ||
1111 | 1082 | + GtkWidget *hw_profile_combo; | ||
1112 | 1083 | + GtkWidget *input_box; | ||
1113 | 1084 | + GtkWidget *output_box; | ||
1114 | 1085 | + GtkWidget *applications_box; | ||
1115 | 1086 | + GtkWidget *no_apps_label; | ||
1116 | 1087 | + GtkWidget *output_treeview; | ||
1117 | 1088 | + GtkWidget *output_settings_box; | ||
1118 | 1089 | + GtkWidget *output_balance_bar; | ||
1119 | 1090 | + GtkWidget *output_fade_bar; | ||
1120 | 1091 | + GtkWidget *output_lfe_bar; | ||
1121 | 1092 | + GtkWidget *output_profile_combo; | ||
1122 | 1093 | + GtkWidget *input_profile_combo; | ||
1123 | 1094 | + GtkWidget *input_treeview; | ||
1124 | 1095 | + GtkWidget *input_settings_box; | ||
1125 | 1096 | + GtkWidget *sound_theme_chooser; | ||
1126 | 1097 | + GtkWidget *click_feedback_button; | ||
1127 | 1098 | + GtkWidget *audible_bell_button; | ||
1128 | 1099 | + GtkSizeGroup *size_group; | ||
1129 | 1100 | + GtkWidget *selected_output_label; | ||
1130 | 1101 | + GtkWidget *selected_input_label; | ||
1131 | 1102 | + GtkWidget *test_output_button; | ||
1132 | 1103 | + GSettings *indicator_settings; | ||
1133 | 1104 | + | ||
1134 | 1105 | + gdouble last_input_peak; | ||
1135 | 1106 | + guint num_apps; | ||
1136 | 1107 | +}; | ||
1137 | 1108 | + | ||
1138 | 1109 | +enum { | ||
1139 | 1110 | + NAME_COLUMN, | ||
1140 | 1111 | + DEVICE_COLUMN, | ||
1141 | 1112 | + ACTIVE_COLUMN, | ||
1142 | 1113 | + ID_COLUMN, | ||
1143 | 1114 | + SPEAKERS_COLUMN, | ||
1144 | 1115 | + ICON_COLUMN, | ||
1145 | 1116 | + NUM_COLUMNS | ||
1146 | 1117 | +}; | ||
1147 | 1118 | + | ||
1148 | 1119 | +enum { | ||
1149 | 1120 | + HW_ID_COLUMN, | ||
1150 | 1121 | + HW_ICON_COLUMN, | ||
1151 | 1122 | + HW_NAME_COLUMN, | ||
1152 | 1123 | + HW_STATUS_COLUMN, | ||
1153 | 1124 | + HW_PROFILE_COLUMN, | ||
1154 | 1125 | + HW_PROFILE_HUMAN_COLUMN, | ||
1155 | 1126 | + HW_SENSITIVE_COLUMN, | ||
1156 | 1127 | + HW_NUM_COLUMNS | ||
1157 | 1128 | +}; | ||
1158 | 1129 | + | ||
1159 | 1130 | +enum | ||
1160 | 1131 | +{ | ||
1161 | 1132 | + PROP_0, | ||
1162 | 1133 | + PROP_MIXER_CONTROL | ||
1163 | 1134 | +}; | ||
1164 | 1135 | + | ||
1165 | 1136 | +static void gvc_mixer_dialog_class_init (GvcMixerDialogClass *klass); | ||
1166 | 1137 | +static void gvc_mixer_dialog_init (GvcMixerDialog *mixer_dialog); | ||
1167 | 1138 | +static void gvc_mixer_dialog_finalize (GObject *object); | ||
1168 | 1139 | + | ||
1169 | 1140 | +static void bar_set_stream (GvcMixerDialog *dialog, | ||
1170 | 1141 | + GtkWidget *bar, | ||
1171 | 1142 | + GvcMixerStream *stream); | ||
1172 | 1143 | + | ||
1173 | 1144 | +static void on_adjustment_value_changed (GtkAdjustment *adjustment, | ||
1174 | 1145 | + GvcMixerDialog *dialog); | ||
1175 | 1146 | +static void on_control_output_added (GvcMixerControl *control, | ||
1176 | 1147 | + guint id, | ||
1177 | 1148 | + GvcMixerDialog *dialog); | ||
1178 | 1149 | +static void on_control_active_output_update (GvcMixerControl *control, | ||
1179 | 1150 | + guint id, | ||
1180 | 1151 | + GvcMixerDialog *dialog); | ||
1181 | 1152 | + | ||
1182 | 1153 | +static void on_control_active_input_update (GvcMixerControl *control, | ||
1183 | 1154 | + guint id, | ||
1184 | 1155 | + GvcMixerDialog *dialog); | ||
1185 | 1156 | + | ||
1186 | 1157 | +G_DEFINE_TYPE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_VBOX) | ||
1187 | 1158 | + | ||
1188 | 1159 | + | ||
1189 | 1160 | +static void | ||
1190 | 1161 | +update_description (GvcMixerDialog *dialog, | ||
1191 | 1162 | + guint column, | ||
1192 | 1163 | + const char *value, | ||
1193 | 1164 | + GvcMixerStream *stream) | ||
1194 | 1165 | +{ | ||
1195 | 1166 | + GtkTreeModel *model; | ||
1196 | 1167 | + GtkTreeIter iter; | ||
1197 | 1168 | + guint id; | ||
1198 | 1169 | + | ||
1199 | 1170 | + if (GVC_IS_MIXER_SOURCE (stream)) | ||
1200 | 1171 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview)); | ||
1201 | 1172 | + else if (GVC_IS_MIXER_SINK (stream)) | ||
1202 | 1173 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); | ||
1203 | 1174 | + else | ||
1204 | 1175 | + g_assert_not_reached (); | ||
1205 | 1176 | + | ||
1206 | 1177 | + if (gtk_tree_model_get_iter_first (model, &iter) == FALSE){ | ||
1207 | 1178 | + g_warning ("The tree is empty => Cannot update the description"); | ||
1208 | 1179 | + return; | ||
1209 | 1180 | + } | ||
1210 | 1181 | + | ||
1211 | 1182 | + id = gvc_mixer_stream_get_id (stream); | ||
1212 | 1183 | + do { | ||
1213 | 1184 | + guint current_id; | ||
1214 | 1185 | + | ||
1215 | 1186 | + gtk_tree_model_get (model, &iter, | ||
1216 | 1187 | + ID_COLUMN, ¤t_id, | ||
1217 | 1188 | + -1); | ||
1218 | 1189 | + if (id != current_id) | ||
1219 | 1190 | + continue; | ||
1220 | 1191 | + | ||
1221 | 1192 | + gtk_list_store_set (GTK_LIST_STORE (model), | ||
1222 | 1193 | + &iter, | ||
1223 | 1194 | + column, value, | ||
1224 | 1195 | + -1); | ||
1225 | 1196 | + break; | ||
1226 | 1197 | + } while (gtk_tree_model_iter_next (model, &iter)); | ||
1227 | 1198 | +} | ||
1228 | 1199 | + | ||
1229 | 1200 | +static void | ||
1230 | 1201 | +profile_selection_changed (GvcComboBox *combo_box, | ||
1231 | 1202 | + const char *profile, | ||
1232 | 1203 | + GvcMixerDialog *dialog) | ||
1233 | 1204 | +{ | ||
1234 | 1205 | + g_debug ("profile_selection_changed - %s", profile); | ||
1235 | 1206 | + GvcMixerUIDevice *out; | ||
1236 | 1207 | + out = g_object_get_data (G_OBJECT (combo_box), "uidevice"); | ||
1237 | 1208 | + | ||
1238 | 1209 | + if (out == NULL) { | ||
1239 | 1210 | + g_warning ("Could not find Output for profile combo box"); | ||
1240 | 1211 | + return; | ||
1241 | 1212 | + } | ||
1242 | 1213 | + | ||
1243 | 1214 | + g_debug (" \n on profile selection changed on output with \n description %s \n origin %s \n id %i \n \n", | ||
1244 | 1215 | + gvc_mixer_ui_device_get_description (out), | ||
1245 | 1216 | + gvc_mixer_ui_device_get_origin (out), | ||
1246 | 1217 | + gvc_mixer_ui_device_get_id (out)); | ||
1247 | 1218 | + | ||
1248 | 1219 | + if (gvc_mixer_control_change_profile_on_selected_device (dialog->priv->mixer_control, out, profile) == FALSE) { | ||
1249 | 1220 | + g_warning ("Could not change profile on device %s", | ||
1250 | 1221 | + gvc_mixer_ui_device_get_description (out)); | ||
1251 | 1222 | + } | ||
1252 | 1223 | +} | ||
1253 | 1224 | + | ||
1254 | 1225 | +#define DECAY_STEP .15 | ||
1255 | 1226 | + | ||
1256 | 1227 | +static void | ||
1257 | 1228 | +update_input_peak (GvcMixerDialog *dialog, | ||
1258 | 1229 | + gdouble v) | ||
1259 | 1230 | +{ | ||
1260 | 1231 | + GtkAdjustment *adj; | ||
1261 | 1232 | + | ||
1262 | 1233 | + if (dialog->priv->last_input_peak >= DECAY_STEP) { | ||
1263 | 1234 | + if (v < dialog->priv->last_input_peak - DECAY_STEP) { | ||
1264 | 1235 | + v = dialog->priv->last_input_peak - DECAY_STEP; | ||
1265 | 1236 | + } | ||
1266 | 1237 | + } | ||
1267 | 1238 | + | ||
1268 | 1239 | + dialog->priv->last_input_peak = v; | ||
1269 | 1240 | + | ||
1270 | 1241 | + adj = gvc_level_bar_get_peak_adjustment (GVC_LEVEL_BAR (dialog->priv->input_level_bar)); | ||
1271 | 1242 | + if (v >= 0) { | ||
1272 | 1243 | + gtk_adjustment_set_value (adj, v); | ||
1273 | 1244 | + } else { | ||
1274 | 1245 | + gtk_adjustment_set_value (adj, 0.0); | ||
1275 | 1246 | + } | ||
1276 | 1247 | +} | ||
1277 | 1248 | + | ||
1278 | 1249 | +static void | ||
1279 | 1250 | +update_input_meter (GvcMixerDialog *dialog, | ||
1280 | 1251 | + uint32_t source_index, | ||
1281 | 1252 | + uint32_t sink_input_idx, | ||
1282 | 1253 | + double v) | ||
1283 | 1254 | +{ | ||
1284 | 1255 | + update_input_peak (dialog, v); | ||
1285 | 1256 | +} | ||
1286 | 1257 | + | ||
1287 | 1258 | +static void | ||
1288 | 1259 | +on_monitor_suspended_callback (pa_stream *s, | ||
1289 | 1260 | + void *userdata) | ||
1290 | 1261 | +{ | ||
1291 | 1262 | + GvcMixerDialog *dialog; | ||
1292 | 1263 | + | ||
1293 | 1264 | + dialog = userdata; | ||
1294 | 1265 | + | ||
1295 | 1266 | + if (pa_stream_is_suspended (s)) { | ||
1296 | 1267 | + g_debug ("Stream suspended"); | ||
1297 | 1268 | + update_input_meter (dialog, | ||
1298 | 1269 | + pa_stream_get_device_index (s), | ||
1299 | 1270 | + PA_INVALID_INDEX, | ||
1300 | 1271 | + -1); | ||
1301 | 1272 | + } | ||
1302 | 1273 | +} | ||
1303 | 1274 | + | ||
1304 | 1275 | +static void | ||
1305 | 1276 | +on_monitor_read_callback (pa_stream *s, | ||
1306 | 1277 | + size_t length, | ||
1307 | 1278 | + void *userdata) | ||
1308 | 1279 | +{ | ||
1309 | 1280 | + GvcMixerDialog *dialog; | ||
1310 | 1281 | + const void *data; | ||
1311 | 1282 | + double v; | ||
1312 | 1283 | + | ||
1313 | 1284 | + dialog = userdata; | ||
1314 | 1285 | + | ||
1315 | 1286 | + if (pa_stream_peek (s, &data, &length) < 0) { | ||
1316 | 1287 | + g_warning ("Failed to read data from stream"); | ||
1317 | 1288 | + return; | ||
1318 | 1289 | + } | ||
1319 | 1290 | + | ||
1320 | 1291 | + assert (length > 0); | ||
1321 | 1292 | + assert (length % sizeof (float) == 0); | ||
1322 | 1293 | + | ||
1323 | 1294 | + v = ((const float *) data)[length / sizeof (float) -1]; | ||
1324 | 1295 | + | ||
1325 | 1296 | + pa_stream_drop (s); | ||
1326 | 1297 | + | ||
1327 | 1298 | + if (v < 0) { | ||
1328 | 1299 | + v = 0; | ||
1329 | 1300 | + } | ||
1330 | 1301 | + if (v > 1) { | ||
1331 | 1302 | + v = 1; | ||
1332 | 1303 | + } | ||
1333 | 1304 | + | ||
1334 | 1305 | + update_input_meter (dialog, | ||
1335 | 1306 | + pa_stream_get_device_index (s), | ||
1336 | 1307 | + pa_stream_get_monitor_stream (s), | ||
1337 | 1308 | + v); | ||
1338 | 1309 | +} | ||
1339 | 1310 | + | ||
1340 | 1311 | +static void | ||
1341 | 1312 | +create_monitor_stream_for_source (GvcMixerDialog *dialog, | ||
1342 | 1313 | + GvcMixerStream *stream) | ||
1343 | 1314 | +{ | ||
1344 | 1315 | + pa_stream *s; | ||
1345 | 1316 | + char t[16]; | ||
1346 | 1317 | + pa_buffer_attr attr; | ||
1347 | 1318 | + pa_sample_spec ss; | ||
1348 | 1319 | + pa_context *context; | ||
1349 | 1320 | + int res; | ||
1350 | 1321 | + pa_proplist *proplist; | ||
1351 | 1322 | + gboolean has_monitor; | ||
1352 | 1323 | + | ||
1353 | 1324 | + if (stream == NULL) { | ||
1354 | 1325 | + g_debug ("\n create_monitor_stream_for_source - stream is null - returning\n"); | ||
1355 | 1326 | + return; | ||
1356 | 1327 | + } | ||
1357 | 1328 | + has_monitor = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (stream), "has-monitor")); | ||
1358 | 1329 | + if (has_monitor != FALSE) { | ||
1359 | 1330 | + g_debug ("\n create_monitor_stream_for_source, has monitor is not false - returning \n"); | ||
1360 | 1331 | + return; | ||
1361 | 1332 | + } | ||
1362 | 1333 | + | ||
1363 | 1334 | + g_debug ("Create monitor for %u", | ||
1364 | 1335 | + gvc_mixer_stream_get_index (stream)); | ||
1365 | 1336 | + | ||
1366 | 1337 | + context = gvc_mixer_control_get_pa_context (dialog->priv->mixer_control); | ||
1367 | 1338 | + | ||
1368 | 1339 | + if (pa_context_get_server_protocol_version (context) < 13) { | ||
1369 | 1340 | + g_debug ("\n create_monitor_stream_for_source - protocol version is less 13 \n"); | ||
1370 | 1341 | + return; | ||
1371 | 1342 | + } | ||
1372 | 1343 | + | ||
1373 | 1344 | + ss.channels = 1; | ||
1374 | 1345 | + ss.format = PA_SAMPLE_FLOAT32; | ||
1375 | 1346 | + ss.rate = 25; | ||
1376 | 1347 | + | ||
1377 | 1348 | + memset (&attr, 0, sizeof (attr)); | ||
1378 | 1349 | + attr.fragsize = sizeof (float); | ||
1379 | 1350 | + attr.maxlength = (uint32_t) -1; | ||
1380 | 1351 | + | ||
1381 | 1352 | + snprintf (t, sizeof (t), "%u", gvc_mixer_stream_get_index (stream)); | ||
1382 | 1353 | + | ||
1383 | 1354 | + proplist = pa_proplist_new (); | ||
1384 | 1355 | + pa_proplist_sets (proplist, PA_PROP_APPLICATION_ID, "org.gnome.VolumeControl"); | ||
1385 | 1356 | + s = pa_stream_new_with_proplist (context, _("Peak detect"), &ss, NULL, proplist); | ||
1386 | 1357 | + pa_proplist_free (proplist); | ||
1387 | 1358 | + if (s == NULL) { | ||
1388 | 1359 | + g_warning ("Failed to create monitoring stream"); | ||
1389 | 1360 | + return; | ||
1390 | 1361 | + } | ||
1391 | 1362 | + | ||
1392 | 1363 | + pa_stream_set_read_callback (s, on_monitor_read_callback, dialog); | ||
1393 | 1364 | + pa_stream_set_suspended_callback (s, on_monitor_suspended_callback, dialog); | ||
1394 | 1365 | + | ||
1395 | 1366 | + res = pa_stream_connect_record (s, | ||
1396 | 1367 | + t, | ||
1397 | 1368 | + &attr, | ||
1398 | 1369 | + (pa_stream_flags_t) (PA_STREAM_DONT_MOVE | ||
1399 | 1370 | + |PA_STREAM_PEAK_DETECT | ||
1400 | 1371 | + |PA_STREAM_ADJUST_LATENCY)); | ||
1401 | 1372 | + if (res < 0) { | ||
1402 | 1373 | + g_warning ("Failed to connect monitoring stream"); | ||
1403 | 1374 | + pa_stream_unref (s); | ||
1404 | 1375 | + } else { | ||
1405 | 1376 | + g_object_set_data (G_OBJECT (stream), "has-monitor", GINT_TO_POINTER (TRUE)); | ||
1406 | 1377 | + g_object_set_data (G_OBJECT (dialog->priv->input_level_bar), "pa_stream", s); | ||
1407 | 1378 | + g_object_set_data (G_OBJECT (dialog->priv->input_level_bar), "stream", stream); | ||
1408 | 1379 | + } | ||
1409 | 1380 | +} | ||
1410 | 1381 | + | ||
1411 | 1382 | + | ||
1412 | 1383 | +static void | ||
1413 | 1384 | +stop_monitor_stream_for_source (GvcMixerDialog *dialog) | ||
1414 | 1385 | +{ | ||
1415 | 1386 | + pa_stream *s; | ||
1416 | 1387 | + pa_context *context; | ||
1417 | 1388 | + int res = 0; | ||
1418 | 1389 | + GvcMixerStream *stream; | ||
1419 | 1390 | + | ||
1420 | 1391 | + stream = g_object_get_data (G_OBJECT (dialog->priv->input_level_bar), "stream"); | ||
1421 | 1392 | + | ||
1422 | 1393 | + if (stream == NULL){ | ||
1423 | 1394 | + g_debug ("\n stop_monitor_stream_for_source - gvcstream is null - returning \n"); | ||
1424 | 1395 | + return; | ||
1425 | 1396 | + } | ||
1426 | 1397 | + else{ | ||
1427 | 1398 | + g_debug ("\n stop_monitor_stream_for_source - gvcstream is not null - continue \n"); | ||
1428 | 1399 | + } | ||
1429 | 1400 | + | ||
1430 | 1401 | + s = g_object_get_data (G_OBJECT (dialog->priv->input_level_bar), "pa_stream"); | ||
1431 | 1402 | + | ||
1432 | 1403 | + if (s != NULL){ | ||
1433 | 1404 | + res = pa_stream_disconnect (s); | ||
1434 | 1405 | + if (res == 0) { | ||
1435 | 1406 | + g_debug("stream has been disconnected"); | ||
1436 | 1407 | + pa_stream_unref (s); | ||
1437 | 1408 | + } | ||
1438 | 1409 | + g_object_set_data (G_OBJECT (dialog->priv->input_level_bar), "pa_stream", NULL); | ||
1439 | 1410 | + } | ||
1440 | 1411 | + | ||
1441 | 1412 | + context = gvc_mixer_control_get_pa_context (dialog->priv->mixer_control); | ||
1442 | 1413 | + | ||
1443 | 1414 | + if (pa_context_get_server_protocol_version (context) < 13) { | ||
1444 | 1415 | + return; | ||
1445 | 1416 | + } | ||
1446 | 1417 | + if (res == 0) { | ||
1447 | 1418 | + g_object_set_data (G_OBJECT (stream), "has-monitor", GINT_TO_POINTER (FALSE)); | ||
1448 | 1419 | + } | ||
1449 | 1420 | + g_debug ("Stopping monitor for %u", pa_stream_get_index (s)); | ||
1450 | 1421 | + g_object_set_data (G_OBJECT (dialog->priv->input_level_bar), "stream", NULL); | ||
1451 | 1422 | +} | ||
1452 | 1423 | + | ||
1453 | 1424 | +static void | ||
1454 | 1425 | +gvc_mixer_dialog_set_mixer_control (GvcMixerDialog *dialog, | ||
1455 | 1426 | + GvcMixerControl *control) | ||
1456 | 1427 | +{ | ||
1457 | 1428 | + g_return_if_fail (GVC_MIXER_DIALOG (dialog)); | ||
1458 | 1429 | + g_return_if_fail (GVC_IS_MIXER_CONTROL (control)); | ||
1459 | 1430 | + | ||
1460 | 1431 | + g_object_ref (control); | ||
1461 | 1432 | + | ||
1462 | 1433 | + if (dialog->priv->mixer_control != NULL) { | ||
1463 | 1434 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
1464 | 1435 | + G_CALLBACK (on_control_active_output_update), | ||
1465 | 1436 | + dialog); | ||
1466 | 1437 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
1467 | 1438 | + G_CALLBACK (on_control_active_input_update), | ||
1468 | 1439 | + dialog); | ||
1469 | 1440 | + g_object_unref (dialog->priv->mixer_control); | ||
1470 | 1441 | + } | ||
1471 | 1442 | + | ||
1472 | 1443 | + dialog->priv->mixer_control = control; | ||
1473 | 1444 | + | ||
1474 | 1445 | + g_signal_connect (dialog->priv->mixer_control, | ||
1475 | 1446 | + "active-output-update", | ||
1476 | 1447 | + G_CALLBACK (on_control_active_output_update), | ||
1477 | 1448 | + dialog); | ||
1478 | 1449 | + g_signal_connect (dialog->priv->mixer_control, | ||
1479 | 1450 | + "active-input-update", | ||
1480 | 1451 | + G_CALLBACK (on_control_active_input_update), | ||
1481 | 1452 | + dialog); | ||
1482 | 1453 | + | ||
1483 | 1454 | + g_object_notify (G_OBJECT (dialog), "mixer-control"); | ||
1484 | 1455 | +} | ||
1485 | 1456 | + | ||
1486 | 1457 | +static GvcMixerControl * | ||
1487 | 1458 | +gvc_mixer_dialog_get_mixer_control (GvcMixerDialog *dialog) | ||
1488 | 1459 | +{ | ||
1489 | 1460 | + g_return_val_if_fail (GVC_IS_MIXER_DIALOG (dialog), NULL); | ||
1490 | 1461 | + | ||
1491 | 1462 | + return dialog->priv->mixer_control; | ||
1492 | 1463 | +} | ||
1493 | 1464 | + | ||
1494 | 1465 | +static void | ||
1495 | 1466 | +gvc_mixer_dialog_set_property (GObject *object, | ||
1496 | 1467 | + guint prop_id, | ||
1497 | 1468 | + const GValue *value, | ||
1498 | 1469 | + GParamSpec *pspec) | ||
1499 | 1470 | +{ | ||
1500 | 1471 | + GvcMixerDialog *self = GVC_MIXER_DIALOG (object); | ||
1501 | 1472 | + | ||
1502 | 1473 | + switch (prop_id) { | ||
1503 | 1474 | + case PROP_MIXER_CONTROL: | ||
1504 | 1475 | + gvc_mixer_dialog_set_mixer_control (self, g_value_get_object (value)); | ||
1505 | 1476 | + break; | ||
1506 | 1477 | + default: | ||
1507 | 1478 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
1508 | 1479 | + break; | ||
1509 | 1480 | + } | ||
1510 | 1481 | +} | ||
1511 | 1482 | + | ||
1512 | 1483 | +static void | ||
1513 | 1484 | +gvc_mixer_dialog_get_property (GObject *object, | ||
1514 | 1485 | + guint prop_id, | ||
1515 | 1486 | + GValue *value, | ||
1516 | 1487 | + GParamSpec *pspec) | ||
1517 | 1488 | +{ | ||
1518 | 1489 | + GvcMixerDialog *self = GVC_MIXER_DIALOG (object); | ||
1519 | 1490 | + | ||
1520 | 1491 | + switch (prop_id) { | ||
1521 | 1492 | + case PROP_MIXER_CONTROL: | ||
1522 | 1493 | + g_value_set_object (value, gvc_mixer_dialog_get_mixer_control (self)); | ||
1523 | 1494 | + break; | ||
1524 | 1495 | + default: | ||
1525 | 1496 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
1526 | 1497 | + break; | ||
1527 | 1498 | + } | ||
1528 | 1499 | +} | ||
1529 | 1500 | + | ||
1530 | 1501 | +static void | ||
1531 | 1502 | +on_adjustment_value_changed (GtkAdjustment *adjustment, | ||
1532 | 1503 | + GvcMixerDialog *dialog) | ||
1533 | 1504 | +{ | ||
1534 | 1505 | + GvcMixerStream *stream; | ||
1535 | 1506 | + | ||
1536 | 1507 | + stream = g_object_get_data (G_OBJECT (adjustment), "gvc-mixer-dialog-stream"); | ||
1537 | 1508 | + if (stream != NULL) { | ||
1538 | 1509 | + GObject *bar; | ||
1539 | 1510 | + gdouble volume, rounded; | ||
1540 | 1511 | + char *name; | ||
1541 | 1512 | + | ||
1542 | 1513 | + volume = gtk_adjustment_get_value (adjustment); | ||
1543 | 1514 | + rounded = round (volume); | ||
1544 | 1515 | + | ||
1545 | 1516 | + bar = g_object_get_data (G_OBJECT (adjustment), "gvc-mixer-dialog-bar"); | ||
1546 | 1517 | + g_object_get (bar, "name", &name, NULL); | ||
1547 | 1518 | + g_debug ("Setting stream volume %lf (rounded: %lf) for bar '%s'", volume, rounded, name); | ||
1548 | 1519 | + g_free (name); | ||
1549 | 1520 | + | ||
1550 | 1521 | + /* FIXME would need to do that in the balance bar really... */ | ||
1551 | 1522 | + /* Make sure we do not unmute muted streams, there's a button for that */ | ||
1552 | 1523 | + if (volume == 0.0) | ||
1553 | 1524 | + gvc_mixer_stream_set_is_muted (stream, TRUE); | ||
1554 | 1525 | + /* Only push the volume if it's actually changed */ | ||
1555 | 1526 | + if (gvc_mixer_stream_set_volume(stream, (pa_volume_t) rounded) != FALSE) | ||
1556 | 1527 | + gvc_mixer_stream_push_volume (stream); | ||
1557 | 1528 | + } | ||
1558 | 1529 | +} | ||
1559 | 1530 | + | ||
1560 | 1531 | +static void | ||
1561 | 1532 | +on_bar_is_muted_notify (GObject *object, | ||
1562 | 1533 | + GParamSpec *pspec, | ||
1563 | 1534 | + GvcMixerDialog *dialog) | ||
1564 | 1535 | +{ | ||
1565 | 1536 | + gboolean is_muted; | ||
1566 | 1537 | + GvcMixerStream *stream; | ||
1567 | 1538 | + | ||
1568 | 1539 | + is_muted = gvc_channel_bar_get_is_muted (GVC_CHANNEL_BAR (object)); | ||
1569 | 1540 | + | ||
1570 | 1541 | + stream = g_object_get_data (object, "gvc-mixer-dialog-stream"); | ||
1571 | 1542 | + if (stream != NULL) { | ||
1572 | 1543 | + gvc_mixer_stream_change_is_muted (stream, is_muted); | ||
1573 | 1544 | + } else { | ||
1574 | 1545 | + char *name; | ||
1575 | 1546 | + g_object_get (object, "name", &name, NULL); | ||
1576 | 1547 | + g_warning ("Unable to find stream for bar '%s'", name); | ||
1577 | 1548 | + g_free (name); | ||
1578 | 1549 | + } | ||
1579 | 1550 | +} | ||
1580 | 1551 | + | ||
1581 | 1552 | +static GtkWidget * | ||
1582 | 1553 | +lookup_bar_for_stream (GvcMixerDialog *dialog, | ||
1583 | 1554 | + GvcMixerStream *stream) | ||
1584 | 1555 | +{ | ||
1585 | 1556 | + GtkWidget *bar; | ||
1586 | 1557 | + | ||
1587 | 1558 | + bar = g_hash_table_lookup (dialog->priv->bars, GUINT_TO_POINTER (gvc_mixer_stream_get_id (stream))); | ||
1588 | 1559 | + | ||
1589 | 1560 | + return bar; | ||
1590 | 1561 | +} | ||
1591 | 1562 | + | ||
1592 | 1563 | +// TODO | ||
1593 | 1564 | +// Do we need this ? | ||
1594 | 1565 | +// UI devices now pull description material mainly for the card ports. | ||
1595 | 1566 | +// Therefore the need for stream description dynamic changes more than ever seems unneccessary. | ||
1596 | 1567 | +static void | ||
1597 | 1568 | +on_stream_description_notify (GvcMixerStream *stream, | ||
1598 | 1569 | + GParamSpec *pspec, | ||
1599 | 1570 | + GvcMixerDialog *dialog) | ||
1600 | 1571 | +{ | ||
1601 | 1572 | + update_description (dialog, NAME_COLUMN, | ||
1602 | 1573 | + gvc_mixer_stream_get_description (stream), | ||
1603 | 1574 | + stream); | ||
1604 | 1575 | +} | ||
1605 | 1576 | + | ||
1606 | 1577 | +static void | ||
1607 | 1578 | +on_stream_volume_notify (GObject *object, | ||
1608 | 1579 | + GParamSpec *pspec, | ||
1609 | 1580 | + GvcMixerDialog *dialog) | ||
1610 | 1581 | +{ | ||
1611 | 1582 | + GvcMixerStream *stream; | ||
1612 | 1583 | + GtkWidget *bar; | ||
1613 | 1584 | + GtkAdjustment *adj; | ||
1614 | 1585 | + stream = GVC_MIXER_STREAM (object); | ||
1615 | 1586 | + | ||
1616 | 1587 | + bar = lookup_bar_for_stream (dialog, stream); | ||
1617 | 1588 | + | ||
1618 | 1589 | + if (bar == NULL) { | ||
1619 | 1590 | + if (stream == gvc_mixer_control_get_default_sink(dialog->priv->mixer_control)) { | ||
1620 | 1591 | + bar = dialog->priv->output_bar; | ||
1621 | 1592 | + } | ||
1622 | 1593 | + else if(stream == gvc_mixer_control_get_default_source(dialog->priv->mixer_control)) { | ||
1623 | 1594 | + bar = dialog->priv->input_bar; | ||
1624 | 1595 | + } | ||
1625 | 1596 | + else{ | ||
1626 | 1597 | + g_warning ("Unable to find bar for stream %s in on_stream_volume_notify()", | ||
1627 | 1598 | + gvc_mixer_stream_get_name (stream)); | ||
1628 | 1599 | + return; | ||
1629 | 1600 | + } | ||
1630 | 1601 | + } | ||
1631 | 1602 | + | ||
1632 | 1603 | + adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (bar))); | ||
1633 | 1604 | + | ||
1634 | 1605 | + g_signal_handlers_block_by_func (adj, | ||
1635 | 1606 | + on_adjustment_value_changed, | ||
1636 | 1607 | + dialog); | ||
1637 | 1608 | + | ||
1638 | 1609 | + gtk_adjustment_set_value (adj, | ||
1639 | 1610 | + gvc_mixer_stream_get_volume (stream)); | ||
1640 | 1611 | + | ||
1641 | 1612 | + g_signal_handlers_unblock_by_func (adj, | ||
1642 | 1613 | + on_adjustment_value_changed, | ||
1643 | 1614 | + dialog); | ||
1644 | 1615 | +} | ||
1645 | 1616 | + | ||
1646 | 1617 | +static void | ||
1647 | 1618 | +on_stream_is_muted_notify (GObject *object, | ||
1648 | 1619 | + GParamSpec *pspec, | ||
1649 | 1620 | + GvcMixerDialog *dialog) | ||
1650 | 1621 | +{ | ||
1651 | 1622 | + GvcMixerStream *stream; | ||
1652 | 1623 | + GtkWidget *bar; | ||
1653 | 1624 | + gboolean is_muted; | ||
1654 | 1625 | + | ||
1655 | 1626 | + stream = GVC_MIXER_STREAM (object); | ||
1656 | 1627 | + | ||
1657 | 1628 | + bar = lookup_bar_for_stream (dialog, stream); | ||
1658 | 1629 | + | ||
1659 | 1630 | + if (bar == NULL) { | ||
1660 | 1631 | + if (stream == gvc_mixer_control_get_default_sink(dialog->priv->mixer_control)) { | ||
1661 | 1632 | + bar = dialog->priv->output_bar; | ||
1662 | 1633 | + } | ||
1663 | 1634 | + else if(stream == gvc_mixer_control_get_default_source(dialog->priv->mixer_control)) { | ||
1664 | 1635 | + bar = dialog->priv->input_bar; | ||
1665 | 1636 | + } | ||
1666 | 1637 | + else{ | ||
1667 | 1638 | + g_warning ("Unable to find bar for stream %s in on_stream_muted_notify()", | ||
1668 | 1639 | + gvc_mixer_stream_get_name (stream)); | ||
1669 | 1640 | + return; | ||
1670 | 1641 | + } | ||
1671 | 1642 | + } | ||
1672 | 1643 | + | ||
1673 | 1644 | + | ||
1674 | 1645 | + is_muted = gvc_mixer_stream_get_is_muted (stream); | ||
1675 | 1646 | + gvc_channel_bar_set_is_muted (GVC_CHANNEL_BAR (bar), | ||
1676 | 1647 | + is_muted); | ||
1677 | 1648 | + | ||
1678 | 1649 | + if (stream == gvc_mixer_control_get_default_sink (dialog->priv->mixer_control)) { | ||
1679 | 1650 | + gtk_widget_set_sensitive (dialog->priv->applications_box, | ||
1680 | 1651 | + !is_muted); | ||
1681 | 1652 | + } | ||
1682 | 1653 | + | ||
1683 | 1654 | +} | ||
1684 | 1655 | + | ||
1685 | 1656 | +static void | ||
1686 | 1657 | +save_bar_for_stream (GvcMixerDialog *dialog, | ||
1687 | 1658 | + GvcMixerStream *stream, | ||
1688 | 1659 | + GtkWidget *bar) | ||
1689 | 1660 | +{ | ||
1690 | 1661 | + g_debug ("\n saving bar for stream %s", | ||
1691 | 1662 | + gvc_mixer_stream_get_name (stream)); | ||
1692 | 1663 | + g_hash_table_insert (dialog->priv->bars, | ||
1693 | 1664 | + GUINT_TO_POINTER (gvc_mixer_stream_get_id (stream)), | ||
1694 | 1665 | + bar); | ||
1695 | 1666 | +} | ||
1696 | 1667 | + | ||
1697 | 1668 | +static GtkWidget * | ||
1698 | 1669 | +create_bar (GvcMixerDialog *dialog, | ||
1699 | 1670 | + gboolean add_to_size_group, | ||
1700 | 1671 | + gboolean symmetric) | ||
1701 | 1672 | +{ | ||
1702 | 1673 | + GtkWidget *bar; | ||
1703 | 1674 | + | ||
1704 | 1675 | + bar = gvc_channel_bar_new (); | ||
1705 | 1676 | + gtk_widget_set_sensitive (bar, FALSE); | ||
1706 | 1677 | + if (add_to_size_group && dialog->priv->size_group != NULL) { | ||
1707 | 1678 | + gvc_channel_bar_set_size_group (GVC_CHANNEL_BAR (bar), | ||
1708 | 1679 | + dialog->priv->size_group, | ||
1709 | 1680 | + symmetric); | ||
1710 | 1681 | + } | ||
1711 | 1682 | + gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (bar), | ||
1712 | 1683 | + GTK_ORIENTATION_HORIZONTAL); | ||
1713 | 1684 | + gvc_channel_bar_set_show_mute (GVC_CHANNEL_BAR (bar), | ||
1714 | 1685 | + TRUE); | ||
1715 | 1686 | + g_signal_connect (bar, | ||
1716 | 1687 | + "notify::is-muted", | ||
1717 | 1688 | + G_CALLBACK (on_bar_is_muted_notify), | ||
1718 | 1689 | + dialog); | ||
1719 | 1690 | + return bar; | ||
1720 | 1691 | +} | ||
1721 | 1692 | + | ||
1722 | 1693 | +static GtkWidget * | ||
1723 | 1694 | +create_app_bar (GvcMixerDialog *dialog, | ||
1724 | 1695 | + const char *name, | ||
1725 | 1696 | + const char *icon_name) | ||
1726 | 1697 | +{ | ||
1727 | 1698 | + GtkWidget *bar; | ||
1728 | 1699 | + | ||
1729 | 1700 | + bar = create_bar (dialog, FALSE, FALSE); | ||
1730 | 1701 | + gvc_channel_bar_set_ellipsize (GVC_CHANNEL_BAR (bar), TRUE); | ||
1731 | 1702 | + gvc_channel_bar_set_icon_name (GVC_CHANNEL_BAR (bar), icon_name); | ||
1732 | 1703 | + if (name == NULL || strchr (name, '_') == NULL) { | ||
1733 | 1704 | + gvc_channel_bar_set_name (GVC_CHANNEL_BAR (bar), name); | ||
1734 | 1705 | + } else { | ||
1735 | 1706 | + char **tokens, *escaped; | ||
1736 | 1707 | + | ||
1737 | 1708 | + tokens = g_strsplit (name, "_", -1); | ||
1738 | 1709 | + escaped = g_strjoinv ("__", tokens); | ||
1739 | 1710 | + g_strfreev (tokens); | ||
1740 | 1711 | + gvc_channel_bar_set_name (GVC_CHANNEL_BAR (bar), escaped); | ||
1741 | 1712 | + g_free (escaped); | ||
1742 | 1713 | + } | ||
1743 | 1714 | + | ||
1744 | 1715 | + return bar; | ||
1745 | 1716 | +} | ||
1746 | 1717 | + | ||
1747 | 1718 | +static gint test_it = 0; | ||
1748 | 1719 | + | ||
1749 | 1720 | +/* active_input_update | ||
1750 | 1721 | + * Handle input update change from the backend (control). | ||
1751 | 1722 | + * Trust the backend whole-heartedly to deliver the correct input | ||
1752 | 1723 | + * i.e. keep it MVC. | ||
1753 | 1724 | + */ | ||
1754 | 1725 | +static void | ||
1755 | 1726 | +active_input_update (GvcMixerDialog *dialog, | ||
1756 | 1727 | + GvcMixerUIDevice *active_input) | ||
1757 | 1728 | +{ | ||
1758 | 1729 | + g_debug ("\n active_input_update %s \n", gvc_mixer_ui_device_get_description (active_input)); | ||
1759 | 1730 | + // First make sure the correct UI device is selected. | ||
1760 | 1731 | + GtkTreeModel *model; | ||
1761 | 1732 | + GtkTreeIter iter; | ||
1762 | 1733 | + | ||
1763 | 1734 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview)); | ||
1764 | 1735 | + | ||
1765 | 1736 | + if (gtk_tree_model_get_iter_first (model, &iter) == FALSE){ | ||
1766 | 1737 | + g_warning ("The tree is empty => we have no devices so cannot set the active input"); | ||
1767 | 1738 | + return; | ||
1768 | 1739 | + } | ||
1769 | 1740 | + | ||
1770 | 1741 | + do { | ||
1771 | 1742 | + gboolean is_selected = FALSE; | ||
1772 | 1743 | + gint id; | ||
1773 | 1744 | + | ||
1774 | 1745 | + gtk_tree_model_get (model, &iter, | ||
1775 | 1746 | + ID_COLUMN, &id, | ||
1776 | 1747 | + -1); | ||
1777 | 1748 | + | ||
1778 | 1749 | + is_selected = id == gvc_mixer_ui_device_get_id (active_input); | ||
1779 | 1750 | + | ||
1780 | 1751 | + gtk_list_store_set (GTK_LIST_STORE (model), | ||
1781 | 1752 | + &iter, | ||
1782 | 1753 | + ACTIVE_COLUMN, is_selected, | ||
1783 | 1754 | + -1); | ||
1784 | 1755 | + | ||
1785 | 1756 | + if (is_selected) { | ||
1786 | 1757 | + GtkTreeSelection *selection; | ||
1787 | 1758 | + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->input_treeview)); | ||
1788 | 1759 | + gtk_tree_selection_select_iter (selection, &iter); | ||
1789 | 1760 | + } | ||
1790 | 1761 | + | ||
1791 | 1762 | + }while (gtk_tree_model_iter_next (model, &iter)); | ||
1792 | 1763 | + | ||
1793 | 1764 | + | ||
1794 | 1765 | + // Not ideal but for now destroy the combo and recreate below. | ||
1795 | 1766 | + if (dialog->priv->input_profile_combo != NULL) { | ||
1796 | 1767 | + gtk_container_remove (GTK_CONTAINER (dialog->priv->input_settings_box), | ||
1797 | 1768 | + dialog->priv->input_profile_combo); | ||
1798 | 1769 | + dialog->priv->input_profile_combo = NULL; | ||
1799 | 1770 | + } | ||
1800 | 1771 | + | ||
1801 | 1772 | + GvcMixerStream *stream; | ||
1802 | 1773 | + GtkAdjustment *adj; | ||
1803 | 1774 | + | ||
1804 | 1775 | + stream = gvc_mixer_control_get_stream_from_device (dialog->priv->mixer_control, | ||
1805 | 1776 | + active_input); | ||
1806 | 1777 | + if (stream == NULL) { | ||
1807 | 1778 | + g_warning ("active_input_update - couldn't find a stream from the supposed active input"); | ||
1808 | 1779 | + gtk_widget_set_sensitive (dialog->priv->input_bar, | ||
1809 | 1780 | + FALSE); | ||
1810 | 1781 | + return; | ||
1811 | 1782 | + } | ||
1812 | 1783 | + | ||
1813 | 1784 | + // Set the label accordingly | ||
1814 | 1785 | + adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (dialog->priv->input_bar))); | ||
1815 | 1786 | + g_signal_handlers_disconnect_by_func(adj, on_adjustment_value_changed, dialog); | ||
1816 | 1787 | + | ||
1817 | 1788 | + gtk_label_set_label (GTK_LABEL(dialog->priv->selected_input_label), | ||
1818 | 1789 | + g_strdup_printf(_("Settings for %s"), | ||
1819 | 1790 | + gvc_mixer_ui_device_get_description (active_input))); | ||
1820 | 1791 | + | ||
1821 | 1792 | + gvc_channel_bar_set_base_volume (GVC_CHANNEL_BAR (dialog->priv->input_bar), | ||
1822 | 1793 | + gvc_mixer_stream_get_base_volume (stream)); | ||
1823 | 1794 | + gvc_channel_bar_set_is_amplified (GVC_CHANNEL_BAR (dialog->priv->input_bar), | ||
1824 | 1795 | + gvc_mixer_stream_get_can_decibel (stream)); | ||
1825 | 1796 | + /* Update the adjustment in case the previous bar wasn't decibel | ||
1826 | 1797 | + * capable, and we clipped it */ | ||
1827 | 1798 | + adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (dialog->priv->input_bar))); | ||
1828 | 1799 | + gtk_adjustment_set_value (adj, | ||
1829 | 1800 | + gvc_mixer_stream_get_volume (stream)); | ||
1830 | 1801 | + | ||
1831 | 1802 | + stop_monitor_stream_for_source (dialog); | ||
1832 | 1803 | + //if (test_it < 6){ | ||
1833 | 1804 | + create_monitor_stream_for_source (dialog, stream); | ||
1834 | 1805 | + test_it += 1; | ||
1835 | 1806 | + //} | ||
1836 | 1807 | + bar_set_stream (dialog, dialog->priv->input_bar, stream); | ||
1837 | 1808 | + // remove any previous stream that might have been pointed at | ||
1838 | 1809 | + // the static input bar and connect new signals from new stream. | ||
1839 | 1810 | + | ||
1840 | 1811 | + const GList* profiles = gvc_mixer_ui_device_get_profiles (active_input); | ||
1841 | 1812 | + | ||
1842 | 1813 | + if (profiles != NULL && !gvc_mixer_ui_device_should_profiles_be_hidden (active_input)){ | ||
1843 | 1814 | + const gchar *active_profile; | ||
1844 | 1815 | + dialog->priv->input_profile_combo = gvc_combo_box_new (_("Mode:")); | ||
1845 | 1816 | + gvc_combo_box_set_profiles (GVC_COMBO_BOX (dialog->priv->input_profile_combo), | ||
1846 | 1817 | + profiles); | ||
1847 | 1818 | + | ||
1848 | 1819 | + active_profile = gvc_mixer_ui_device_get_active_profile (active_input); | ||
1849 | 1820 | + if (active_profile) | ||
1850 | 1821 | + gvc_combo_box_set_active (GVC_COMBO_BOX (dialog->priv->input_profile_combo), active_profile); | ||
1851 | 1822 | + | ||
1852 | 1823 | + g_object_set_data (G_OBJECT (dialog->priv->input_profile_combo), | ||
1853 | 1824 | + "uidevice", | ||
1854 | 1825 | + active_input); | ||
1855 | 1826 | + | ||
1856 | 1827 | + g_signal_connect (G_OBJECT (dialog->priv->input_profile_combo), "changed", | ||
1857 | 1828 | + G_CALLBACK (profile_selection_changed), dialog); | ||
1858 | 1829 | + | ||
1859 | 1830 | + gtk_box_pack_start (GTK_BOX (dialog->priv->input_settings_box), | ||
1860 | 1831 | + dialog->priv->input_profile_combo, | ||
1861 | 1832 | + TRUE, FALSE, 0); | ||
1862 | 1833 | + | ||
1863 | 1834 | + if (dialog->priv->size_group != NULL) { | ||
1864 | 1835 | + gvc_combo_box_set_size_group (GVC_COMBO_BOX (dialog->priv->input_profile_combo), | ||
1865 | 1836 | + dialog->priv->size_group, FALSE); | ||
1866 | 1837 | + } | ||
1867 | 1838 | + gtk_widget_show (dialog->priv->input_profile_combo); | ||
1868 | 1839 | + } | ||
1869 | 1840 | +} | ||
1870 | 1841 | + | ||
1871 | 1842 | +/* active_output_update | ||
1872 | 1843 | + * Handle output update change from the backend (control). | ||
1873 | 1844 | + * Trust the backend whole heartedly to deliver the correct output | ||
1874 | 1845 | + * i.e. keep it MVC. | ||
1875 | 1846 | + */ | ||
1876 | 1847 | +static void | ||
1877 | 1848 | +active_output_update (GvcMixerDialog *dialog, | ||
1878 | 1849 | + GvcMixerUIDevice *active_output) | ||
1879 | 1850 | +{ | ||
1880 | 1851 | + // First make sure the correct UI device is selected. | ||
1881 | 1852 | + GtkTreeModel *model; | ||
1882 | 1853 | + GtkTreeIter iter; | ||
1883 | 1854 | + g_debug ("\n\n active output update - device id = %i \n\n", | ||
1884 | 1855 | + gvc_mixer_ui_device_get_id (active_output)); | ||
1885 | 1856 | + | ||
1886 | 1857 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); | ||
1887 | 1858 | + | ||
1888 | 1859 | + if (gtk_tree_model_get_iter_first (model, &iter) == FALSE){ | ||
1889 | 1860 | + g_warning ("The tree is empty => we have no devices in the tree => cannot set the active output"); | ||
1890 | 1861 | + return; | ||
1891 | 1862 | + } | ||
1892 | 1863 | + | ||
1893 | 1864 | + do { | ||
1894 | 1865 | + gboolean is_selected; | ||
1895 | 1866 | + gint id; | ||
1896 | 1867 | + | ||
1897 | 1868 | + gtk_tree_model_get (model, &iter, | ||
1898 | 1869 | + ID_COLUMN, &id, | ||
1899 | 1870 | + ACTIVE_COLUMN, &is_selected, | ||
1900 | 1871 | + -1); | ||
1901 | 1872 | + | ||
1902 | 1873 | + if (is_selected && id == gvc_mixer_ui_device_get_id (active_output)) { | ||
1903 | 1874 | + g_debug ("\n\n unneccessary active output update unless it was a profile change on the same device ? \n\n"); | ||
1904 | 1875 | + } | ||
1905 | 1876 | + | ||
1906 | 1877 | + is_selected = id == gvc_mixer_ui_device_get_id (active_output); | ||
1907 | 1878 | + | ||
1908 | 1879 | + gtk_list_store_set (GTK_LIST_STORE (model), | ||
1909 | 1880 | + &iter, | ||
1910 | 1881 | + ACTIVE_COLUMN, is_selected, | ||
1911 | 1882 | + -1); | ||
1912 | 1883 | + | ||
1913 | 1884 | + if (is_selected) { | ||
1914 | 1885 | + GtkTreeSelection *selection; | ||
1915 | 1886 | + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->output_treeview)); | ||
1916 | 1887 | + gtk_tree_selection_select_iter (selection, &iter); | ||
1917 | 1888 | + } | ||
1918 | 1889 | + | ||
1919 | 1890 | + }while (gtk_tree_model_iter_next (model, &iter)); | ||
1920 | 1891 | + | ||
1921 | 1892 | + // Not ideal but for now destroy the combo and recreate below. | ||
1922 | 1893 | + if (dialog->priv->output_profile_combo != NULL) { | ||
1923 | 1894 | + gtk_container_remove (GTK_CONTAINER (dialog->priv->output_settings_box), | ||
1924 | 1895 | + dialog->priv->output_profile_combo); | ||
1925 | 1896 | + dialog->priv->output_profile_combo = NULL; | ||
1926 | 1897 | + } | ||
1927 | 1898 | + | ||
1928 | 1899 | + GvcMixerStream *stream; | ||
1929 | 1900 | + const GvcChannelMap *map; | ||
1930 | 1901 | + GtkAdjustment *adj; | ||
1931 | 1902 | + | ||
1932 | 1903 | + stream = gvc_mixer_control_get_stream_from_device (dialog->priv->mixer_control, | ||
1933 | 1904 | + active_output); | ||
1934 | 1905 | + | ||
1935 | 1906 | + if (stream == NULL) { | ||
1936 | 1907 | + g_warning ("active_output_update - couldn't find a stream from the supposed active output"); | ||
1937 | 1908 | + return; | ||
1938 | 1909 | + } | ||
1939 | 1910 | + | ||
1940 | 1911 | + gboolean is_muted = gvc_mixer_stream_get_is_muted (stream); | ||
1941 | 1912 | + gtk_widget_set_sensitive (dialog->priv->applications_box, | ||
1942 | 1913 | + !is_muted); | ||
1943 | 1914 | + adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (dialog->priv->output_bar))); | ||
1944 | 1915 | + g_signal_handlers_disconnect_by_func(adj, on_adjustment_value_changed, dialog); | ||
1945 | 1916 | + | ||
1946 | 1917 | + bar_set_stream (dialog, dialog->priv->output_bar, stream); | ||
1947 | 1918 | + gvc_channel_bar_set_base_volume (GVC_CHANNEL_BAR (dialog->priv->output_bar), | ||
1948 | 1919 | + gvc_mixer_stream_get_base_volume (stream)); | ||
1949 | 1920 | + gvc_channel_bar_set_is_amplified (GVC_CHANNEL_BAR (dialog->priv->output_bar), | ||
1950 | 1921 | + gvc_mixer_stream_get_can_decibel (stream)); | ||
1951 | 1922 | + /* Update the adjustment in case the previous bar wasn't decibel | ||
1952 | 1923 | + * capable, and we clipped it */ | ||
1953 | 1924 | + adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (dialog->priv->output_bar))); | ||
1954 | 1925 | + gtk_adjustment_set_value (adj, | ||
1955 | 1926 | + gvc_mixer_stream_get_volume (stream)); | ||
1956 | 1927 | + | ||
1957 | 1928 | + map = gvc_mixer_stream_get_channel_map (stream); | ||
1958 | 1929 | + | ||
1959 | 1930 | + if (map == NULL) { | ||
1960 | 1931 | + g_warning ("Active output stream has no channel map"); | ||
1961 | 1932 | + gtk_widget_set_sensitive (dialog->priv->output_bar, FALSE); | ||
1962 | 1933 | + gtk_widget_set_sensitive (dialog->priv->output_balance_bar, FALSE); | ||
1963 | 1934 | + gtk_widget_set_sensitive (dialog->priv->output_lfe_bar, FALSE); | ||
1964 | 1935 | + gtk_widget_set_sensitive (dialog->priv->output_fade_bar, FALSE); | ||
1965 | 1936 | + return; | ||
1966 | 1937 | + } | ||
1967 | 1938 | + | ||
1968 | 1939 | + | ||
1969 | 1940 | + // Swap bars to the active map | ||
1970 | 1941 | + gvc_balance_bar_set_map (GVC_BALANCE_BAR (dialog->priv->output_balance_bar), | ||
1971 | 1942 | + map); | ||
1972 | 1943 | + gvc_balance_bar_set_map (GVC_BALANCE_BAR (dialog->priv->output_fade_bar), | ||
1973 | 1944 | + map); | ||
1974 | 1945 | + gvc_balance_bar_set_map (GVC_BALANCE_BAR (dialog->priv->output_lfe_bar), | ||
1975 | 1946 | + map); | ||
1976 | 1947 | + | ||
1977 | 1948 | + // Set sensitivities accordingly. | ||
1978 | 1949 | + gtk_widget_set_sensitive (dialog->priv->output_balance_bar, | ||
1979 | 1950 | + gvc_channel_map_can_balance (map)); | ||
1980 | 1951 | + gtk_widget_set_sensitive (dialog->priv->output_fade_bar, | ||
1981 | 1952 | + gvc_channel_map_can_fade (map)); | ||
1982 | 1953 | + gtk_widget_set_sensitive (dialog->priv->output_lfe_bar, | ||
1983 | 1954 | + gvc_channel_map_has_lfe (map)); | ||
1984 | 1955 | + gtk_widget_set_sensitive (dialog->priv->output_bar, | ||
1985 | 1956 | + TRUE); | ||
1986 | 1957 | + // Set the label accordingly | ||
1987 | 1958 | + gtk_label_set_label (GTK_LABEL(dialog->priv->selected_output_label), | ||
1988 | 1959 | + g_strdup_printf(_("Settings for %s"), | ||
1989 | 1960 | + gvc_mixer_ui_device_get_description (active_output))); | ||
1990 | 1961 | + g_debug ("\n active_output_update %s \n", gvc_mixer_ui_device_get_description (active_output)); | ||
1991 | 1962 | + | ||
1992 | 1963 | + GList* profiles = gvc_mixer_ui_device_get_profiles (active_output); | ||
1993 | 1964 | + | ||
1994 | 1965 | + if (profiles != NULL && !gvc_mixer_ui_device_should_profiles_be_hidden (active_output)) { | ||
1995 | 1966 | + const gchar *active_profile; | ||
1996 | 1967 | + | ||
1997 | 1968 | + dialog->priv->output_profile_combo = gvc_combo_box_new (_("Mode:")); | ||
1998 | 1969 | + gvc_combo_box_set_profiles (GVC_COMBO_BOX (dialog->priv->output_profile_combo), | ||
1999 | 1970 | + profiles); | ||
2000 | 1971 | + | ||
2001 | 1972 | + gtk_box_pack_start (GTK_BOX (dialog->priv->output_settings_box), | ||
2002 | 1973 | + dialog->priv->output_profile_combo, | ||
2003 | 1974 | + FALSE, FALSE, 3); | ||
2004 | 1975 | + | ||
2005 | 1976 | + if (dialog->priv->size_group != NULL) { | ||
2006 | 1977 | + gvc_combo_box_set_size_group (GVC_COMBO_BOX (dialog->priv->output_profile_combo), | ||
2007 | 1978 | + dialog->priv->size_group, FALSE); | ||
2008 | 1979 | + } | ||
2009 | 1980 | + | ||
2010 | 1981 | + active_profile = gvc_mixer_ui_device_get_active_profile (active_output); | ||
2011 | 1982 | + if (active_profile) | ||
2012 | 1983 | + gvc_combo_box_set_active (GVC_COMBO_BOX (dialog->priv->output_profile_combo), active_profile); | ||
2013 | 1984 | + | ||
2014 | 1985 | + | ||
2015 | 1986 | + g_object_set_data (G_OBJECT (dialog->priv->output_profile_combo), | ||
2016 | 1987 | + "uidevice", | ||
2017 | 1988 | + active_output); | ||
2018 | 1989 | + g_signal_connect (G_OBJECT (dialog->priv->output_profile_combo), "changed", | ||
2019 | 1990 | + G_CALLBACK (profile_selection_changed), dialog); | ||
2020 | 1991 | + | ||
2021 | 1992 | + gtk_widget_show (dialog->priv->output_profile_combo); | ||
2022 | 1993 | + } | ||
2023 | 1994 | + | ||
2024 | 1995 | +} | ||
2025 | 1996 | + | ||
2026 | 1997 | +static void | ||
2027 | 1998 | +bar_set_stream (GvcMixerDialog *dialog, | ||
2028 | 1999 | + GtkWidget *bar, | ||
2029 | 2000 | + GvcMixerStream *stream) | ||
2030 | 2001 | +{ | ||
2031 | 2002 | + GtkAdjustment *adj; | ||
2032 | 2003 | + | ||
2033 | 2004 | + g_assert (bar != NULL); | ||
2034 | 2005 | + | ||
2035 | 2006 | + gtk_widget_set_sensitive (bar, (stream != NULL)); | ||
2036 | 2007 | + | ||
2037 | 2008 | + adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (bar))); | ||
2038 | 2009 | + | ||
2039 | 2010 | + g_signal_handlers_disconnect_by_func (adj, on_adjustment_value_changed, dialog); | ||
2040 | 2011 | + | ||
2041 | 2012 | + g_object_set_data (G_OBJECT (bar), "gvc-mixer-dialog-stream", stream); | ||
2042 | 2013 | + g_object_set_data (G_OBJECT (adj), "gvc-mixer-dialog-stream", stream); | ||
2043 | 2014 | + g_object_set_data (G_OBJECT (adj), "gvc-mixer-dialog-bar", bar); | ||
2044 | 2015 | + | ||
2045 | 2016 | + if (stream != NULL) { | ||
2046 | 2017 | + gboolean is_muted; | ||
2047 | 2018 | + | ||
2048 | 2019 | + is_muted = gvc_mixer_stream_get_is_muted (stream); | ||
2049 | 2020 | + gvc_channel_bar_set_is_muted (GVC_CHANNEL_BAR (bar), is_muted); | ||
2050 | 2021 | + | ||
2051 | 2022 | + gtk_adjustment_set_value (adj, | ||
2052 | 2023 | + gvc_mixer_stream_get_volume (stream)); | ||
2053 | 2024 | + g_signal_connect (stream, | ||
2054 | 2025 | + "notify::is-muted", | ||
2055 | 2026 | + G_CALLBACK (on_stream_is_muted_notify), | ||
2056 | 2027 | + dialog); | ||
2057 | 2028 | + g_signal_connect (stream, | ||
2058 | 2029 | + "notify::volume", | ||
2059 | 2030 | + G_CALLBACK (on_stream_volume_notify), | ||
2060 | 2031 | + dialog); | ||
2061 | 2032 | + g_signal_connect (adj, | ||
2062 | 2033 | + "value-changed", | ||
2063 | 2034 | + G_CALLBACK (on_adjustment_value_changed), | ||
2064 | 2035 | + dialog); | ||
2065 | 2036 | + } | ||
2066 | 2037 | +} | ||
2067 | 2038 | + | ||
2068 | 2039 | +/** | ||
2069 | 2040 | +* This method handles all streams that are not an input or output | ||
2070 | 2041 | +* i.e. effects streams and application streams | ||
2071 | 2042 | +* TODO rename to truly reflect its usage. | ||
2072 | 2043 | +**/ | ||
2073 | 2044 | +static void | ||
2074 | 2045 | +add_stream (GvcMixerDialog *dialog, | ||
2075 | 2046 | + GvcMixerStream *stream) | ||
2076 | 2047 | +{ | ||
2077 | 2048 | + | ||
2078 | 2049 | + GtkWidget *bar; | ||
2079 | 2050 | + bar = NULL; | ||
2080 | 2051 | + | ||
2081 | 2052 | + if (stream == gvc_mixer_control_get_event_sink_input (dialog->priv->mixer_control)) { | ||
2082 | 2053 | + bar = dialog->priv->effects_bar; | ||
2083 | 2054 | + g_debug ("Adding effects stream"); | ||
2084 | 2055 | + } else { | ||
2085 | 2056 | + // Must be a sink/source input/output | ||
2086 | 2057 | + const char *name; | ||
2087 | 2058 | + name = gvc_mixer_stream_get_name (stream); | ||
2088 | 2059 | + g_debug ("\n Add bar for application stream : %s", | ||
2089 | 2060 | + name); | ||
2090 | 2061 | + | ||
2091 | 2062 | + bar = create_app_bar (dialog, name, | ||
2092 | 2063 | + gvc_mixer_stream_get_icon_name (stream)); | ||
2093 | 2064 | + | ||
2094 | 2065 | + gtk_box_pack_start (GTK_BOX (dialog->priv->applications_box), bar, FALSE, FALSE, 12); | ||
2095 | 2066 | + dialog->priv->num_apps++; | ||
2096 | 2067 | + gtk_widget_hide (dialog->priv->no_apps_label); | ||
2097 | 2068 | + } | ||
2098 | 2069 | + // We should have a bar by now. | ||
2099 | 2070 | + g_assert (bar != NULL); | ||
2100 | 2071 | + GvcMixerStream *old_stream; | ||
2101 | 2072 | + | ||
2102 | 2073 | + if (bar != NULL) { | ||
2103 | 2074 | + old_stream = g_object_get_data (G_OBJECT (bar), "gvc-mixer-dialog-stream"); | ||
2104 | 2075 | + if (old_stream != NULL) { | ||
2105 | 2076 | + char *name; | ||
2106 | 2077 | + g_object_get (bar, "name", &name, NULL); | ||
2107 | 2078 | + g_debug ("Disconnecting old stream '%s' from bar '%s'", | ||
2108 | 2079 | + gvc_mixer_stream_get_name (old_stream), name); | ||
2109 | 2080 | + g_free (name); | ||
2110 | 2081 | + | ||
2111 | 2082 | + g_signal_handlers_disconnect_by_func (old_stream, on_stream_is_muted_notify, dialog); | ||
2112 | 2083 | + g_signal_handlers_disconnect_by_func (old_stream, on_stream_volume_notify, dialog); | ||
2113 | 2084 | + g_print ("\n in add stream \n"); | ||
2114 | 2085 | + g_hash_table_remove (dialog->priv->bars, GUINT_TO_POINTER (gvc_mixer_stream_get_id (old_stream))); | ||
2115 | 2086 | + } | ||
2116 | 2087 | + save_bar_for_stream (dialog, stream, bar); | ||
2117 | 2088 | + bar_set_stream (dialog, bar, stream); | ||
2118 | 2089 | + gtk_widget_show (bar); | ||
2119 | 2090 | + } | ||
2120 | 2091 | +} | ||
2121 | 2092 | + | ||
2122 | 2093 | +static void | ||
2123 | 2094 | +remove_stream (GvcMixerDialog *dialog, | ||
2124 | 2095 | + guint id) | ||
2125 | 2096 | +{ | ||
2126 | 2097 | + GtkWidget *bar; | ||
2127 | 2098 | + bar = g_hash_table_lookup (dialog->priv->bars, GUINT_TO_POINTER (id)); | ||
2128 | 2099 | + if (bar != NULL) { | ||
2129 | 2100 | + g_hash_table_remove (dialog->priv->bars, GUINT_TO_POINTER (id)); | ||
2130 | 2101 | + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (bar)), | ||
2131 | 2102 | + bar); | ||
2132 | 2103 | + dialog->priv->num_apps--; | ||
2133 | 2104 | + if (dialog->priv->num_apps == 0) { | ||
2134 | 2105 | + gtk_widget_show (dialog->priv->no_apps_label); | ||
2135 | 2106 | + } | ||
2136 | 2107 | + } | ||
2137 | 2108 | + | ||
2138 | 2109 | +} | ||
2139 | 2110 | + | ||
2140 | 2111 | +static void | ||
2141 | 2112 | +on_control_stream_added (GvcMixerControl *control, | ||
2142 | 2113 | + guint id, | ||
2143 | 2114 | + GvcMixerDialog *dialog) | ||
2144 | 2115 | +{ | ||
2145 | 2116 | + GvcMixerStream *stream; | ||
2146 | 2117 | + stream = gvc_mixer_control_lookup_stream_id (control, id); | ||
2147 | 2118 | + | ||
2148 | 2119 | + if (stream == NULL) | ||
2149 | 2120 | + return; | ||
2150 | 2121 | + | ||
2151 | 2122 | + const char *app_id; | ||
2152 | 2123 | + app_id = gvc_mixer_stream_get_application_id (stream); | ||
2153 | 2124 | + | ||
2154 | 2125 | + if (stream == gvc_mixer_control_get_event_sink_input (dialog->priv->mixer_control) || (!GVC_IS_MIXER_SOURCE (stream) && | ||
2155 | 2126 | + !GVC_IS_MIXER_SINK (stream) | ||
2156 | 2127 | + && !gvc_mixer_stream_is_virtual (stream) | ||
2157 | 2128 | + && g_strcmp0 (app_id, "org.gnome.VolumeControl") != 0 | ||
2158 | 2129 | + && g_strcmp0 (app_id, "org.PulseAudio.pavucontrol") != 0)) { | ||
2159 | 2130 | + | ||
2160 | 2131 | + GtkWidget *bar; | ||
2161 | 2132 | + | ||
2162 | 2133 | + bar = g_hash_table_lookup (dialog->priv->bars, GUINT_TO_POINTER (id)); | ||
2163 | 2134 | + if (bar != NULL) { | ||
2164 | 2135 | + g_debug ("GvcMixerDialog: Stream %u already added", id); | ||
2165 | 2136 | + return; | ||
2166 | 2137 | + } | ||
2167 | 2138 | + add_stream (dialog, stream); | ||
2168 | 2139 | + } | ||
2169 | 2140 | +} | ||
2170 | 2141 | + | ||
2171 | 2142 | +static void | ||
2172 | 2143 | +on_control_stream_removed (GvcMixerControl *control, | ||
2173 | 2144 | + guint id, | ||
2174 | 2145 | + GvcMixerDialog *dialog) | ||
2175 | 2146 | +{ | ||
2176 | 2147 | + remove_stream (dialog, id); | ||
2177 | 2148 | +} | ||
2178 | 2149 | + | ||
2179 | 2150 | +static gboolean | ||
2180 | 2151 | +find_item_by_id (GtkTreeModel *model, | ||
2181 | 2152 | + guint id, | ||
2182 | 2153 | + guint column, | ||
2183 | 2154 | + GtkTreeIter *iter) | ||
2184 | 2155 | +{ | ||
2185 | 2156 | + gboolean found_item; | ||
2186 | 2157 | + | ||
2187 | 2158 | + found_item = FALSE; | ||
2188 | 2159 | + | ||
2189 | 2160 | + if (!gtk_tree_model_get_iter_first (model, iter)) { | ||
2190 | 2161 | + return FALSE; | ||
2191 | 2162 | + } | ||
2192 | 2163 | + | ||
2193 | 2164 | + do { | ||
2194 | 2165 | + guint t_id; | ||
2195 | 2166 | + | ||
2196 | 2167 | + gtk_tree_model_get (model, iter, | ||
2197 | 2168 | + column, &t_id, -1); | ||
2198 | 2169 | + | ||
2199 | 2170 | + if (id == t_id) { | ||
2200 | 2171 | + found_item = TRUE; | ||
2201 | 2172 | + } | ||
2202 | 2173 | + } while (!found_item && gtk_tree_model_iter_next (model, iter)); | ||
2203 | 2174 | + | ||
2204 | 2175 | + return found_item; | ||
2205 | 2176 | +} | ||
2206 | 2177 | + | ||
2207 | 2178 | +static void | ||
2208 | 2179 | +add_input_ui_entry (GvcMixerDialog *dialog, | ||
2209 | 2180 | + GvcMixerUIDevice *input) | ||
2210 | 2181 | +{ | ||
2211 | 2182 | + g_debug ("\n Add input ui entry with id : %u \n", | ||
2212 | 2183 | + gvc_mixer_ui_device_get_id (input)); | ||
2213 | 2184 | + | ||
2214 | 2185 | + gchar *port_name; | ||
2215 | 2186 | + gchar *origin; | ||
2216 | 2187 | + gchar *description; | ||
2217 | 2188 | + gboolean active; | ||
2218 | 2189 | + gboolean available; | ||
2219 | 2190 | + gint stream_id; | ||
2220 | 2191 | + GvcMixerCard *card; | ||
2221 | 2192 | + | ||
2222 | 2193 | + g_object_get (G_OBJECT (input), | ||
2223 | 2194 | + "stream-id", &stream_id, | ||
2224 | 2195 | + "card", &card, | ||
2225 | 2196 | + "origin", &origin, | ||
2226 | 2197 | + "description", &description, | ||
2227 | 2198 | + "port-name", &port_name, | ||
2228 | 2199 | + "port-available", &available, | ||
2229 | 2200 | + NULL); | ||
2230 | 2201 | + GtkTreeModel *model; | ||
2231 | 2202 | + GtkTreeIter iter; | ||
2232 | 2203 | + const GvcChannelMap *map; | ||
2233 | 2204 | + GIcon *icon; | ||
2234 | 2205 | + | ||
2235 | 2206 | + if (card == NULL) { | ||
2236 | 2207 | + GvcMixerStream *stream; | ||
2237 | 2208 | + g_debug ("just detected a network source"); | ||
2238 | 2209 | + stream = gvc_mixer_control_get_stream_from_device (dialog->priv->mixer_control, input); | ||
2239 | 2210 | + if (stream == NULL) { | ||
2240 | 2211 | + g_warning ("tried to add the network source but the stream was null - fail ?!"); | ||
2241 | 2212 | + g_free (port_name); | ||
2242 | 2213 | + g_free (origin); | ||
2243 | 2214 | + g_free (description); | ||
2244 | 2215 | + return; | ||
2245 | 2216 | + } | ||
2246 | 2217 | + icon = gvc_mixer_stream_get_gicon (stream); | ||
2247 | 2218 | + } | ||
2248 | 2219 | + else | ||
2249 | 2220 | + icon = gvc_mixer_card_get_gicon (card); | ||
2250 | 2221 | + | ||
2251 | 2222 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview)); | ||
2252 | 2223 | + gtk_list_store_append (GTK_LIST_STORE (model), &iter); | ||
2253 | 2224 | + | ||
2254 | 2225 | + gtk_list_store_set (GTK_LIST_STORE (model), | ||
2255 | 2226 | + &iter, | ||
2256 | 2227 | + NAME_COLUMN, description, | ||
2257 | 2228 | + DEVICE_COLUMN, origin, | ||
2258 | 2229 | + ACTIVE_COLUMN, FALSE, | ||
2259 | 2230 | + ICON_COLUMN, icon, | ||
2260 | 2231 | + ID_COLUMN, gvc_mixer_ui_device_get_id (input), | ||
2261 | 2232 | + SPEAKERS_COLUMN,origin, | ||
2262 | 2233 | + -1); | ||
2263 | 2234 | + | ||
2264 | 2235 | + if (icon != NULL) | ||
2265 | 2236 | + g_object_unref (icon); | ||
2266 | 2237 | + | ||
2267 | 2238 | + // TODO check this. | ||
2268 | 2239 | + /*g_signal_connect (output, | ||
2269 | 2240 | + "notify::description", | ||
2270 | 2241 | + G_CALLBACK (on_output_description_notify), | ||
2271 | 2242 | + dialog);*/ | ||
2272 | 2243 | + | ||
2273 | 2244 | + g_free (port_name); | ||
2274 | 2245 | + g_free (origin); | ||
2275 | 2246 | + g_free (description); | ||
2276 | 2247 | +} | ||
2277 | 2248 | + | ||
2278 | 2249 | +static void | ||
2279 | 2250 | +add_output_ui_entry (GvcMixerDialog *dialog, | ||
2280 | 2251 | + GvcMixerUIDevice *output) | ||
2281 | 2252 | +{ | ||
2282 | 2253 | + g_debug ("\n Add output ui entry with id : %u \n", | ||
2283 | 2254 | + gvc_mixer_ui_device_get_id (output)); | ||
2284 | 2255 | + | ||
2285 | 2256 | + gchar *sink_port_name; | ||
2286 | 2257 | + gchar *origin; | ||
2287 | 2258 | + gchar *description; | ||
2288 | 2259 | + gboolean active; | ||
2289 | 2260 | + gboolean available; | ||
2290 | 2261 | + gint sink_stream_id; | ||
2291 | 2262 | + GvcMixerCard *card; | ||
2292 | 2263 | + | ||
2293 | 2264 | + g_object_get (G_OBJECT (output), | ||
2294 | 2265 | + "stream-id", &sink_stream_id, | ||
2295 | 2266 | + "card", &card, | ||
2296 | 2267 | + "origin", &origin, | ||
2297 | 2268 | + "description", &description, | ||
2298 | 2269 | + "port-name", &sink_port_name, | ||
2299 | 2270 | + "port-available", &available, | ||
2300 | 2271 | + NULL); | ||
2301 | 2272 | + | ||
2302 | 2273 | + GtkTreeModel *model; | ||
2303 | 2274 | + GtkTreeIter iter; | ||
2304 | 2275 | + const GvcChannelMap *map; | ||
2305 | 2276 | + GIcon *icon; | ||
2306 | 2277 | + | ||
2307 | 2278 | + if (card == NULL) { | ||
2308 | 2279 | + g_debug ("just detected a network sink"); | ||
2309 | 2280 | + | ||
2310 | 2281 | + GvcMixerStream *stream; | ||
2311 | 2282 | + stream = gvc_mixer_control_get_stream_from_device (dialog->priv->mixer_control, output); | ||
2312 | 2283 | + if (stream == NULL) { | ||
2313 | 2284 | + g_warning ("tried to add the network sink but the stream was null - fail ?!"); | ||
2314 | 2285 | + g_free (sink_port_name); | ||
2315 | 2286 | + g_free (origin); | ||
2316 | 2287 | + g_free (description); | ||
2317 | 2288 | + return; | ||
2318 | 2289 | + } | ||
2319 | 2290 | + icon = gvc_mixer_stream_get_gicon (stream); | ||
2320 | 2291 | + } | ||
2321 | 2292 | + else | ||
2322 | 2293 | + icon = gvc_mixer_card_get_gicon (card); | ||
2323 | 2294 | + | ||
2324 | 2295 | + | ||
2325 | 2296 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); | ||
2326 | 2297 | + gtk_list_store_append (GTK_LIST_STORE (model), &iter); | ||
2327 | 2298 | + | ||
2328 | 2299 | + gtk_list_store_set (GTK_LIST_STORE (model), | ||
2329 | 2300 | + &iter, | ||
2330 | 2301 | + NAME_COLUMN, description, | ||
2331 | 2302 | + DEVICE_COLUMN, origin, | ||
2332 | 2303 | + ACTIVE_COLUMN, FALSE, | ||
2333 | 2304 | + ICON_COLUMN, icon, | ||
2334 | 2305 | + ID_COLUMN, gvc_mixer_ui_device_get_id (output), | ||
2335 | 2306 | + SPEAKERS_COLUMN,origin, | ||
2336 | 2307 | + -1); | ||
2337 | 2308 | + | ||
2338 | 2309 | + if (icon != NULL) | ||
2339 | 2310 | + g_object_unref (icon); | ||
2340 | 2311 | + | ||
2341 | 2312 | + // TODO check this. | ||
2342 | 2313 | + /*g_signal_connect (output, | ||
2343 | 2314 | + "notify::description", | ||
2344 | 2315 | + G_CALLBACK (on_output_description_notify), | ||
2345 | 2316 | + dialog);*/ | ||
2346 | 2317 | + | ||
2347 | 2318 | + g_free (sink_port_name); | ||
2348 | 2319 | + g_free (origin); | ||
2349 | 2320 | + g_free (description); | ||
2350 | 2321 | +} | ||
2351 | 2322 | + | ||
2352 | 2323 | +static void | ||
2353 | 2324 | +on_control_output_added (GvcMixerControl *control, | ||
2354 | 2325 | + guint id, | ||
2355 | 2326 | + GvcMixerDialog *dialog) | ||
2356 | 2327 | +{ | ||
2357 | 2328 | + GvcMixerUIDevice* out = NULL; | ||
2358 | 2329 | + out = gvc_mixer_control_lookup_output_id (control, id); | ||
2359 | 2330 | + | ||
2360 | 2331 | + if (out == NULL) { | ||
2361 | 2332 | + g_warning ("on_control_output_added - tried to fetch an output of id %u but got nothing", id); | ||
2362 | 2333 | + return; | ||
2363 | 2334 | + } | ||
2364 | 2335 | + | ||
2365 | 2336 | + add_output_ui_entry (dialog, out); | ||
2366 | 2337 | +} | ||
2367 | 2338 | + | ||
2368 | 2339 | +static void | ||
2369 | 2340 | +on_control_active_output_update (GvcMixerControl *control, | ||
2370 | 2341 | + guint id, | ||
2371 | 2342 | + GvcMixerDialog *dialog) | ||
2372 | 2343 | +{ | ||
2373 | 2344 | + GvcMixerUIDevice* out = NULL; | ||
2374 | 2345 | + out = gvc_mixer_control_lookup_output_id (control, id); | ||
2375 | 2346 | + | ||
2376 | 2347 | + if (out == NULL) { | ||
2377 | 2348 | + g_warning ("\n on_control_active_output_update - tried to fetch an output of id %u but got nothing", id); | ||
2378 | 2349 | + return; | ||
2379 | 2350 | + } | ||
2380 | 2351 | + active_output_update (dialog, out); | ||
2381 | 2352 | +} | ||
2382 | 2353 | + | ||
2383 | 2354 | +static void | ||
2384 | 2355 | +on_control_active_input_update (GvcMixerControl *control, | ||
2385 | 2356 | + guint id, | ||
2386 | 2357 | + GvcMixerDialog *dialog) | ||
2387 | 2358 | +{ | ||
2388 | 2359 | + GvcMixerUIDevice* in = NULL; | ||
2389 | 2360 | + in = gvc_mixer_control_lookup_input_id (control, id); | ||
2390 | 2361 | + | ||
2391 | 2362 | + if (in == NULL) { | ||
2392 | 2363 | + g_warning ("on_control_active_input_update - tried to fetch an input of id %u but got nothing", id); | ||
2393 | 2364 | + return; | ||
2394 | 2365 | + } | ||
2395 | 2366 | + active_input_update (dialog, in); | ||
2396 | 2367 | +} | ||
2397 | 2368 | + | ||
2398 | 2369 | +static void | ||
2399 | 2370 | +on_control_input_added (GvcMixerControl *control, | ||
2400 | 2371 | + guint id, | ||
2401 | 2372 | + GvcMixerDialog *dialog) | ||
2402 | 2373 | +{ | ||
2403 | 2374 | + GvcMixerUIDevice* in = NULL; | ||
2404 | 2375 | + in = gvc_mixer_control_lookup_input_id (control, id); | ||
2405 | 2376 | + | ||
2406 | 2377 | + if (in == NULL) { | ||
2407 | 2378 | + g_warning ("on_control_input_added - tried to fetch an input of id %u but got nothing", id); | ||
2408 | 2379 | + return; | ||
2409 | 2380 | + } | ||
2410 | 2381 | + add_input_ui_entry (dialog, in); | ||
2411 | 2382 | +} | ||
2412 | 2383 | + | ||
2413 | 2384 | +static void | ||
2414 | 2385 | +on_control_output_removed (GvcMixerControl *control, | ||
2415 | 2386 | + guint id, | ||
2416 | 2387 | + GvcMixerDialog *dialog) | ||
2417 | 2388 | +{ | ||
2418 | 2389 | + GtkWidget *bar; | ||
2419 | 2390 | + gboolean found; | ||
2420 | 2391 | + GtkTreeIter iter; | ||
2421 | 2392 | + GtkTreeModel *model; | ||
2422 | 2393 | + | ||
2423 | 2394 | + GvcMixerUIDevice* out = NULL; | ||
2424 | 2395 | + out = gvc_mixer_control_lookup_output_id (control, id); | ||
2425 | 2396 | + | ||
2426 | 2397 | + gint sink_stream_id; | ||
2427 | 2398 | + | ||
2428 | 2399 | + g_object_get (G_OBJECT (out), | ||
2429 | 2400 | + "stream-id", &sink_stream_id, | ||
2430 | 2401 | + NULL); | ||
2431 | 2402 | + | ||
2432 | 2403 | + g_debug ("Remove output from dialog \n id : %u \n sink stream id : %i \n", | ||
2433 | 2404 | + id, | ||
2434 | 2405 | + sink_stream_id); | ||
2435 | 2406 | + | ||
2436 | 2407 | + /* remove from any models */ | ||
2437 | 2408 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); | ||
2438 | 2409 | + found = find_item_by_id (GTK_TREE_MODEL (model), id, ID_COLUMN, &iter); | ||
2439 | 2410 | + if (found) { | ||
2440 | 2411 | + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); | ||
2441 | 2412 | + } | ||
2442 | 2413 | +} | ||
2443 | 2414 | + | ||
2444 | 2415 | + | ||
2445 | 2416 | + | ||
2446 | 2417 | +static void | ||
2447 | 2418 | +on_control_input_removed (GvcMixerControl *control, | ||
2448 | 2419 | + guint id, | ||
2449 | 2420 | + GvcMixerDialog *dialog) | ||
2450 | 2421 | +{ | ||
2451 | 2422 | + GtkWidget *bar; | ||
2452 | 2423 | + gboolean found; | ||
2453 | 2424 | + GtkTreeIter iter; | ||
2454 | 2425 | + GtkTreeModel *model; | ||
2455 | 2426 | + | ||
2456 | 2427 | + GvcMixerUIDevice* in = NULL; | ||
2457 | 2428 | + in = gvc_mixer_control_lookup_input_id (control, id); | ||
2458 | 2429 | + | ||
2459 | 2430 | + gint stream_id; | ||
2460 | 2431 | + | ||
2461 | 2432 | + g_object_get (G_OBJECT (in), | ||
2462 | 2433 | + "stream-id", &stream_id, | ||
2463 | 2434 | + NULL); | ||
2464 | 2435 | + | ||
2465 | 2436 | + g_debug ("Remove input from dialog \n id : %u \n stream id : %i \n", | ||
2466 | 2437 | + id, | ||
2467 | 2438 | + stream_id); | ||
2468 | 2439 | + | ||
2469 | 2440 | + /* remove from any models */ | ||
2470 | 2441 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview)); | ||
2471 | 2442 | + found = find_item_by_id (GTK_TREE_MODEL (model), id, ID_COLUMN, &iter); | ||
2472 | 2443 | + if (found) { | ||
2473 | 2444 | + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); | ||
2474 | 2445 | + } | ||
2475 | 2446 | +} | ||
2476 | 2447 | + | ||
2477 | 2448 | +static void | ||
2478 | 2449 | +_gtk_label_make_bold (GtkLabel *label) | ||
2479 | 2450 | +{ | ||
2480 | 2451 | + PangoFontDescription *font_desc; | ||
2481 | 2452 | + | ||
2482 | 2453 | + font_desc = pango_font_description_new (); | ||
2483 | 2454 | + | ||
2484 | 2455 | + pango_font_description_set_weight (font_desc, | ||
2485 | 2456 | + PANGO_WEIGHT_BOLD); | ||
2486 | 2457 | + | ||
2487 | 2458 | + /* This will only affect the weight of the font, the rest is | ||
2488 | 2459 | + * from the current state of the widget, which comes from the | ||
2489 | 2460 | + * theme or user prefs, since the font desc only has the | ||
2490 | 2461 | + * weight flag turned on. | ||
2491 | 2462 | + */ | ||
2492 | 2463 | + gtk_widget_modify_font (GTK_WIDGET (label), font_desc); | ||
2493 | 2464 | + | ||
2494 | 2465 | + pango_font_description_free (font_desc); | ||
2495 | 2466 | +} | ||
2496 | 2467 | + | ||
2497 | 2468 | + | ||
2498 | 2469 | +static void | ||
2499 | 2470 | +on_input_selection_changed (GtkTreeSelection *selection, | ||
2500 | 2471 | + GvcMixerDialog *dialog) | ||
2501 | 2472 | +{ | ||
2502 | 2473 | + GtkTreeModel *model; | ||
2503 | 2474 | + GtkTreeIter iter; | ||
2504 | 2475 | + gboolean toggled; | ||
2505 | 2476 | + guint id; | ||
2506 | 2477 | + | ||
2507 | 2478 | + if (gtk_tree_selection_get_selected (selection, &model, &iter) == FALSE) { | ||
2508 | 2479 | + g_debug ("Could not get default input from selection"); | ||
2509 | 2480 | + return; | ||
2510 | 2481 | + } | ||
2511 | 2482 | + | ||
2512 | 2483 | + gtk_tree_model_get (model, &iter, | ||
2513 | 2484 | + ID_COLUMN, &id, | ||
2514 | 2485 | + ACTIVE_COLUMN, &toggled, | ||
2515 | 2486 | + -1); | ||
2516 | 2487 | + | ||
2517 | 2488 | + toggled ^= 1; | ||
2518 | 2489 | + GvcMixerUIDevice *input; | ||
2519 | 2490 | + //g_debug ("on_input_selection_changed - try swap to input with id %u", id); | ||
2520 | 2491 | + input = gvc_mixer_control_lookup_input_id (dialog->priv->mixer_control, id); | ||
2521 | 2492 | + | ||
2522 | 2493 | + if (input == NULL) { | ||
2523 | 2494 | + g_warning ("on_input_selection_changed - Unable to find input with id: %u", id); | ||
2524 | 2495 | + return; | ||
2525 | 2496 | + } | ||
2526 | 2497 | + | ||
2527 | 2498 | + gvc_mixer_control_change_input (dialog->priv->mixer_control, input); | ||
2528 | 2499 | +} | ||
2529 | 2500 | + | ||
2530 | 2501 | +static void | ||
2531 | 2502 | +on_output_selection_changed (GtkTreeSelection *selection, | ||
2532 | 2503 | + GvcMixerDialog *dialog) | ||
2533 | 2504 | +{ | ||
2534 | 2505 | + GtkTreeModel *model; | ||
2535 | 2506 | + GtkTreeIter iter; | ||
2536 | 2507 | + gboolean active; | ||
2537 | 2508 | + guint id; | ||
2538 | 2509 | + | ||
2539 | 2510 | + if (gtk_tree_selection_get_selected (selection, &model, &iter) == FALSE) { | ||
2540 | 2511 | + g_debug ("Could not get default output from selection"); | ||
2541 | 2512 | + return; | ||
2542 | 2513 | + } | ||
2543 | 2514 | + | ||
2544 | 2515 | + gtk_tree_model_get (model, &iter, | ||
2545 | 2516 | + ID_COLUMN, &id, | ||
2546 | 2517 | + ACTIVE_COLUMN, &active, | ||
2547 | 2518 | + -1); | ||
2548 | 2519 | + | ||
2549 | 2520 | + g_debug ("\n\n on_output_selection_changed - active %i \n\n", active); | ||
2550 | 2521 | + if (active){ | ||
2551 | 2522 | + return; | ||
2552 | 2523 | + } | ||
2553 | 2524 | + | ||
2554 | 2525 | + GvcMixerUIDevice *output; | ||
2555 | 2526 | + g_debug ("\n on_output_selection_changed - try swap to output with id %u", id); | ||
2556 | 2527 | + output = gvc_mixer_control_lookup_output_id (dialog->priv->mixer_control, id); | ||
2557 | 2528 | + | ||
2558 | 2529 | + if (output == NULL) { | ||
2559 | 2530 | + g_warning ("on_output_selection_changed - Unable to find output with id: %u", id); | ||
2560 | 2531 | + return; | ||
2561 | 2532 | + } | ||
2562 | 2533 | + | ||
2563 | 2534 | + gvc_mixer_control_change_output (dialog->priv->mixer_control, output); | ||
2564 | 2535 | +} | ||
2565 | 2536 | + | ||
2566 | 2537 | +static void | ||
2567 | 2538 | +name_to_text (GtkTreeViewColumn *column, | ||
2568 | 2539 | + GtkCellRenderer *cell, | ||
2569 | 2540 | + GtkTreeModel *model, | ||
2570 | 2541 | + GtkTreeIter *iter, | ||
2571 | 2542 | + gpointer user_data) | ||
2572 | 2543 | +{ | ||
2573 | 2544 | + char *name, *mapping; | ||
2574 | 2545 | + | ||
2575 | 2546 | + gtk_tree_model_get(model, iter, | ||
2576 | 2547 | + NAME_COLUMN, &name, | ||
2577 | 2548 | + SPEAKERS_COLUMN, &mapping, | ||
2578 | 2549 | + -1); | ||
2579 | 2550 | + | ||
2580 | 2551 | + if (mapping == NULL) { | ||
2581 | 2552 | + g_object_set (cell, "text", name, NULL); | ||
2582 | 2553 | + } else { | ||
2583 | 2554 | + char *str; | ||
2584 | 2555 | + | ||
2585 | 2556 | + str = g_strdup_printf ("%s\n<i>%s</i>", | ||
2586 | 2557 | + name, mapping); | ||
2587 | 2558 | + g_object_set (cell, "markup", str, NULL); | ||
2588 | 2559 | + g_free (str); | ||
2589 | 2560 | + } | ||
2590 | 2561 | + | ||
2591 | 2562 | + g_free (name); | ||
2592 | 2563 | + g_free (mapping); | ||
2593 | 2564 | +} | ||
2594 | 2565 | + | ||
2595 | 2566 | +static GtkWidget * | ||
2596 | 2567 | +create_stream_treeview (GvcMixerDialog *dialog, | ||
2597 | 2568 | + GCallback on_selection_changed) | ||
2598 | 2569 | +{ | ||
2599 | 2570 | + GtkWidget *treeview; | ||
2600 | 2571 | + GtkListStore *store; | ||
2601 | 2572 | + GtkCellRenderer *renderer; | ||
2602 | 2573 | + GtkTreeViewColumn *column; | ||
2603 | 2574 | + GtkTreeSelection *selection; | ||
2604 | 2575 | + | ||
2605 | 2576 | + treeview = gtk_tree_view_new (); | ||
2606 | 2577 | + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); | ||
2607 | 2578 | + | ||
2608 | 2579 | + store = gtk_list_store_new (NUM_COLUMNS, | ||
2609 | 2580 | + G_TYPE_STRING, | ||
2610 | 2581 | + G_TYPE_STRING, | ||
2611 | 2582 | + G_TYPE_BOOLEAN, | ||
2612 | 2583 | + G_TYPE_UINT, | ||
2613 | 2584 | + G_TYPE_STRING, | ||
2614 | 2585 | + G_TYPE_ICON); | ||
2615 | 2586 | + gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), | ||
2616 | 2587 | + GTK_TREE_MODEL (store)); | ||
2617 | 2588 | + | ||
2618 | 2589 | + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); | ||
2619 | 2590 | + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); | ||
2620 | 2591 | + | ||
2621 | 2592 | + column = gtk_tree_view_column_new (); | ||
2622 | 2593 | + gtk_tree_view_column_set_title (column, _("Name")); | ||
2623 | 2594 | + renderer = gtk_cell_renderer_pixbuf_new (); | ||
2624 | 2595 | + gtk_tree_view_column_pack_start (column, renderer, FALSE); | ||
2625 | 2596 | + g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); | ||
2626 | 2597 | + gtk_tree_view_column_set_attributes (column, renderer, | ||
2627 | 2598 | + "gicon", ICON_COLUMN, | ||
2628 | 2599 | + NULL); | ||
2629 | 2600 | + | ||
2630 | 2601 | + renderer = gtk_cell_renderer_text_new (); | ||
2631 | 2602 | + gtk_tree_view_column_pack_start (column, renderer, TRUE); | ||
2632 | 2603 | + gtk_tree_view_column_set_cell_data_func (column, renderer, | ||
2633 | 2604 | + name_to_text, NULL, NULL); | ||
2634 | 2605 | + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); | ||
2635 | 2606 | + | ||
2636 | 2607 | + g_signal_connect ( selection, "changed", | ||
2637 | 2608 | + on_selection_changed, dialog); | ||
2638 | 2609 | +#if 0 | ||
2639 | 2610 | + renderer = gtk_cell_renderer_text_new (); | ||
2640 | 2611 | + column = gtk_tree_view_column_new_with_attributes (_("Device"), | ||
2641 | 2612 | + renderer, | ||
2642 | 2613 | + "text", DEVICE_COLUMN, | ||
2643 | 2614 | + NULL); | ||
2644 | 2615 | + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); | ||
2645 | 2616 | +#endif | ||
2646 | 2617 | + return treeview; | ||
2647 | 2618 | +} | ||
2648 | 2619 | + | ||
2649 | 2620 | +static void | ||
2650 | 2621 | +on_profile_changed (GvcComboBox *widget, | ||
2651 | 2622 | + const char *profile, | ||
2652 | 2623 | + gpointer user_data) | ||
2653 | 2624 | +{ | ||
2654 | 2625 | + GvcMixerCard *card; | ||
2655 | 2626 | + | ||
2656 | 2627 | + card = g_object_get_data (G_OBJECT (widget), "card"); | ||
2657 | 2628 | + if (card == NULL) { | ||
2658 | 2629 | + g_warning ("Could not find card for combobox"); | ||
2659 | 2630 | + return; | ||
2660 | 2631 | + } | ||
2661 | 2632 | + | ||
2662 | 2633 | + g_debug ("Profile changed to %s for card %s", profile, | ||
2663 | 2634 | + gvc_mixer_card_get_name (card)); | ||
2664 | 2635 | + | ||
2665 | 2636 | + gvc_mixer_card_change_profile (card, profile); | ||
2666 | 2637 | +} | ||
2667 | 2638 | + | ||
2668 | 2639 | +static void | ||
2669 | 2640 | +on_test_speakers_clicked (GtkButton *widget, | ||
2670 | 2641 | + gpointer user_data) | ||
2671 | 2642 | +{ | ||
2672 | 2643 | + GvcMixerDialog *dialog = GVC_MIXER_DIALOG (user_data); | ||
2673 | 2644 | + GtkTreeModel *model; | ||
2674 | 2645 | + GtkTreeIter iter; | ||
2675 | 2646 | + gint active_output = GVC_MIXER_UI_DEVICE_INVALID; | ||
2676 | 2647 | + | ||
2677 | 2648 | + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); | ||
2678 | 2649 | + | ||
2679 | 2650 | + if (gtk_tree_model_get_iter_first (model, &iter) == FALSE){ | ||
2680 | 2651 | + g_warning ("The tree is empty => we have no device to test speakers with return"); | ||
2681 | 2652 | + return; | ||
2682 | 2653 | + } | ||
2683 | 2654 | + | ||
2684 | 2655 | + do { | ||
2685 | 2656 | + gboolean is_selected = FALSE ; | ||
2686 | 2657 | + gint id; | ||
2687 | 2658 | + | ||
2688 | 2659 | + gtk_tree_model_get (model, &iter, | ||
2689 | 2660 | + ID_COLUMN, &id, | ||
2690 | 2661 | + ACTIVE_COLUMN, &is_selected, | ||
2691 | 2662 | + -1); | ||
2692 | 2663 | + | ||
2693 | 2664 | + if (is_selected) { | ||
2694 | 2665 | + active_output = id; | ||
2695 | 2666 | + break; | ||
2696 | 2667 | + } | ||
2697 | 2668 | + | ||
2698 | 2669 | + }while (gtk_tree_model_iter_next (model, &iter)); | ||
2699 | 2670 | + | ||
2700 | 2671 | + if (active_output == GVC_MIXER_UI_DEVICE_INVALID) { | ||
2701 | 2672 | + g_warning ("Cant find the active output from the UI"); | ||
2702 | 2673 | + return; | ||
2703 | 2674 | + } | ||
2704 | 2675 | + | ||
2705 | 2676 | + GvcMixerUIDevice *output; | ||
2706 | 2677 | + output = gvc_mixer_control_lookup_output_id (dialog->priv->mixer_control, (guint)active_output); | ||
2707 | 2678 | + gint stream_id = gvc_mixer_ui_device_get_stream_id(output); | ||
2708 | 2679 | + | ||
2709 | 2680 | + if (stream_id == GVC_MIXER_UI_DEVICE_INVALID) | ||
2710 | 2681 | + return; | ||
2711 | 2682 | + | ||
2712 | 2683 | + g_debug ("Test the speakers on the %s", gvc_mixer_ui_device_get_description (output)); | ||
2713 | 2684 | + | ||
2714 | 2685 | + GvcMixerStream *stream; | ||
2715 | 2686 | + GvcMixerCardProfile *profile; | ||
2716 | 2687 | + GtkWidget *d, *speaker_test, *container; | ||
2717 | 2688 | + char *title; | ||
2718 | 2689 | + | ||
2719 | 2690 | + stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control, stream_id); | ||
2720 | 2691 | + if (stream == NULL) { | ||
2721 | 2692 | + g_debug ("Stream/sink not found"); | ||
2722 | 2693 | + return; | ||
2723 | 2694 | + } | ||
2724 | 2695 | + title = g_strdup_printf (_("Speaker Testing for %s"), gvc_mixer_ui_device_get_description (output)); | ||
2725 | 2696 | + d = gtk_dialog_new_with_buttons (title, | ||
2726 | 2697 | + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget))), | ||
2727 | 2698 | + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | ||
2728 | 2699 | + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | ||
2729 | 2700 | + NULL); | ||
2730 | 2701 | + gtk_window_set_has_resize_grip (GTK_WINDOW (d), FALSE); | ||
2731 | 2702 | + | ||
2732 | 2703 | + g_free (title); | ||
2733 | 2704 | + speaker_test = gvc_speaker_test_new (dialog->priv->mixer_control, | ||
2734 | 2705 | + stream); | ||
2735 | 2706 | + gtk_widget_show (speaker_test); | ||
2736 | 2707 | + container = gtk_dialog_get_content_area (GTK_DIALOG (d)); | ||
2737 | 2708 | + gtk_container_add (GTK_CONTAINER (container), speaker_test); | ||
2738 | 2709 | + | ||
2739 | 2710 | + gtk_dialog_run (GTK_DIALOG (d)); | ||
2740 | 2711 | + gtk_widget_destroy (d); | ||
2741 | 2712 | +} | ||
2742 | 2713 | + | ||
2743 | 2714 | +static GObject * | ||
2744 | 2715 | +gvc_mixer_dialog_constructor (GType type, | ||
2745 | 2716 | + guint n_construct_properties, | ||
2746 | 2717 | + GObjectConstructParam *construct_params) | ||
2747 | 2718 | +{ | ||
2748 | 2719 | + GObject *object; | ||
2749 | 2720 | + GvcMixerDialog *self; | ||
2750 | 2721 | + GtkWidget *main_vbox; | ||
2751 | 2722 | + GtkWidget *label; | ||
2752 | 2723 | + GtkWidget *alignment; | ||
2753 | 2724 | + GtkWidget *alignment_settings_box; | ||
2754 | 2725 | + GtkWidget *settings_box; | ||
2755 | 2726 | + GtkWidget *box; | ||
2756 | 2727 | + GtkWidget *sbox; | ||
2757 | 2728 | + GtkWidget *ebox; | ||
2758 | 2729 | + GtkWidget *test_sound_box; | ||
2759 | 2730 | + GSList *streams; | ||
2760 | 2731 | + GSList *cards; | ||
2761 | 2732 | + GSList *l; | ||
2762 | 2733 | + GvcMixerStream *stream; | ||
2763 | 2734 | + GvcMixerCard *card; | ||
2764 | 2735 | + GtkTreeSelection *selection; | ||
2765 | 2736 | + | ||
2766 | 2737 | + object = G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->constructor (type, n_construct_properties, construct_params); | ||
2767 | 2738 | + | ||
2768 | 2739 | + self = GVC_MIXER_DIALOG (object); | ||
2769 | 2740 | + | ||
2770 | 2741 | + main_vbox = GTK_WIDGET (self); | ||
2771 | 2742 | + gtk_box_set_spacing (GTK_BOX (main_vbox), 2); | ||
2772 | 2743 | + | ||
2773 | 2744 | + gtk_container_set_border_width (GTK_CONTAINER (self), 3); | ||
2774 | 2745 | + | ||
2775 | 2746 | + self->priv->output_stream_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); | ||
2776 | 2747 | + alignment = gtk_alignment_new (0, 0, 1, 1); | ||
2777 | 2748 | + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 0, 0); | ||
2778 | 2749 | + gtk_container_add (GTK_CONTAINER (alignment), self->priv->output_stream_box); | ||
2779 | 2750 | + gtk_box_pack_start (GTK_BOX (main_vbox), | ||
2780 | 2751 | + alignment, | ||
2781 | 2752 | + FALSE, FALSE, 0); | ||
2782 | 2753 | + | ||
2783 | 2754 | + self->priv->notebook = gtk_notebook_new (); | ||
2784 | 2755 | + gtk_box_pack_start (GTK_BOX (main_vbox), | ||
2785 | 2756 | + self->priv->notebook, | ||
2786 | 2757 | + TRUE, TRUE, 0); | ||
2787 | 2758 | + gtk_container_set_border_width (GTK_CONTAINER (self->priv->notebook), 5); | ||
2788 | 2759 | + | ||
2789 | 2760 | + /* Output page */ | ||
2790 | 2761 | + self->priv->output_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); | ||
2791 | 2762 | + gtk_container_set_border_width (GTK_CONTAINER (self->priv->output_box), 12); | ||
2792 | 2763 | + label = gtk_label_new (_("Output")); | ||
2793 | 2764 | + gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook), | ||
2794 | 2765 | + self->priv->output_box, | ||
2795 | 2766 | + label); | ||
2796 | 2767 | + | ||
2797 | 2768 | + box = gtk_frame_new (_("Play sound through")); | ||
2798 | 2769 | + gtk_widget_set_size_request (GTK_WIDGET (box), 310, -1); | ||
2799 | 2770 | + label = gtk_frame_get_label_widget (GTK_FRAME (box)); | ||
2800 | 2771 | + _gtk_label_make_bold (GTK_LABEL (label)); | ||
2801 | 2772 | + gtk_label_set_use_underline (GTK_LABEL (label), TRUE); | ||
2802 | 2773 | + gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE); | ||
2803 | 2774 | + gtk_box_pack_start (GTK_BOX (self->priv->output_box), box, FALSE, TRUE, 0); | ||
2804 | 2775 | + | ||
2805 | 2776 | + alignment = gtk_alignment_new (0, 0, 1, 1); | ||
2806 | 2777 | + gtk_container_add (GTK_CONTAINER (box), alignment); | ||
2807 | 2778 | + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 10, 5, 0, 15); | ||
2808 | 2779 | + | ||
2809 | 2780 | + self->priv->output_treeview = create_stream_treeview (self, | ||
2810 | 2781 | + G_CALLBACK (on_output_selection_changed)); | ||
2811 | 2782 | + gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->output_treeview); | ||
2812 | 2783 | + | ||
2813 | 2784 | + box = gtk_scrolled_window_new (NULL, NULL); | ||
2814 | 2785 | + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box), | ||
2815 | 2786 | + GTK_POLICY_NEVER, | ||
2816 | 2787 | + GTK_POLICY_AUTOMATIC); | ||
2817 | 2788 | + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box), | ||
2818 | 2789 | + GTK_SHADOW_IN); | ||
2819 | 2790 | + gtk_container_add (GTK_CONTAINER (box), self->priv->output_treeview); | ||
2820 | 2791 | + gtk_container_add (GTK_CONTAINER (alignment), box); | ||
2821 | 2792 | + | ||
2822 | 2793 | + self->priv->selected_output_label = gtk_label_new (_("Settings for the selected device")); | ||
2823 | 2794 | + gtk_widget_set_halign (self->priv->selected_output_label, GTK_ALIGN_START); | ||
2824 | 2795 | + gtk_widget_set_valign (self->priv->selected_output_label, GTK_ALIGN_START); | ||
2825 | 2796 | + gtk_misc_set_padding (GTK_MISC (self->priv->selected_output_label), 0, 0); | ||
2826 | 2797 | + _gtk_label_make_bold (GTK_LABEL (self->priv->selected_output_label)); | ||
2827 | 2798 | + settings_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); | ||
2828 | 2799 | + alignment_settings_box = gtk_alignment_new (0, 0, 1, 1); | ||
2829 | 2800 | + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment_settings_box), 7, 0, 0, 0); | ||
2830 | 2801 | + self->priv->output_settings_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); | ||
2831 | 2802 | + gtk_container_add (GTK_CONTAINER (alignment_settings_box), self->priv->output_settings_box); | ||
2832 | 2803 | + | ||
2833 | 2804 | + gtk_box_pack_start (GTK_BOX (self->priv->output_box), | ||
2834 | 2805 | + settings_box, | ||
2835 | 2806 | + FALSE, | ||
2836 | 2807 | + FALSE, | ||
2837 | 2808 | + 0); | ||
2838 | 2809 | + gtk_box_pack_start (GTK_BOX (settings_box), | ||
2839 | 2810 | + self->priv->selected_output_label, | ||
2840 | 2811 | + FALSE, | ||
2841 | 2812 | + FALSE, | ||
2842 | 2813 | + 0); | ||
2843 | 2814 | + gtk_box_pack_start (GTK_BOX (settings_box), | ||
2844 | 2815 | + alignment_settings_box, | ||
2845 | 2816 | + FALSE, | ||
2846 | 2817 | + FALSE, | ||
2847 | 2818 | + 0); | ||
2848 | 2819 | + | ||
2849 | 2820 | + self->priv->output_balance_bar = gvc_balance_bar_new (BALANCE_TYPE_RL); | ||
2850 | 2821 | + if (self->priv->size_group != NULL) { | ||
2851 | 2822 | + gvc_balance_bar_set_size_group (GVC_BALANCE_BAR (self->priv->output_balance_bar), | ||
2852 | 2823 | + self->priv->size_group, | ||
2853 | 2824 | + FALSE); | ||
2854 | 2825 | + } | ||
2855 | 2826 | + gtk_box_pack_start (GTK_BOX (self->priv->output_settings_box), | ||
2856 | 2827 | + self->priv->output_balance_bar, | ||
2857 | 2828 | + FALSE, FALSE, 3); | ||
2858 | 2829 | + gtk_widget_show (self->priv->output_balance_bar); | ||
2859 | 2830 | + | ||
2860 | 2831 | + self->priv->output_fade_bar = gvc_balance_bar_new (BALANCE_TYPE_FR); | ||
2861 | 2832 | + if (self->priv->size_group != NULL) { | ||
2862 | 2833 | + gvc_balance_bar_set_size_group (GVC_BALANCE_BAR (self->priv->output_fade_bar), | ||
2863 | 2834 | + self->priv->size_group, | ||
2864 | 2835 | + FALSE); | ||
2865 | 2836 | + } | ||
2866 | 2837 | + gtk_box_pack_start (GTK_BOX (self->priv->output_settings_box), | ||
2867 | 2838 | + self->priv->output_fade_bar, | ||
2868 | 2839 | + FALSE, FALSE, 3); | ||
2869 | 2840 | + gtk_widget_show (self->priv->output_fade_bar); | ||
2870 | 2841 | + | ||
2871 | 2842 | + self->priv->output_lfe_bar = gvc_balance_bar_new (BALANCE_TYPE_LFE); | ||
2872 | 2843 | + if (self->priv->size_group != NULL) { | ||
2873 | 2844 | + gvc_balance_bar_set_size_group (GVC_BALANCE_BAR (self->priv->output_lfe_bar), | ||
2874 | 2845 | + self->priv->size_group, | ||
2875 | 2846 | + FALSE); | ||
2876 | 2847 | + } | ||
2877 | 2848 | + gtk_box_pack_start (GTK_BOX (self->priv->output_settings_box), | ||
2878 | 2849 | + self->priv->output_lfe_bar, | ||
2879 | 2850 | + FALSE, FALSE, 3); | ||
2880 | 2851 | + gtk_widget_show (self->priv->output_lfe_bar); | ||
2881 | 2852 | + | ||
2882 | 2853 | + /* Creating a box and try to deal using the same size group. */ | ||
2883 | 2854 | + test_sound_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); | ||
2884 | 2855 | + gtk_box_pack_end (GTK_BOX (self->priv->output_settings_box), | ||
2885 | 2856 | + test_sound_box, | ||
2886 | 2857 | + FALSE, | ||
2887 | 2858 | + FALSE, | ||
2888 | 2859 | + 5); | ||
2889 | 2860 | + | ||
2890 | 2861 | + sbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); | ||
2891 | 2862 | + gtk_box_pack_start (GTK_BOX (test_sound_box), | ||
2892 | 2863 | + sbox, | ||
2893 | 2864 | + FALSE, FALSE, 0); | ||
2894 | 2865 | + | ||
2895 | 2866 | + label = gtk_label_new (_("Test:")); | ||
2896 | 2867 | + gtk_box_pack_start (GTK_BOX (sbox), | ||
2897 | 2868 | + label, | ||
2898 | 2869 | + FALSE, FALSE, 0); | ||
2899 | 2870 | + if (self->priv->size_group != NULL) | ||
2900 | 2871 | + gtk_size_group_add_widget (self->priv->size_group, sbox); | ||
2901 | 2872 | + | ||
2902 | 2873 | + self->priv->test_output_button = gtk_button_new_with_label (_("Test Sound")); | ||
2903 | 2874 | + | ||
2904 | 2875 | + /* FIXME: I am getting mental with all these hardcoded padding values, | ||
2905 | 2876 | + * Here 8 works fine, not sure why. */ | ||
2906 | 2877 | + gtk_box_pack_start (GTK_BOX (test_sound_box), | ||
2907 | 2878 | + self->priv->test_output_button, | ||
2908 | 2879 | + TRUE, TRUE, 8); | ||
2909 | 2880 | + | ||
2910 | 2881 | + /* Is this needed */ | ||
2911 | 2882 | + if (self->priv->size_group != NULL) | ||
2912 | 2883 | + gtk_size_group_add_widget (self->priv->size_group, self->priv->test_output_button); | ||
2913 | 2884 | + | ||
2914 | 2885 | + gtk_widget_show (test_sound_box); | ||
2915 | 2886 | + | ||
2916 | 2887 | + //gtk_container_add (GTK_CONTAINER (box), self->priv->output_settings_box); | ||
2917 | 2888 | + g_signal_connect (self->priv->test_output_button, | ||
2918 | 2889 | + "released", | ||
2919 | 2890 | + G_CALLBACK (on_test_speakers_clicked), | ||
2920 | 2891 | + self); | ||
2921 | 2892 | + | ||
2922 | 2893 | + /* Input page */ | ||
2923 | 2894 | + self->priv->input_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); | ||
2924 | 2895 | + gtk_container_set_border_width (GTK_CONTAINER (self->priv->input_box), 12); | ||
2925 | 2896 | + label = gtk_label_new (_("Input")); | ||
2926 | 2897 | + gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook), | ||
2927 | 2898 | + self->priv->input_box, | ||
2928 | 2899 | + label); | ||
2929 | 2900 | + box = gtk_frame_new (_("Record sound from")); | ||
2930 | 2901 | + gtk_widget_set_size_request (GTK_WIDGET (box), 310, -1); | ||
2931 | 2902 | + label = gtk_frame_get_label_widget (GTK_FRAME (box)); | ||
2932 | 2903 | + _gtk_label_make_bold (GTK_LABEL (label)); | ||
2933 | 2904 | + gtk_label_set_use_underline (GTK_LABEL (label), TRUE); | ||
2934 | 2905 | + gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE); | ||
2935 | 2906 | + gtk_box_pack_start (GTK_BOX (self->priv->input_box), box, FALSE, TRUE, 0); | ||
2936 | 2907 | + | ||
2937 | 2908 | + alignment = gtk_alignment_new (0, 0, 1, 1); | ||
2938 | 2909 | + gtk_container_add (GTK_CONTAINER (box), alignment); | ||
2939 | 2910 | + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 10, 5, 0, 15); | ||
2940 | 2911 | + | ||
2941 | 2912 | + self->priv->input_treeview = create_stream_treeview (self, | ||
2942 | 2913 | + G_CALLBACK (on_input_selection_changed)); | ||
2943 | 2914 | + gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->input_treeview); | ||
2944 | 2915 | + | ||
2945 | 2916 | + box = gtk_scrolled_window_new (NULL, NULL); | ||
2946 | 2917 | + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box), | ||
2947 | 2918 | + GTK_POLICY_NEVER, | ||
2948 | 2919 | + GTK_POLICY_AUTOMATIC); | ||
2949 | 2920 | + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box), | ||
2950 | 2921 | + GTK_SHADOW_IN); | ||
2951 | 2922 | + gtk_container_add (GTK_CONTAINER (box), self->priv->input_treeview); | ||
2952 | 2923 | + gtk_container_add (GTK_CONTAINER (alignment), box); | ||
2953 | 2924 | + | ||
2954 | 2925 | + self->priv->selected_input_label = gtk_label_new (_("Settings for the selected device")); | ||
2955 | 2926 | + gtk_widget_set_halign (self->priv->selected_input_label, GTK_ALIGN_START); | ||
2956 | 2927 | + _gtk_label_make_bold (GTK_LABEL (self->priv->selected_input_label)); | ||
2957 | 2928 | + | ||
2958 | 2929 | + self->priv->input_settings_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); | ||
2959 | 2930 | + gtk_box_pack_start (GTK_BOX (self->priv->input_box), | ||
2960 | 2931 | + self->priv->input_settings_box, | ||
2961 | 2932 | + FALSE, | ||
2962 | 2933 | + FALSE, | ||
2963 | 2934 | + 0); | ||
2964 | 2935 | + gtk_box_pack_start (GTK_BOX (self->priv->input_settings_box), | ||
2965 | 2936 | + self->priv->selected_input_label, | ||
2966 | 2937 | + FALSE, | ||
2967 | 2938 | + FALSE, | ||
2968 | 2939 | + 0); | ||
2969 | 2940 | + | ||
2970 | 2941 | + self->priv->input_bar = create_bar (self, FALSE, TRUE); | ||
2971 | 2942 | + gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->input_bar), | ||
2972 | 2943 | + _("_Input volume:")); | ||
2973 | 2944 | + gvc_channel_bar_set_low_icon_name (GVC_CHANNEL_BAR (self->priv->input_bar), | ||
2974 | 2945 | + "audio-input-microphone-low-symbolic"); | ||
2975 | 2946 | + gvc_channel_bar_set_high_icon_name (GVC_CHANNEL_BAR (self->priv->input_bar), | ||
2976 | 2947 | + "audio-input-microphone-high-symbolic"); | ||
2977 | 2948 | + gtk_widget_set_sensitive (self->priv->input_bar, FALSE); | ||
2978 | 2949 | + | ||
2979 | 2950 | + if (self->priv->size_group != NULL) { | ||
2980 | 2951 | + gvc_channel_bar_set_size_group (GVC_CHANNEL_BAR (self->priv->input_bar), | ||
2981 | 2952 | + self->priv->size_group, | ||
2982 | 2953 | + FALSE); | ||
2983 | 2954 | + } | ||
2984 | 2955 | + | ||
2985 | 2956 | + gtk_box_pack_start (GTK_BOX (self->priv->input_settings_box), | ||
2986 | 2957 | + self->priv->input_bar, | ||
2987 | 2958 | + FALSE, FALSE, 15); | ||
2988 | 2959 | + gtk_widget_show (self->priv->input_bar); | ||
2989 | 2960 | + | ||
2990 | 2961 | + | ||
2991 | 2962 | + /* Creating a box and try to deal using the same size group. */ | ||
2992 | 2963 | + GtkWidget *input_level_box; | ||
2993 | 2964 | + input_level_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); | ||
2994 | 2965 | + gtk_box_pack_start (GTK_BOX (self->priv->input_settings_box), | ||
2995 | 2966 | + input_level_box, | ||
2996 | 2967 | + FALSE, | ||
2997 | 2968 | + FALSE, | ||
2998 | 2969 | + 5); | ||
2999 | 2970 | + | ||
3000 | 2971 | + sbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); | ||
3001 | 2972 | + gtk_box_pack_start (GTK_BOX (input_level_box), | ||
3002 | 2973 | + sbox, | ||
3003 | 2974 | + FALSE, FALSE, 0); | ||
3004 | 2975 | + | ||
3005 | 2976 | + label = gtk_label_new (_("Input level:")); | ||
3006 | 2977 | + gtk_box_pack_start (GTK_BOX (sbox), | ||
3007 | 2978 | + label, | ||
3008 | 2979 | + FALSE, FALSE, 0); | ||
3009 | 2980 | + if (self->priv->size_group != NULL) | ||
3010 | 2981 | + gtk_size_group_add_widget (self->priv->size_group, sbox); | ||
3011 | 2982 | + | ||
3012 | 2983 | + | ||
3013 | 2984 | + self->priv->input_level_bar = gvc_level_bar_new (); | ||
3014 | 2985 | + gvc_level_bar_set_orientation (GVC_LEVEL_BAR (self->priv->input_level_bar), | ||
3015 | 2986 | + GTK_ORIENTATION_HORIZONTAL); | ||
3016 | 2987 | + gvc_level_bar_set_scale (GVC_LEVEL_BAR (self->priv->input_level_bar), | ||
3017 | 2988 | + GVC_LEVEL_SCALE_LINEAR); | ||
3018 | 2989 | + | ||
3019 | 2990 | + gtk_box_pack_start (GTK_BOX (input_level_box), | ||
3020 | 2991 | + self->priv->input_level_bar, | ||
3021 | 2992 | + TRUE, TRUE, 0); | ||
3022 | 2993 | + | ||
3023 | 2994 | + /* Effects page */ | ||
3024 | 2995 | + self->priv->sound_effects_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); | ||
3025 | 2996 | + gtk_container_set_border_width (GTK_CONTAINER (self->priv->sound_effects_box), 12); | ||
3026 | 2997 | + label = gtk_label_new (_("Sound Effects")); | ||
3027 | 2998 | + gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook), | ||
3028 | 2999 | + self->priv->sound_effects_box, | ||
3029 | 3000 | + label); | ||
3030 | 3001 | + | ||
3031 | 3002 | + self->priv->effects_bar = create_bar (self, FALSE, TRUE); | ||
3032 | 3003 | + gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->effects_bar), | ||
3033 | 3004 | + _("_Alert volume:")); | ||
3034 | 3005 | + gtk_widget_set_sensitive (self->priv->effects_bar, FALSE); | ||
3035 | 3006 | + gtk_box_pack_start (GTK_BOX (self->priv->sound_effects_box), | ||
3036 | 3007 | + self->priv->effects_bar, FALSE, FALSE, 0); | ||
3037 | 3008 | + | ||
3038 | 3009 | + self->priv->sound_theme_chooser = gvc_sound_theme_chooser_new (); | ||
3039 | 3010 | + gtk_box_pack_start (GTK_BOX (self->priv->sound_effects_box), | ||
3040 | 3011 | + self->priv->sound_theme_chooser, | ||
3041 | 3012 | + TRUE, TRUE, 6); | ||
3042 | 3013 | + | ||
3043 | 3014 | + /* Applications */ | ||
3044 | 3015 | + self->priv->applications_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); | ||
3045 | 3016 | + gtk_container_set_border_width (GTK_CONTAINER (self->priv->applications_box), 12); | ||
3046 | 3017 | + label = gtk_label_new (_("Applications")); | ||
3047 | 3018 | + gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook), | ||
3048 | 3019 | + self->priv->applications_box, | ||
3049 | 3020 | + label); | ||
3050 | 3021 | + self->priv->no_apps_label = gtk_label_new (_("No application is currently playing or recording audio.")); | ||
3051 | 3022 | + gtk_box_pack_start (GTK_BOX (self->priv->applications_box), | ||
3052 | 3023 | + self->priv->no_apps_label, | ||
3053 | 3024 | + TRUE, TRUE, 0); | ||
3054 | 3025 | + | ||
3055 | 3026 | + self->priv->output_stream_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); | ||
3056 | 3027 | + alignment = gtk_alignment_new (0, 0, 1, 1); | ||
3057 | 3028 | + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0); | ||
3058 | 3029 | + gtk_container_add (GTK_CONTAINER (alignment), self->priv->output_stream_box); | ||
3059 | 3030 | + gtk_box_pack_start (GTK_BOX (main_vbox), | ||
3060 | 3031 | + alignment, | ||
3061 | 3032 | + FALSE, FALSE, 0); | ||
3062 | 3033 | + // Output volume | ||
3063 | 3034 | + self->priv->output_bar = create_bar (self, FALSE, TRUE); | ||
3064 | 3035 | + gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->output_bar), | ||
3065 | 3036 | + _("_Output volume:")); | ||
3066 | 3037 | + gtk_widget_set_sensitive (self->priv->output_bar, FALSE); | ||
3067 | 3038 | + gtk_widget_set_size_request (self->priv->output_bar, 460, -1); | ||
3068 | 3039 | + | ||
3069 | 3040 | + gtk_box_pack_start (GTK_BOX (self->priv->output_stream_box), | ||
3070 | 3041 | + self->priv->output_bar, TRUE, FALSE, 12); | ||
3071 | 3042 | + | ||
3072 | 3043 | + gtk_widget_show_all (main_vbox); | ||
3073 | 3044 | + | ||
3074 | 3045 | + g_signal_connect (self->priv->mixer_control, | ||
3075 | 3046 | + "stream-added", | ||
3076 | 3047 | + G_CALLBACK (on_control_stream_added), | ||
3077 | 3048 | + self); | ||
3078 | 3049 | + g_signal_connect (self->priv->mixer_control, | ||
3079 | 3050 | + "stream-removed", | ||
3080 | 3051 | + G_CALLBACK (on_control_stream_removed), | ||
3081 | 3052 | + self); | ||
3082 | 3053 | + g_signal_connect (self->priv->mixer_control, | ||
3083 | 3054 | + "output-added", | ||
3084 | 3055 | + G_CALLBACK (on_control_output_added), | ||
3085 | 3056 | + self); | ||
3086 | 3057 | + g_signal_connect (self->priv->mixer_control, | ||
3087 | 3058 | + "output-removed", | ||
3088 | 3059 | + G_CALLBACK (on_control_output_removed), | ||
3089 | 3060 | + self); | ||
3090 | 3061 | + g_signal_connect (self->priv->mixer_control, | ||
3091 | 3062 | + "input-added", | ||
3092 | 3063 | + G_CALLBACK (on_control_input_added), | ||
3093 | 3064 | + self); | ||
3094 | 3065 | + g_signal_connect (self->priv->mixer_control, | ||
3095 | 3066 | + "input-removed", | ||
3096 | 3067 | + G_CALLBACK (on_control_input_removed), | ||
3097 | 3068 | + self); | ||
3098 | 3069 | + return object; | ||
3099 | 3070 | +} | ||
3100 | 3071 | + | ||
3101 | 3072 | +static void | ||
3102 | 3073 | +gvc_mixer_dialog_dispose (GObject *object) | ||
3103 | 3074 | +{ | ||
3104 | 3075 | + GvcMixerDialog *dialog = GVC_MIXER_DIALOG (object); | ||
3105 | 3076 | + | ||
3106 | 3077 | + g_clear_object (&dialog->priv->indicator_settings); | ||
3107 | 3078 | + | ||
3108 | 3079 | + if (dialog->priv->mixer_control != NULL) { | ||
3109 | 3080 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3110 | 3081 | + on_control_output_added, | ||
3111 | 3082 | + dialog); | ||
3112 | 3083 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3113 | 3084 | + on_control_output_removed, | ||
3114 | 3085 | + dialog); | ||
3115 | 3086 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3116 | 3087 | + on_control_active_input_update, | ||
3117 | 3088 | + dialog); | ||
3118 | 3089 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3119 | 3090 | + on_control_active_output_update, | ||
3120 | 3091 | + dialog); | ||
3121 | 3092 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3122 | 3093 | + on_control_input_added, | ||
3123 | 3094 | + dialog); | ||
3124 | 3095 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3125 | 3096 | + on_control_input_removed, | ||
3126 | 3097 | + dialog); | ||
3127 | 3098 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3128 | 3099 | + on_control_stream_added, | ||
3129 | 3100 | + dialog); | ||
3130 | 3101 | + g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control, | ||
3131 | 3102 | + on_control_stream_removed, | ||
3132 | 3103 | + dialog); | ||
3133 | 3104 | + g_object_unref (dialog->priv->mixer_control); | ||
3134 | 3105 | + dialog->priv->mixer_control = NULL; | ||
3135 | 3106 | + } | ||
3136 | 3107 | + | ||
3137 | 3108 | + if (dialog->priv->bars != NULL) { | ||
3138 | 3109 | + g_hash_table_destroy (dialog->priv->bars); | ||
3139 | 3110 | + dialog->priv->bars = NULL; | ||
3140 | 3111 | + } | ||
3141 | 3112 | + | ||
3142 | 3113 | + G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->dispose (object); | ||
3143 | 3114 | +} | ||
3144 | 3115 | + | ||
3145 | 3116 | +static void | ||
3146 | 3117 | +gvc_mixer_dialog_class_init (GvcMixerDialogClass *klass) | ||
3147 | 3118 | +{ | ||
3148 | 3119 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
3149 | 3120 | + | ||
3150 | 3121 | + object_class->constructor = gvc_mixer_dialog_constructor; | ||
3151 | 3122 | + object_class->dispose = gvc_mixer_dialog_dispose; | ||
3152 | 3123 | + object_class->finalize = gvc_mixer_dialog_finalize; | ||
3153 | 3124 | + object_class->set_property = gvc_mixer_dialog_set_property; | ||
3154 | 3125 | + object_class->get_property = gvc_mixer_dialog_get_property; | ||
3155 | 3126 | + | ||
3156 | 3127 | + g_object_class_install_property (object_class, | ||
3157 | 3128 | + PROP_MIXER_CONTROL, | ||
3158 | 3129 | + g_param_spec_object ("mixer-control", | ||
3159 | 3130 | + "mixer control", | ||
3160 | 3131 | + "mixer control", | ||
3161 | 3132 | + GVC_TYPE_MIXER_CONTROL, | ||
3162 | 3133 | + G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); | ||
3163 | 3134 | + | ||
3164 | 3135 | + g_type_class_add_private (klass, sizeof (GvcMixerDialogPrivate)); | ||
3165 | 3136 | +} | ||
3166 | 3137 | + | ||
3167 | 3138 | + | ||
3168 | 3139 | +static void | ||
3169 | 3140 | +gvc_mixer_dialog_init (GvcMixerDialog *dialog) | ||
3170 | 3141 | +{ | ||
3171 | 3142 | + dialog->priv = GVC_MIXER_DIALOG_GET_PRIVATE (dialog); | ||
3172 | 3143 | + dialog->priv->bars = g_hash_table_new (NULL, NULL); | ||
3173 | 3144 | + dialog->priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); | ||
3174 | 3145 | +} | ||
3175 | 3146 | + | ||
3176 | 3147 | +static void | ||
3177 | 3148 | +gvc_mixer_dialog_finalize (GObject *object) | ||
3178 | 3149 | +{ | ||
3179 | 3150 | + GvcMixerDialog *mixer_dialog; | ||
3180 | 3151 | + | ||
3181 | 3152 | + g_return_if_fail (object != NULL); | ||
3182 | 3153 | + g_return_if_fail (GVC_IS_MIXER_DIALOG (object)); | ||
3183 | 3154 | + | ||
3184 | 3155 | + mixer_dialog = GVC_MIXER_DIALOG (object); | ||
3185 | 3156 | + | ||
3186 | 3157 | + g_return_if_fail (mixer_dialog->priv != NULL); | ||
3187 | 3158 | + G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->finalize (object); | ||
3188 | 3159 | +} | ||
3189 | 3160 | + | ||
3190 | 3161 | +GvcMixerDialog * | ||
3191 | 3162 | +gvc_mixer_dialog_new (GvcMixerControl *control) | ||
3192 | 3163 | +{ | ||
3193 | 3164 | + GObject *dialog; | ||
3194 | 3165 | + dialog = g_object_new (GVC_TYPE_MIXER_DIALOG, | ||
3195 | 3166 | + "mixer-control", control, | ||
3196 | 3167 | + NULL); | ||
3197 | 3168 | + return GVC_MIXER_DIALOG (dialog); | ||
3198 | 3169 | +} | ||
3199 | 3170 | + | ||
3200 | 3171 | +enum { | ||
3201 | 3172 | + PAGE_OUTPUT, | ||
3202 | 3173 | + PAGE_INPUT, | ||
3203 | 3174 | + PAGE_EVENTS, | ||
3204 | 3175 | + PAGE_APPLICATIONS | ||
3205 | 3176 | +}; | ||
3206 | 3177 | + | ||
3207 | 3178 | +gboolean | ||
3208 | 3179 | +gvc_mixer_dialog_set_page (GvcMixerDialog *self, | ||
3209 | 3180 | + const char *page) | ||
3210 | 3181 | +{ | ||
3211 | 3182 | + guint num; | ||
3212 | 3183 | + | ||
3213 | 3184 | + g_return_val_if_fail (self != NULL, FALSE); | ||
3214 | 3185 | + | ||
3215 | 3186 | + num = PAGE_OUTPUT; | ||
3216 | 3187 | + | ||
3217 | 3188 | + if (g_str_equal (page, "effects")) | ||
3218 | 3189 | + num = PAGE_EVENTS; | ||
3219 | 3190 | + else if (g_str_equal (page, "input")) | ||
3220 | 3191 | + num = PAGE_INPUT; | ||
3221 | 3192 | + else if (g_str_equal (page, "output")) | ||
3222 | 3193 | + num = PAGE_OUTPUT; | ||
3223 | 3194 | + else if (g_str_equal (page, "applications")) | ||
3224 | 3195 | + num = PAGE_APPLICATIONS; | ||
3225 | 3196 | + | ||
3226 | 3197 | + gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), num); | ||
3227 | 3198 | + | ||
3228 | 3199 | + return TRUE; | ||
3229 | 3200 | +} | ||
3230 | 3201 | Index: gnome-control-center-3.6.2/panels/sound-nua/gvc-mixer-dialog.h | ||
3231 | 3202 | =================================================================== | ||
3232 | 3203 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
3233 | 3204 | +++ gnome-control-center-3.6.2/panels/sound-nua/gvc-mixer-dialog.h 2012-11-13 16:25:40.893717986 +0100 | ||
3234 | 3205 | @@ -0,0 +1,56 @@ | ||
3235 | 3206 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | ||
3236 | 3207 | + * | ||
3237 | 3208 | + * Copyright (C) 2008 Red Hat, Inc. | ||
3238 | 3209 | + * | ||
3239 | 3210 | + * This program is free software; you can redistribute it and/or modify | ||
3240 | 3211 | + * it under the terms of the GNU General Public License as published by | ||
3241 | 3212 | + * the Free Software Foundation; either version 2 of the License, or | ||
3242 | 3213 | + * (at your option) any later version. | ||
3243 | 3214 | + * | ||
3244 | 3215 | + * This program is distributed in the hope that it will be useful, | ||
3245 | 3216 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3246 | 3217 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3247 | 3218 | + * GNU General Public License for more details. | ||
3248 | 3219 | + * | ||
3249 | 3220 | + * You should have received a copy of the GNU General Public License | ||
3250 | 3221 | + * along with this program; if not, write to the Free Software | ||
3251 | 3222 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
3252 | 3223 | + * | ||
3253 | 3224 | + */ | ||
3254 | 3225 | + | ||
3255 | 3226 | +#ifndef __GVC_MIXER_DIALOG_H | ||
3256 | 3227 | +#define __GVC_MIXER_DIALOG_H | ||
3257 | 3228 | + | ||
3258 | 3229 | +#include <glib-object.h> | ||
3259 | 3230 | +#include "gvc-mixer-control.h" | ||
3260 | 3231 | + | ||
3261 | 3232 | +G_BEGIN_DECLS | ||
3262 | 3233 | + | ||
3263 | 3234 | +#define GVC_TYPE_MIXER_DIALOG (gvc_mixer_dialog_get_type ()) | ||
3264 | 3235 | +#define GVC_MIXER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_DIALOG, GvcMixerDialog)) | ||
3265 | 3236 | +#define GVC_MIXER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_DIALOG, GvcMixerDialogClass)) | ||
3266 | 3237 | +#define GVC_IS_MIXER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_DIALOG)) | ||
3267 | 3238 | +#define GVC_IS_MIXER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_DIALOG)) | ||
3268 | 3239 | +#define GVC_MIXER_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_DIALOG, GvcMixerDialogClass)) | ||
3269 | 3240 | + | ||
3270 | 3241 | +typedef struct GvcMixerDialogPrivate GvcMixerDialogPrivate; | ||
3271 | 3242 | + | ||
3272 | 3243 | +typedef struct | ||
3273 | 3244 | +{ | ||
3274 | 3245 | + GtkVBox parent; | ||
3275 | 3246 | + GvcMixerDialogPrivate *priv; | ||
3276 | 3247 | +} GvcMixerDialog; | ||
3277 | 3248 | + | ||
3278 | 3249 | +typedef struct | ||
3279 | 3250 | +{ | ||
3280 | 3251 | + GtkVBoxClass parent_class; | ||
3281 | 3252 | +} GvcMixerDialogClass; | ||
3282 | 3253 | + | ||
3283 | 3254 | +GType gvc_mixer_dialog_get_type (void); | ||
3284 | 3255 | + | ||
3285 | 3256 | +GvcMixerDialog * gvc_mixer_dialog_new (GvcMixerControl *control); | ||
3286 | 3257 | +gboolean gvc_mixer_dialog_set_page (GvcMixerDialog *dialog, const gchar* page); | ||
3287 | 3258 | + | ||
3288 | 3259 | +G_END_DECLS | ||
3289 | 3260 | + | ||
3290 | 3261 | +#endif /* __GVC_MIXER_DIALOG_H */ | ||
3291 | 3262 | Index: gnome-control-center-3.6.2/panels/sound/data/gnome-sound-panel.desktop.in.in | ||
3292 | 3263 | =================================================================== | ||
3293 | 3264 | --- gnome-control-center-3.6.2.orig/panels/sound/data/gnome-sound-panel.desktop.in.in 2012-10-01 11:39:00.000000000 +0200 | ||
3294 | 3265 | +++ gnome-control-center-3.6.2/panels/sound/data/gnome-sound-panel.desktop.in.in 2012-11-13 16:25:40.897717987 +0100 | ||
3295 | 3266 | @@ -7,7 +7,7 @@ | ||
3296 | 3267 | Type=Application | ||
3297 | 3268 | StartupNotify=true | ||
3298 | 3269 | Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel; | ||
3299 | 3270 | -OnlyShowIn=GNOME;Unity; | ||
3300 | 3271 | +OnlyShowIn=GNOME; | ||
3301 | 3272 | X-GNOME-Bugzilla-Bugzilla=GNOME | ||
3302 | 3273 | X-GNOME-Bugzilla-Product=gnome-control-center | ||
3303 | 3274 | X-GNOME-Bugzilla-Component=sound | ||
3304 | 3275 | Index: gnome-control-center-3.6.2/panels/universal-access/cc-ua-panel.c | ||
3305 | 3276 | =================================================================== | ||
3306 | 3277 | --- gnome-control-center-3.6.2.orig/panels/universal-access/cc-ua-panel.c 2012-11-13 16:25:40.341717994 +0100 | ||
3307 | 3278 | +++ gnome-control-center-3.6.2/panels/universal-access/cc-ua-panel.c 2012-11-13 16:25:40.897717987 +0100 | ||
3308 | 3279 | @@ -492,7 +492,10 @@ | ||
3309 | 3280 | CcShell *shell; | ||
3310 | 3281 | |||
3311 | 3282 | shell = cc_panel_get_shell (CC_PANEL (panel)); | ||
3312 | 3283 | - cc_shell_set_active_panel_from_id (shell, "sound", NULL, NULL); | ||
3313 | 3284 | + if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0) | ||
3314 | 3285 | + cc_shell_set_active_panel_from_id (shell, "sound-nua", NULL, NULL); | ||
3315 | 3286 | + else | ||
3316 | 3287 | + cc_shell_set_active_panel_from_id (shell, "sound", NULL, NULL); | ||
3317 | 3288 | |||
3318 | 3289 | return TRUE; | ||
3319 | 3290 | } | ||
3320 | 3291 | Index: gnome-control-center-3.6.2/shell/gnome-control-center.c | ||
3321 | 3292 | =================================================================== | ||
3322 | 3293 | --- gnome-control-center-3.6.2.orig/shell/gnome-control-center.c 2012-11-13 16:25:40.669717988 +0100 | ||
3323 | 3294 | +++ gnome-control-center-3.6.2/shell/gnome-control-center.c 2012-11-13 16:25:40.897717987 +0100 | ||
3324 | 3295 | @@ -984,6 +984,10 @@ | ||
3325 | 3296 | |||
3326 | 3297 | g_clear_pointer (&priv->current_panel_id, g_free); | ||
3327 | 3298 | |||
3328 | 3299 | + if (!g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") && | ||
3329 | 3300 | + !g_strcmp0(start_id, "sound")) | ||
3330 | 3301 | + start_id = "sound-nua"; | ||
3331 | 3302 | + | ||
3332 | 3303 | /* clear any custom widgets */ | ||
3333 | 3304 | _shell_remove_all_custom_widgets (priv); | ||
3334 | 3305 |
Thanks David!