Skip to content

Commit

Permalink
Sort by display name
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Sep 15, 2023
1 parent 64c0684 commit 84f1162
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions css_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def unlock(self):

async def load(self, inject_now : bool = True):
Log("Loading themes...")
self.themes = []
self.themes : list[Theme] = []

themesPath = get_theme_path()
self.last_load_errors = await self._parse_themes(themesPath)
Expand All @@ -43,7 +43,7 @@ async def load(self, inject_now : bool = True):
await x.load(inject_now)

await self._cache_lists()
self.themes.sort(key=lambda d: d.name)
self.themes.sort(key=lambda d: d.get_display_name())

async def set_theme_state(self, name : str, state : bool, set_deps : bool = True, set_deps_value : bool = True) -> Result:
Log(f"Setting state for {name} to {state}")
Expand Down
11 changes: 7 additions & 4 deletions css_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Theme:
def __init__(self, themePath : str, json : dict, configPath : str = None):
self.configPath = configPath if (configPath is not None) else themePath
self.displayName = None
self.display_name = None
self.configJsonPath = self.configPath + "/config" + ("_ROOT.json" if USER == "root" else "_USER.json")
self.patches = []
self.injects = []
Expand Down Expand Up @@ -55,7 +55,7 @@ def __init__(self, themePath : str, json : dict, configPath : str = None):
self.created = path.getmtime(jsonPath)

self.name = json["name"]
self.displayName = json["display_name"] if ("display_name" in json) else None
self.display_name = json["display_name"] if ("display_name" in json) else None
self.id = json["id"] if ("id" in json) else self.name
self.version = json["version"] if ("version" in json) else "v1.0"
self.author = json["author"] if ("author" in json) else ""
Expand Down Expand Up @@ -173,7 +173,7 @@ def to_dict(self) -> dict:
return {
"id": self.id,
"name": self.name,
"display_name": self.displayName if (self.displayName is not None) else self.name,
"display_name": self.get_display_name(),
"version": self.version,
"author": self.author,
"enabled": self.enabled,
Expand All @@ -184,4 +184,7 @@ def to_dict(self) -> dict:
"flags": self.flags,
"created": self.created,
"modified": self.modified,
}
}

def get_display_name(self) -> str:
return self.display_name if (self.display_name is not None) else self.name

0 comments on commit 84f1162

Please sign in to comment.