Commit f262ea52 authored by John Stowers's avatar John Stowers

Show correct theme name for new style themes

parent b4a3119a
3.0.4
* Support system wide themes
* Support system wide themes (bug 648751)
* Fix duplicate themes (bug 649687)
* A themeing specification for shell themes has been developed and agreed upon
by a number of theme authors. If installing a theme matching this specification
show the appropriate name
3.0.3
* Autostart nautilus at login if it is configured to show
......
......@@ -20,6 +20,7 @@ import shutil
import zipfile
import tempfile
import logging
import json
from gi.repository import Gtk
from gi.repository import GLib
......@@ -151,19 +152,32 @@ class ShellThemeTweak(Tweak):
with zipfile.ZipFile(f, 'r') as z:
try:
fragment = ()
theme_name = None
for n in z.namelist():
if n.endswith("gnome-shell.css"):
fragment = n.split("/")[0:-1]
break
if n.endswith("gnome-shell/theme.json"):
logging.info("New style theme detected (theme.json)")
#new style theme - extract the name from the json file
tmp = tempfile.mkdtemp()
z.extract(n, tmp)
with open(os.path.join(tmp,n)) as f:
try:
theme_name = json.load(f)["shell-theme"]["name"]
except:
logging.warning("Invalid theme format", exc_info=True)
if not fragment:
raise Exception("Could not find gnome-shell.css")
#old style themes name was taken from the zip name
if fragment[0] == "theme" and len(fragment) == 1:
theme_name = os.path.basename(f)
else:
theme_name = fragment[0]
if not theme_name:
logging.info("Old style theme detected (theme.json)")
#old style themes name was taken from the zip name
if fragment[0] == "theme" and len(fragment) == 1:
theme_name = os.path.basename(f)
else:
theme_name = fragment[0]
theme_members_path = "/".join(fragment)
installed_name, updated = self._extract_theme_zip(
......@@ -186,6 +200,8 @@ class ShellThemeTweak(Tweak):
except:
#does not look like a valid theme
self.notify_error("Invalid theme file")
logging.warning("Error parsing theme zip", exc_info=True)
#set button back to default state
chooser.unselect_all()
......
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