aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sound-menu.vala27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/sound-menu.vala b/src/sound-menu.vala
index 38c5214..b93c513 100644
--- a/src/sound-menu.vala
+++ b/src/sound-menu.vala
@@ -82,8 +82,10 @@ public class SoundMenu: Object
this.mic_volume_shown = true;
}
else if (!value && this.mic_volume_shown) {
- /* TODO: Make smarter */
- this.volume_section.remove (this.volume_section.get_n_items () -1);
+ int location = -1;
+ while ((location = find_action(this.volume_section, "indicator.mic-volume")) != -1) {
+ this.volume_section.remove (location);
+ }
this.mic_volume_shown = false;
}
}
@@ -95,18 +97,35 @@ public class SoundMenu: Object
}
set {
if (value && !this.high_volume_warning_shown) {
- var item = new MenuItem(_("High volume can damage your hearing."), null);
+ /* NOTE: Action doesn't really exist, just used to find below when removing */
+ var item = new MenuItem(_("High volume can damage your hearing."), "indicator.high-volume-warning-item");
volume_section.append_item (item);
this.high_volume_warning_shown = true;
}
else if (!value && this.high_volume_warning_shown) {
- /* TODO: Make smarter */
+ int location = -1;
+ while ((location = find_action(this.volume_section, "indicator.high-volume-warning-item")) != -1) {
+ this.volume_section.remove (location);
+ }
this.volume_section.remove (this.volume_section.get_n_items () -1);
this.high_volume_warning_shown = false;
}
}
}
+ int find_action (Menu menu, string in_action) {
+ int n = menu.get_n_items ();
+ for (int i = 0; i < n; i++) {
+ string action;
+ menu.get_item_attribute (0, "action", "s", out action);
+ if (in_action == action)
+ return i;
+ }
+
+ return -1;
+ }
+
+
public void add_player (MediaPlayer player) {
if (this.notify_handlers.contains (player))
return;