Skip to content

Commit

Permalink
configuration prune button in Preferences (resolves #120)
Browse files Browse the repository at this point in the history
release 2.3.9
  • Loading branch information
yktoo committed Jun 28, 2022
1 parent 1e73e33 commit c760d52
Show file tree
Hide file tree
Showing 10 changed files with 653 additions and 380 deletions.
5 changes: 4 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. Ubuntu] and its version
- Desktop environment [e.g. GNOME] and its version
- Sound Switcher Indicator version [e.g. 2.3.8]
- Sound Switcher Indicator version [e.g. 2.3.9]
- Installation source: `snap`, `.deb`, PPA, source code etc.

**Indicator config:**
Attach the file `~/.config/indicator-sound-switcher.json`

**Indicator log:**
In order to fetch it, quit the indicator from the menu ("Quit"), open Terminal and start it again as follows:
```bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/dist/
/locale/
/.idea/
/venv/
MANIFEST
*.pyc
*.mo
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
indicator-sound-switcher (2.3.9-1) jammy; urgency=low

* Configuration prune button in Preferences (#120)

-- Dmitry Kann <yktooo@gmail.com> Tue, 28 Jun 2022 11:28:02 +0200

indicator-sound-switcher (2.3.8-1) jammy; urgency=low

* Only consider available ports for shortcut switching (#118)
Expand Down
2 changes: 1 addition & 1 deletion doc/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ find . -name '*.py' -or -name '*.glade' | xargs xgettext --from-code=UTF-8 --out

1. `sudo apt-get install poedit`
2. Open the `po/<language>.po` file with Poeditor
3. Select in Poeditor: Catalogue -> Update from POT file… -> Select the file `po/indicator-sound-switcher.pot`
3. Select in Poeditor: Translation -> Update from POT file… -> Select the file `po/indicator-sound-switcher.pot`
4. Edit and save the translation
5. Commit the file and send a pull request to the author
374 changes: 206 additions & 168 deletions lib/indicator_sound_switcher/prefs.glade

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions lib/indicator_sound_switcher/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,58 @@ def on_destroy(self, dlg):
# Make sure config update has run
self.indicator_refresh_cb()

def on_config_prune(self, *args):
"""Signal handler: Prune configuration button clicked."""
logging.debug('PreferencesDialog.on_config_prune()')

# Show a confirmation dialog
pruned = False
cnt = 0
dialog = Gtk.MessageDialog(
transient_for=self.prefs_dialog,
flags=0,
message_type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.OK_CANCEL,
text=_('Prune configuration'))
dialog.format_secondary_text(_(
'This will remove any settings about devices that are currently offline, such as Bluetooth headphones or '
'external sound cards.\n\n'
'Do you wish to continue?'))
response = dialog.run()
if response == Gtk.ResponseType.OK:
# Make a set of known devices
known = {card.name for card in self.indicator.cards.values()}
logging.debug('Pruning config')

# Remove unknown devices from the config
for name in list(self.indicator.config['devices'].keys()):
if name not in known:
del self.indicator.config['devices'][name]
cnt += 1
logging.debug(' - Pruned device `%s`', name)

# Save the configuration if there was a change
if cnt > 0:
logging.debug('Config changed, saving')
self.indicator.config_save()

pruned = True

# Kill the dialog
dialog.destroy()

# Show info message after pruning
if pruned:
info_dlg = Gtk.MessageDialog(
transient_for=self.prefs_dialog,
flags=0,
message_type=Gtk.MessageType.INFO,
buttons=Gtk.ButtonsType.CLOSE,
text=_('Prune configuration'))
info_dlg.format_secondary_text(_('Removed {} device configuration entries.').format(cnt))
info_dlg.run()
info_dlg.destroy()

def on_refresh(self, *args):
"""Signal handler: Refresh button clicked."""
logging.debug('PreferencesDialog.on_refresh()')
Expand Down
153 changes: 104 additions & 49 deletions po/indicator-sound-switcher.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-03 17:38+0100\n"
"POT-Creation-Date: 2022-06-28 11:21+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,124 +17,179 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: lib/indicator_sound_switcher/prefs.py:181
msgid "Out"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:181
msgid "In"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:216
#: lib/indicator_sound_switcher/prefs.py:224
#: lib/indicator_sound_switcher/prefs.py:400
msgid "(none)"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:417
msgid "Keyboard shortcut"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:424
msgid ""
"Press the desired key combination, <b>Backspace</b> to remove any shortcut, "
"or <b>Esc</b> to cancel."
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:49
#: build/lib/indicator_sound_switcher/prefs.glade:49
#: lib/indicator_sound_switcher/prefs.glade:546
msgid "Preferences"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:50
#: build/lib/indicator_sound_switcher/prefs.glade:50
#: lib/indicator_sound_switcher/prefs.glade:547
msgid "Sound Switcher Indicator"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:111
#: build/lib/indicator_sound_switcher/prefs.glade:111
#: lib/indicator_sound_switcher/prefs.glade:90
msgid "Show inputs"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:126
#: build/lib/indicator_sound_switcher/prefs.glade:126
#: lib/indicator_sound_switcher/prefs.glade:105
msgid "Show outputs"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:166
#: build/lib/indicator_sound_switcher/prefs.glade:166
#: lib/indicator_sound_switcher/prefs.glade:178
msgid "_General"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:189
#: build/lib/indicator_sound_switcher/prefs.glade:189
#: lib/indicator_sound_switcher/prefs.glade:202
msgid "Devices"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:204
#: build/lib/indicator_sound_switcher/prefs.glade:204
#: lib/indicator_sound_switcher/prefs.glade:217
msgid "Device settings"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:219
#: build/lib/indicator_sound_switcher/prefs.glade:219
#: lib/indicator_sound_switcher/prefs.glade:232
msgid "Port settings"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:278
#: lib/indicator_sound_switcher/prefs.glade:408
#: build/lib/indicator_sound_switcher/prefs.glade:278
#: build/lib/indicator_sound_switcher/prefs.glade:408
#: lib/indicator_sound_switcher/prefs.glade:291
#: lib/indicator_sound_switcher/prefs.glade:422
msgid "Custom name:"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:291
#: lib/indicator_sound_switcher/prefs.glade:444
#: build/lib/indicator_sound_switcher/prefs.glade:291
#: build/lib/indicator_sound_switcher/prefs.glade:444
#: lib/indicator_sound_switcher/prefs.glade:304
#: lib/indicator_sound_switcher/prefs.glade:458
msgid "Reset"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:313
#: build/lib/indicator_sound_switcher/prefs.glade:313
#: lib/indicator_sound_switcher/prefs.glade:326
msgid "Ports:"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:372
#: build/lib/indicator_sound_switcher/prefs.glade:372
#: lib/indicator_sound_switcher/prefs.glade:386
msgid "Visible:"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:396
#: build/lib/indicator_sound_switcher/prefs.glade:396
#: lib/indicator_sound_switcher/prefs.glade:410
msgid "Always available:"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:420
#: build/lib/indicator_sound_switcher/prefs.glade:420
#: lib/indicator_sound_switcher/prefs.glade:434
msgid "Preferred profile:"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:471
#: build/lib/indicator_sound_switcher/prefs.glade:471
#: lib/indicator_sound_switcher/prefs.glade:485
msgid "Keyboard shortcut:"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:505
#: build/lib/indicator_sound_switcher/prefs.glade:505
#: lib/indicator_sound_switcher/prefs.glade:519
msgid "_Devices"
msgstr ""

#: build/lib/indicator_sound_switcher/port.py:99
#: lib/indicator_sound_switcher/port.py:99
msgid "(unknown device)"
msgstr ""

#: build/lib/indicator_sound_switcher/prefs.py:181
#: lib/indicator_sound_switcher/prefs.py:182
msgid "Out"
msgstr ""

#: build/lib/indicator_sound_switcher/prefs.py:181
#: lib/indicator_sound_switcher/prefs.py:182
msgid "In"
msgstr ""

#: build/lib/indicator_sound_switcher/prefs.py:216
#: build/lib/indicator_sound_switcher/prefs.py:224
#: build/lib/indicator_sound_switcher/prefs.py:400
#: lib/indicator_sound_switcher/card.py:71
#: lib/indicator_sound_switcher/prefs.py:217
#: lib/indicator_sound_switcher/prefs.py:225
#: lib/indicator_sound_switcher/prefs.py:446
msgid "(none)"
msgstr ""

#: build/lib/indicator_sound_switcher/prefs.py:417
#: lib/indicator_sound_switcher/prefs.py:463
msgid "Keyboard shortcut"
msgstr ""

#: build/lib/indicator_sound_switcher/prefs.py:424
#: lib/indicator_sound_switcher/prefs.py:470
msgid ""
"Press the desired key combination, <b>Backspace</b> to remove any shortcut, "
"or <b>Esc</b> to cancel."
msgstr ""

#: build/lib/indicator_sound_switcher/indicator.py:192
#: lib/indicator_sound_switcher/indicator.py:195
msgid "Written by Dmitry Kann"
msgstr ""

#: lib/indicator_sound_switcher/indicator.py:993
#: build/lib/indicator_sound_switcher/indicator.py:990
#: lib/indicator_sound_switcher/indicator.py:1041
msgid "Inputs"
msgstr ""

#: lib/indicator_sound_switcher/indicator.py:1001
#: build/lib/indicator_sound_switcher/indicator.py:998
#: lib/indicator_sound_switcher/indicator.py:1049
msgid "Outputs"
msgstr ""

#: lib/indicator_sound_switcher/indicator.py:1008
#: build/lib/indicator_sound_switcher/indicator.py:1005
#: lib/indicator_sound_switcher/indicator.py:1056
msgid "_Refresh"
msgstr ""

#: lib/indicator_sound_switcher/indicator.py:1009
#: build/lib/indicator_sound_switcher/indicator.py:1006
#: lib/indicator_sound_switcher/indicator.py:1057
msgid "_Preferences…"
msgstr ""

#: lib/indicator_sound_switcher/indicator.py:1010
#: build/lib/indicator_sound_switcher/indicator.py:1007
#: lib/indicator_sound_switcher/indicator.py:1058
msgid "_About"
msgstr ""

#: lib/indicator_sound_switcher/indicator.py:1011
#: build/lib/indicator_sound_switcher/indicator.py:1008
#: lib/indicator_sound_switcher/indicator.py:1059
msgid "_Quit"
msgstr ""

#: lib/indicator_sound_switcher/prefs.glade:153
msgid "Prune configuration…"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:285
#: lib/indicator_sound_switcher/prefs.py:320
msgid "Prune configuration"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:287
msgid ""
"This will remove any settings about devices that are currently offline, such "
"as Bluetooth headphones or external sound cards.\n"
"\n"
"Do you wish to continue?"
msgstr ""

#: lib/indicator_sound_switcher/prefs.py:321
msgid "Removed {} device configuration entries."
msgstr ""
Loading

0 comments on commit c760d52

Please # to comment.