[gnome-tweak-tool] Show correct theme name for new style themes
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Show correct theme name for new style themes
- Date: Tue, 10 May 2011 21:40:14 +0000 (UTC)
commit f262ea5200b9676be2a991a7b26defb3b56123a3
Author: John Stowers <john stowers gmail com>
Date: Sun May 8 15:55:31 2011 +1200
Show correct theme name for new style themes
NEWS | 6 +++++-
gtweak/tweaks/tweak_shell.py | 28 ++++++++++++++++++++++------
2 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index ce5651e..40dd177 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
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
diff --git a/gtweak/tweaks/tweak_shell.py b/gtweak/tweaks/tweak_shell.py
index a571cc4..a9e1fa6 100644
--- a/gtweak/tweaks/tweak_shell.py
+++ b/gtweak/tweaks/tweak_shell.py
@@ -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()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]