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-15 23:25:36 +00:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
|
|
|
|
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();
|
|
|
|
|
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-02-09 16:50:29 +00:00
|
|
|
this._group.add_actor(this.dash);
|
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
|
|
|
});
|