Merge lp:~elementary-pantheon/wingpanel-indicator-sound/mic-icon into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Corentin Noël
Approved revision: 137
Merged at revision: 138
Proposed branch: lp:~elementary-pantheon/wingpanel-indicator-sound/mic-icon
Merge into: lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
Diff against target: 176 lines (+74/-22)
3 files modified
src/CMakeLists.txt (+1/-0)
src/Indicator.vala (+22/-22)
src/Widgets/DisplayWidget.vala (+51/-0)
To merge this branch: bzr merge lp:~elementary-pantheon/wingpanel-indicator-sound/mic-icon
Reviewer Review Type Date Requested Status
Corentin Noël Approve
Review via email: mp+313666@code.launchpad.net

Commit message

* Create DisplayWidget.vala
* If the microphone is in use, show a mic icon in the panel

To post a comment you must log in.
137. By Danielle Foré

show microphone icon when mic is on

Revision history for this message
Corentin Noël (tintou) wrote :

That's elegant

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2016-11-07 15:14:18 +0000
3+++ src/CMakeLists.txt 2016-12-21 03:28:29 +0000
4@@ -14,6 +14,7 @@
5 # Add all your vala files and requires packages to the List below to include them in the build
6 vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}
7 Indicator.vala
8+ Widgets/DisplayWidget.vala
9 Widgets/MaxWidthLabel.vala
10 Widgets/Scale.vala
11 Widgets/MprisGui.vala
12
13=== modified file 'src/Indicator.vala'
14--- src/Indicator.vala 2016-12-20 20:54:01 +0000
15+++ src/Indicator.vala 2016-12-21 03:28:29 +0000
16@@ -16,10 +16,10 @@
17 */
18
19 public class Sound.Indicator : Wingpanel.Indicator {
20+ private DisplayWidget display_widget;
21 private Gtk.Grid main_grid;
22 private Widgets.Scale volume_scale;
23 private Widgets.Scale mic_scale;
24- private Wingpanel.Widgets.OverlayIcon panel_icon;
25 private Wingpanel.Widgets.Button settings_button;
26 private Wingpanel.Widgets.Separator first_seperator;
27 private Wingpanel.Widgets.Separator mic_seperator;
28@@ -61,21 +61,6 @@
29 }
30
31 construct {
32- panel_icon = new Wingpanel.Widgets.OverlayIcon ("audio-output-none");
33-
34- // toggle mute on middle click
35- panel_icon.button_press_event.connect ((e) => {
36- if (e.button == Gdk.BUTTON_MIDDLE) {
37- volume_control.toggle_mute ();
38- return Gdk.EVENT_STOP;
39- }
40-
41- return Gdk.EVENT_PROPAGATE;
42- });
43-
44- // change volume on scroll
45- panel_icon.scroll_event.connect (on_icon_scroll_event);
46-
47 var locale = Intl.setlocale (LocaleCategory.MESSAGES, null);
48
49 volume_scale = new Widgets.Scale ("audio-volume-high-symbolic", true, 0.0, max_volume, 0.01);
50@@ -112,7 +97,7 @@
51 private void on_volume_change () {
52 var volume = volume_control.volume.volume / this.max_volume;
53 volume_scale.get_scale ().set_value (volume);
54- panel_icon.set_main_icon_name (get_volume_icon (volume));
55+ display_widget.icon_name = get_volume_icon (volume);
56 }
57
58 private void on_mic_volume_change () {
59@@ -124,7 +109,7 @@
60 volume_scale.get_switch ().active = !volume_control.mute;
61
62 string volume_icon = get_volume_icon (volume_control.volume.volume);
63- panel_icon.set_main_icon_name (volume_icon);
64+ display_widget.icon_name = volume_icon;
65
66 if (volume_control.mute) {
67 volume_scale.set_icon ("audio-volume-muted-symbolic");
68@@ -153,12 +138,12 @@
69 this.sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => {
70 this.mute_blocks_sound = false;
71 this.sound_was_blocked_timeout_id = 0;
72- panel_icon.set_main_icon_name (get_volume_icon (volume_control.volume.volume));
73+ display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
74 return false;
75 });
76 }
77
78- panel_icon.set_main_icon_name (get_volume_icon (volume_control.volume.volume));
79+ display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
80 }
81
82 private bool on_icon_scroll_event (Gdk.EventScroll e) {
83@@ -201,11 +186,13 @@
84 mic_scale.show_all();
85 mic_seperator.no_show_all = false;
86 mic_seperator.show ();
87+ display_widget.show_mic = true;
88 } else {
89 mic_scale.no_show_all = true;
90 mic_scale.hide();
91 mic_seperator.no_show_all = true;
92 mic_seperator.hide ();
93+ display_widget.show_mic = false;
94 }
95 }
96
97@@ -238,8 +225,21 @@
98 }
99
100 public override Gtk.Widget get_display_widget () {
101- panel_icon.set_main_icon_name (get_volume_icon (volume_control.volume.volume));
102- return panel_icon;
103+ display_widget = new DisplayWidget ();
104+ display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
105+
106+ display_widget.button_press_event.connect ((e) => {
107+ if (e.button == Gdk.BUTTON_MIDDLE) {
108+ volume_control.toggle_mute ();
109+ return Gdk.EVENT_STOP;
110+ }
111+
112+ return Gdk.EVENT_PROPAGATE;
113+ });
114+
115+ display_widget.scroll_event.connect (on_icon_scroll_event);
116+
117+ return display_widget;
118 }
119
120 public override Gtk.Widget? get_widget () {
121
122=== added file 'src/Widgets/DisplayWidget.vala'
123--- src/Widgets/DisplayWidget.vala 1970-01-01 00:00:00 +0000
124+++ src/Widgets/DisplayWidget.vala 2016-12-21 03:28:29 +0000
125@@ -0,0 +1,51 @@
126+/*
127+* Copyright (c) 2016 elementary LLC. (http://launchpad.net/wingpanel-indicator-sound)
128+*
129+* This program is free software; you can redistribute it and/or
130+* modify it under the terms of the GNU General Public
131+* License as published by the Free Software Foundation; either
132+* version 2 of the License, or (at your option) any later version.
133+*
134+* This program is distributed in the hope that it will be useful,
135+* but WITHOUT ANY WARRANTY; without even the implied warranty of
136+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
137+* General Public License for more details.
138+*
139+* You should have received a copy of the GNU General Public
140+* License along with this program; if not, write to the
141+* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
142+* Boston, MA 02111-1307, USA.
143+*/
144+
145+public class DisplayWidget : Gtk.Grid {
146+ private Gtk.Image volume_icon;
147+ private Gtk.Revealer mic_revealer;
148+
149+ public bool show_mic {
150+ set {
151+ mic_revealer.reveal_child = value;
152+ }
153+ }
154+
155+ public string icon_name {
156+ set {
157+ volume_icon.icon_name = value;
158+ }
159+ }
160+
161+ construct {
162+ volume_icon = new Gtk.Image ();
163+ volume_icon.icon_name = "audio-volume-high-symbolic";
164+ volume_icon.icon_size = Gtk.IconSize.LARGE_TOOLBAR;
165+
166+ var mic_icon = new Gtk.Image.from_icon_name ("audio-input-microphone-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
167+ mic_icon.margin_start = 12;
168+
169+ mic_revealer = new Gtk.Revealer ();
170+ mic_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT;
171+ mic_revealer.add (mic_icon);
172+
173+ add (volume_icon);
174+ add (mic_revealer);
175+ }
176+}

Subscribers

People subscribed via source and target branches

to all changes: