[gnome-shell-extensions] Add user-theme extension



commit 27a1714f377fb4e2b9d2cf139fc338bdf4957eb8
Author: John Stowers <john stowers gmail com>
Date:   Thu Mar 10 13:07:18 2011 +1300

    Add user-theme extension
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644271

 configure.ac                                       |    5 +-
 extensions/Makefile.am                             |    2 +-
 extensions/user-theme/Makefile.am                  |   14 ++++++
 extensions/user-theme/extension.js                 |   43 ++++++++++++++++++++
 extensions/user-theme/metadata.json.in             |    9 ++++
 ...nome.shell.extensions.user-theme.gschema.xml.in |    9 ++++
 po/POTFILES.in                                     |    1 +
 7 files changed, 80 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a8c7785..b56830f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ GLIB_GSETTINGS
 ADDITIONAL_PACKAGES=
 
 dnl keep this in sync with extensions/Makefile.am
-ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock"
+ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme"
 AC_ARG_ENABLE([extensions],
 	[AS_HELP_STRING([--enable-extensions],[Space separated list of extensions to enable. Default is that all extensions are built.])],
 	[],
@@ -34,7 +34,7 @@ for e in $enable_extensions; do
 			ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
 			ADDITIONAL_PACKAGES="gnome-desktop-3.0 >= 2.91.6"
 			;;
-		alternate-tab|example|windowsNavigator|auto-move-windows|dock)
+		alternate-tab|example|windowsNavigator|auto-move-windows|dock|user-theme)
 			ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
 			;;
 		*)
@@ -59,6 +59,7 @@ AC_CONFIG_FILES([
   extensions/example/Makefile
   extensions/windowsNavigator/Makefile
   extensions/xrandr-indicator/Makefile
+  extensions/user-theme/Makefile
   extensions/Makefile
   Makefile
   po/Makefile.in
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index 21524cc..7a05e6d 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -1,3 +1,3 @@
-DIST_SUBDIRS = example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock
+DIST_SUBDIRS = example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme
 
 SUBDIRS = $(ENABLED_EXTENSIONS)
diff --git a/extensions/user-theme/Makefile.am b/extensions/user-theme/Makefile.am
new file mode 100644
index 0000000..6f237eb
--- /dev/null
+++ b/extensions/user-theme/Makefile.am
@@ -0,0 +1,14 @@
+EXTENSION_ID = user-theme
+
+include ../../extension.mk
+
+gschemas_in = org.gnome.shell.extensions.user-theme.gschema.xml.in
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
+
+ GSETTINGS_RULES@
+
+CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
+EXTRA_DIST += $(gschemas_in)
diff --git a/extensions/user-theme/extension.js b/extensions/user-theme/extension.js
new file mode 100644
index 0000000..136b6f5
--- /dev/null
+++ b/extensions/user-theme/extension.js
@@ -0,0 +1,43 @@
+// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
+// Load shell theme from ~/.themes/name/gnome-shell
+
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+const Main = imports.ui.main;
+
+const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.user-theme';
+const SETTINGS_KEY = 'name';
+
+function ThemeManager() {
+    this._init();
+}
+
+ThemeManager.prototype = {
+    _init: function() {
+        this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
+        this._settings.connect('changed::'+SETTINGS_KEY, Lang.bind(this, this._changeTheme));
+        this._changeTheme();
+    },
+
+    _changeTheme: function() {
+        let _stylesheet = null;
+        let _themeName = this._settings.get_string(SETTINGS_KEY);
+
+        if (_themeName) {
+            let _userCssStylesheet = GLib.get_home_dir() + '/.themes/' + _themeName + '/gnome-shell/gnome-shell.css';
+            file = Gio.file_new_for_path(_userCssStylesheet);
+            if (file.query_exists(null))
+                _stylesheet = _userCssStylesheet;
+        }
+
+        global.log('loading user theme: ' + _stylesheet)
+        Main.setThemeStylesheet(_stylesheet);
+        Main.loadTheme();
+    }
+}
+
+
+function main(metadata) {
+    new ThemeManager();
+}
diff --git a/extensions/user-theme/metadata.json.in b/extensions/user-theme/metadata.json.in
new file mode 100644
index 0000000..e71533e
--- /dev/null
+++ b/extensions/user-theme/metadata.json.in
@@ -0,0 +1,9 @@
+{
+ "uuid": "@uuid@",
+ "name": "User Themes",
+ "description": "Load shell themes from user directory",
+ "shell-version": [ "@shell_current@" ],
+ "localedir": "@LOCALEDIR@",
+ "original-authors": [ "john stowers gmail com" ],
+ "url": "@url@"
+}
diff --git a/extensions/user-theme/org.gnome.shell.extensions.user-theme.gschema.xml.in b/extensions/user-theme/org.gnome.shell.extensions.user-theme.gschema.xml.in
new file mode 100644
index 0000000..f765841
--- /dev/null
+++ b/extensions/user-theme/org.gnome.shell.extensions.user-theme.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist gettext-domain="gnome-shell-extensions">
+  <schema id="org.gnome.shell.extensions.user-theme" path="/org/gnome/shell/extensions/user-theme/">
+    <key name="name" type="s">
+      <default>""</default>
+      <_summary>Theme name</_summary>
+      <_description>The name of the theme, to be loaded from ~/.themes/name/gnome-shell</_description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/extensions/user-theme/stylesheet.css b/extensions/user-theme/stylesheet.css
new file mode 100644
index 0000000..e69de29
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2e0c502..65a1487 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,4 +4,5 @@ extensions/xrandr-indicator/extension.js
 extensions/alternate-tab/extension.js
 extensions/auto-move-windows/extension.js
 extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.xml.in
+extensions/user-theme/org.gnome.shell.extensions.user-theme.gschema.xml.in
 extensions/dock/extension.js



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]