2013-02-14 19:41:38 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 14:07:06 +00:00
|
|
|
/* exported ControlsManager */
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2021-01-25 20:50:59 +00:00
|
|
|
const { Clutter, GObject, St } = imports.gi;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2013-02-25 23:05:45 +00:00
|
|
|
const Dash = imports.ui.dash;
|
2013-02-14 19:41:38 +00:00
|
|
|
const Main = imports.ui.main;
|
2013-02-15 23:25:36 +00:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
2020-05-29 08:50:14 +00:00
|
|
|
const Overview = imports.ui.overview;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2020-05-29 08:50:14 +00:00
|
|
|
var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2020-12-11 12:47:28 +00:00
|
|
|
var DashFader = GObject.registerClass(
|
2020-12-11 12:59:46 +00:00
|
|
|
class DashFader extends St.Widget {
|
2019-07-16 09:24:13 +00:00
|
|
|
_init(dash) {
|
2020-12-11 12:47:28 +00:00
|
|
|
super._init({
|
|
|
|
x_expand: true,
|
2021-01-18 23:57:30 +00:00
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
2021-01-19 17:20:58 +00:00
|
|
|
y_align: Clutter.ActorAlign.END,
|
2020-12-11 12:47:28 +00:00
|
|
|
});
|
2013-01-24 04:11:23 +00:00
|
|
|
|
2013-02-15 23:26:24 +00:00
|
|
|
this._dash = dash;
|
2020-12-11 12:47:28 +00:00
|
|
|
this.add_child(this._dash);
|
2020-12-11 12:59:46 +00: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 12:47:28 +00:00
|
|
|
}
|
2013-01-24 04:11:23 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onWindowDragBegin() {
|
2020-12-11 12:59:46 +00:00
|
|
|
this.ease({
|
|
|
|
opacity: 128,
|
|
|
|
duration: SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-02-19 03:34:27 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onWindowDragEnd() {
|
2020-12-11 12:59:46 +00:00
|
|
|
this.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
mode: Clutter.AnimationMode.EASE_IN_QUAD,
|
|
|
|
});
|
2013-01-24 04:11:23 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
2013-02-15 23:25:36 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var ControlsManager = GObject.registerClass(
|
|
|
|
class ControlsManager extends St.Widget {
|
|
|
|
_init(searchEntry) {
|
|
|
|
super._init({
|
2020-11-27 13:59:29 +00:00
|
|
|
layout_manager: new Clutter.BinLayout(),
|
2019-07-16 09:24:13 +00:00
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
2019-08-20 21:43:54 +00:00
|
|
|
clip_to_allocation: true,
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
|
|
|
|
2013-02-25 23:05:45 +00:00
|
|
|
this.dash = new Dash.Dash();
|
2020-12-11 12:47:28 +00:00
|
|
|
this._dashFader = new DashFader(this.dash);
|
2013-02-25 23:05:45 +00:00
|
|
|
|
2019-07-08 08:03:20 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
|
|
|
|
|
|
|
|
this._workspaceAdjustment = new St.Adjustment({
|
2020-06-16 20:03:07 +00:00
|
|
|
actor: this,
|
2019-07-08 08:03:20 +00: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 23:05:45 +00:00
|
|
|
this.viewSelector = new ViewSelector.ViewSelector(searchEntry,
|
2019-07-08 08:03:20 +00:00
|
|
|
this._workspaceAdjustment, this.dash.showAppsButton);
|
2013-02-15 23:25:36 +00:00
|
|
|
|
2020-12-11 12:47:28 +00:00
|
|
|
this._group = new St.BoxLayout({
|
|
|
|
name: 'overview-group',
|
|
|
|
vertical: true,
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
});
|
2019-07-16 09:24:13 +00:00
|
|
|
this.add_actor(this._group);
|
2013-02-25 23:05:45 +00:00
|
|
|
|
2021-01-29 14:38:08 +00:00
|
|
|
this._group.add_child(this.viewSelector);
|
2021-01-18 23:57:30 +00:00
|
|
|
this._group.add_actor(this._dashFader);
|
2013-02-18 04:45:24 +00:00
|
|
|
|
2019-07-08 08:03:20 +00: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 23:04:08 +00:00
|
|
|
this._workspaceAdjustment.remove_transition('value');
|
2019-07-08 08:03:20 +00:00
|
|
|
this._workspaceAdjustment.value = activeIndex;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|