Skip to content

Commit c760d52

Browse files
committed
configuration prune button in Preferences (resolves #120)
release 2.3.9
1 parent 1e73e33 commit c760d52

File tree

10 files changed

+653
-380
lines changed

10 files changed

+653
-380
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ If applicable, add screenshots to help explain your problem.
2626
**Desktop (please complete the following information):**
2727
- OS: [e.g. Ubuntu] and its version
2828
- Desktop environment [e.g. GNOME] and its version
29-
- Sound Switcher Indicator version [e.g. 2.3.8]
29+
- Sound Switcher Indicator version [e.g. 2.3.9]
3030
- Installation source: `snap`, `.deb`, PPA, source code etc.
3131

32+
**Indicator config:**
33+
Attach the file `~/.config/indicator-sound-switcher.json`
34+
3235
**Indicator log:**
3336
In order to fetch it, quit the indicator from the menu ("Quit"), open Terminal and start it again as follows:
3437
```bash

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/dist/
33
/locale/
44
/.idea/
5+
/venv/
56
MANIFEST
67
*.pyc
78
*.mo

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
indicator-sound-switcher (2.3.9-1) jammy; urgency=low
2+
3+
* Configuration prune button in Preferences (#120)
4+
5+
-- Dmitry Kann <[email protected]> Tue, 28 Jun 2022 11:28:02 +0200
6+
17
indicator-sound-switcher (2.3.8-1) jammy; urgency=low
28

39
* Only consider available ports for shortcut switching (#118)

doc/i18n.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ find . -name '*.py' -or -name '*.glade' | xargs xgettext --from-code=UTF-8 --out
1010

1111
1. `sudo apt-get install poedit`
1212
2. Open the `po/<language>.po` file with Poeditor
13-
3. Select in Poeditor: Catalogue -> Update from POT file… -> Select the file `po/indicator-sound-switcher.pot`
13+
3. Select in Poeditor: Translation -> Update from POT file… -> Select the file `po/indicator-sound-switcher.pot`
1414
4. Edit and save the translation
1515
5. Commit the file and send a pull request to the author

lib/indicator_sound_switcher/prefs.glade

Lines changed: 206 additions & 168 deletions
Large diffs are not rendered by default.

lib/indicator_sound_switcher/prefs.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,58 @@ def on_destroy(self, dlg):
270270
# Make sure config update has run
271271
self.indicator_refresh_cb()
272272

273+
def on_config_prune(self, *args):
274+
"""Signal handler: Prune configuration button clicked."""
275+
logging.debug('PreferencesDialog.on_config_prune()')
276+
277+
# Show a confirmation dialog
278+
pruned = False
279+
cnt = 0
280+
dialog = Gtk.MessageDialog(
281+
transient_for=self.prefs_dialog,
282+
flags=0,
283+
message_type=Gtk.MessageType.WARNING,
284+
buttons=Gtk.ButtonsType.OK_CANCEL,
285+
text=_('Prune configuration'))
286+
dialog.format_secondary_text(_(
287+
'This will remove any settings about devices that are currently offline, such as Bluetooth headphones or '
288+
'external sound cards.\n\n'
289+
'Do you wish to continue?'))
290+
response = dialog.run()
291+
if response == Gtk.ResponseType.OK:
292+
# Make a set of known devices
293+
known = {card.name for card in self.indicator.cards.values()}
294+
logging.debug('Pruning config')
295+
296+
# Remove unknown devices from the config
297+
for name in list(self.indicator.config['devices'].keys()):
298+
if name not in known:
299+
del self.indicator.config['devices'][name]
300+
cnt += 1
301+
logging.debug(' - Pruned device `%s`', name)
302+
303+
# Save the configuration if there was a change
304+
if cnt > 0:
305+
logging.debug('Config changed, saving')
306+
self.indicator.config_save()
307+
308+
pruned = True
309+
310+
# Kill the dialog
311+
dialog.destroy()
312+
313+
# Show info message after pruning
314+
if pruned:
315+
info_dlg = Gtk.MessageDialog(
316+
transient_for=self.prefs_dialog,
317+
flags=0,
318+
message_type=Gtk.MessageType.INFO,
319+
buttons=Gtk.ButtonsType.CLOSE,
320+
text=_('Prune configuration'))
321+
info_dlg.format_secondary_text(_('Removed {} device configuration entries.').format(cnt))
322+
info_dlg.run()
323+
info_dlg.destroy()
324+
273325
def on_refresh(self, *args):
274326
"""Signal handler: Refresh button clicked."""
275327
logging.debug('PreferencesDialog.on_refresh()')

po/indicator-sound-switcher.pot

Lines changed: 104 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-01-03 17:38+0100\n"
11+
"POT-Creation-Date: 2022-06-28 11:21+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -17,124 +17,179 @@ msgstr ""
1717
"Content-Type: text/plain; charset=UTF-8\n"
1818
"Content-Transfer-Encoding: 8bit\n"
1919

20-
#: lib/indicator_sound_switcher/prefs.py:181
21-
msgid "Out"
22-
msgstr ""
23-
24-
#: lib/indicator_sound_switcher/prefs.py:181
25-
msgid "In"
26-
msgstr ""
27-
28-
#: lib/indicator_sound_switcher/prefs.py:216
29-
#: lib/indicator_sound_switcher/prefs.py:224
30-
#: lib/indicator_sound_switcher/prefs.py:400
31-
msgid "(none)"
32-
msgstr ""
33-
34-
#: lib/indicator_sound_switcher/prefs.py:417
35-
msgid "Keyboard shortcut"
36-
msgstr ""
37-
38-
#: lib/indicator_sound_switcher/prefs.py:424
39-
msgid ""
40-
"Press the desired key combination, <b>Backspace</b> to remove any shortcut, "
41-
"or <b>Esc</b> to cancel."
42-
msgstr ""
43-
44-
#: lib/indicator_sound_switcher/prefs.glade:49
20+
#: build/lib/indicator_sound_switcher/prefs.glade:49
21+
#: lib/indicator_sound_switcher/prefs.glade:546
4522
msgid "Preferences"
4623
msgstr ""
4724

48-
#: lib/indicator_sound_switcher/prefs.glade:50
25+
#: build/lib/indicator_sound_switcher/prefs.glade:50
26+
#: lib/indicator_sound_switcher/prefs.glade:547
4927
msgid "Sound Switcher Indicator"
5028
msgstr ""
5129

52-
#: lib/indicator_sound_switcher/prefs.glade:111
30+
#: build/lib/indicator_sound_switcher/prefs.glade:111
31+
#: lib/indicator_sound_switcher/prefs.glade:90
5332
msgid "Show inputs"
5433
msgstr ""
5534

56-
#: lib/indicator_sound_switcher/prefs.glade:126
35+
#: build/lib/indicator_sound_switcher/prefs.glade:126
36+
#: lib/indicator_sound_switcher/prefs.glade:105
5737
msgid "Show outputs"
5838
msgstr ""
5939

60-
#: lib/indicator_sound_switcher/prefs.glade:166
40+
#: build/lib/indicator_sound_switcher/prefs.glade:166
41+
#: lib/indicator_sound_switcher/prefs.glade:178
6142
msgid "_General"
6243
msgstr ""
6344

64-
#: lib/indicator_sound_switcher/prefs.glade:189
45+
#: build/lib/indicator_sound_switcher/prefs.glade:189
46+
#: lib/indicator_sound_switcher/prefs.glade:202
6547
msgid "Devices"
6648
msgstr ""
6749

68-
#: lib/indicator_sound_switcher/prefs.glade:204
50+
#: build/lib/indicator_sound_switcher/prefs.glade:204
51+
#: lib/indicator_sound_switcher/prefs.glade:217
6952
msgid "Device settings"
7053
msgstr ""
7154

72-
#: lib/indicator_sound_switcher/prefs.glade:219
55+
#: build/lib/indicator_sound_switcher/prefs.glade:219
56+
#: lib/indicator_sound_switcher/prefs.glade:232
7357
msgid "Port settings"
7458
msgstr ""
7559

76-
#: lib/indicator_sound_switcher/prefs.glade:278
77-
#: lib/indicator_sound_switcher/prefs.glade:408
60+
#: build/lib/indicator_sound_switcher/prefs.glade:278
61+
#: build/lib/indicator_sound_switcher/prefs.glade:408
62+
#: lib/indicator_sound_switcher/prefs.glade:291
63+
#: lib/indicator_sound_switcher/prefs.glade:422
7864
msgid "Custom name:"
7965
msgstr ""
8066

81-
#: lib/indicator_sound_switcher/prefs.glade:291
82-
#: lib/indicator_sound_switcher/prefs.glade:444
67+
#: build/lib/indicator_sound_switcher/prefs.glade:291
68+
#: build/lib/indicator_sound_switcher/prefs.glade:444
69+
#: lib/indicator_sound_switcher/prefs.glade:304
70+
#: lib/indicator_sound_switcher/prefs.glade:458
8371
msgid "Reset"
8472
msgstr ""
8573

86-
#: lib/indicator_sound_switcher/prefs.glade:313
74+
#: build/lib/indicator_sound_switcher/prefs.glade:313
75+
#: lib/indicator_sound_switcher/prefs.glade:326
8776
msgid "Ports:"
8877
msgstr ""
8978

90-
#: lib/indicator_sound_switcher/prefs.glade:372
79+
#: build/lib/indicator_sound_switcher/prefs.glade:372
80+
#: lib/indicator_sound_switcher/prefs.glade:386
9181
msgid "Visible:"
9282
msgstr ""
9383

94-
#: lib/indicator_sound_switcher/prefs.glade:396
84+
#: build/lib/indicator_sound_switcher/prefs.glade:396
85+
#: lib/indicator_sound_switcher/prefs.glade:410
9586
msgid "Always available:"
9687
msgstr ""
9788

98-
#: lib/indicator_sound_switcher/prefs.glade:420
89+
#: build/lib/indicator_sound_switcher/prefs.glade:420
90+
#: lib/indicator_sound_switcher/prefs.glade:434
9991
msgid "Preferred profile:"
10092
msgstr ""
10193

102-
#: lib/indicator_sound_switcher/prefs.glade:471
94+
#: build/lib/indicator_sound_switcher/prefs.glade:471
95+
#: lib/indicator_sound_switcher/prefs.glade:485
10396
msgid "Keyboard shortcut:"
10497
msgstr ""
10598

106-
#: lib/indicator_sound_switcher/prefs.glade:505
99+
#: build/lib/indicator_sound_switcher/prefs.glade:505
100+
#: lib/indicator_sound_switcher/prefs.glade:519
107101
msgid "_Devices"
108102
msgstr ""
109103

104+
#: build/lib/indicator_sound_switcher/port.py:99
110105
#: lib/indicator_sound_switcher/port.py:99
111106
msgid "(unknown device)"
112107
msgstr ""
113108

109+
#: build/lib/indicator_sound_switcher/prefs.py:181
110+
#: lib/indicator_sound_switcher/prefs.py:182
111+
msgid "Out"
112+
msgstr ""
113+
114+
#: build/lib/indicator_sound_switcher/prefs.py:181
115+
#: lib/indicator_sound_switcher/prefs.py:182
116+
msgid "In"
117+
msgstr ""
118+
119+
#: build/lib/indicator_sound_switcher/prefs.py:216
120+
#: build/lib/indicator_sound_switcher/prefs.py:224
121+
#: build/lib/indicator_sound_switcher/prefs.py:400
122+
#: lib/indicator_sound_switcher/card.py:71
123+
#: lib/indicator_sound_switcher/prefs.py:217
124+
#: lib/indicator_sound_switcher/prefs.py:225
125+
#: lib/indicator_sound_switcher/prefs.py:446
126+
msgid "(none)"
127+
msgstr ""
128+
129+
#: build/lib/indicator_sound_switcher/prefs.py:417
130+
#: lib/indicator_sound_switcher/prefs.py:463
131+
msgid "Keyboard shortcut"
132+
msgstr ""
133+
134+
#: build/lib/indicator_sound_switcher/prefs.py:424
135+
#: lib/indicator_sound_switcher/prefs.py:470
136+
msgid ""
137+
"Press the desired key combination, <b>Backspace</b> to remove any shortcut, "
138+
"or <b>Esc</b> to cancel."
139+
msgstr ""
140+
141+
#: build/lib/indicator_sound_switcher/indicator.py:192
114142
#: lib/indicator_sound_switcher/indicator.py:195
115143
msgid "Written by Dmitry Kann"
116144
msgstr ""
117145

118-
#: lib/indicator_sound_switcher/indicator.py:993
146+
#: build/lib/indicator_sound_switcher/indicator.py:990
147+
#: lib/indicator_sound_switcher/indicator.py:1041
119148
msgid "Inputs"
120149
msgstr ""
121150

122-
#: lib/indicator_sound_switcher/indicator.py:1001
151+
#: build/lib/indicator_sound_switcher/indicator.py:998
152+
#: lib/indicator_sound_switcher/indicator.py:1049
123153
msgid "Outputs"
124154
msgstr ""
125155

126-
#: lib/indicator_sound_switcher/indicator.py:1008
156+
#: build/lib/indicator_sound_switcher/indicator.py:1005
157+
#: lib/indicator_sound_switcher/indicator.py:1056
127158
msgid "_Refresh"
128159
msgstr ""
129160

130-
#: lib/indicator_sound_switcher/indicator.py:1009
161+
#: build/lib/indicator_sound_switcher/indicator.py:1006
162+
#: lib/indicator_sound_switcher/indicator.py:1057
131163
msgid "_Preferences…"
132164
msgstr ""
133165

134-
#: lib/indicator_sound_switcher/indicator.py:1010
166+
#: build/lib/indicator_sound_switcher/indicator.py:1007
167+
#: lib/indicator_sound_switcher/indicator.py:1058
135168
msgid "_About"
136169
msgstr ""
137170

138-
#: lib/indicator_sound_switcher/indicator.py:1011
171+
#: build/lib/indicator_sound_switcher/indicator.py:1008
172+
#: lib/indicator_sound_switcher/indicator.py:1059
139173
msgid "_Quit"
140174
msgstr ""
175+
176+
#: lib/indicator_sound_switcher/prefs.glade:153
177+
msgid "Prune configuration…"
178+
msgstr ""
179+
180+
#: lib/indicator_sound_switcher/prefs.py:285
181+
#: lib/indicator_sound_switcher/prefs.py:320
182+
msgid "Prune configuration"
183+
msgstr ""
184+
185+
#: lib/indicator_sound_switcher/prefs.py:287
186+
msgid ""
187+
"This will remove any settings about devices that are currently offline, such "
188+
"as Bluetooth headphones or external sound cards.\n"
189+
"\n"
190+
"Do you wish to continue?"
191+
msgstr ""
192+
193+
#: lib/indicator_sound_switcher/prefs.py:321
194+
msgid "Removed {} device configuration entries."
195+
msgstr ""

0 commit comments

Comments
 (0)