Add user-theme extension

https://bugzilla.gnome.org/show_bug.cgi?id=644271
This commit is contained in:
John Stowers
2011-03-10 13:07:18 +13:00
parent 41ec4150e5
commit 27a1714f37
8 changed files with 80 additions and 3 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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();
}

View File

@@ -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@"
}

View File

@@ -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>

View File

View File

@@ -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