├── simple-dock@nothing.org
├── logs
│ ├── log.tmp
│ └── log.sh
├── schemas
│ ├── gschemas.compiled
│ └── simple-dock.gschema.xml
├── stylesheet.css
├── compile.sh
├── gnomedash.js
├── metadata.json
├── extension.js
├── convenience.js
├── prefs.js
├── intellihide.js
├── atomappdisplay.js
├── messageTrayModified.js
├── atomdock.js
├── LICENSE
└── atomdash.js
├── screenshot.png
├── install.sh
└── README.md
/simple-dock@nothing.org/logs/log.tmp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/optimisme/gnome-shell-simple-dock/HEAD/screenshot.png
--------------------------------------------------------------------------------
/simple-dock@nothing.org/schemas/gschemas.compiled:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/optimisme/gnome-shell-simple-dock/HEAD/simple-dock@nothing.org/schemas/gschemas.compiled
--------------------------------------------------------------------------------
/simple-dock@nothing.org/stylesheet.css:
--------------------------------------------------------------------------------
1 | .sd_notification {
2 | border-radius: 10px 10px 10px 10px;
3 | }
4 | .sd_notification_top {
5 | border-radius: 0px 0px 10px 10px;
6 | }
7 | .sd_notification_bottom {
8 | border-radius: 10px 10px 0px 0px;
9 | }
10 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/compile.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | glib-compile-schemas schemas
4 |
5 | # msgfmt ./locale/en/LC_MESSAGES/en.po
6 | # mv ./messages.mo ./locale/en/LC_MESSAGES/simple-dock.mo
7 |
8 | # msgfmt ./locale/es/LC_MESSAGES/es.po
9 | # mv ./messages.mo ./locale/es/LC_MESSAGES/simple-dock.mo
10 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/logs/log.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Call: imports.misc.util.spawnCommandLine('/home/albert/.local/share/gnome-shell/extensions/simple-dock@nothing.org/logs/log.sh si');
4 | # Logs: tail -f ~/.local/share/gnome-shell/extensions/simple-dock@nothing.org/logs/log.tmp
5 | echo $1 >> /home/albert/.local/share/gnome-shell/extensions/simple-dock@nothing.org/logs/log.tmp
6 |
7 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Install extension
4 | gnome-shell-extension-tool -d simple-dock@nothing.org
5 | mkdir -p ~/.local/share/gnome-shell/extensions/simple-dock@nothing.org
6 | rm -r ~/.local/share/gnome-shell/extensions/simple-dock@nothing.org/*
7 | cp -rf simple-dock@nothing.org/* ~/.local/share/gnome-shell/extensions/simple-dock@nothing.org
8 |
9 | # Activate extension
10 | gnome-shell-extension-tool -e simple-dock@nothing.org
11 | echo "Restart Gnome Shell with 'Alt+F2' and then command 'r' + 'Intro'"
12 |
13 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/gnomedash.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /*jshint esnext: true */
3 | /*jshint indent: 4 */
4 | const Lang = imports.lang;
5 | const Main = imports.ui.main;
6 |
7 | const GnomeDash = new Lang.Class({
8 | Name: 'GnomeDash',
9 |
10 | _init: function() {
11 | this._dash = Main.overview._dash.actor.get_parent();
12 | },
13 |
14 | hideDash: function() {
15 | this._dash.hide();
16 | },
17 |
18 | showDash: function() {
19 | this._dash.show();
20 | }
21 | });
22 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "_generated": "Generated by SweetTooth, do not edit",
3 | "description": "Bottom dock\n\nFeaturing:\n- Minimize focused application.\n- Minimize to dock icon.\n- Drag and drop favorites.\n- Cycle windows with scroll. \n- Application menus\n- Applications button (Optional).\n- Adjust icon sizes (Optional)\n- Adjust background opacity (Optional)\n- Intelligent auto hide (Optional).",
4 | "name": "Simple Dock",
5 | "settings-schema": "org.gnome.shell.extensions.simple-dock",
6 | "shell-version": [
7 | "3.18",
8 | "3.17.91",
9 | "3.20",
10 | "3.22",
11 | "3.23.90",
12 | "3.24"
13 | ],
14 | "url": "https://github.com/optimisme/gnome-shell-simple-dock",
15 | "uuid": "simple-dock@nothing.org",
16 | "version": 64
17 | }
18 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/schemas/simple-dock.gschema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | Show applications button
7 | Show applications button
8 |
9 |
10 | 0
11 | Show method
12 | Shows or hides dock
13 |
14 |
15 | 48
16 | Maximum icon size
17 | Maximum icon size
18 |
19 |
20 | 0.4
21 | Background opacity
22 | Sets the background opacity.
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | gnome-shell-simple-dock
2 | =======================
3 |
4 | 
5 |
6 | Bottom dock for gnome shell
7 |
8 | Featuring:
9 |
10 | - Minimize focused application.
11 | - Minimize to dock icon.
12 | - Drag and drop favorites.
13 | - Cycle windows with scroll.
14 | - Action list menus
15 | - Adapt notifications (Optional for 3.14).
16 | - Applications button (Optional).
17 | - Adjust icon sizes (Optional)
18 | - Adjust background opacity (Optional)
19 | - Intelligent auto hide (Optional).
20 |
21 | INSTALLATION
22 | ------------
23 |
24 | With 'Firefox' or 'Gnome Web' from 'Gnome shell extensions webtool':
25 |
26 | https://extensions.gnome.org/extension/815/simple-dock/
27 |
28 | Manually (up to date version):
29 |
30 | cd ~
31 | git clone https://github.com/optimisme/gnome-shell-simple-dock.git
32 | cd gnome-shell-simple-dock
33 | chmod 744 install.sh
34 | ./install.sh
35 |
36 | Then, use 'Gnome tweak tool' to activate the extension
37 |
38 | CUSTOMIZATION
39 | ------------
40 |
41 | Right clicking on applications button and choosing 'Simple Dock Settings'
42 | Using 'Tweak tool' (can be installed from 'Software'), the extension can be customized or disabled.
43 |
44 | UNINSTALLATION
45 | ------------
46 |
47 | To uninstall this extension, remove the folder where the extension is installed:
48 |
49 | rm -rf ~/.local/share/gnome-shell/extensions/simple-dock@nothing.org
50 |
51 |
52 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/extension.js:
--------------------------------------------------------------------------------
1 | const Config = imports.misc.config;
2 | const St = imports.gi.St;
3 | const Shell = imports.gi.Shell;
4 | const Main = imports.ui.main;
5 | const LayoutManager = Main.layoutManager;
6 | const ExtensionUtils = imports.misc.extensionUtils;
7 | const Me = ExtensionUtils.getCurrentExtension();
8 | const Gio = imports.gi.Gio;
9 | const GnomeDash = Me.imports.gnomedash;
10 | const Intellihide = Me.imports.intellihide;
11 | const AtomDock = Me.imports.atomdock;
12 |
13 | let oldDash;
14 | let atomDock;
15 | let intellihide;
16 | let settings = null;
17 | let settingsAppsButtonSignal = null;
18 | let settingsShowMethodSignal = null;
19 | let settingsIconSignal = null;
20 | let settingsBackgroundSignal = null;
21 |
22 | // Settings
23 | const SETTINGS_SHOW_APPS_BUTTON = "show-apps-button";
24 | const SETTINGS_SHOW_METHOD = "show-method";
25 | const SETTINGS_MAX_ICON_SIZE = "max-icon-size";
26 | const SETTINGS_BACKGROUND_OPACITY = "background-opacity";
27 |
28 | function settingsAppsButtonChanged() {
29 | atomDock.setShowAppsButton(settings.get_boolean(SETTINGS_SHOW_APPS_BUTTON));
30 | }
31 |
32 | function settingsShowMethodChanged() {
33 | intellihide.setShowMethod(settings.get_int(SETTINGS_SHOW_METHOD));
34 | }
35 |
36 | function settingsIconChanged() {
37 | atomDock.setMaxIconSize(settings.get_int(SETTINGS_MAX_ICON_SIZE), true);
38 | }
39 |
40 | function settingsBackgroundChanged() {
41 | atomDock.setBackgroundOpacity(settings.get_double(SETTINGS_BACKGROUND_OPACITY), true);
42 | }
43 |
44 | // Init settings
45 | function initSettings() {
46 | const GioSSS = Gio.SettingsSchemaSource;
47 | let schemaSource = GioSSS.new_from_directory(Me.path + "/schemas", GioSSS.get_default(), false);
48 |
49 | let schemaObj = schemaSource.lookup(Me.metadata["settings-schema"], true);
50 | if(!schemaObj) {
51 | throw new Error("Schema " + Me.metadata["settings-schema"] + " could not be found for extension " +
52 | Me.uuid + ". Please check your installation.");
53 | }
54 | settings = new Gio.Settings({ settings_schema: schemaObj });
55 | }
56 |
57 | function init() {
58 | oldDash = new GnomeDash.GnomeDash();
59 | initSettings();
60 | }
61 |
62 | function show() {
63 | atomDock.intelliShow();
64 | }
65 |
66 | function hide() {
67 | atomDock.intelliHide();
68 | }
69 |
70 | function enable() {
71 | // Hide old dash
72 | oldDash.hideDash();
73 |
74 | // Enable new dock
75 | atomDock = new AtomDock.AtomDock();
76 | let iconSize = settings.get_int(SETTINGS_MAX_ICON_SIZE);
77 | if (iconSize) {
78 | atomDock.setMaxIconSize(iconSize, false);
79 | } else {
80 | atomDock.setMaxIconSize(48, false);
81 | }
82 |
83 | let appsButton = settings.get_boolean(SETTINGS_SHOW_APPS_BUTTON);
84 | if (typeof appsButton !== 'undefined') {
85 | atomDock.setShowAppsButton(appsButton);
86 | } else {
87 | atomDock.setShowAppsButton(true);
88 | }
89 |
90 | let backOpacity = settings.get_double(SETTINGS_BACKGROUND_OPACITY);
91 | atomDock.setBackgroundOpacity(backOpacity, true);
92 |
93 | intellihide = new Intellihide.Intellihide(show, hide, atomDock);
94 |
95 | let showMethod = settings.get_int(SETTINGS_SHOW_METHOD);
96 | if (showMethod) {
97 | intellihide.setShowMethod(showMethod);
98 | } else {
99 | intellihide.setShowMethod(0);
100 | }
101 |
102 | settingsAppsButtonSignal = settings.connect("changed::" + SETTINGS_SHOW_APPS_BUTTON,
103 | function() { settingsAppsButtonChanged(); });
104 |
105 | settingsShowMethodSignal = settings.connect("changed::" + SETTINGS_SHOW_METHOD,
106 | function() { settingsShowMethodChanged(); });
107 |
108 | settingsIconSignal = settings.connect("changed::" + SETTINGS_MAX_ICON_SIZE,
109 | function() { settingsIconChanged(); });
110 |
111 | settingsBackgroundSignal = settings.connect("changed::" + SETTINGS_BACKGROUND_OPACITY,
112 | function() { settingsBackgroundChanged(); });
113 | }
114 |
115 | function disable() {
116 |
117 | intellihide.destroy();
118 | atomDock.destroy();
119 | oldDash.showDash();
120 |
121 | if(settingsAppsButtonSignal != null) {
122 | settings.disconnect(settingsAppsButtonSignal);
123 | settingsAppsButtonSignal = null;
124 | }
125 |
126 | if(settingsShowMethodSignal != null) {
127 | settings.disconnect(settingsShowMethodSignal);
128 | settingsShowMethodSignal = null;
129 | }
130 |
131 | if(settingsIconSignal != null) {
132 | settings.disconnect(settingsIconSignal);
133 | settingsIconSignal = null;
134 | }
135 |
136 | if(settingsBackgroundSignal != null) {
137 | settings.disconnect(settingsBackgroundSignal);
138 | settingsBackgroundSignal = null;
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/convenience.js:
--------------------------------------------------------------------------------
1 | /* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */
2 | /*jshint esnext: true */
3 | /*jshint indent: 4 */
4 |
5 | /*
6 | * Taken from Michele's Dash to Dock extension
7 | * https://github.com/micheleg/dash-to-dock
8 | *
9 | * Part of this file comes from gnome-shell-extensions:
10 | * http://git.gnome.org/browse/gnome-shell-extensions/
11 | *
12 | */
13 |
14 | const Gettext = imports.gettext;
15 | const Gio = imports.gi.Gio;
16 | const Lang = imports.lang;
17 |
18 | const Config = imports.misc.config;
19 | const ExtensionUtils = imports.misc.extensionUtils;
20 |
21 | /**
22 | * initTranslations:
23 | * @domain: (optional): the gettext domain to use
24 | *
25 | * Initialize Gettext to load translations from extensionsdir/locale.
26 | * If @domain is not provided, it will be taken from metadata['gettext-domain']
27 | */
28 | function initTranslations(domain) {
29 |
30 | let extension = ExtensionUtils.getCurrentExtension();
31 |
32 | domain = domain || extension.metadata['gettext-domain'];
33 |
34 | // check if this extension was built with "make zip-file", and thus
35 | // has the locale files in a subfolder
36 | // otherwise assume that extension has been installed in the
37 | // same prefix as gnome-shell
38 | let localeDir = extension.dir.get_child('locale');
39 | if (localeDir.query_exists(null)) {
40 | Gettext.bindtextdomain(domain, localeDir.get_path());
41 | } else {
42 | Gettext.bindtextdomain(domain, Config.LOCALEDIR);
43 | }
44 | }
45 |
46 | /**
47 | * getSettings:
48 | * @schema: (optional): the GSettings schema id
49 | *
50 | * Builds and return a GSettings schema for @schema, using schema files
51 | * in extensionsdir/schemas. If @schema is not provided, it is taken from
52 | * metadata['settings-schema'].
53 | */
54 | function getSettings(schema) {
55 |
56 | let extension = ExtensionUtils.getCurrentExtension();
57 |
58 | schema = schema || extension.metadata['settings-schema'];
59 |
60 | const GioSSS = Gio.SettingsSchemaSource;
61 |
62 | // check if this extension was built with "make zip-file", and thus
63 | // has the schema files in a subfolder
64 | // otherwise assume that extension has been installed in the
65 | // same prefix as gnome-shell (and therefore schemas are available
66 | // in the standard folders)
67 | let schemaDir = extension.dir.get_child('schemas');
68 | let schemaSource;
69 | if (schemaDir.query_exists(null)) {
70 | schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
71 | GioSSS.get_default(),
72 | false);
73 | } else {
74 | schemaSource = GioSSS.get_default();
75 | }
76 |
77 | let schemaObj = schemaSource.lookup(schema, true);
78 | if (!schemaObj) {
79 | throw new Error('Schema ' + schema + ' could not be found for extension ' +
80 | extension.metadata.uuid + '. Please check your installation.');
81 | }
82 |
83 | return new Gio.Settings({ settings_schema: schemaObj });
84 | }
85 |
86 | // try to simplify global signals handling
87 | const GlobalSignalHandler = new Lang.Class({
88 | Name: 'AtomDock.GlobalSignalHandler',
89 |
90 | _init: function(){
91 | this._signals = {};
92 | },
93 |
94 | push: function(/*unlimited 3-long array arguments*/){
95 | this._addSignals('generic', arguments);
96 | },
97 |
98 | disconnect: function() {
99 | for (let label in this._signals) {
100 | if (this._signals.hasOwnProperty(label)) {
101 | this.disconnectWithLabel(label);
102 | }
103 | }
104 | },
105 |
106 | pushWithLabel: function(label /* plus unlimited 3-long array arguments*/) {
107 | // skip first element of thearguments array;
108 | let elements = [];
109 | for (let i = 1 ; i< arguments.length; i++) {
110 | elements.push(arguments[i]);
111 | }
112 |
113 | this._addSignals(label, elements);
114 | },
115 |
116 | _addSignals: function(label, elements) {
117 |
118 | if (this._signals[label] === undefined) {
119 | this._signals[label] = [];
120 | }
121 |
122 | for (let i = 0; i < elements.length; i++) {
123 |
124 | let object = elements[i][0];
125 | let event = elements[i][1];
126 |
127 | let id = object.connect(event, elements[i][2]);
128 | this._signals[label].push( [ object , id ] );
129 | }
130 | },
131 |
132 | disconnectWithLabel: function(label) {
133 |
134 | if (this._signals[label]) {
135 | for (let i = 0; i < this._signals[label].length; i++) {
136 | this._signals[label][i][0].disconnect(this._signals[label][i][1]);
137 | }
138 |
139 | delete this._signals[label];
140 | }
141 | }
142 |
143 | });
144 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/prefs.js:
--------------------------------------------------------------------------------
1 | const Gio = imports.gi.Gio;
2 | const Gtk = imports.gi.Gtk;
3 | const Config = imports.misc.config;
4 |
5 | const Me = imports.misc.extensionUtils.getCurrentExtension();
6 | const _ = imports.gettext.domain(Me.uuid).gettext;
7 |
8 | const SETTINGS_SHOW_APPS_BUTTON = "show-apps-button";
9 | const SETTINGS_SHOW_METHOD = "show-method";
10 | const SETTINGS_MAX_ICON_SIZE = "max-icon-size";
11 | const SETTINGS_BACKGROUND_OPACITY = "background-opacity";
12 |
13 | let settings;
14 |
15 | function init() {
16 |
17 | imports.gettext.bindtextdomain(Me.uuid, Me.path + "/locale");
18 | const GioSSS = Gio.SettingsSchemaSource;
19 |
20 | let schemaSource = GioSSS.new_from_directory(Me.path + "/schemas",
21 | GioSSS.get_default(), false);
22 |
23 | let schemaObj = schemaSource.lookup(Me.metadata["settings-schema"], true);
24 | if(!schemaObj) {
25 | throw new Error("Schema " + Me.metadata["settings-schema"] + " could not be found for extension " +
26 | Me.uuid + ". Please check your installation.");
27 | }
28 |
29 | settings = new Gio.Settings({ settings_schema: schemaObj });
30 | }
31 |
32 | function buildPrefsWidget() {
33 |
34 | let showAppsLabel = new Gtk.Label({ xalign: 1, label: _("Show applications button") + "*:" });
35 | let showAppsSwitch = new Gtk.Switch({
36 | hexpand: false,
37 | active: settings.get_boolean(SETTINGS_SHOW_APPS_BUTTON)
38 | });
39 | showAppsSwitch.connect("notify::active", function(button) {
40 | settings.set_boolean(SETTINGS_SHOW_APPS_BUTTON, button.active);
41 | });
42 | showAppsSwitch.set_tooltip_text(_("Show applications button"));
43 |
44 | let allSizes =[ 16, 24, 32, 48, 64, 96, 128 ];
45 | let iconSizeLabel = new Gtk.Label({ xalign: 1, label: _("Maximum icon size") + ":" });
46 | let settingIconCombo = new Gtk.ComboBoxText({ halign:Gtk.Align.START });
47 | settingIconCombo.append_text(_("16"));
48 | settingIconCombo.append_text(_("24"));
49 | settingIconCombo.append_text(_("32"));
50 | settingIconCombo.append_text(_("48"));
51 | settingIconCombo.append_text(_("64"));
52 | settingIconCombo.append_text(_("96"));
53 | settingIconCombo.append_text(_("128"));
54 | settingIconCombo.set_active(allSizes.indexOf(settings.get_int(SETTINGS_MAX_ICON_SIZE)));
55 | settingIconCombo.connect("changed", function(widget) {
56 | settings.set_int(SETTINGS_MAX_ICON_SIZE, allSizes[widget.get_active()]);
57 | });
58 | settingIconCombo.set_tooltip_text(_("Maximum icon size"));
59 |
60 | let opacityLabel = new Gtk.Label({ xalign: 1, label: _("Background opacity") + ":" });
61 | let opacitySlider = new Gtk.Scale({orientation: Gtk.Orientation.HORIZONTAL, valuePos: Gtk.PositionType.RIGHT});
62 | opacitySlider.set_range(0, 100);
63 | opacitySlider.set_value(settings.get_double(SETTINGS_BACKGROUND_OPACITY) * 100);
64 | opacitySlider.set_digits(0);
65 | opacitySlider.set_increments(5,5);
66 | opacitySlider.set_size_request(150, -1);
67 | opacitySlider.connect("value-changed", function(widget) {
68 | settings.set_double(SETTINGS_BACKGROUND_OPACITY, widget.get_value()/100);
69 | });
70 | opacitySlider.set_tooltip_text(_("Sets background opacity"));
71 |
72 | let showMethodLabel = new Gtk.Label({ xalign: 1, label: _("Show method") + ":" });
73 | let showMethod0 = new Gtk.RadioButton ({ label: _("Hide if focused window overlaps the dock") });
74 | let showMethod1 = new Gtk.RadioButton ({ group: showMethod0, label: _("Hide when not being used") });
75 | let showMethod2 = new Gtk.RadioButton ({ group: showMethod0, label: _("Always show") });
76 | switch (settings.get_int(SETTINGS_SHOW_METHOD)) {
77 | case 0:
78 | showMethod0.set_active (true);
79 | break;
80 | case 1:
81 | showMethod1.set_active (true);
82 | break;
83 | case 2:
84 | showMethod2.set_active (true);
85 | break;
86 | }
87 | showMethod0.connect("toggled", function(widget) {
88 | if (widget.get_active()) { settings.set_int(SETTINGS_SHOW_METHOD, 0); }
89 | });
90 | showMethod1.connect("toggled", function(widget) {
91 | if (widget.get_active()) { settings.set_int(SETTINGS_SHOW_METHOD, 1); }
92 | });
93 | showMethod2.connect("toggled", function(widget) {
94 | if (widget.get_active()) { settings.set_int(SETTINGS_SHOW_METHOD, 2); }
95 | });
96 |
97 | let infoLabel = new Gtk.Label({
98 | halign: Gtk.Align.CENTER,
99 | label: _("*Settings are accessible from 'Applications button', use 'Tweak-Tool' when not shown"),
100 | margin_top: 15
101 | });
102 | infoLabel.set_justify(Gtk.Justification.CENTER);
103 |
104 | var grid = new Gtk.Grid({ column_spacing: 25, halign: Gtk.Align.CENTER, margin: 10, row_spacing: 10 });
105 | grid.set_border_width(15);
106 |
107 | grid.attach(showAppsLabel, 0, 1, 1, 1);
108 | grid.attach(showAppsSwitch, 1, 1, 1, 1);
109 | grid.attach(iconSizeLabel, 0, 2, 1, 1);
110 | grid.attach(settingIconCombo, 1, 2, 1, 1);
111 | grid.attach(opacityLabel, 0, 3, 1, 1);
112 | grid.attach(opacitySlider, 1, 3, 2, 1);
113 | grid.attach(showMethodLabel, 0, 4, 1, 1);
114 | grid.attach(showMethod0, 1, 4, 4, 1);
115 | grid.attach(showMethod1, 1, 5, 4, 1);
116 | grid.attach(showMethod2, 1, 6, 4, 1);
117 | grid.attach(infoLabel, 0, 7, 6, 1);
118 | grid.show_all();
119 |
120 | return grid;
121 | }
122 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/intellihide.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /*jshint esnext: true */
3 | /*jshint indent: 4 */
4 |
5 | const Config = imports.misc.config;
6 | const Lang = imports.lang;
7 | const Mainloop = imports.mainloop;
8 | const Meta = imports.gi.Meta;
9 | const Shell = imports.gi.Shell;
10 | const Main = imports.ui.main;
11 |
12 | const Me = imports.misc.extensionUtils.getCurrentExtension();
13 | const Convenience = Me.imports.convenience;
14 |
15 | const handledWindowTypes = [
16 | Meta.WindowType.NORMAL,
17 | Meta.WindowType.DIALOG,
18 | Meta.WindowType.MODAL_DIALOG,
19 | Meta.WindowType.TOOLBAR,
20 | Meta.WindowType.MENU,
21 | Meta.WindowType.UTILITY,
22 | Meta.WindowType.SPLASHSCREEN
23 | ];
24 |
25 | /*
26 | * Forked from Michele's Dash to Dock extension
27 | * https://github.com/micheleg/dash-to-dock
28 | *
29 | * A rough and ugly implementation of the intellihide behaviour.
30 | * Intellihide object: call show()/hide() function based on the overlap with the
31 | * the target actor object;
32 | *
33 | * Target object has to contain a Clutter.ActorBox object named staticBox and
34 | * emit a 'box-changed' signal when this changes.
35 | *
36 | */
37 |
38 | const Intellihide = new Lang.Class({
39 | Name: 'Intellihide',
40 |
41 | _init: function(show, hide, target) {
42 |
43 | this._signalHandler = new Convenience.GlobalSignalHandler();
44 | this._tracker = Shell.WindowTracker.get_default();
45 | this._focusApp = null;
46 | this.showMethod = 0;
47 | this.overviewShowing = false;
48 |
49 | // current intellihide status
50 | this.status = undefined;
51 | // Set base functions
52 | this.showFunction = show;
53 | this.hideFunction = hide;
54 | // Target object
55 | this._target = target;
56 |
57 | /* Main id of the timeout controlling timeout for updateDockVisibility
58 | * function when windows are dragged around (move and resize).
59 | */
60 | this._windowChangedTimeout = 0;
61 |
62 | // Connect global signals
63 | this._signalHandler.push(
64 | [
65 | this._target, 'box-changed', () => { this._updateDockVisibility(); }
66 | ],
67 | [
68 | this._target.dash, 'redisplay-workspace-switched', () => { this._updateDockVisibility(); }
69 | ],
70 | [
71 | global.display, 'grab-op-begin', () => { this._grabOpBegin(); }
72 | ],
73 | [
74 | global.display, 'grab-op-end', () => { this._grabOpEnd(); }
75 | ],
76 | [
77 | global.window_manager, 'size-change', () => { this._updateDockVisibility(); }
78 | ],
79 | [
80 | global.screen, 'restacked', () => { this._updateDockVisibility(); }
81 | ],
82 | [
83 | global.screen, 'monitors-changed', () => { this._updateDockVisibility(); }
84 | ],
85 | [
86 | Main.overview, 'showing', () => { this._overviewOn(); }
87 | ],
88 | [
89 | Main.overview, 'hidden', () => { this._overviewOff(); }
90 | ]
91 | );
92 |
93 | // initialize: call show forcing to initialize status variable
94 | this._show(true);
95 |
96 | // update visibility
97 | this._updateDockVisibility();
98 | },
99 |
100 | destroy: function() {
101 | // Disconnect global signals
102 | this._signalHandler.disconnect();
103 |
104 | if (this._windowChangedTimeout > 0) {
105 | Mainloop.source_remove(this._windowChangedTimeout);
106 | }
107 |
108 | this._windowChangedTimeout = 0;
109 | },
110 |
111 | _show: function(force) {
112 |
113 | if (this.status !== true || force) {
114 | this.status = true;
115 | this.showFunction();
116 | }
117 |
118 | },
119 |
120 | _hide: function(force) {
121 |
122 | if (this.status !== false || force) {
123 | this.status = false;
124 | this.hideFunction();
125 | }
126 |
127 | },
128 |
129 | _grabOpBegin: function() {
130 | // A good compromise between reactivity and efficiency; to be tuned.
131 | let INTERVAL = 100;
132 |
133 | if (this._windowChangedTimeout > 0) {
134 | Mainloop.source_remove(this._windowChangedTimeout); // Just to be sure
135 | }
136 |
137 | this._windowChangedTimeout = Mainloop.timeout_add(INTERVAL, () => {
138 | this._updateDockVisibility();
139 | // to make the loop continue
140 | return true;
141 | });
142 | },
143 |
144 | _grabOpEnd: function() {
145 |
146 | if (this._windowChangedTimeout > 0) {
147 | Mainloop.source_remove(this._windowChangedTimeout);
148 | }
149 |
150 | this._windowChangedTimeout = 0;
151 | this._updateDockVisibility();
152 | },
153 |
154 | _updateDockVisibility: function() {
155 |
156 | if (this.overviewShowing) {
157 | this._show();
158 | } else if (this.showMethod === 2) {
159 | this._show();
160 | } else if (this.showMethod === 1) {
161 | this._hide();
162 | } else if (this.showMethod === 0) {
163 |
164 | let overlaps = false;
165 | let windows = global.get_window_actors();
166 |
167 | if (windows.length > 0) {
168 | // This is the window on top of all others in the current workspace
169 | let topWindow = windows[windows.length - 1].get_meta_window();
170 | // If there isn't a focused app, use that of the window on top
171 | this._focusApp = this._tracker.focus_app ||
172 | this._tracker.get_window_app(topWindow);
173 |
174 | windows = windows.filter(this._intellihideFilterInteresting, this);
175 |
176 | for (let i = 0; i < windows.length; i++) {
177 |
178 | let win = windows[i].get_meta_window();
179 | if (win) {
180 | let rect = win.get_frame_rect();
181 |
182 | let test = (rect.x < this._target.staticBox.x2) &&
183 | (rect.x +rect.width > this._target.staticBox.x1) &&
184 | (rect.y < this._target.staticBox.y2) &&
185 | (rect.y +rect.height > this._target.staticBox.y1);
186 |
187 | if (test) {
188 | overlaps = true;
189 | break;
190 | }
191 | }
192 | }
193 | }
194 |
195 | if (overlaps) {
196 | this._hide();
197 | } else {
198 | this._show();
199 | }
200 | }
201 | },
202 |
203 | /* Filter interesting windows to be considered for intellihide.
204 | * Consider all windows visible on the current workspace.
205 | * Optionally skip windows of other applications
206 | */
207 | _intellihideFilterInteresting: function(wa) {
208 | let currentWorkspace = global.screen.get_active_workspace_index();
209 |
210 | let meta_win = wa.get_meta_window();
211 | if (!meta_win) {
212 | return false;
213 | }
214 |
215 | if (!this._handledWindow(meta_win)) {
216 | return false;
217 | }
218 |
219 | let wksp = meta_win.get_workspace();
220 | let wksp_index = wksp.index();
221 |
222 | // Skip windows of other apps
223 | if (this._focusApp) {
224 | /* The DropDownTerminal extension is not an application per sec
225 | * so we match its window by wm class instead
226 | */
227 | if (meta_win.get_wm_class() === 'DropDownTerminalWindow') {
228 | return true;
229 | }
230 |
231 | let currentApp = this._tracker.get_window_app(meta_win);
232 |
233 | /* But consider half maximized windows
234 | * Useful if one is using two apps side by side
235 | */
236 | if (this._focusApp !== currentApp &&
237 | !(meta_win.maximized_vertically &&
238 | !meta_win.maximized_horizontally) && !meta_win.is_above()) {
239 | return false;
240 | }
241 | }
242 |
243 | if (wksp_index === currentWorkspace && meta_win.showing_on_its_workspace()) {
244 | return true;
245 | } else {
246 | return false;
247 | }
248 | },
249 |
250 | /* Filter windows by type
251 | * inspired by Opacify@gnome-shell.localdomain.pl
252 | */
253 | _handledWindow: function(metaWindow) {
254 |
255 | /* The DropDownTerminal extension uses the POPUP_MENU window type hint
256 | * so we match its window by wm class instead
257 | */
258 | if (metaWindow.get_wm_class() === 'DropDownTerminalWindow') {
259 |
260 | return true;
261 | }
262 |
263 | let wtype = metaWindow.get_window_type();
264 |
265 | for (let i = 0; i < handledWindowTypes.length; i++) {
266 | let hwtype = handledWindowTypes[i];
267 |
268 | if (hwtype === wtype) {
269 |
270 | return true;
271 | } else if (hwtype > wtype) {
272 |
273 | return false;
274 | }
275 | }
276 |
277 | return false;
278 | },
279 |
280 | _overviewOn: function() {
281 | this.overviewShowing = true;
282 | this._updateDockVisibility();
283 | },
284 |
285 | _overviewOff: function() {
286 | this.overviewShowing = false;
287 | this._updateDockVisibility();
288 | },
289 |
290 | setShowMethod: function(method) {
291 | let trackActor = this._target.actor;
292 | if (method === 2) {
293 | Main.layoutManager._trackActor(trackActor, {affectsStruts: true});
294 | this._target._resetPosition();
295 | } else {
296 | Main.layoutManager._untrackActor(trackActor);
297 | }
298 |
299 | this.showMethod = method;
300 | this._updateDockVisibility();
301 | }
302 | });
303 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/atomappdisplay.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /*jshint esnext: true */
3 | /*jshint indent: 4 */
4 | const Lang = imports.lang;
5 | const Signals = imports.signals;
6 | const Clutter = imports.gi.Clutter;
7 | const Meta = imports.gi.Meta;
8 | const Shell = imports.gi.Shell;
9 | const St = imports.gi.St;
10 |
11 | const AppDisplay = imports.ui.appDisplay;
12 | const AppFavorites = imports.ui.appFavorites;
13 | const Main = imports.ui.main;
14 | const PopupMenu = imports.ui.popupMenu;
15 |
16 | let ShellVersion = imports.misc.config.PACKAGE_VERSION.split(".").map(function (x) { return +x; });
17 | const MAJOR_VERSION = ShellVersion[0];
18 | const MINOR_VERSION = ShellVersion[1];
19 |
20 | /* This class is a extension of the upstream AppIcon class (ui.appDisplay.js).
21 | * Changes are done to modify activate, popup menu and running app behavior.
22 | */
23 | const AtomAppIcon = new Lang.Class({
24 | Name: 'AtomAppIcon',
25 | Extends: AppDisplay.AppIcon,
26 |
27 | _init : function(app, iconParams) {
28 |
29 | this.parent(app, iconParams, { setSizeManually: true, showLabel: false });
30 | this._windowsChangedId = this.app.connect('windows-changed', () => { this._onStateChanged(); });
31 | this.actor.set_style("padding: 0px;");
32 | },
33 |
34 | activate: function (button) {
35 |
36 | let event = Clutter.get_current_event();
37 | let modifiers = event ? event.get_state() : 0;
38 | let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK &&
39 | this.app.state == Shell.AppState.RUNNING ||
40 | button && button == 2;
41 | let focusedApp = Shell.WindowTracker.get_default().focus_app;
42 | let windows = this.getAppInterestingWindows();
43 |
44 | if (openNewWindow) {
45 | this.app.open_new_window(-1);
46 | } else {
47 | if (this.app == focusedApp && !Main.overview._shown) {
48 | this.setMinimizeGeometry(true);
49 | } else {
50 | this.app.activate();
51 | if(windows.length>0) {
52 | for (let i=windows.length-1; i>=0; i--){
53 | Main.activateWindow(windows[i]);
54 | }
55 | }
56 | }
57 | }
58 |
59 | Main.overview.hide();
60 | },
61 |
62 | setMinimizeGeometry: function (minimize){
63 |
64 | let windows = this.getAppInterestingWindows();
65 | let current_workspace = global.screen.get_active_workspace();
66 | let rect = new Meta.Rectangle();
67 |
68 | [rect.x, rect.y] = this.actor.get_transformed_position();
69 | [rect.width, rect.height] = this.actor.get_transformed_size();
70 |
71 | for (let i = 0; i < windows.length; i++) {
72 | let w = windows[i];
73 | // print(w);
74 | if (w.get_workspace() == current_workspace && w.showing_on_its_workspace()){
75 | w.set_icon_geometry(rect);
76 | if (minimize) { w.minimize(); }
77 | }
78 | }
79 | },
80 |
81 | getAppInterestingWindows: function(app) {
82 | // Filter out unnecessary windows, for instance
83 | // nautilus desktop window.
84 | return this.app.get_windows().filter(function(w) { return !w.skip_taskbar; });
85 | },
86 |
87 | _onStateChanged: function() {
88 | if (this.app.state !== Shell.AppState.STOPPED && this._isAppOnActiveWorkspace()) {
89 | this.actor.add_style_class_name('running');
90 | } else {
91 | this.actor.remove_style_class_name('running');
92 | }
93 | this.setMinimizeGeometry(false);
94 | },
95 |
96 | _onDestroy: function() {
97 | if (this._windowsChangedId > 0) {
98 | this.app.disconnect(this._windowsChangedId);
99 | }
100 |
101 | this._windowsChangedId = 0;
102 | this.parent();
103 | },
104 |
105 | popupMenu: function() {
106 | this._removeMenuTimeout();
107 | this.actor.fake_release();
108 | this._draggable.fakeRelease();
109 |
110 | if (!this._menu) {
111 | this._menu = new AtomAppIconMenu(this);
112 | this._menu.connect('activate-window', (menu, window) => { this.activateWindow(window); });
113 | this._menu.connect('open-state-changed', (menu, isPoppedUp) => {
114 | if (!isPoppedUp) {
115 | this._onMenuPoppedDown();
116 | }
117 | });
118 | Main.overview.connect('hiding', () => { this._menu.close(); });
119 | this._menuManager.addMenu(this._menu);
120 | }
121 |
122 | this.emit('menu-state-changed', true);
123 | this.actor.set_hover(true);
124 | this._menu.popup();
125 | this._menuManager.ignoreRelease();
126 | this.emit('sync-tooltip');
127 |
128 | return false;
129 | },
130 |
131 | _isAppOnActiveWorkspace: function() {
132 | return this.app.is_on_workspace(global.screen.get_active_workspace());
133 | }
134 | });
135 |
136 | Signals.addSignalMethods(AtomAppIcon.prototype);
137 |
138 | /* This class is a fork of the upstream AppIconMenu class (ui.appDisplay.js).
139 | * Changes are done to make popup displayed on top side.
140 | */
141 | const AtomAppIconMenu = new Lang.Class({
142 | Name: 'AtomAppIconMenu',
143 | Extends: PopupMenu.PopupMenu,
144 |
145 | _init: function(source) {
146 |
147 | this.parent(source.actor, 0.5, St.Side.TOP);
148 |
149 | // We want to keep the item hovered while the menu is up
150 | this.blockSourceEvents = true;
151 | this._source = source;
152 | this.actor.add_style_class_name('emblem-favorite');
153 |
154 | // Chain our visibility and lifecycle to that of the source
155 | source.actor.connect('notify::mapped', () => {
156 | if (!source.actor.mapped) {
157 | this.close();
158 | }
159 | });
160 |
161 | source.actor.connect('destroy', () => { this.actor.destroy(); });
162 | Main.uiGroup.add_actor(this.actor);
163 | },
164 |
165 | _redisplay: function() {
166 |
167 | let app = this._source.app;
168 | let appInfo = app.get_app_info();
169 | let actions = null;
170 | let windows = app.get_windows().filter(function(w) {
171 | return !w.skip_taskbar;
172 | });
173 |
174 | this.removeAll();
175 |
176 | if (appInfo === null) {
177 |
178 | this._appendListWindows(windows);
179 | this._appendSeparator();
180 | this._appendQuit();
181 |
182 | } else if (!app.is_window_backed()) {
183 |
184 | this._appendListWindows(windows);
185 |
186 | if (windows.length > 0) {
187 |
188 | this._appendSeparator();
189 |
190 | // Add 'action' buttons
191 | actions = appInfo.list_actions();
192 | this._appendActions(appInfo, actions, windows);
193 |
194 | if (actions.length > 0) {
195 |
196 | this._appendSeparator();
197 |
198 | } else {
199 |
200 | this._appendNewWindow(windows);
201 | this._appendSeparator();
202 | }
203 |
204 | this._openWindowMenuItem = null;
205 |
206 | } else {
207 |
208 | this._appendOpen();
209 | this._appendSeparator();
210 | }
211 |
212 | this._appendFavorites(app);
213 |
214 | if (windows.length > 0) {
215 | this._appendQuit();
216 | }
217 | }
218 | },
219 |
220 | _appendListWindows: function (windows) {
221 |
222 | // Add 'open windows' buttons'
223 | this._windowMenuItems = new Array(windows.length);
224 | for (let i = 0; i < windows.length; i++) {
225 | let name = windows[i].title;
226 | let chars = 30;
227 | if (name.length > chars) { name = name.substring(0, 15) + '...' + name.substring(name.length - (chars - 15)); }
228 | this._windowMenuItems[i] = this._appendMenuItem(name);
229 | this._windowMenuItems[i]._refWindow = windows[i];
230 | this._windowMenuItems[i].connect('activate', (actor, event) => {
231 | this.emit('activate-window', actor._refWindow);
232 | this.close();
233 | });
234 | }
235 | },
236 |
237 | _appendActions: function (appInfo, actions, windows) {
238 | let i;
239 | // Add custom application 'actions'
240 | this._actionMenuItems = new Array(actions.length);
241 | for (i = 0; i < actions.length; i++) {
242 | this._actionMenuItems[i] = this._appendMenuItem(appInfo.get_action_name(actions[i]));
243 | this._actionMenuItems[i]._refAction = actions[i];
244 | this._actionMenuItems[i]._refWindow = windows[0];
245 | this._actionMenuItems[i].connect('activate', (actor, event) => {
246 | let app = this._source.app;
247 | app.launch_action(actor._refAction, event.get_time(), -1);
248 | this.emit('activate-window', actor._refWindow);
249 | this.close();
250 | });
251 | }
252 | },
253 |
254 | _appendNewWindow: function (windows) {
255 |
256 | // Add 'new window' button only if there are open windows and there is no 'action'
257 | this._newWindowMenuItem = this._appendMenuItem(_("New Window"));
258 | this._newWindowMenuItem._refWindow = windows[0];
259 | this._newWindowMenuItem.connect('activate', (actor, event) => {
260 | let app = this._source.app;
261 | app.open_new_window(-1);
262 | this.emit('activate-window', actor._refWindow);
263 | this.close();
264 | });
265 | },
266 |
267 | _appendOpen: function () {
268 |
269 | // Add 'open' button (only if there are no open windows)
270 | this._openWindowMenuItem = this._appendMenuItem(_("Open"));
271 | this._openWindowMenuItem.connect('activate', (actor, event) => {
272 | let app = this._source.app;
273 | app.open_new_window(-1);
274 | this.emit('activate-window', null);
275 | this.close();
276 | });
277 | },
278 |
279 | _appendFavorites: function (app) {
280 |
281 | // Add 'add/remove favorites' button
282 | let isFavorite = AppFavorites.getAppFavorites().isFavorite(app.get_id());
283 | this._toggleFavoriteMenuItem = this._appendMenuItem(isFavorite ? _("Remove from Favorites") : _("Add to Favorites"));
284 | this._toggleFavoriteMenuItem.connect('activate', (actor, event) => {
285 | let app = this._source.app;
286 | let favs = AppFavorites.getAppFavorites();
287 | let isFavorite = favs.isFavorite(app.get_id());
288 | if (isFavorite) {
289 | favs.removeFavorite(app.get_id());
290 | } else {
291 | favs.addFavorite(app.get_id());
292 | }
293 | this.close();
294 | });
295 | },
296 |
297 | _appendQuit: function () {
298 |
299 | // Add 'quit' button
300 | this._quitMenuItem = this._appendMenuItem(_("Quit"));
301 | this._quitMenuItem.connect('activate', (actor, event) => {
302 | let app = this._source.app;
303 | let wins = app.get_windows();
304 | for (let i=0; i < wins.length; i++) {
305 | wins[i].delete(global.get_current_time());
306 | }
307 | this.close();
308 | });
309 | },
310 |
311 | _appendSeparator: function () {
312 | let separator = new PopupMenu.PopupSeparatorMenuItem();
313 | this.addMenuItem(separator);
314 | },
315 |
316 | _appendMenuItem: function(labelText) {
317 | let item = new PopupMenu.PopupMenuItem(labelText);
318 | this.addMenuItem(item);
319 | return item;
320 | },
321 |
322 | popup: function(activatingButton) {
323 | this._redisplay();
324 | this.open();
325 | }
326 | });
327 |
328 | Signals.addSignalMethods(AtomAppIconMenu.prototype);
329 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/messageTrayModified.js:
--------------------------------------------------------------------------------
1 | const St = imports.gi.St;
2 | const Shell = imports.gi.Shell;
3 | const Config = imports.misc.config;
4 | const Main = imports.ui.main;
5 | const Mainloop = imports.mainloop;
6 | const MessageTray = Main.messageTray;
7 | const Lang = imports.lang;
8 | const LayoutManager = Main.layoutManager;
9 | const PointerWatcher = imports.ui.pointerWatcher;
10 | const Tweener = imports.ui.tweener;
11 | const ExtensionUtils = imports.misc.extensionUtils;
12 | const Me = ExtensionUtils.getCurrentExtension();
13 | const Convenience = Me.imports.convenience;
14 |
15 | let panel = Main.layoutManager.panelBox;
16 |
17 | // Constants from messageTray:
18 | const ANIMATION_TIME = 0.2;
19 | const IDLE_TIME = 1000;
20 | const State = {
21 | HIDDEN: 0,
22 | SHOWING: 1,
23 | SHOWN: 2,
24 | HIDING: 3
25 | };
26 | const Urgency = {
27 | LOW: 0,
28 | NORMAL: 1,
29 | HIGH: 2,
30 | CRITICAL: 3
31 | };
32 | const TRAY_DWELL_CHECK_INTERVAL = 100;
33 |
34 | let messageTray_showNotification = function() {
35 | this._notification = this._notificationQueue.shift();
36 |
37 | this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME;
38 | if (!this._userActiveWhileNotificationShown) {
39 | // If the user isn't active, set up a watch to let us know
40 | // when the user becomes active.
41 | this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
42 | }
43 |
44 | this._notificationClickedId = this._notification.connect('done-displaying',
45 | Lang.bind(this, this._escapeTray));
46 | this._notificationUnfocusedId = this._notification.connect('unfocused', Lang.bind(this, function() {
47 | this._updateState();
48 | }));
49 | this._notificationBin.child = this._notification.actor;
50 |
51 | this._notificationWidget.opacity = 0;
52 | // > SimpleDock (Notifications to top)
53 | // this._notificationWidget.y = 0;
54 | let yTop = -global.screen_height;
55 | let yBottom = 0;
56 | this._notificationWidget.y = yTop;
57 | // < SimpleDock
58 | this._notificationWidget.show();
59 |
60 | this._updateShowingNotification();
61 |
62 | let [x, y, mods] = global.get_pointer();
63 | // We save the position of the mouse at the time when we started showing the notification
64 | // in order to determine if the notification popped up under it. We make that check if
65 | // the user starts moving the mouse and _onNotificationHoverChanged() gets called. We don't
66 | // expand the notification if it just happened to pop up under the mouse unless the user
67 | // explicitly mouses away from it and then mouses back in.
68 | this._showNotificationMouseX = x;
69 | this._showNotificationMouseY = y;
70 | // We save the coordinates of the mouse at the time when we started showing the notification
71 | // and then we update it in _notificationTimeout(). We don't pop down the notification if
72 | // the mouse is moving towards it or within it.
73 | this._lastSeenMouseX = x;
74 | this._lastSeenMouseY = y;
75 |
76 | this._resetNotificationLeftTimeout();
77 | };
78 |
79 | let messageTray_hideNotification = function(animate) {
80 | this._notificationFocusGrabber.ungrabFocus();
81 |
82 | if (this._notificationExpandedId) {
83 | this._notification.disconnect(this._notificationExpandedId);
84 | this._notificationExpandedId = 0;
85 | }
86 | // > SimpleDock (Notifications to top)
87 | let yPos = -global.screen_height;
88 | // < SimpleDock
89 | if (this._notificationClickedId) {
90 | this._notification.disconnect(this._notificationClickedId);
91 | this._notificationClickedId = 0;
92 | }
93 | if (this._notificationUnfocusedId) {
94 | this._notification.disconnect(this._notificationUnfocusedId);
95 | this._notificationUnfocusedId = 0;
96 | }
97 |
98 | this._resetNotificationLeftTimeout();
99 |
100 | if (animate) {
101 | this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
102 | // > SimpleDock (Notifications to top)
103 | // { y: this.actor.height,
104 | { y: yPos,
105 | // < SimpleDock
106 | opacity: 0,
107 | time: ANIMATION_TIME,
108 | transition: 'easeOutQuad',
109 | onComplete: this._hideNotificationCompleted,
110 | onCompleteScope: this
111 | });
112 | } else {
113 | Tweener.removeTweens(this._notificationWidget);
114 | // > SimpleDock (Notifications to top)
115 | // this._notificationWidget.y = this.actor.height;
116 | this._notificationWidget.y = yPos;
117 | // < SimpleDock
118 | this._notificationWidget.opacity = 0;
119 | this._notificationState = State.HIDDEN;
120 | this._hideNotificationCompleted();
121 | }
122 | };
123 |
124 | let messageTray_updateShowingNotification = function() {
125 | // > SimpleDock (Notifications to top)
126 | this._notification._table.remove_style_class_name('sd_notification');
127 | this._notification._table.remove_style_class_name('sd_notification_top');
128 | this._notification._table.remove_style_class_name('sd_notification_bottom');
129 | this._notification._table.add_style_class_name('sd_notification_top');
130 | // < SimpleDock
131 | this._notification.acknowledged = true;
132 | this._notification.playSound();
133 |
134 | // We auto-expand notifications with CRITICAL urgency, or for which the relevant setting
135 | // is on in the control center.
136 | if (this._notification.urgency == Urgency.CRITICAL ||
137 | this._notification.source.policy.forceExpanded)
138 | this._expandNotification(true);
139 | // > SimpleDock (Notifications to top)
140 | let yTop = panel.y + panel.height - global.screen_height;
141 | if (yTop < (-global.screen_height))
142 | yTop = -global.screen_height;
143 | let yBottom = -this._notificationWidget.height;
144 | this._notificationWidget.x = global.screen_width / 50;
145 | // < SimpleDock
146 | // We tween all notifications to full opacity. This ensures that both new notifications and
147 | // notifications that might have been in the process of hiding get full opacity.
148 | //
149 | // We tween any notification showing in the banner mode to the appropriate height
150 | // (which is banner height or expanded height, depending on the notification state)
151 | // This ensures that both new notifications and notifications in the banner mode that might
152 | // have been in the process of hiding are shown with the correct height.
153 | //
154 | // We use this._showNotificationCompleted() onComplete callback to extend the time the updated
155 | // notification is being shown.
156 |
157 | let tweenParams = { opacity: 255,
158 | // > SimpleDock (Notifications to top)
159 | // y: -this._notificationWidget.height,
160 | y: yTop,
161 | // < SimpleDock
162 | time: ANIMATION_TIME,
163 | transition: 'easeOutQuad',
164 | onComplete: this._showNotificationCompleted,
165 | onCompleteScope: this
166 | };
167 |
168 | this._tween(this._notificationWidget, '_notificationState', State.SHOWN, tweenParams);
169 | };
170 |
171 | let messageTray_onNotificationExpanded = function() {
172 | // > SimpleDock (Notifications to top)
173 | // let expandedY = - this._notificationWidget.height;
174 | let yTop = panel.y + panel.height - global.screen_height;
175 | if (yTop < (-global.screen_height))
176 | yTop = -global.screen_height;
177 | let yBottom = -this._notificationWidget.height;
178 | let expandedY = yTop;
179 | // < SimpleDock
180 | this._closeButton.show();
181 |
182 | // Don't animate the notification to its new position if it has shrunk:
183 | // there will be a very visible "gap" that breaks the illusion.
184 | if (this._notificationWidget.y < expandedY) {
185 | this._notificationWidget.y = expandedY;
186 | } else if (this._notification.y != expandedY) {
187 | // Tween also opacity here, to override a possible tween that's
188 | // currently hiding the notification.
189 | Tweener.addTween(this._notificationWidget,
190 | { y: expandedY,
191 | opacity: 255,
192 | time: ANIMATION_TIME,
193 | transition: 'easeOutQuad',
194 | // HACK: Drive the state machine here better,
195 | // instead of overwriting tweens
196 | onComplete: Lang.bind(this, function() {
197 | this._notificationState = State.SHOWN;
198 | }),
199 | });
200 | }
201 | };
202 |
203 | let messageTray_resetNotificationLeftTimeout = function() {
204 | this._useLongerNotificationLeftTimeout = false;
205 | if (this._notificationLeftTimeoutId) {
206 | Mainloop.source_remove(this._notificationLeftTimeoutId);
207 | this._notificationLeftTimeoutId = 0;
208 | this._notificationLeftMouseX = -1;
209 | this._notificationLeftMouseY = -1;
210 | }
211 | };
212 |
213 | const ModifiedMessageTray = new Lang.Class({
214 | Name: 'ModifiedMessageTray',
215 |
216 | _init: function(enabled) {
217 |
218 | if (enabled) {
219 | this.enable(false);
220 | }
221 | },
222 |
223 | initialize: function() {
224 |
225 | // > SimpleDock (Notifications to top)
226 | this.testNotificationTimeout = undefined;
227 | this.originalNotificationWidgetX = MessageTray._notificationWidget.x;
228 | this.originalShowNotification = MessageTray._showNotification;
229 | this.originalHideNotification = MessageTray._hideNotification;
230 | this.originalUpdateShowingNotification = MessageTray._updateShowingNotification;
231 | this.originalOnNotificationExpanded = MessageTray._onNotificationExpanded;
232 | this.originalResetNotificationLeftTimeout = MessageTray._resetNotificationLeftTimeout;
233 | // < SimpleDock
234 |
235 | // > SimpleDock (Disable Message tray)
236 | this.originalDwell = null;
237 | this.watcher = null;
238 | // < SimpleDock
239 | this.initialized = true;
240 | },
241 |
242 | enable: function(testNotification) {
243 |
244 | if (!this.initialized) { this.initialize(); }
245 |
246 | // > SimpleDock (Notifications to top)
247 | MessageTray._showNotification = messageTray_showNotification;
248 | MessageTray._hideNotification = messageTray_hideNotification;
249 | MessageTray._updateShowingNotification = messageTray_updateShowingNotification;
250 | MessageTray._onNotificationExpanded = messageTray_onNotificationExpanded;
251 | MessageTray._resetNotificationLeftTimeout = messageTray_resetNotificationLeftTimeout;
252 |
253 | if (testNotification) {
254 | this.testNotification();
255 | }
256 | // < SimpleDock
257 |
258 | // > SimpleDock (Disable Message tray)
259 | this.originalDwell = MessageTray._trayDwellTimeout;
260 | if("_trayPressure" in LayoutManager) {
261 | LayoutManager._trayPressure._keybindingMode = Shell.KeyBindingMode.OVERVIEW;
262 | }
263 | MessageTray._trayDwellTimeout = function() { return false; };
264 |
265 | let pointerWatcher = PointerWatcher.getPointerWatcher();
266 | this.watcher = pointerWatcher.addWatch(TRAY_DWELL_CHECK_INTERVAL, this.checkPointer);
267 | // < SimpleDock
268 | },
269 |
270 | disable: function() {
271 |
272 | // > SimpleDock (Notifications to top)
273 | if (this.testNotificationTimeout !== undefined)
274 | Mainloop.source_remove(this.testNotificationTimeout);
275 |
276 | if (MessageTray._notification) {
277 | MessageTray._notification._table.remove_style_class_name('sd_notification');
278 | MessageTray._notification._table.remove_style_class_name('sd_notification_top');
279 | MessageTray._notification._table.remove_style_class_name('sd_notification_bottom');
280 | }
281 |
282 | Main.messageTray._notificationWidget.x = this.originalNotificationWidgetX;
283 | MessageTray._showNotification = this.originalShowNotification;
284 | MessageTray._hideNotification = this.originalHideNotification;
285 | MessageTray._updateShowingNotification = this.originalUpdateShowingNotification;
286 | MessageTray._onNotificationExpanded = this.originalOnNotificationExpanded;
287 | MessageTray._resetNotificationLeftTimeout = this.originalResetNotificationLeftTimeout;
288 | // < SimpleDock
289 |
290 | // > SimpleDock (Disable Message tray)
291 | if("_trayPressure" in LayoutManager) {
292 | LayoutManager._trayPressure._keybindingMode = Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.OVERVIEW;
293 | }
294 | if(this.originalDwell !== null) {
295 | MessageTray._trayDwellTimeout = this.originalDwell;
296 | }
297 | if (this.watcher !== null) {
298 | let pointerWatcher = PointerWatcher.getPointerWatcher();
299 | pointerWatcher._removeWatch(this.watcher);
300 | }
301 | // < SimpleDock
302 | this.initialized = false;
303 | },
304 |
305 | destroy: function() {
306 | this.disable();
307 | },
308 |
309 | // > SimpleDock (Notifications to top)
310 | testNotification: function() {
311 | if (this.testNotificationTimeout !== undefined)
312 | Mainloop.source_remove(this.testNotificationTimeout);
313 |
314 | this.testNotificationTimeout = Mainloop.timeout_add(250,
315 | Lang.bind(this, function() {
316 | Main.notify("Simple Dock", "This is just a notification example.\n\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
317 | return false;
318 | }));
319 | },
320 | // < SimpleDock
321 |
322 | // > SimpleDock (Disable Message tray)
323 | showMessageTray: function() {
324 | if (MessageTray._trayState === 0) {
325 | MessageTray.openTray();
326 | } else {
327 | MessageTray.hide();
328 | }
329 | },
330 | // < SimpleDock
331 |
332 | // > SimpleDock (Disable Message tray)
333 | checkPointer: function (x, y) {
334 | let monitor = Main.layoutManager.bottomMonitor;
335 |
336 | if (y !== monitor.y + monitor.height - 1) return; // Prevent absurd calculations
337 |
338 | let shouldDwell = (x >= monitor.x && x <= monitor.x + monitor.width
339 | && (x <= (monitor.x + 2) || x >= (monitor.x + monitor.width - 2)));
340 |
341 | if (shouldDwell && MessageTray._trayState === 0) {
342 | MessageTray.openTray();
343 | }
344 | }
345 | // < SimpleDock
346 | });
347 |
348 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/atomdock.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /*jshint esnext: true */
3 | /*jshint indent: 4 */
4 |
5 | const Lang = imports.lang;
6 | const Mainloop = imports.mainloop;
7 | const Signals = imports.signals;
8 | const Clutter = imports.gi.Clutter;
9 | const Gtk = imports.gi.Gtk;
10 | const Shell = imports.gi.Shell;
11 | const St = imports.gi.St;
12 |
13 | const Main = imports.ui.main;
14 | const Tweener = imports.ui.tweener;
15 |
16 | const Me = imports.misc.extensionUtils.getCurrentExtension();
17 | const Convenience = Me.imports.convenience;
18 | const AtomDash = Me.imports.atomdash;
19 |
20 | // This will be on settings scheme
21 | const ANIMATION_TIME = 0.15;
22 | const SHOW_DELAY = 0.1;
23 | const HIDE_DELAY = 0.1;
24 |
25 | /* This class handles the dock and intellihide behavior.
26 | * Heavily inspired from Michele's Dash to Dock extension
27 | * https://github.com/micheleg/dash-to-dock
28 | */
29 | const AtomDock = new Lang.Class({
30 | Name: 'AtomDock',
31 |
32 | _init: function() {
33 |
34 | // initialize animation status object
35 | this._animStatus = new AnimationStatus(true);
36 | this._animIgnore = false;
37 |
38 | // Default background opacity
39 | this._backgroundOpacity = -1;
40 |
41 | // Current autohide status
42 | this._autoIntelliStatus = false;
43 |
44 | // Put dock on the primary monitor
45 | this._monitor = Main.layoutManager.primaryMonitor;
46 |
47 | // Used to store dock position for intellihide checking
48 | this.staticBox = new Clutter.ActorBox();
49 |
50 | // Create dash
51 | this.dash = new AtomDash.AtomDash();
52 |
53 |
54 | this.actor = new St.Bin({
55 | name: 'atomDockContainer',
56 | reactive: false,
57 | x_align: St.Align.MIDDLE
58 | });
59 |
60 | this.actor._delegate = this;
61 |
62 | this._box = new St.BoxLayout({
63 | name: 'atomDockBox',
64 | reactive: true,
65 | track_hover: true
66 | });
67 |
68 | this._box.connect("notify::hover", () => { this._hoverChanged(); });
69 | this._box.connect('scroll-event', (actor, event) => { this.onScrollEvent(actor, event); });
70 |
71 | this._signalHandler = new Convenience.GlobalSignalHandler();
72 | this._signalHandler.push(
73 | [
74 | this.dash, 'menu-closed', () => { this._box.sync_hover(); }
75 | ],
76 | [
77 | global.screen, 'monitors-changed', () => { this._resetPosition(); }
78 | ],
79 | [
80 | St.ThemeContext.get_for_stage(global.stage), 'changed', () => { this._onThemeChanged(); }
81 | ]
82 | );
83 |
84 | // Hide the dock while setting position and theme
85 | this.actor.set_opacity(0);
86 |
87 | /* Since the actor is not a topLevel child and its parent is now not
88 | * added to the Chrome, the allocation change of the parent container
89 | * (slide in and slideout) doesn't trigger anymore an update of the
90 | * input regions. Force the update manually.
91 | */
92 | this.actor.connect('notify::allocation', () => { Main.layoutManager._queueUpdateRegions(); });
93 |
94 | this.dash._container.connect('allocation-changed', () => { this._updateStaticBox(); });
95 |
96 | // Reset position when icon size changed
97 | this.dash.connect('icon-size-changed', () => { this._updateYPosition(); });
98 |
99 | // sync hover after a popupmenu is closed
100 | this.dash.connect('menu-closed', () => { this._box.sync_hover(); });
101 |
102 | // Dash accessibility
103 | Main.ctrlAltTabManager.addGroup(this.dash.actor, _("Dock"), 'user-bookmarks-symbolic', { focusCallback: () => { this._onAccessibilityFocus(); }});
104 |
105 | /* Delay operations that require the shell to be fully loaded and with
106 | * user theme applied.
107 | */
108 | this._realizeId = this.actor.connect('realize', () => { this._initialize(); });
109 |
110 | // Add dash container actor and the container to the Chrome
111 | this.actor.set_child(this._box);
112 | this._box.add_actor(this.dash.actor);
113 |
114 | Main.uiGroup.add_child(this.actor);
115 |
116 | Main.layoutManager._trackActor(this._box, { trackFullscreen: true });
117 | /* Pretend this._box is isToplevel child so that fullscreen
118 | * is actually tracked.
119 | */
120 | let index = Main.layoutManager._findActor(this._box);
121 | Main.layoutManager._trackedActors[index].isToplevel = true;
122 | },
123 |
124 | _initialize: function() {
125 |
126 | if (this._realizeId > 0) {
127 | this.actor.disconnect(this._realizeId);
128 | this._realizeId = 0;
129 | }
130 |
131 | // Adjust dock theme to match global theme
132 | this._adjustTheme();
133 |
134 |
135 | // Set initial position
136 | this._resetPosition();
137 |
138 | // Show the dock;
139 | this.actor.set_opacity(255);
140 | },
141 |
142 | _resetPosition: function() {
143 |
144 | // Get primary monitor to display dock
145 | this._monitor = Main.layoutManager.primaryMonitor;
146 |
147 | // Update static box location
148 | this._updateStaticBox();
149 |
150 | this.actor.width = this._monitor.width;
151 | this.actor.x = this._monitor.x;
152 | this.actor.x_align = St.Align.MIDDLE;
153 | this._updateYPosition();
154 | this.dash._container.set_width(-1);
155 | },
156 |
157 | _updateYPosition: function() {
158 | this.actor.y = this._monitor.y + this._monitor.height - this._box.height;
159 | // Modify legacy overview each time the dock repositioned
160 | this._modifyLegacyOverview();
161 | },
162 |
163 | _updateStaticBox: function() {
164 | // Init static box in accordance with dock's placement
165 | this.staticBox.init_rect(
166 | this._monitor.x + this._box.x,
167 | this._monitor.y + this._monitor.height - this._box.height,
168 | this._box.width,
169 | this._box.height
170 | );
171 |
172 | this.emit('box-changed');
173 | },
174 |
175 | _onThemeChanged: function() {
176 | this.dash._queueRedisplay();
177 | this._adjustTheme();
178 | this._resetPosition();
179 | },
180 |
181 | _adjustTheme: function() {
182 | // Prevent shell crash if the actor is not on the stage.
183 | // It happens enabling/disabling repeatedly the extension
184 | if (!this.dash._container.get_stage()) {
185 | return;
186 | }
187 |
188 | this.dash._container.set_style(null);
189 |
190 | let themeNode = this.dash._container.get_theme_node();
191 | let backOriginal = themeNode.get_background_color();
192 | let backR = 0;
193 | let backG = 0;
194 | let backB = 0;
195 | let backA = this._backgroundOpacity;
196 | let borderColor = themeNode.get_border_color(St.Side.BOTTOM);
197 | let borderWidth = themeNode.get_border_width(St.Side.BOTTOM);
198 | let borderRadius = themeNode.get_border_radius(St.Corner.TOPRIGHT);
199 |
200 | if (typeof backOriginal === 'object') {
201 | if (typeof backOriginal.red === 'number') {
202 | backR = backOriginal.red;
203 | }
204 | if (typeof backOriginal.green === 'number') {
205 | backG = backOriginal.green;
206 | }
207 | if (typeof backOriginal.blue === 'number') {
208 | backB = backOriginal.blue;
209 | }
210 | }
211 |
212 | /* We're "swapping" bottom border and bottom-right corner styles to
213 | * left and top-left corner
214 | */
215 | let newStyle = 'background-color: rgba('
216 | + backR + ', ' + backG + ', ' + backB + ', ' + backA + '); '
217 | + 'padding: 0; border-bottom: none;'
218 | + 'border-radius: ' + borderRadius + 'px ' + borderRadius + 'px 0 0;'
219 | + 'border-left: ' + borderWidth + 'px solid ' + borderColor.to_string() + ';';
220 |
221 | if (backA === 0) {
222 | newStyle = newStyle + 'padding: 0; border: none;';
223 | }
224 |
225 | this.dash._container.set_style(newStyle);
226 | },
227 |
228 | _modifyLegacyOverview: function() {
229 | // Set legacy overview bottom padding
230 | let actorStyle = 'padding-bottom: ' + this._box.height + 'px;';
231 | Main.overview.viewSelector.actor.set_style(actorStyle);
232 | },
233 |
234 | _restoreLegacyOverview: function() {
235 | // Remove legacy overview bottom padding
236 | Main.overview.viewSelector.actor.set_style(null);
237 | },
238 |
239 | // Show the dock and give focus to it
240 | _onAccessibilityFocus: function() {
241 | this._box.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
242 | this._animateIn(ANIMATION_TIME, 0);
243 | },
244 |
245 | destroy: function() {
246 | // Disconnect global signals
247 | this._signalHandler.disconnect();
248 |
249 | // Destroy everything
250 | this.dash.destroy();
251 | this.actor.destroy();
252 |
253 | // Restore legacy overview modifications
254 | this._restoreLegacyOverview();
255 | },
256 |
257 | _hoverChanged: function() {
258 | /* Skip if dock is not in autohide mode for instance because it is shown
259 | * by intellihide. Delay the hover changes check while switching
260 | * workspace: the workspaceSwitcherPopup steals the hover status and it
261 | * is not restored until the mouse move again (sync_hover has no effect).
262 | */
263 | if (Main.wm._workspaceSwitcherPopup) {
264 | Mainloop.timeout_add(500, () => {
265 | this._box.sync_hover();
266 | this._hoverChanged();
267 | return false;
268 | });
269 | } else if (this._autoIntelliStatus) {
270 | if (this._box.hover) {
271 | this._showHover();
272 | } else {
273 | this._hideHover();
274 | }
275 | }
276 | },
277 |
278 | _showHover: function() {
279 | let anim = this._animStatus;
280 |
281 | if (this._animIgnore) return;
282 |
283 | if (anim.hidden() || anim.hiding()) {
284 | let delay;
285 | /* If the dock is hidden, wait this._settings.get_double('show-delay')
286 | * before showing it otherwise show it immediately.
287 | */
288 | if (anim.hidden()) {
289 | delay = SHOW_DELAY;
290 | } else if (anim.hiding()) {
291 | /* suppress all potential queued hiding animations
292 | * (always give priority to show)
293 | */
294 | this._removeAnimations();
295 | delay = 0;
296 | }
297 |
298 | this.emit('showing');
299 | this._animateIn(ANIMATION_TIME, delay);
300 | }
301 | },
302 |
303 | _hideHover: function() {
304 | let anim = this._animStatus;
305 |
306 | if (this._animIgnore) return;
307 |
308 | // If no hiding animation is running or queued
309 | if (anim.showing() || anim.shown()) {
310 | let delay;
311 |
312 | /* If a show is queued but still not started (i.e the mouse was
313 | * over the screen border but then went away, i.e not a sufficient
314 | * amount of time is passeed to trigger the dock showing) remove it.
315 | */
316 | if (anim.showing()) {
317 | if (anim.running) {
318 | /* if a show already started, let it finish;
319 | * queue hide without removing the show. To obtain this I
320 | * increase the delay to avoid the overlap and interference
321 | * between the animations
322 | */
323 | delay = HIDE_DELAY + 1.2 * ANIMATION_TIME + SHOW_DELAY;
324 | } else {
325 | this._removeAnimations();
326 | delay = 0;
327 | }
328 | } else if (anim.shown()) {
329 | delay = HIDE_DELAY;
330 | }
331 |
332 | this.emit('hiding');
333 | this._animateOut(ANIMATION_TIME, delay);
334 |
335 | }
336 | },
337 |
338 | _removeAnimations: function() {
339 | Tweener.removeTweens(this.actor);
340 | this._animStatus.clearAll();
341 | },
342 |
343 | _animateIn: function(time, delay) {
344 | this._animStatus.queue(true);
345 | Tweener.addTween(this.actor, {
346 | y: this._monitor.y + this._monitor.height - this._box.height,
347 | time: time,
348 | delay: delay,
349 | transition: 'easeOutQuad',
350 |
351 | onStart: () => { this._animStatus.start(); },
352 |
353 | onOverwrite : () => { this._animStatus.clear(); },
354 |
355 | onComplete: () => { this._animStatus.end(); }
356 | });
357 | },
358 |
359 | _animateOut: function(time, delay) {
360 | this._animStatus.queue(false);
361 | Tweener.addTween(this.actor, {
362 | y: this._monitor.y + this._monitor.height - 1,
363 | time: time,
364 | delay: delay,
365 | transition: 'easeOutQuad',
366 |
367 | onStart: () => { this._animStatus.start(); },
368 |
369 | onOverwrite : () => { this._animStatus.clear(); },
370 |
371 | onComplete: () => { this._animStatus.end(); }
372 | });
373 | },
374 |
375 | // Show previous/next application window
376 | onScrollEvent: function (actor, event) {
377 |
378 | // Limit fast scrolls
379 | if (typeof this.scrollTime === 'undefined') { this.scrollTime = 0; }
380 | let now = Date.now();
381 | if ((now - this.scrollTime) < 200) { return; }
382 | this.scrollTime = now;
383 |
384 | // Get scroll direction
385 | let goUp = false;
386 | let goDn = false;
387 | switch (event.get_scroll_direction()) {
388 | case Clutter.ScrollDirection.SMOOTH:
389 | let [dx, dy] = event.get_scroll_delta();
390 | if (dy === 0) { show = true; }
391 | if (dy >= 1) { goUp = true; }
392 | if (dy <= -1) { goDn = true; }
393 | break;
394 | case Clutter.ScrollDirection.UP:
395 | goUp = true;
396 | break;
397 | case Clutter.ScrollDirection.DOWN:
398 | goDn = true;
399 | break;
400 | }
401 | var diff = 0;
402 | if (goUp) {
403 | diff = -1;
404 | }
405 | if (goDn) {
406 | diff = +1;
407 | }
408 |
409 | // Get running windows (and active one)
410 | let children = this.getRunningWindows();
411 | let active = 0;
412 | for (let i = 0; i < children.length; i++) {
413 | if (children[i].has_focus()) {
414 | active = i;
415 | break;
416 | }
417 | }
418 |
419 | // Set new active window
420 | active = active + diff;
421 | if (active >= children.length) {
422 | active = 0;
423 | }
424 | if (active < 0) {
425 | active = children.length - 1;
426 | }
427 | Main.activateWindow(children[active]);
428 | },
429 |
430 | getRunningWindows: function () {
431 | let apps = Shell.AppSystem.get_default().get_running().sort();
432 | let windows = [];
433 | let counter;
434 | for (counter = 0; counter < apps.length; counter = counter + 1) {
435 | var appWindows = apps[counter].get_windows().filter(function(w) { return !w.skip_taskbar; }).sort(function (a, b) {
436 | return a.get_stable_sequence() - b.get_stable_sequence();
437 | });
438 | windows = windows.concat(appWindows);
439 | }
440 | return windows;
441 | },
442 |
443 | // Show or hide applications button
444 | setShowAppsButton: function(show) {
445 | this.dash.setShowAppsButton(show);
446 | },
447 |
448 | // Changes the allowed maximum icon size
449 | setMaxIconSize: function(size, redisplay) {
450 | if (this.dash) {
451 | this.dash.maxIconSize = size;
452 | if (redisplay) {
453 | this.dash._redisplay();
454 | }
455 | }
456 | },
457 |
458 | // Changes the background opacity
459 | setBackgroundOpacity: function(opacity, update) {
460 | this._backgroundOpacity = opacity;
461 | if (update) {
462 | this._adjustTheme();
463 | }
464 | },
465 |
466 | // Disable autohide effect, thus show dash
467 | intelliShow: function() {
468 |
469 | if (this._animIgnore) return;
470 |
471 | if (this._autoIntelliStatus === true) {
472 | this._autoIntelliStatus = false;
473 | this._removeAnimations();
474 | this._animateIn(ANIMATION_TIME, 0);
475 | }
476 | },
477 |
478 | // Enable autohide effect, hide dash
479 | intelliHide: function() {
480 |
481 | if (this._animIgnore) return;
482 |
483 | if (this._autoIntelliStatus === false) {
484 | // immediately fadein background if hide is blocked by mouseover,
485 | let delay = 0;
486 | // oterwise start fadein when dock is already hidden.
487 | this._autoIntelliStatus = true;
488 | this._removeAnimations();
489 |
490 | if (this._box.hover === true) {
491 | this._box.sync_hover();
492 | }
493 |
494 | if (!this._box.hover) {
495 | this._animateOut(ANIMATION_TIME, 0);
496 | delay = ANIMATION_TIME;
497 | } else {
498 | delay = 0;
499 | }
500 | }
501 | }
502 |
503 | });
504 |
505 | Signals.addSignalMethods(AtomDock.prototype);
506 |
507 | /*
508 | * Store animation status in a perhaps overcomplicated way.
509 | * status is true for visible, false for hidden
510 | */
511 | const AnimationStatus = new Lang.Class({
512 | Name: 'AnimationStatus',
513 |
514 | _init: function(initialStatus) {
515 | this.status = initialStatus;
516 | this.nextStatus = [];
517 | this.queued = false;
518 | this.running = false;
519 | },
520 |
521 | queue: function(nextStatus) {
522 | this.nextStatus.push(nextStatus);
523 | this.queued = true;
524 | },
525 |
526 | start: function() {
527 |
528 | if (this.nextStatus.length === 1) {
529 | this.queued = false;
530 | }
531 |
532 | this.running = true;
533 | },
534 |
535 | end: function() {
536 |
537 | if (this.nextStatus.length === 1) {
538 | // in the case end is called and start was not
539 | this.queued = false;
540 | }
541 |
542 | this.running = false;
543 | this.status = this.nextStatus.shift();
544 | },
545 |
546 | clear: function() {
547 |
548 | if (this.nextStatus.length == 1) {
549 | this.queued = false;
550 | this.running = false;
551 | }
552 |
553 | this.nextStatus.splice(0, 1);
554 | },
555 |
556 | clearAll: function() {
557 | this.queued = false;
558 | this.running = false;
559 | this.nextStatus.splice(0, this.nextStatus.length);
560 | },
561 |
562 | // Return true if a showing animation is running or queued
563 | showing: function() {
564 |
565 | if ((this.running === true || this.queued === true) &&
566 | this.nextStatus[0] === true) {
567 |
568 | return true;
569 | } else {
570 |
571 | return false;
572 | }
573 | },
574 |
575 | shown: function() {
576 |
577 | if (this.status === true &&
578 | !(this.queued || this.running)) {
579 |
580 | return true;
581 | } else {
582 |
583 | return false;
584 | }
585 | },
586 |
587 | // Return true if an hiding animation is running or queued
588 | hiding: function() {
589 |
590 | if ((this.running === true || this.queued === true) &&
591 | this.nextStatus[0] === false) {
592 |
593 | return true;
594 | } else {
595 |
596 | return false;
597 | }
598 | },
599 |
600 | hidden: function() {
601 |
602 | if (this.status === false && !(this.queued || this.running)) {
603 |
604 | return true;
605 | } else {
606 |
607 | return false;
608 | }
609 | }
610 | });
611 |
--------------------------------------------------------------------------------
/simple-dock@nothing.org/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
--------------------------------------------------------------------------------
/simple-dock@nothing.org/atomdash.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2 | /*jshint esnext: true */
3 | /*jshint indent: 4 */
4 | const Lang = imports.lang;
5 | const Mainloop = imports.mainloop;
6 | const Signals = imports.signals;
7 | const Clutter = imports.gi.Clutter;
8 | const Meta = imports.gi.Meta;
9 | const Shell = imports.gi.Shell;
10 | const St = imports.gi.St;
11 |
12 | const AppDisplay = imports.ui.appDisplay;
13 | const AppFavorites = imports.ui.appFavorites;
14 | const Dash = imports.ui.dash;
15 | const DND = imports.ui.dnd;
16 | const Main = imports.ui.main;
17 | const PopupMenu = imports.ui.popupMenu;
18 | const Tweener = imports.ui.tweener;
19 | const Util = imports.misc.util;
20 |
21 | const Me = imports.misc.extensionUtils.getCurrentExtension();
22 | const Convenience = Me.imports.convenience;
23 | const AtomAppDisplay = Me.imports.atomappdisplay;
24 |
25 | let DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME;
26 | let DASH_ITEM_LABEL_SHOW_TIME = Dash.DASH_ITEM_LABEL_SHOW_TIME;
27 | let DASH_ITEM_LABEL_HIDE_TIME = Dash.DASH_ITEM_LABEL_HIDE_TIME;
28 | let DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT;
29 |
30 | /* This class is a extension of the upstream DashItemContainer class (ui.dash.js).
31 | * Changes are done to make label shows on top side.
32 | */
33 | var showLabelFunction = function() {
34 |
35 | if (!this._labelText) {
36 | return;
37 | }
38 |
39 | this.label.set_text(this._labelText);
40 | this.label.opacity = 0;
41 | this.label.show();
42 |
43 | let [stageX, stageY] = this.get_transformed_position();
44 |
45 | let labelHeight = this.label.get_height();
46 | let labelWidth = this.label.get_width();
47 |
48 | let node = this.label.get_theme_node();
49 | let yOffset = node.get_length('-x-offset'); // borrowing from x-offset
50 |
51 | let y = stageY - labelHeight - yOffset;
52 |
53 | let itemWidth = this.allocation.x2 - this.allocation.x1;
54 | let xOffset = Math.floor((itemWidth - labelWidth) / 2);
55 |
56 | let x = stageX + xOffset;
57 |
58 | this.label.set_position(x, y);
59 |
60 | Tweener.addTween(this.label, {
61 | opacity: 255,
62 | time: DASH_ITEM_LABEL_SHOW_TIME,
63 | transition: 'easeOutQuad',
64 | });
65 | };
66 |
67 | const AppsIconMenu = new Lang.Class({
68 | Name: 'AppsIconMenu',
69 | Extends: PopupMenu.PopupMenu,
70 |
71 | _init: function(source) {
72 | this.parent(source.actor, 0.5, St.Side.TOP);
73 |
74 | // We want to keep the item hovered while the menu is up
75 | this.blockSourceEvents = true;
76 | this._source = source;
77 | this.actor.add_style_class_name('app-well-menu');
78 |
79 | // Chain our visibility and lifecycle to that of the source
80 | source.actor.connect('notify::mapped',
81 | () => {
82 | if (!source.actor.mapped) {
83 | this.close();
84 | }
85 | }
86 | );
87 |
88 | source.actor.connect('destroy', () => { this.actor.destroy(); });
89 |
90 | Main.uiGroup.add_actor(this.actor);
91 | },
92 |
93 | _redisplay: function() {
94 | this.removeAll();
95 | this._settingsMenuItem = this._appendMenuItem(_("Simple Dock Settings"));
96 | this._settingsMenuItem.connect('activate', (actor, event) => {
97 | Util.spawn(["gnome-shell-extension-prefs", Me.metadata.uuid]);
98 | this.close();
99 | });
100 | },
101 |
102 | _appendSeparator: function () {
103 | let separator = new PopupMenu.PopupSeparatorMenuItem();
104 | this.addMenuItem(separator);
105 | },
106 |
107 | _appendMenuItem: function(labelText) {
108 | let item = new PopupMenu.PopupMenuItem(labelText);
109 | this.addMenuItem(item);
110 |
111 | return item;
112 | },
113 |
114 | popup: function(activatingButton) {
115 | this._redisplay();
116 | this.open();
117 | }
118 | });
119 | Signals.addSignalMethods(AppsIconMenu.prototype);
120 |
121 | function extendShowAppsIcon(showAppsIcon){
122 |
123 | showAppsIcon.actor = showAppsIcon.toggleButton;
124 |
125 | // Re-use appIcon methods
126 | showAppsIcon._removeMenuTimeout = AppDisplay.AppIcon.prototype._removeMenuTimeout;
127 | showAppsIcon._setPopupTimeout = AppDisplay.AppIcon.prototype._setPopupTimeout;
128 | showAppsIcon._onButtonPress = AppDisplay.AppIcon.prototype._onButtonPress;
129 | showAppsIcon._onKeyboardPopupMenu = AppDisplay.AppIcon.prototype._onKeyboardPopupMenu;
130 | showAppsIcon._onLeaveEvent = AppDisplay.AppIcon.prototype._onLeaveEvent;
131 | showAppsIcon._onTouchEvent = AppDisplay.AppIcon.prototype._onTouchEvent;
132 | showAppsIcon._onMenuPoppedDown = AppDisplay.AppIcon.prototype._onMenuPoppedDown;
133 |
134 | // No action on clicked (showing of the appsview is controlled elsewhere)
135 | showAppsIcon._onClicked = function(actor, button) {
136 | showAppsIcon._removeMenuTimeout();
137 | };
138 |
139 | showAppsIcon.actor.connect('leave-event', Lang.bind( showAppsIcon, showAppsIcon._onLeaveEvent));
140 | showAppsIcon.actor.connect('button-press-event', Lang.bind( showAppsIcon, showAppsIcon._onButtonPress));
141 | showAppsIcon.actor.connect('touch-event', Lang.bind( showAppsIcon, showAppsIcon._onTouchEvent));
142 | showAppsIcon.actor.connect('clicked', Lang.bind( showAppsIcon, showAppsIcon._onClicked));
143 | showAppsIcon.actor.connect('popup-menu', Lang.bind( showAppsIcon, showAppsIcon._onKeyboardPopupMenu));
144 |
145 | showAppsIcon._menu = null;
146 | showAppsIcon._menuManager = new PopupMenu.PopupMenuManager(showAppsIcon);
147 | showAppsIcon._menuTimeoutId = 0;
148 |
149 | showAppsIcon.showLabel = showLabelFunction;
150 |
151 | showAppsIcon.popupMenu = function() {
152 |
153 | showAppsIcon._removeMenuTimeout();
154 | showAppsIcon.actor.fake_release();
155 |
156 | if (!showAppsIcon._menu) {
157 | showAppsIcon._menu = new AppsIconMenu(showAppsIcon);
158 | showAppsIcon._menu.connect('open-state-changed', (menu, isPoppedUp) => {
159 | if (!isPoppedUp)
160 | showAppsIcon._onMenuPoppedDown();
161 | });
162 | let id = Main.overview.connect('hiding', () => { showAppsIcon._menu.close(); });
163 | showAppsIcon.actor.connect('destroy', function() {
164 | Main.overview.disconnect(id);
165 | });
166 | showAppsIcon._menuManager.addMenu(showAppsIcon._menu);
167 | }
168 | showAppsIcon.emit('menu-state-changed', true);
169 | showAppsIcon.actor.set_hover(true);
170 | showAppsIcon._menu.popup();
171 | showAppsIcon._menuManager.ignoreRelease();
172 | showAppsIcon.emit('sync-tooltip');
173 | return false;
174 | };
175 |
176 | Signals.addSignalMethods(showAppsIcon);
177 | }
178 |
179 | const AtomDashItemContainer = new Lang.Class({
180 | Name: 'AtomDashItemContainer',
181 | Extends: Dash.DashItemContainer,
182 |
183 | _init: function() {
184 | this.parent();
185 | },
186 |
187 | showLabel: showLabelFunction
188 | });
189 |
190 | /* This class is a extension of the upstream ShowAppsIcon class (ui.dash.js).
191 | * Changes are done to make label shows on top side.
192 | */
193 | const AtomShowAppsIcon = new Lang.Class({
194 | Name: 'AtomShowAppsIcon',
195 | Extends: Dash.ShowAppsIcon,
196 |
197 | _init: function() {
198 | this.parent();
199 | },
200 |
201 | showLabel: showLabelFunction
202 | });
203 |
204 | /* This class is a fork of the upstream DashActor class (ui.dash.js).
205 | * Heavily inspired from Michele's Dash to Dock extension
206 | * https://github.com/micheleg/dash-to-dock
207 | */
208 | const AtomDashActor = new Lang.Class({
209 | Name: 'AtomDashActor',
210 | Extends: St.Widget,
211 |
212 | _init: function() {
213 |
214 | let layout = new Clutter.BoxLayout({
215 | orientation: Clutter.Orientation.HORIZONTAL
216 | });
217 |
218 | this.parent({
219 | name: 'dash',
220 | layout_manager: layout,
221 | clip_to_allocation: true
222 | });
223 | },
224 |
225 | vfunc_allocate: function(box, flags) {
226 |
227 | let contentBox = this.get_theme_node().get_content_box(box);
228 | let availWidth = contentBox.x2 - contentBox.x1;
229 |
230 | this.set_allocation(box, flags);
231 |
232 | let [appIcons, showAppsButton] = this.get_children();
233 | let [t, showAppsNatWidth] = showAppsButton.get_preferred_width(availWidth);
234 |
235 | let childBox = new Clutter.ActorBox();
236 |
237 | childBox.x1 = contentBox.x1;
238 | childBox.y1 = contentBox.y1;
239 | childBox.x2 = contentBox.x2 - showAppsNatWidth;
240 | childBox.y2 = contentBox.y2;
241 |
242 | appIcons.allocate(childBox, flags);
243 |
244 | childBox.x1 = contentBox.x2 - showAppsNatWidth;
245 | childBox.x2 = contentBox.x2;
246 |
247 | showAppsButton.allocate(childBox, flags);
248 | },
249 |
250 | vfunc_get_preferred_width: function(forHeight) {
251 |
252 | // We want to request the natural height of all our children
253 | // as our natural height, so we chain up to StWidget (which
254 | // then calls BoxLayout), but we only request the showApps
255 | // button as the minimum size
256 | let t;
257 | let natWidth;
258 | let showAppsButton;
259 | let minWidth;
260 | [t, natWidth] = this.parent(forHeight);
261 | let themeNode = this.get_theme_node();
262 | let adjustedForHeight = themeNode.adjust_for_height(forHeight);
263 | [t, showAppsButton] = this.get_children();
264 | [minWidth, t] = showAppsButton.get_preferred_width(adjustedForHeight);
265 |
266 | [minWidth, t] = themeNode.adjust_preferred_width(minWidth, natWidth);
267 |
268 | return [minWidth, natWidth];
269 | }
270 | });
271 |
272 | /* This class is a fork of the upstream Dash class (ui.dash.js).
273 | * Heavily inspired from Michele's Dash to Dock extension
274 | * https://github.com/micheleg/dash-to-dock
275 | */
276 | const AtomDash = new Lang.Class({
277 | Name: 'AtomDash',
278 |
279 | _init: function() {
280 | this._signalHandler = new Convenience.GlobalSignalHandler();
281 | this._monitorWidth = this._getMonitorWidth();
282 |
283 | this._workspaceSwitched = false;
284 | this._maxWidth = -1;
285 | this.iconSize = 1;
286 | this.maxIconSize = 1;
287 | this._shownInitially = false;
288 | this._dragPlaceholder = null;
289 | this._dragPlaceholderPos = -1;
290 | this._animatingPlaceholdersCount = 0;
291 | this._showLabelTimeoutId = 0;
292 | this._resetHoverTimeoutId = 0;
293 | this._labelShowing = false;
294 |
295 | this._container = new AtomDashActor();
296 |
297 | this._box = new St.BoxLayout({
298 | vertical: false,
299 | clip_to_allocation: true
300 | });
301 |
302 | this._box._delegate = this;
303 | this._container.add_actor(this._box);
304 |
305 | this._showAppsIcon = new AtomShowAppsIcon();
306 | extendShowAppsIcon(this._showAppsIcon);
307 | this._showAppsIcon.childScale = 1;
308 | this._showAppsIcon.childOpacity = 255;
309 | this._showAppsIcon.icon.setIconSize(this.iconSize);
310 | this._showAppsIcon.connect('menu-state-changed',
311 | (appIcon, opened) => {
312 | this._itemMenuStateChanged(appIcon, opened);
313 | }
314 | );
315 |
316 | this._hookUpLabel(this._showAppsIcon);
317 |
318 | this.showAppsButton = this._showAppsIcon.toggleButton;
319 | this.showAppsButton.set_style("padding: 0px;");
320 | this.showAppsButton.connect('notify::checked', () => { this._onShowAppsButtonToggled(); });
321 |
322 | this._container.add_actor(this._showAppsIcon);
323 |
324 | this.actor = new St.Bin({ child: this._container });
325 | this.actor.connect('notify::width',
326 | () => {
327 | if (this._maxWidth !== this.actor.width) {
328 | this._queueRedisplay();
329 | }
330 |
331 | this._maxWidth = this.actor.width;
332 | }
333 | );
334 |
335 | this._workId = Main.initializeDeferredWork(this._box, () => { this._redisplay(); });
336 |
337 | this._appSystem = Shell.AppSystem.get_default();
338 |
339 | this._signalHandler.push(
340 | [
341 | global.screen, 'monitors-changed', () => {
342 | this._monitorWidth = this._getMonitorWidth();
343 | this._queueRedisplay();
344 | }
345 | ],
346 | [
347 | global.screen, 'workspace-switched', () => {
348 | // Placeholder variable to tell redisplay that this is workspace switched event
349 | this._workspaceSwitched = true;
350 | this._queueRedisplay();
351 | }
352 | ],
353 | [
354 | this._appSystem, 'installed-changed', () => {
355 | AppFavorites.getAppFavorites().reload();
356 | this._queueRedisplay();
357 | }
358 | ],
359 | [
360 | AppFavorites.getAppFavorites(), 'changed', () => { this._queueRedisplay(); }
361 | ],
362 | [
363 | this._appSystem, 'app-state-changed', () => { this._queueRedisplay(); }
364 | ],
365 | [
366 | Main.overview, 'item-drag-begin', () => { this._onDragBegin(); }
367 | ],
368 | [
369 | Main.overview, 'item-drag-end', () => { this._onDragEnd(); }
370 | ],
371 | [
372 | Main.overview, 'item-drag-cancelled', () => { this._onDragCancelled(); }
373 | ],
374 | [
375 | Main.overview.viewSelector._showAppsButton, 'notify::checked', () => { this._syncShowAppsButtonToggled(); }
376 | ]
377 | );
378 | },
379 |
380 | _getMonitorWidth: function() {
381 | // 85% of monitor width as icon size adjustment threshold
382 | return Math.floor(Main.layoutManager.primaryMonitor.width * 0.85);
383 | },
384 |
385 | destroy: function() {
386 | this._signalHandler.disconnect();
387 | },
388 |
389 | _onDragBegin: function() {
390 | this._dragCancelled = false;
391 | this._dragMonitor = {
392 | dragMotion: Lang.bind(this, this._onDragMotion)
393 | };
394 | DND.addDragMonitor(this._dragMonitor);
395 |
396 | if (this._box.get_n_children() === 0) {
397 | this._emptyDropTarget = new Dash.EmptyDropTargetItem();
398 | this._box.insert_child_at_index(this._emptyDropTarget, 0);
399 | this._emptyDropTarget.show(true);
400 | }
401 | },
402 |
403 | _onDragCancelled: function() {
404 | this._dragCancelled = true;
405 | this._endDrag();
406 | },
407 |
408 | _onDragEnd: function() {
409 |
410 | if (this._dragCancelled) {
411 | return;
412 | }
413 |
414 | this._endDrag();
415 | },
416 |
417 | _endDrag: function() {
418 |
419 | this._clearDragPlaceholder();
420 | this._clearEmptyDropTarget();
421 | this._showAppsIcon.setDragApp(null);
422 | DND.removeDragMonitor(this._dragMonitor);
423 | },
424 |
425 | _onDragMotion: function(dragEvent) {
426 | let app = Dash.getAppFromSource(dragEvent.source);
427 |
428 | if (app === null) {
429 | return DND.DragMotionResult.CONTINUE;
430 | }
431 |
432 | let showAppsHovered = this._showAppsIcon.contains(dragEvent.targetActor);
433 |
434 | if (!this._box.contains(dragEvent.targetActor) || showAppsHovered) {
435 | this._clearDragPlaceholder();
436 | }
437 |
438 | if (showAppsHovered) {
439 | this._showAppsIcon.setDragApp(app);
440 | } else {
441 | this._showAppsIcon.setDragApp(null);
442 | }
443 |
444 | return DND.DragMotionResult.CONTINUE;
445 | },
446 |
447 | _appIdListToHash: function(apps) {
448 | let ids = {};
449 |
450 | for (let i = 0; i < apps.length; i++) {
451 | ids[apps[i].get_id()] = apps[i];
452 | }
453 |
454 | return ids;
455 | },
456 |
457 | _queueRedisplay: function () {
458 | Main.queueDeferredWork(this._workId);
459 | },
460 |
461 | _hookUpLabel: function(item, appIcon) {
462 | item.child.connect('notify::hover', () => {
463 | this._syncLabel(item, appIcon);
464 | });
465 |
466 | Main.overview.connect('hiding', () => {
467 | this._labelShowing = false;
468 | item.hideLabel();
469 | });
470 |
471 | if (appIcon) {
472 | appIcon.connect('sync-tooltip', () => {
473 | this._syncLabel(item, appIcon);
474 | });
475 | }
476 | },
477 |
478 | _createAppItem: function(app) {
479 | let appIcon = new AtomAppDisplay.AtomAppIcon(app, {
480 | setSizeManually: true,
481 | showLabel: false
482 | });
483 |
484 | appIcon._draggable.connect('drag-begin',
485 | () => {
486 | appIcon.actor.opacity = 50;
487 | }
488 | );
489 |
490 | appIcon._draggable.connect('drag-end',
491 | () => {
492 | appIcon.actor.opacity = 255;
493 | }
494 | );
495 |
496 | let item = new AtomDashItemContainer();
497 | item.setChild(appIcon.actor);
498 | appIcon.connect('menu-state-changed',
499 | (appIcon, opened) => {
500 | this._itemMenuStateChanged(appIcon, opened);
501 | }
502 | );
503 |
504 | // Override default AppIcon label_actor, now the
505 | // accessible_name is set at DashItemContainer.setLabelText
506 | appIcon.actor.label_actor = null;
507 | item.setLabelText(app.get_name());
508 |
509 | appIcon.icon.setIconSize(this.iconSize);
510 | this._hookUpLabel(item, appIcon);
511 |
512 | return item;
513 | },
514 |
515 | _itemMenuStateChanged: function(item, opened) {
516 | // When the menu closes, it calls sync_hover, which means
517 | // that the notify::hover handler does everything we need to.
518 | if (opened) {
519 | if (this._showLabelTimeoutId > 0) {
520 | Mainloop.source_remove(this._showLabelTimeoutId);
521 | this._showLabelTimeoutId = 0;
522 | }
523 | //item.hideLabel();
524 | } else {
525 | this.emit('menu-closed');
526 | }
527 | },
528 |
529 | _syncLabel: function (item, appIcon) {
530 |
531 | let shouldShow = appIcon ? appIcon.shouldShowTooltip() : item.child.get_hover();
532 | if (shouldShow && this._showLabelTimeoutId === 0) {
533 | let timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT;
534 | this._showLabelTimeoutId = Mainloop.timeout_add(timeout,
535 | () => {
536 | this._labelShowing = true;
537 | item.showLabel();
538 | this._showLabelTimeoutId = 0;
539 | return false;
540 | }, null);
541 |
542 | if (this._resetHoverTimeoutId > 0) {
543 | Mainloop.source_remove(this._resetHoverTimeoutId);
544 | this._resetHoverTimeoutId = 0;
545 | }
546 | } else {
547 | if (this._showLabelTimeoutId > 0) {
548 | Mainloop.source_remove(this._showLabelTimeoutId);
549 | this._showLabelTimeoutId = 0;
550 | }
551 | item.hideLabel();
552 | if (this._labelShowing) {
553 | this._resetHoverTimeoutId = Mainloop.timeout_add(DASH_ITEM_HOVER_TIMEOUT,
554 | () => {
555 | this._labelShowing = false;
556 | this._resetHoverTimeoutId = 0;
557 | return false;
558 | }, null);
559 | }
560 | }
561 | },
562 |
563 | _adjustIconSize: function() {
564 |
565 | // For the icon size, we only consider children which are "proper"
566 | // icons (i.e. ignoring drag placeholders) and which are not
567 | // animating out (which means they will be destroyed at the end of
568 | // the animation)
569 | let iconChildren = this._box.get_children().filter(function(actor) {
570 | return actor.child &&
571 | actor.child._delegate &&
572 | actor.child._delegate.icon &&
573 | !actor.animatingOut;
574 | });
575 |
576 | iconChildren.push(this._showAppsIcon);
577 |
578 | if (this._maxWidth === -1) {
579 | return;
580 | }
581 |
582 | let themeNode = this._container.get_theme_node();
583 | let maxAllocation = new Clutter.ActorBox({
584 | x1: 0, y1: 0,
585 | x2: this._monitorWidth,
586 | y2: 64 /* whatever */
587 | });
588 |
589 | let maxContent = themeNode.get_content_box(maxAllocation);
590 | let availWidth = maxContent.x2 - maxContent.x1;
591 |
592 | let spacing = themeNode.get_length('spacing');
593 |
594 | let firstButton = iconChildren[0].child;
595 | let firstIcon = firstButton._delegate.icon;
596 |
597 | let minWidth, natWidth;
598 |
599 | // Remove unnecesary padding for first button
600 | firstButton.set_style("padding: 0px;");
601 |
602 | // Enforce the current icon size during the size request
603 | let [currentWidth, currentHeight] = firstIcon.icon.get_size();
604 |
605 | firstIcon.icon.set_size(this.iconSize, this.iconSize);
606 | [minWidth, natWidth] = firstButton.get_preferred_width(-1);
607 |
608 | firstIcon.icon.set_size(currentWidth, currentHeight);
609 |
610 | // Subtract icon padding and box spacing from the available width
611 | availWidth -= iconChildren.length * (natWidth - this.iconSize) +
612 | (iconChildren.length - 1) * spacing;
613 |
614 | let availSize = availWidth / iconChildren.length;
615 |
616 | let iconSizes = [16, 24, 32, 48, 64, 96, 128];
617 | switch (this.maxIconSize) {
618 | case 16:
619 | iconSizes = [16];
620 | break;
621 | case 24:
622 | iconSizes = [16, 24];
623 | break;
624 | case 32:
625 | iconSizes = [16, 24, 32];
626 | break;
627 | case 48:
628 | iconSizes = [16, 24, 32, 48];
629 | break;
630 | case 64:
631 | iconSizes = [16, 24, 32, 48, 64];
632 | break;
633 | case 96:
634 | iconSizes = [16, 24, 32, 48, 64, 96];
635 | break;
636 | }
637 | let newIconSize = 16;
638 |
639 | for (let i = 0; i < iconSizes.length; i++) {
640 | if (iconSizes[i] <= availSize) {
641 | newIconSize = iconSizes[i];
642 | }
643 | }
644 |
645 | if (newIconSize === this.iconSize) {
646 | return;
647 | }
648 |
649 | let oldIconSize = this.iconSize;
650 | this.iconSize = newIconSize;
651 |
652 | let scale = oldIconSize / newIconSize;
653 | for (let i = 0; i < iconChildren.length; i++) {
654 | let icon = iconChildren[i].child._delegate.icon;
655 |
656 | // Set the new size immediately, to keep the icons' sizes
657 | // in sync with this.iconSize
658 | icon.setIconSize(this.iconSize);
659 |
660 | // Don't animate the icon size change when the overview
661 | // is transitioning, not visible or when initially filling
662 | // the dash
663 | if (!Main.overview.visible ||
664 | Main.overview.animationInProgress ||
665 | !this._shownInitially) {
666 |
667 | continue;
668 | }
669 |
670 | let [targetWidth, targetHeight] = icon.icon.get_size();
671 |
672 | // Scale the icon's texture to the previous size and
673 | // tween to the new size
674 | icon.icon.set_size(icon.icon.width * scale,
675 | icon.icon.height * scale);
676 |
677 | Tweener.addTween(icon.icon, {
678 | width: targetWidth,
679 | height: targetHeight,
680 | time: DASH_ANIMATION_TIME,
681 | transition: 'easeOutQuad'
682 | });
683 | }
684 | // Moved event emitter in the end for AtomDock resetPosition event
685 | this.emit('icon-size-changed');
686 | },
687 |
688 | _redisplay: function() {
689 | let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
690 | let running = this._appSystem.get_running().sort();
691 | let children = this._box.get_children().filter(function(actor) {
692 | return actor.child &&
693 | actor.child._delegate &&
694 | actor.child._delegate.app;
695 | });
696 | // Apps currently in the dash
697 | let oldApps = children.map(function(actor) {
698 | return actor.child._delegate.app;
699 | });
700 | // Apps supposed to be in the dash
701 | let newApps = [];
702 |
703 | for (let id in favorites) {
704 | if (favorites.hasOwnProperty(id)) {
705 | newApps.push(favorites[id]);
706 | }
707 | }
708 |
709 | for (let i = 0; i < running.length; i++) {
710 | let app = running[i];
711 | if (app.get_id() in favorites /*||
712 | !app.is_on_workspace(global.screen.get_active_workspace())*/) {
713 |
714 | continue;
715 | }
716 | newApps.push(app);
717 | }
718 |
719 | /* Figure out the actual changes to the list of items; we iterate
720 | * over both the list of items currently in the dash and the list
721 | * of items expected there, and collect additions and removals.
722 | * Moves are both an addition and a removal, where the order of
723 | * the operations depends on whether we encounter the position
724 | * where the item has been added first or the one from where it
725 | * was removed.
726 | * There is an assumption that only one item is moved at a given
727 | * time; when moving several items at once, everything will still
728 | * end up at the right position, but there might be additional
729 | * additions/removals (e.g. it might remove all the launchers
730 | * and add them back in the new order even if a smaller set of
731 | * additions and removals is possible).
732 | * If above assumptions turns out to be a problem, we might need
733 | * to use a more sophisticated algorithm, e.g. Longest Common
734 | * Subsequence as used by diff.
735 | */
736 | let addedItems = [];
737 | let removedActors = [];
738 | let removedActorsFilter = function(result, actor) {
739 | let removedApp = actor.child._delegate.app;
740 |
741 | return result || removedApp === newApps[newIndex];
742 | };
743 |
744 | let newIndex = 0;
745 | let oldIndex = 0;
746 | while (newIndex < newApps.length || oldIndex < oldApps.length) {
747 | // No change at oldIndex/newIndex
748 | if (oldApps[oldIndex] === newApps[newIndex]) {
749 | oldIndex++;
750 | newIndex++;
751 |
752 | continue;
753 | }
754 |
755 | // App removed at oldIndex
756 | if (oldApps[oldIndex] &&
757 | newApps.indexOf(oldApps[oldIndex]) === -1) {
758 |
759 | removedActors.push(children[oldIndex]);
760 | oldIndex++;
761 |
762 | continue;
763 | }
764 |
765 | // App added at newIndex
766 | if (newApps[newIndex] &&
767 | oldApps.indexOf(newApps[newIndex]) === -1) {
768 |
769 | addedItems.push({
770 | app: newApps[newIndex],
771 | item: this._createAppItem(newApps[newIndex]),
772 | pos: newIndex
773 | });
774 | newIndex++;
775 |
776 | continue;
777 | }
778 |
779 | // App moved
780 | let insertHere = newApps[newIndex + 1] &&
781 | newApps[newIndex + 1] === oldApps[oldIndex];
782 |
783 | let alreadyRemoved = removedActors.reduce(removedActorsFilter, false);
784 |
785 | if (insertHere || alreadyRemoved) {
786 | let newItem = this._createAppItem(newApps[newIndex]);
787 | addedItems.push({
788 | app: newApps[newIndex],
789 | item: newItem,
790 | pos: newIndex + removedActors.length
791 | });
792 | newIndex++;
793 | } else {
794 | removedActors.push(children[oldIndex]);
795 | oldIndex++;
796 | }
797 | }
798 |
799 | for (let i = 0; i < addedItems.length; i++) {
800 |
801 | this._box.insert_child_at_index(addedItems[i].item,
802 | addedItems[i].pos);
803 | }
804 |
805 | for (let i = 0; i < removedActors.length; i++) {
806 | let item = removedActors[i];
807 | /* Don't animate item removal when the overview is transitioning
808 | * or hidden
809 | */
810 | if (Main.overview.visible && !Main.overview.animationInProgress) {
811 | item.animateOutAndDestroy();
812 | } else {
813 | item.destroy();
814 | }
815 | }
816 |
817 | this._adjustIconSize();
818 |
819 | /* Skip animations on first run when adding the initial set
820 | * of items, to avoid all items zooming in at once
821 | */
822 |
823 | let animate = this._shownInitially && Main.overview.visible &&
824 | !Main.overview.animationInProgress;
825 |
826 | if (!this._shownInitially) {
827 | this._shownInitially = true;
828 | }
829 |
830 | for (let i = 0; i < addedItems.length; i++) {
831 | addedItems[i].item.show(animate);
832 | }
833 |
834 | /* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=692744
835 | * Without it, StBoxLayout may use a stale size cache
836 | */
837 | this._box.queue_relayout();
838 |
839 | // On workspace-switched event, emit this to trigger intellihide check
840 | if (this._workspaceSwitched) {
841 | this._workspaceSwitched = false;
842 | this.emit('redisplay-workspace-switched');
843 | }
844 | },
845 |
846 | _clearDragPlaceholder: function() {
847 |
848 | if (this._dragPlaceholder) {
849 | this._animatingPlaceholdersCount++;
850 | this._dragPlaceholder.animateOutAndDestroy();
851 | this._dragPlaceholder.connect('destroy',
852 | () => {
853 | this._animatingPlaceholdersCount--;
854 | }
855 | );
856 | this._dragPlaceholder = null;
857 | }
858 | this._dragPlaceholderPos = -1;
859 | },
860 |
861 | _clearEmptyDropTarget: function() {
862 |
863 | if (this._emptyDropTarget) {
864 | this._emptyDropTarget.animateOutAndDestroy();
865 | this._emptyDropTarget = null;
866 | }
867 | },
868 |
869 | handleDragOver : function(source, actor, x, y, time) {
870 |
871 | let app = Dash.getAppFromSource(source);
872 |
873 | // Don't allow favoriting of transient apps
874 | if (app === null || app.is_window_backed()) {
875 | return DND.DragMotionResult.NO_DROP;
876 | }
877 |
878 | let favorites = AppFavorites.getAppFavorites().getFavorites();
879 | let numFavorites = favorites.length;
880 | let favPos = favorites.indexOf(app);
881 | let children = this._box.get_children();
882 | let numChildren = children.length;
883 | let boxWidth = this._box.width;
884 | let pos = 0;
885 |
886 | /* Keep the placeholder out of the index calculation; assuming that
887 | * the remove target has the same size as "normal" items, we don't
888 | * need to do the same adjustment there.
889 | */
890 | if (this._dragPlaceholder) {
891 | boxWidth -= this._dragPlaceholder.width;
892 | numChildren--;
893 | }
894 |
895 | if (!this._emptyDropTarget) {
896 | pos = Math.floor(x * numChildren / boxWidth);
897 | }
898 |
899 | if (pos !== this._dragPlaceholderPos && pos <= numFavorites &&
900 | this._animatingPlaceholdersCount === 0) {
901 |
902 | this._dragPlaceholderPos = pos;
903 |
904 | // Don't allow positioning before or after self
905 | if (favPos !== -1 && (pos === favPos || pos === favPos + 1)) {
906 | this._clearDragPlaceholder();
907 |
908 | return DND.DragMotionResult.CONTINUE;
909 | }
910 |
911 | /* If the placeholder already exists, we just move
912 | * it, but if we are adding it, expand its size in
913 | * an animation
914 | */
915 | let fadeIn = true;
916 |
917 | if (this._dragPlaceholder) {
918 | this._dragPlaceholder.destroy();
919 | fadeIn = false;
920 | }
921 |
922 | this._dragPlaceholder = new Dash.DragPlaceholderItem();
923 | this._dragPlaceholder.child.set_width (this.iconSize / 2);
924 | this._dragPlaceholder.child.set_height (this.iconSize);
925 | this._box.insert_child_at_index(this._dragPlaceholder,
926 | this._dragPlaceholderPos);
927 | this._dragPlaceholder.show(fadeIn);
928 | }
929 |
930 | /* Remove the drag placeholder if we are not in the
931 | * "favorites zone"
932 | */
933 | if (pos > numFavorites) {
934 | this._clearDragPlaceholder();
935 | }
936 |
937 | if (!this._dragPlaceholder) {
938 | return DND.DragMotionResult.NO_DROP;
939 | }
940 |
941 | let srcIsFavorite = (favPos !== -1);
942 |
943 | if (srcIsFavorite) {
944 | return DND.DragMotionResult.MOVE_DROP;
945 | }
946 |
947 | return DND.DragMotionResult.COPY_DROP;
948 | },
949 |
950 | // Draggable target interface
951 | acceptDrop : function(source, actor, x, y, time) {
952 |
953 | let app = Dash.getAppFromSource(source);
954 |
955 | // Don't allow favoriting of transient apps
956 | if (app === null || app.is_window_backed()) {
957 | return false;
958 | }
959 |
960 | let id = app.get_id();
961 |
962 | let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
963 |
964 | let srcIsFavorite = (id in favorites);
965 |
966 | let favPos = 0;
967 | let children = this._box.get_children();
968 | for (let i = 0; i < this._dragPlaceholderPos; i++) {
969 | let childId = children[i].child._delegate.app.get_id();
970 | if (childId === id ||
971 | (this._dragPlaceholder &&
972 | children[i] === this._dragPlaceholder)) {
973 |
974 | continue;
975 | }
976 |
977 | if (childId in favorites) {
978 | favPos++;
979 | }
980 | }
981 |
982 | /* No drag placeholder means we don't wan't to favorite the app
983 | * and we are dragging it to its original position
984 | */
985 | if (!this._dragPlaceholder) {
986 | return true;
987 | }
988 |
989 | Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
990 | let appFavorites = AppFavorites.getAppFavorites();
991 |
992 | if (srcIsFavorite) {
993 | appFavorites.moveFavoriteToPos(id, favPos);
994 | } else {
995 | appFavorites.addFavoriteAtPos(id, favPos);
996 | }
997 |
998 | return false;
999 | });
1000 |
1001 | return true;
1002 | },
1003 |
1004 | _onShowAppsButtonToggled: function() {
1005 | /* Sync the status of the default appButtons. Only if the two statuses
1006 | * are different, that means the user interacted with the extension
1007 | * provided application button, cutomize the behaviour. Otherwise the
1008 | * shell has changed the status (due to the _syncShowAppsButtonToggled
1009 | * function below) and it has already performed the desired action.
1010 | */
1011 |
1012 | let selector = Main.overview.viewSelector;
1013 | if (selector._showAppsButton.checked !== this.showAppsButton.checked) {
1014 |
1015 | if (this.showAppsButton.checked) {
1016 | selector._showAppsButton.checked = true;
1017 | if (!Main.overview._shown) {
1018 |
1019 | Main.overview.show();
1020 | }
1021 | } else {
1022 | // force exiting overview if needed
1023 | Main.overview.hide();
1024 | }
1025 | }
1026 | },
1027 |
1028 | // Keep ShowAppsButton status in sync with the overview status
1029 | _syncShowAppsButtonToggled: function() {
1030 | let showStatus = Main.overview.viewSelector._showAppsButton.checked;
1031 | this.showAppsButton.checked = showStatus;
1032 | },
1033 |
1034 | setShowAppsButton: function(show) {
1035 | if (show) {
1036 | this.showAppsButton.set_width(-1);
1037 | this.showAppsButton.show();
1038 | } else {
1039 | this.showAppsButton.set_width(0);
1040 | this.showAppsButton.hide();
1041 | }
1042 | }
1043 | });
1044 |
1045 | Signals.addSignalMethods(AtomDash.prototype);
1046 |
--------------------------------------------------------------------------------