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-15 18:25:36 -05:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
|
|
|
|
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();
|
|
|
|
|
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
|
|
|
|
2021-01-29 15:38:08 +01:00
|
|
|
this._group.add_child(this.viewSelector);
|
2021-02-09 17:50:29 +01:00
|
|
|
this._group.add_actor(this.dash);
|
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
|
|
|
});
|