Commit b9badc47 authored by Lukáš Tyrychtr's avatar Lukáš Tyrychtr Committed by Jeremy Bicha

appearance: Add sound theme chooser

Add a sound theme chooser below the other theming options.

This feature may be useful for accessibility or for people who
want different sound effects.


Closes: #16

parent 0342e84d
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
# SPDX-License-Identifier: GPL-3.0+ # SPDX-License-Identifier: GPL-3.0+
# License-Filename: LICENSES/GPL-3.0 # License-Filename: LICENSES/GPL-3.0
import os
import os.path import os.path
import logging import logging
import zipfile import zipfile
import tempfile import tempfile
import json import json
import pprint import pprint
import configparser
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GLib from gi.repository import GLib
...@@ -23,6 +25,29 @@ from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsCom ...@@ -23,6 +25,29 @@ from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsCom
_shell = GnomeShellFactory().get_shell() _shell = GnomeShellFactory().get_shell()
_shell_loaded = _shell is not None _shell_loaded = _shell is not None
def get_theme_name(index_path):
"""Given an index file path, gets the relevant sound theme's name."""
config = configparser.ConfigParser()
return config["Sound Theme"]["Name"]
def get_sound_themes():
"""Gets the available sound themes as a (theme_directory_name, theme_display_name) tuple list."""
themes = []
seen = set()
for location in get_resource_dirs("sounds"):
for item in os.listdir(location):
candidate = os.path.join(location, item)
index_file = os.path.join(candidate, "index.theme")
if os.path.isdir(candidate) and os.path.exists(index_file):
theme_info = (os.path.basename(candidate), get_theme_name(index_file))
if theme_info[1] not in seen:
return themes
class GtkThemeSwitcher(GSettingsComboTweak): class GtkThemeSwitcher(GSettingsComboTweak):
def __init__(self, **options): def __init__(self, **options):
GSettingsComboTweak.__init__(self, GSettingsComboTweak.__init__(self,
...@@ -261,6 +286,8 @@ TWEAK_GROUPS = [ ...@@ -261,6 +286,8 @@ TWEAK_GROUPS = [
CursorThemeSwitcher(), CursorThemeSwitcher(),
IconThemeSwitcher(), IconThemeSwitcher(),
ShellThemeTweak(loaded=_shell_loaded), ShellThemeTweak(loaded=_shell_loaded),
GSettingsComboTweak(_("Sound"), "org.gnome.desktop.sound", "theme-name", get_sound_themes(),
desc=_("Specifies which sound theme to use for sound events.")),
Title(_("Background"), "", uid="title-theme"), Title(_("Background"), "", uid="title-theme"),
GSettingsFileChooserButtonTweak(_("Image"),"org.gnome.desktop.background", "picture-uri", GSettingsFileChooserButtonTweak(_("Image"),"org.gnome.desktop.background", "picture-uri",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment