Merge lp:~charlesk/gnome-control-center/bug-829648-add-visibility-toggle into lp:gnome-control-center

Proposed by Charles Kerr
Status: Needs review
Proposed branch: lp:~charlesk/gnome-control-center/bug-829648-add-visibility-toggle
Merge into: lp:gnome-control-center
Diff against target: 102 lines (+57/-0)
1 file modified
panels/sound/gvc-mixer-dialog.c (+57/-0)
To merge this branch: bzr merge lp:~charlesk/gnome-control-center/bug-829648-add-visibility-toggle
Reviewer Review Type Date Requested Status
VCS imports Pending
Review via email: mp+90043@code.launchpad.net

Description of the change

This adds a visibility toggle to the sound panel for LP bug #829648

To post a comment you must log in.

Unmerged revisions

11117. By Charles Kerr on 2012-01-25

add indicator-sound visibility toggle for lp bug #829648

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/sound/gvc-mixer-dialog.c'
2--- panels/sound/gvc-mixer-dialog.c 2011-10-24 13:41:44 +0000
3+++ panels/sound/gvc-mixer-dialog.c 2012-01-25 05:30:31 +0000
4@@ -48,6 +48,8 @@
5
6 #define GVC_MIXER_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_DIALOG, GvcMixerDialogPrivate))
7
8+#define INDICATOR_SOUND_SCHEMA "com.canonical.indicator.sound"
9+
10 struct GvcMixerDialogPrivate
11 {
12 GvcMixerControl *mixer_control;
13@@ -80,6 +82,8 @@
14 GtkWidget *click_feedback_button;
15 GtkWidget *audible_bell_button;
16 GtkSizeGroup *size_group;
17+ GSettings *indicator_settings;
18+ GtkWidget *indicator_check;
19
20 gdouble last_input_peak;
21 guint num_apps;
22@@ -1712,13 +1716,40 @@
23 return treeview;
24 }
25
26+#define VISIBLE_KEY "visible"
27+
28+static void
29+on_indicator_visible_toggled (GtkToggleButton *toggle, GvcMixerDialog *dialog)
30+{
31+ const gboolean value = gtk_toggle_button_get_active (toggle);
32+ GSettings * settings = dialog->priv->indicator_settings;
33+
34+ if ((settings == NULL) || !g_settings_set_boolean (settings, VISIBLE_KEY, value))
35+ g_warning ("Unable to set %s.%s", INDICATOR_SOUND_SCHEMA, VISIBLE_KEY);
36+}
37+
38+static void
39+on_settings_changed (GSettings *settings, gchar *key, GvcMixerDialog *dialog)
40+{
41+ g_return_if_fail (!g_strcmp0 (key,VISIBLE_KEY));
42+
43+ GtkToggleButton * toggle = GTK_TOGGLE_BUTTON(dialog->priv->indicator_check);
44+ const gboolean oldval = gtk_toggle_button_get_active (toggle);
45+ const gboolean newval = g_settings_get_boolean (settings, key);
46+ if (oldval != newval)
47+ gtk_toggle_button_set_active (toggle, newval);
48+}
49+
50 static GObject *
51 gvc_mixer_dialog_constructor (GType type,
52 guint n_construct_properties,
53 GObjectConstructParam *construct_params)
54 {
55+ gboolean visible;
56+ GSettings *settings;
57 GObject *object;
58 GvcMixerDialog *self;
59+ GtkWidget *w;
60 GtkWidget *main_vbox;
61 GtkWidget *label;
62 GtkWidget *alignment;
63@@ -1980,6 +2011,27 @@
64 G_CALLBACK (on_control_card_removed),
65 self);
66
67+ w = gtk_check_button_new_with_mnemonic(_( "_Show sound volume in the menu bar"));
68+ alignment = gtk_alignment_new (0, 0, 1, 1);
69+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 5, 5);
70+ gtk_container_add (GTK_CONTAINER (alignment), w);
71+ gtk_box_pack_start (GTK_BOX (main_vbox), alignment, FALSE, FALSE, 0);
72+ settings = g_settings_new (INDICATOR_SOUND_SCHEMA);
73+ if (settings == NULL) {
74+ visible = TRUE;
75+ } else {
76+ g_signal_connect (settings, "changed::" VISIBLE_KEY, G_CALLBACK (on_settings_changed), self);
77+ visible = g_settings_get_boolean (settings, VISIBLE_KEY);
78+ }
79+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), visible);
80+ if (settings == NULL) {
81+ gtk_widget_set_sensitive (w, FALSE);
82+ } else {
83+ g_signal_connect (w, "toggled", G_CALLBACK(on_indicator_visible_toggled), self);
84+ }
85+ self->priv->indicator_check = w;
86+ self->priv->indicator_settings = settings;
87+
88 gtk_widget_show_all (main_vbox);
89
90 streams = gvc_mixer_control_get_streams (self->priv->mixer_control);
91@@ -2004,6 +2056,11 @@
92 {
93 GvcMixerDialog *dialog = GVC_MIXER_DIALOG (object);
94
95+ if (dialog->priv->indicator_settings != NULL) {
96+ g_object_unref (dialog->priv->indicator_settings);
97+ dialog->priv->indicator_settings = NULL;
98+ }
99+
100 if (dialog->priv->mixer_control != NULL) {
101 g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control,
102 on_control_stream_added,

Subscribers

People subscribed via source and target branches

to all changes: