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

« back to all changes in this revision

Viewing changes to extensions/alternate-tab/prefs.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-09-07 11:57:39 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120907115739-rgeqt97ey8eg36h4
Tags: 3.5.91-0ubuntu1
* New upstream release.
* debian/patches/01_update-version-numbers.patch:
  - Dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
const Me = ExtensionUtils.getCurrentExtension();
20
20
const Convenience = Me.imports.convenience;
21
21
 
22
 
const SETTINGS_BEHAVIOUR_KEY = 'behaviour';
23
 
const SETTINGS_HIGHLIGHT_KEY = 'highlight-selected';
24
 
const SETTINGS_SHOW_APP_ICON_KEY = 'show-app-icon';
 
22
const SETTINGS_APP_ICON_MODE = 'app-icon-mode';
 
23
const SETTINGS_CURRENT_WORKSPACE_ONLY = 'current-workspace-only';
25
24
 
26
25
const MODES = {
27
 
    all_thumbnails: {
28
 
        name: N_("All & Thumbnails"),
29
 
        description: N_("This mode presents all applications from all workspaces in one selection \
30
 
list. Instead of using the application icon of every window, it uses small \
31
 
thumbnails resembling the window itself."),
32
 
        extra_widgets: [
33
 
            { label: N_("Show overlaid application icon"), key: SETTINGS_SHOW_APP_ICON_KEY }
34
 
        ]
35
 
    },
36
 
    workspace_icons: {
37
 
        name: N_("Workspace & Icons"),
38
 
        description: N_("This mode lets you switch between the applications of your current \
39
 
workspace and gives you additionally the option to switch to the last used \
40
 
application of your previous workspace. This is always the last symbol in \
41
 
the list and is separated by a separator/vertical line if available. \n\
42
 
Every window is represented by its application icon."),
43
 
        extra_widgets: [
44
 
            { label: N_("Move current selection to front before closing the popup"), key: SETTINGS_HIGHLIGHT_KEY }
45
 
        ]
46
 
    }
 
26
    thumbnail_only: N_("Thumbnail only"),
 
27
    app_icon_only: N_("Application icon only"),
 
28
    both: N_("Thumbnail and application icon"),
47
29
};
48
30
 
49
31
const AltTabSettingsWidget = new GObject.Class({
53
35
 
54
36
    _init : function(params) {
55
37
        this.parent(params);
56
 
        this.column_spacing = 10;
57
38
        this.margin = 10;
 
39
        this.orientation = Gtk.Orientation.VERTICAL;
58
40
 
59
41
        this._settings = Convenience.getSettings();
60
42
 
61
 
        let introLabel = _("The Alternate Tab can be used in different modes, that \
62
 
affect the way windows are chosen and presented.");
63
 
 
64
 
        this.attach(new Gtk.Label({ label: introLabel, wrap: true, sensitive: true,
65
 
                                    margin_bottom: 10, margin_top: 5 }),
66
 
                    0, 0, 2, 1);
 
43
        let presentLabel = _("Present windows as");
 
44
        this.add(new Gtk.Label({ label: presentLabel, sensitive: true,
 
45
                                 margin_bottom: 10, margin_top: 5 }));
67
46
 
68
47
        let top = 1;
69
48
        let radio = null;
70
 
        let currentMode = this._settings.get_string(SETTINGS_BEHAVIOUR_KEY);
 
49
        let currentMode = this._settings.get_string(SETTINGS_APP_ICON_MODE);
71
50
        for (let mode in MODES) {
72
51
            // copy the mode variable because it has function scope, not block scope
73
52
            // so cannot be used in a closure
74
53
            let modeCapture = mode;
75
 
            let obj = MODES[mode];
76
 
            let name = Gettext.gettext(obj.name);
77
 
            let description = Gettext.gettext(obj.description);
78
 
            let nextra = obj.extra_widgets.length;
 
54
            let name = Gettext.gettext(MODES[mode]);
79
55
 
80
56
            radio = new Gtk.RadioButton({ group: radio, label: name, valign: Gtk.Align.START });
81
57
            radio.connect('toggled', Lang.bind(this, function(widget) {
82
58
                if (widget.active)
83
 
                    this._settings.set_string(SETTINGS_BEHAVIOUR_KEY, modeCapture);
84
 
                this._updateSensitivity(widget, widget.active);
 
59
                    this._settings.set_string(SETTINGS_APP_ICON_MODE, modeCapture);
85
60
            }));
86
 
            this.attach(radio, 0, top, 1, nextra + 1);
87
 
 
88
 
            let descriptionLabel = new Gtk.Label({ label: description, wrap: true, sensitive: true,
89
 
                                                   xalign: 0.0, justify: Gtk.Justification.FILL });
90
 
            this.attach(descriptionLabel, 1, top, 1, 1);
91
 
 
92
 
            radio._extra = [];
93
 
            for (let i = 0; i < nextra; i++) {
94
 
                let key = obj.extra_widgets[i].key;
95
 
                let label = Gettext.gettext(obj.extra_widgets[i].label);
96
 
 
97
 
                let extra = new Gtk.CheckButton({ label: label });
98
 
                this._settings.bind(key, extra, 'active', Gio.SettingsBindFlags.DEFAULT);
99
 
 
100
 
                radio._extra.push(extra);
101
 
                this.attach(extra, 1, top + i + 1, 1, 1);                            
102
 
            }
 
61
            this.add(radio);
103
62
 
104
63
            if (mode == currentMode)
105
64
                radio.active = true;
106
 
            this._updateSensitivity(radio, radio.active);
107
 
 
108
 
            top += nextra + 1;
 
65
            top += 1;
109
66
        }
110
 
    },
111
67
 
112
 
    _updateSensitivity: function(widget, active) {
113
 
        for (let i = 0; i < widget._extra.length; i++)
114
 
            widget._extra[i].sensitive = active;
 
68
        let check = new Gtk.CheckButton({ label: _("Show only windows in the current workspace"),
 
69
                                          margin_top: 12 });
 
70
        this._settings.bind(SETTINGS_CURRENT_WORKSPACE_ONLY, check, 'active', Gio.SettingsBindFlags.DEFAULT);
 
71
        this.add(check);
115
72
    },
116
73
});
117
74