2013-02-14 14:41:38 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 09:07:06 -05:00
|
|
|
/* exported ControlsManager */
|
2013-02-14 14:41:38 -05:00
|
|
|
|
2021-01-25 15:50:59 -05:00
|
|
|
const { Clutter, GObject, St } = imports.gi;
|
2013-02-14 14:41:38 -05:00
|
|
|
|
2013-02-25 18:05:45 -05:00
|
|
|
const Dash = imports.ui.dash;
|
2013-02-14 14:41:38 -05:00
|
|
|
const Main = imports.ui.main;
|
2013-02-15 18:25:36 -05:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
2020-05-29 04:50:14 -04:00
|
|
|
const Overview = imports.ui.overview;
|
2013-02-14 14:41:38 -05:00
|
|
|
|
2020-05-29 04:50:14 -04:00
|
|
|
var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
|
2013-02-14 14:41:38 -05:00
|
|
|
|
2020-12-11 07:47:28 -05:00
|
|
|
var DashFader = GObject.registerClass(
|
2020-12-11 07:59:46 -05:00
|
|
|
class DashFader extends St.Widget {
|
2019-07-16 05:24:13 -04:00
|
|
|
_init(dash) {
|
2020-12-11 07:47:28 -05:00
|
|
|
super._init({
|
|
|
|
x_expand: true,
|
2021-01-18 18:57:30 -05:00
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
2021-01-19 12:20:58 -05:00
|
|
|
y_align: Clutter.ActorAlign.END,
|
2020-12-11 07:47:28 -05:00
|
|
|
});
|
2013-01-23 23:11:23 -05:00
|
|
|
|
2013-02-15 18:26:24 -05:00
|
|
|
this._dash = dash;
|
2020-12-11 07:47:28 -05:00
|
|
|
this.add_child(this._dash);
|
2020-12-11 07:59:46 -05:00
|
|
|
|
|
|
|
Main.overview.connect('window-drag-begin', this._onWindowDragBegin.bind(this));
|
|
|
|
Main.overview.connect('window-drag-cancelled', this._onWindowDragEnd.bind(this));
|
|
|
|
Main.overview.connect('window-drag-end', this._onWindowDragEnd.bind(this));
|
2020-12-11 07:47:28 -05:00
|
|
|
}
|
2013-01-23 23:11:23 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onWindowDragBegin() {
|
2020-12-11 07:59:46 -05:00
|
|
|
this.ease({
|
|
|
|
opacity: 128,
|
|
|
|
duration: SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-02-18 22:34:27 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onWindowDragEnd() {
|
2020-12-11 07:59:46 -05:00
|
|
|
this.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
mode: Clutter.AnimationMode.EASE_IN_QUAD,
|
|
|
|
});
|
2013-01-23 23:11:23 -05:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
2013-02-15 18:25:36 -05:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var ControlsManager = GObject.registerClass(
|
|
|
|
class ControlsManager extends St.Widget {
|
|
|
|
_init(searchEntry) {
|
|
|
|
super._init({
|
2020-11-27 08:59:29 -05:00
|
|
|
layout_manager: new Clutter.BinLayout(),
|
2019-07-16 05:24:13 -04:00
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
2019-08-20 17:43:54 -04:00
|
|
|
clip_to_allocation: true,
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
|
|
|
|
2013-02-25 18:05:45 -05:00
|
|
|
this.dash = new Dash.Dash();
|
2020-12-11 07:47:28 -05:00
|
|
|
this._dashFader = new DashFader(this.dash);
|
2013-02-25 18:05:45 -05:00
|
|
|
|
2019-07-08 04:03:20 -04:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
|
|
|
|
|
|
|
|
this._workspaceAdjustment = new St.Adjustment({
|
2020-06-16 16:03:07 -04:00
|
|
|
actor: this,
|
2019-07-08 04:03:20 -04:00
|
|
|
value: activeWorkspaceIndex,
|
|
|
|
lower: 0,
|
|
|
|
page_increment: 1,
|
|
|
|
page_size: 1,
|
|
|
|
step_increment: 0,
|
|
|
|
upper: workspaceManager.n_workspaces,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._nWorkspacesNotifyId =
|
|
|
|
workspaceManager.connect('notify::n-workspaces',
|
|
|
|
this._updateAdjustment.bind(this));
|
|
|
|
|
2013-02-25 18:05:45 -05:00
|
|
|
this.viewSelector = new ViewSelector.ViewSelector(searchEntry,
|
2019-07-08 04:03:20 -04:00
|
|
|
this._workspaceAdjustment, this.dash.showAppsButton);
|
2013-02-15 18:25:36 -05:00
|
|
|
|
2020-12-11 07:47:28 -05:00
|
|
|
this._group = new St.BoxLayout({
|
|
|
|
name: 'overview-group',
|
|
|
|
vertical: true,
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
});
|
2019-07-16 05:24:13 -04:00
|
|
|
this.add_actor(this._group);
|
2013-02-25 18:05:45 -05:00
|
|
|
|
2020-12-11 07:47:28 -05:00
|
|
|
const box = new St.BoxLayout({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
});
|
|
|
|
box.add_child(this.viewSelector);
|
2013-02-25 18:05:45 -05:00
|
|
|
|
2020-12-11 07:47:28 -05:00
|
|
|
this._group.add_child(box);
|
2021-01-18 18:57:30 -05:00
|
|
|
this._group.add_actor(this._dashFader);
|
2013-02-17 23:45:24 -05:00
|
|
|
|
2019-07-08 04:03:20 -04:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
global.workspace_manager.disconnect(this._nWorkspacesNotifyId);
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateAdjustment() {
|
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let newNumWorkspaces = workspaceManager.n_workspaces;
|
|
|
|
let activeIndex = workspaceManager.get_active_workspace_index();
|
|
|
|
|
|
|
|
this._workspaceAdjustment.upper = newNumWorkspaces;
|
|
|
|
|
|
|
|
// A workspace might have been inserted or removed before the active
|
|
|
|
// one, causing the adjustment to go out of sync, so update the value
|
2020-04-27 19:04:08 -04:00
|
|
|
this._workspaceAdjustment.remove_transition('value');
|
2019-07-08 04:03:20 -04:00
|
|
|
this._workspaceAdjustment.value = activeIndex;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|