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
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-11-07 15:14:18 +0000
+++ src/CMakeLists.txt 2016-12-21 03:28:29 +0000
@@ -14,6 +14,7 @@
14# Add all your vala files and requires packages to the List below to include them in the build14# Add all your vala files and requires packages to the List below to include them in the build
15vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}15vala_precompile (VALA_C ${CMAKE_PROJECT_NAME}
16 Indicator.vala16 Indicator.vala
17 Widgets/DisplayWidget.vala
17 Widgets/MaxWidthLabel.vala18 Widgets/MaxWidthLabel.vala
18 Widgets/Scale.vala19 Widgets/Scale.vala
19 Widgets/MprisGui.vala20 Widgets/MprisGui.vala
2021
=== modified file 'src/Indicator.vala'
--- src/Indicator.vala 2016-12-20 20:54:01 +0000
+++ src/Indicator.vala 2016-12-21 03:28:29 +0000
@@ -16,10 +16,10 @@
16 */16 */
1717
18public class Sound.Indicator : Wingpanel.Indicator {18public class Sound.Indicator : Wingpanel.Indicator {
19 private DisplayWidget display_widget;
19 private Gtk.Grid main_grid;20 private Gtk.Grid main_grid;
20 private Widgets.Scale volume_scale;21 private Widgets.Scale volume_scale;
21 private Widgets.Scale mic_scale;22 private Widgets.Scale mic_scale;
22 private Wingpanel.Widgets.OverlayIcon panel_icon;
23 private Wingpanel.Widgets.Button settings_button;23 private Wingpanel.Widgets.Button settings_button;
24 private Wingpanel.Widgets.Separator first_seperator;24 private Wingpanel.Widgets.Separator first_seperator;
25 private Wingpanel.Widgets.Separator mic_seperator;25 private Wingpanel.Widgets.Separator mic_seperator;
@@ -61,21 +61,6 @@
61 }61 }
6262
63 construct {63 construct {
64 panel_icon = new Wingpanel.Widgets.OverlayIcon ("audio-output-none");
65
66 // toggle mute on middle click
67 panel_icon.button_press_event.connect ((e) => {
68 if (e.button == Gdk.BUTTON_MIDDLE) {
69 volume_control.toggle_mute ();
70 return Gdk.EVENT_STOP;
71 }
72
73 return Gdk.EVENT_PROPAGATE;
74 });
75
76 // change volume on scroll
77 panel_icon.scroll_event.connect (on_icon_scroll_event);
78
79 var locale = Intl.setlocale (LocaleCategory.MESSAGES, null);64 var locale = Intl.setlocale (LocaleCategory.MESSAGES, null);
8065
81 volume_scale = new Widgets.Scale ("audio-volume-high-symbolic", true, 0.0, max_volume, 0.01);66 volume_scale = new Widgets.Scale ("audio-volume-high-symbolic", true, 0.0, max_volume, 0.01);
@@ -112,7 +97,7 @@
112 private void on_volume_change () {97 private void on_volume_change () {
113 var volume = volume_control.volume.volume / this.max_volume;98 var volume = volume_control.volume.volume / this.max_volume;
114 volume_scale.get_scale ().set_value (volume);99 volume_scale.get_scale ().set_value (volume);
115 panel_icon.set_main_icon_name (get_volume_icon (volume));100 display_widget.icon_name = get_volume_icon (volume);
116 }101 }
117102
118 private void on_mic_volume_change () {103 private void on_mic_volume_change () {
@@ -124,7 +109,7 @@
124 volume_scale.get_switch ().active = !volume_control.mute;109 volume_scale.get_switch ().active = !volume_control.mute;
125110
126 string volume_icon = get_volume_icon (volume_control.volume.volume);111 string volume_icon = get_volume_icon (volume_control.volume.volume);
127 panel_icon.set_main_icon_name (volume_icon);112 display_widget.icon_name = volume_icon;
128113
129 if (volume_control.mute) {114 if (volume_control.mute) {
130 volume_scale.set_icon ("audio-volume-muted-symbolic");115 volume_scale.set_icon ("audio-volume-muted-symbolic");
@@ -153,12 +138,12 @@
153 this.sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => {138 this.sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => {
154 this.mute_blocks_sound = false;139 this.mute_blocks_sound = false;
155 this.sound_was_blocked_timeout_id = 0;140 this.sound_was_blocked_timeout_id = 0;
156 panel_icon.set_main_icon_name (get_volume_icon (volume_control.volume.volume));141 display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
157 return false;142 return false;
158 });143 });
159 }144 }
160145
161 panel_icon.set_main_icon_name (get_volume_icon (volume_control.volume.volume));146 display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
162 }147 }
163148
164 private bool on_icon_scroll_event (Gdk.EventScroll e) {149 private bool on_icon_scroll_event (Gdk.EventScroll e) {
@@ -201,11 +186,13 @@
201 mic_scale.show_all();186 mic_scale.show_all();
202 mic_seperator.no_show_all = false;187 mic_seperator.no_show_all = false;
203 mic_seperator.show ();188 mic_seperator.show ();
189 display_widget.show_mic = true;
204 } else {190 } else {
205 mic_scale.no_show_all = true;191 mic_scale.no_show_all = true;
206 mic_scale.hide();192 mic_scale.hide();
207 mic_seperator.no_show_all = true;193 mic_seperator.no_show_all = true;
208 mic_seperator.hide ();194 mic_seperator.hide ();
195 display_widget.show_mic = false;
209 }196 }
210 }197 }
211198
@@ -238,8 +225,21 @@
238 }225 }
239226
240 public override Gtk.Widget get_display_widget () {227 public override Gtk.Widget get_display_widget () {
241 panel_icon.set_main_icon_name (get_volume_icon (volume_control.volume.volume));228 display_widget = new DisplayWidget ();
242 return panel_icon;229 display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
230
231 display_widget.button_press_event.connect ((e) => {
232 if (e.button == Gdk.BUTTON_MIDDLE) {
233 volume_control.toggle_mute ();
234 return Gdk.EVENT_STOP;
235 }
236
237 return Gdk.EVENT_PROPAGATE;
238 });
239
240 display_widget.scroll_event.connect (on_icon_scroll_event);
241
242 return display_widget;
243 }243 }
244244
245 public override Gtk.Widget? get_widget () {245 public override Gtk.Widget? get_widget () {
246246
=== added file 'src/Widgets/DisplayWidget.vala'
--- src/Widgets/DisplayWidget.vala 1970-01-01 00:00:00 +0000
+++ src/Widgets/DisplayWidget.vala 2016-12-21 03:28:29 +0000
@@ -0,0 +1,51 @@
1/*
2* Copyright (c) 2016 elementary LLC. (http://launchpad.net/wingpanel-indicator-sound)
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU General Public
6* License as published by the Free Software Foundation; either
7* version 2 of the License, or (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* General Public License for more details.
13*
14* You should have received a copy of the GNU General Public
15* License along with this program; if not, write to the
16* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17* Boston, MA 02111-1307, USA.
18*/
19
20public class DisplayWidget : Gtk.Grid {
21 private Gtk.Image volume_icon;
22 private Gtk.Revealer mic_revealer;
23
24 public bool show_mic {
25 set {
26 mic_revealer.reveal_child = value;
27 }
28 }
29
30 public string icon_name {
31 set {
32 volume_icon.icon_name = value;
33 }
34 }
35
36 construct {
37 volume_icon = new Gtk.Image ();
38 volume_icon.icon_name = "audio-volume-high-symbolic";
39 volume_icon.icon_size = Gtk.IconSize.LARGE_TOOLBAR;
40
41 var mic_icon = new Gtk.Image.from_icon_name ("audio-input-microphone-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
42 mic_icon.margin_start = 12;
43
44 mic_revealer = new Gtk.Revealer ();
45 mic_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT;
46 mic_revealer.add (mic_icon);
47
48 add (volume_icon);
49 add (mic_revealer);
50 }
51}

Subscribers

People subscribed via source and target branches

to all changes: