~ubuntu-branches/ubuntu/saucy/gnome-shell-extensions/saucy-proposed

« back to all changes in this revision

Viewing changes to .pc/look-in-data-home-for-themes.patch/extensions/user-theme/extension.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-09-11 16:40:53 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20130911164053-vw2yrofw21q2rjxt
Tags: 3.8.4-0ubuntu1
* New upstream bugfix release.
  - systemMonitor blocks the message tray menu properly
  - translation updates
* Dropped patches applied in new version:
  - fix-hibernate.patch
  - fix-applications-menu-resolution-change.patch
  - look-in-data-home-for-themes.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
2
 
// Load shell theme from ~/.themes/name/gnome-shell
3
 
 
4
 
const GLib = imports.gi.GLib;
5
 
const Gio = imports.gi.Gio;
6
 
const Lang = imports.lang;
7
 
const Main = imports.ui.main;
8
 
 
9
 
const SETTINGS_KEY = 'name';
10
 
 
11
 
const ExtensionUtils = imports.misc.extensionUtils;
12
 
const Me = ExtensionUtils.getCurrentExtension();
13
 
const Convenience = Me.imports.convenience;
14
 
 
15
 
const ThemeManager = new Lang.Class({
16
 
    Name: 'UserTheme.ThemeManager',
17
 
 
18
 
    _init: function() {
19
 
        this._settings = Convenience.getSettings();
20
 
    },
21
 
 
22
 
    enable: function() {
23
 
        this._changedId = this._settings.connect('changed::'+SETTINGS_KEY, Lang.bind(this, this._changeTheme));
24
 
        this._changeTheme();
25
 
    },
26
 
 
27
 
    disable: function() {
28
 
        if (this._changedId) {
29
 
            this._settings.disconnect(this._changedId);
30
 
            this._changedId = 0;
31
 
        }
32
 
 
33
 
        Main.setThemeStylesheet(null);
34
 
        Main.loadTheme();
35
 
    },
36
 
 
37
 
    _changeTheme: function() {
38
 
        let _stylesheet = null;
39
 
        let _themeName = this._settings.get_string(SETTINGS_KEY);
40
 
 
41
 
        if (_themeName) {
42
 
            let _userCssStylesheet = GLib.get_home_dir() + '/.themes/' + _themeName + '/gnome-shell/gnome-shell.css';
43
 
            let file = Gio.file_new_for_path(_userCssStylesheet);
44
 
            if (file.query_exists(null))
45
 
                _stylesheet = _userCssStylesheet;
46
 
            else {
47
 
                let sysdirs = GLib.get_system_data_dirs();
48
 
                for (let i = 0; i < sysdirs.length; i++) {
49
 
                    _userCssStylesheet = sysdirs[i] + '/themes/' + _themeName + '/gnome-shell/gnome-shell.css';
50
 
                    let file = Gio.file_new_for_path(_userCssStylesheet);
51
 
                    if (file.query_exists(null)) {
52
 
                        _stylesheet = _userCssStylesheet;
53
 
                        break;
54
 
                    }
55
 
                }
56
 
            }
57
 
        }
58
 
 
59
 
        if (_stylesheet)
60
 
            global.log('loading user theme: ' + _stylesheet);
61
 
        else
62
 
            global.log('loading default theme (Adwaita)');
63
 
        Main.setThemeStylesheet(_stylesheet);
64
 
        Main.loadTheme();
65
 
    }
66
 
});
67
 
 
68
 
function init() {
69
 
    return new ThemeManager();
70
 
}