Skip to content

Commit

Permalink
Some exactness changes
Browse files Browse the repository at this point in the history
Bumped required python version to 3.6 (the app uses f-strings)
Removed assertion that global themes stay under /usr/share
  • Loading branch information
ALEX11BR committed Oct 7, 2021
1 parent 5072efa commit 4dd4397
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
22 changes: 9 additions & 13 deletions src/getavailablethemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import os
from pathlib import Path
from gi.repository import Gtk, GLib, GdkPixbuf

from .pixbuffromxcursor import pixbufFromXCursor
Expand All @@ -38,8 +39,7 @@ def getAvailableGtk3Themes():
lookupPaths = [
os.path.join(GLib.get_user_data_dir(), "themes"),
os.path.join(GLib.get_home_dir(), ".themes"),
"/usr/share/themes"
]
] + [os.path.join(dataDir, "themes") for dataDir in GLib.get_system_data_dirs()]
for lookupPath in lookupPaths:
try:
for f in os.listdir(lookupPath):
Expand All @@ -63,8 +63,7 @@ def getAvailableIconThemes():
lookupPaths = [
os.path.join(GLib.get_user_data_dir(), "icons"),
os.path.join(GLib.get_home_dir(), ".icons"),
"/usr/share/icons"
]
] + [os.path.join(dataDir, "icons") for dataDir in GLib.get_system_data_dirs()]
for lookupPath in lookupPaths:
try:
for f in os.listdir(lookupPath):
Expand Down Expand Up @@ -102,8 +101,7 @@ def getAvailableCursorThemes():
lookupPaths = [
os.path.join(GLib.get_user_data_dir(), "icons"),
os.path.join(GLib.get_home_dir(), ".icons"),
"/usr/share/icons"
]
] + [os.path.join(dataDir, "icons") for dataDir in GLib.get_system_data_dirs()]
for lookupPath in lookupPaths:
try:
for f in os.listdir(lookupPath):
Expand Down Expand Up @@ -135,8 +133,7 @@ def getAvailableGtk4Themes():
lookupPaths = [
os.path.join(GLib.get_user_data_dir(), "themes"),
os.path.join(GLib.get_home_dir(), ".themes"),
"/usr/share/themes"
]
] + [os.path.join(dataDir, "themes") for dataDir in GLib.get_system_data_dirs()]
for lookupPath in lookupPaths:
try:
for f in os.listdir(lookupPath):
Expand All @@ -152,8 +149,7 @@ def getAvailableGtk2Themes():
lookupPaths = [
os.path.join(GLib.get_user_data_dir(), "themes"),
os.path.join(GLib.get_home_dir(), ".themes"),
"/usr/share/themes"
]
] + [os.path.join(dataDir, "themes") for dataDir in GLib.get_system_data_dirs()]
for lookupPath in lookupPaths:
try:
for f in os.listdir(lookupPath):
Expand All @@ -163,13 +159,13 @@ def getAvailableGtk2Themes():
pass
return uniquifySortedListStore(availableThemes)

def getAvailableKvantumThemes():
def getAvailableKvantumThemes(kvantumPath):
availableThemes = Gtk.ListStore(str, str)
availableThemes.set_sort_column_id(0, Gtk.SortType.ASCENDING)
availableThemes.append(["Kvantum", "default"])
lookupPaths = [
os.path.join(GLib.get_user_config_dir(), "Kvantum"),
"/usr/share/Kvantum"
os.path.join(Path(kvantumPath).parent.parent, "share", "Kvantum")
]
for lookupPath in lookupPaths:
try:
Expand All @@ -180,4 +176,4 @@ def getAvailableKvantumThemes():
availableThemes.append([f+"Dark", f+"Dark"])
except:
pass
return uniquifySortedListStore(availableThemes)
return uniquifySortedListStore(availableThemes)
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
conf.set('pkgdatadir', pkgdatadir)
conf.set('gtkversion', '3.0')

pythondep = python.dependency(version: '>= 3.5')
pythondep = python.dependency(version: '>= 3.6')
pygobjectdep = dependency('pygobject-3.0')
xcursordep = dependency('xcursor')
gdkpixbufdep = dependency('gdk-pixbuf-2.0')
Expand Down
5 changes: 3 additions & 2 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def __init__(self, app):
self.anotherGtk4ThemeSwitch.set_active(hasAnotherGtk4Theme)
self.gtk4SearchableThemeList.set_visible(hasAnotherGtk4Theme)

if shutil.which("kvantummanager"):
kvantumPath = shutil.which("kvantummanager")
if kvantumPath:
try:
kvantumKeyFile = GLib.KeyFile()
kvantumKeyFile.load_from_file(os.path.join(GLib.get_user_config_dir(), "Kvantum", "kvantum.kvconfig"), GLib.KeyFileFlags.NONE)
Expand All @@ -186,7 +187,7 @@ def __init__(self, app):
self.kvantumThemeName = self.gtkProps.gtk_theme_name
hasAnotherKvantumTheme = self.gtkProps.gtk_theme_name != self.kvantumThemeName
self.kvantumSearchableThemeList = SearchableThemeList(
getAvailableKvantumThemes(),
getAvailableKvantumThemes(kvantumPath),
self.kvantumThemeName,
self.onKvantumThemeChanged
)
Expand Down

0 comments on commit 4dd4397

Please sign in to comment.