~ps-jenkins/indicator-sound/ubuntu-vivid-proposed

« back to all changes in this revision

Viewing changes to src/sound-menu.vala

  • Committer: CI bot
  • Author(s): Ted Gould
  • Date: 2014-11-05 17:56:17 UTC
  • mfrom: (460.2.9 mega-merge)
  • Revision ID: ps-jenkins@lists.canonical.com-20141105175617-xoz3kmwa537vwaz0
Manually merging branches to resolve conflicts Fixes: 1358340, 1373404, 1378564, 1378961, 1381871
Approved by: PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
                                this.mic_volume_shown = true;
94
94
                        }
95
95
                        else if (!value && this.mic_volume_shown) {
96
 
                                this.volume_section.remove (this.volume_section.get_n_items () -1);
 
96
                                int location = -1;
 
97
                                while ((location = find_action(this.volume_section, "indicator.mic-volume")) != -1) {
 
98
                                        this.volume_section.remove (location);
 
99
                                }
97
100
                                this.mic_volume_shown = false;
98
101
                        }
99
102
                }
100
103
        }
101
104
 
 
105
        public bool show_high_volume_warning {
 
106
                get {
 
107
                        return this.high_volume_warning_shown;
 
108
                }
 
109
                set {
 
110
                        if (value && !this.high_volume_warning_shown) {
 
111
                                /* NOTE: Action doesn't really exist, just used to find below when removing */
 
112
                                var item = new MenuItem(_("High volume can damage your hearing."), "indicator.high-volume-warning-item");
 
113
                                volume_section.append_item (item);
 
114
                                this.high_volume_warning_shown = true;
 
115
                        }
 
116
                        else if (!value && this.high_volume_warning_shown) {
 
117
                                int location = -1;
 
118
                                while ((location = find_action(this.volume_section, "indicator.high-volume-warning-item")) != -1) {
 
119
                                        this.volume_section.remove (location);
 
120
                                }
 
121
                                this.high_volume_warning_shown = false;
 
122
                        }
 
123
                }
 
124
        }
 
125
 
 
126
        int find_action (Menu menu, string in_action) {
 
127
                int n = menu.get_n_items ();
 
128
                for (int i = 0; i < n; i++) {
 
129
                        string action;
 
130
                        menu.get_item_attribute (i, "action", "s", out action);
 
131
                        if (in_action == action)
 
132
                                return i;
 
133
                }
 
134
 
 
135
                return -1;
 
136
        }
 
137
 
 
138
 
102
139
        public void add_player (MediaPlayer player) {
103
140
                if (this.notify_handlers.contains (player))
104
141
                        return;
141
178
        Menu volume_section;
142
179
        bool mic_volume_shown;
143
180
        bool settings_shown = false;
 
181
        bool high_volume_warning_shown = false;
144
182
        bool hide_inactive;
145
183
        bool hide_players = false;
146
184
        HashTable<MediaPlayer, ulong> notify_handlers;