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