mirror of
https://github.com/BreizhHardware/multi-monitors-add-on.git
synced 2026-01-18 16:47:26 +01:00
Some final cleaning.
This commit is contained in:
@@ -9,7 +9,8 @@ in dynamic fashion, no restart needed.
|
||||
Versions
|
||||
========
|
||||
|
||||
* Branch [master](https://github.com/spin83/multi-monitors-add-on/tree/master) contains extension for GNOME 3.24, 3.26, 3.28 and 3.30
|
||||
* Branch [master](https://github.com/spin83/multi-monitors-add-on/tree/master) contains extension for GNOME 3.32
|
||||
* Branch [gnome-3-24_3-30](https://github.com/spin83/multi-monitors-add-on/tree/master) contains extension for GNOME 3.24, 3.26, 3.28 and 3.30
|
||||
* Branch [gnome-3-20_3-22](https://github.com/spin83/multi-monitors-add-on/tree/gnome-3-20_3-22) contains extension for GNOME 3.20 and 3.22
|
||||
* Branch [gnome-3-16_3-18](https://github.com/spin83/multi-monitors-add-on/tree/gnome-3-16_3-18) contains extension for GNOME 3.16 and 3.18
|
||||
* Branch [gnome-3-14](https://github.com/spin83/multi-monitors-add-on/tree/gnome-3-14) contains extension for GNOME 3.14
|
||||
@@ -20,7 +21,7 @@ Installation from git
|
||||
|
||||
git clone git://github.com/spin83/multi-monitors-add-on.git
|
||||
cd multi-monitors-add-on
|
||||
cp -r multi-monitors-add-on@spin83 ~/.local/share/gnome-shell/extensions
|
||||
cp -r multi-monitors-add-on@spin83 ~/.local/share/gnome-shell/extensions/
|
||||
|
||||
Restart the shell and then enable the extension.
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, visit https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
const Lang = imports.lang;
|
||||
|
||||
const St = imports.gi.St;
|
||||
const Gio = imports.gi.Gio;
|
||||
const { St, Gio, GObject } = imports.gi;
|
||||
|
||||
const Util = imports.misc.util;
|
||||
|
||||
@@ -32,107 +29,107 @@ const CE = imports.misc.extensionUtils.getCurrentExtension();
|
||||
const Convenience = CE.imports.convenience;
|
||||
const extensionPath = CE.path;
|
||||
|
||||
var MultiMonitorsIndicator = new Lang.Class({
|
||||
Name: 'MultiMonitorsIndicator',
|
||||
Extends: PanelMenu.Button,
|
||||
|
||||
_init() {
|
||||
this.parent(0.0, "MultiMonitorsAddOn", false);
|
||||
|
||||
Convenience.initTranslations();
|
||||
|
||||
this.text = null;
|
||||
|
||||
this._mmStatusIcon = new St.BoxLayout({ style_class: 'multimonitor-status-indicators-box' });
|
||||
this._mmStatusIcon.hide();
|
||||
this.actor.add_child(this._mmStatusIcon);
|
||||
this._leftRightIcon = true;
|
||||
|
||||
this.menu.addAction(_("Preferences"), this._onPreferences.bind(this));
|
||||
|
||||
this._viewMonitorsId = Main.layoutManager.connect('monitors-changed', this._viewMonitors.bind(this));
|
||||
this.connect('destroy', this._onDestroy.bind(this));
|
||||
this._viewMonitors();
|
||||
},
|
||||
|
||||
_onDestroy(actor) {
|
||||
Main.layoutManager.disconnect(this._viewMonitorsId);
|
||||
},
|
||||
|
||||
_syncIndicatorsVisible() {
|
||||
this._mmStatusIcon.visible = this._mmStatusIcon.get_children().some(a => a.visible);
|
||||
},
|
||||
|
||||
_icon_name (icon, iconName) {
|
||||
icon.set_gicon(Gio.icon_new_for_string(extensionPath+"/icons/"+iconName+".svg"));
|
||||
},
|
||||
|
||||
_viewMonitors() {
|
||||
let monitors = this._mmStatusIcon.get_children();
|
||||
|
||||
let monitorChange = Main.layoutManager.monitors.length - monitors.length;
|
||||
if(monitorChange>0){
|
||||
global.log("Add Monitors ...");
|
||||
for(let idx = 0; idx<monitorChange; idx++){
|
||||
let icon;
|
||||
icon = new St.Icon({style_class: 'system-status-icon multimonitor-status-icon'});
|
||||
this._mmStatusIcon.add_child(icon);
|
||||
icon.connect('notify::visible', this._syncIndicatorsVisible.bind(this));
|
||||
|
||||
if (this._leftRightIcon)
|
||||
this._icon_name(icon, 'multi-monitors-l-symbolic');
|
||||
else
|
||||
this._icon_name(icon, 'multi-monitors-r-symbolic');
|
||||
this._leftRightIcon = !this._leftRightIcon;
|
||||
}
|
||||
this._syncIndicatorsVisible();
|
||||
}
|
||||
else if(monitorChange<0){
|
||||
global.log("Remove Monitors ...");
|
||||
monitorChange = -monitorChange;
|
||||
var MultiMonitorsIndicator = (() => {
|
||||
let MultiMonitorsIndicator = class MultiMonitorsIndicator extends PanelMenu.Button {
|
||||
_init() {
|
||||
super._init(0.0, "MultiMonitorsAddOn", false);
|
||||
|
||||
for(let idx = 0; idx<monitorChange; idx++){
|
||||
let icon = this._mmStatusIcon.get_last_child();
|
||||
this._mmStatusIcon.remove_child(icon);
|
||||
icon.destroy();
|
||||
this._leftRightIcon = !this._leftRightIcon;
|
||||
Convenience.initTranslations();
|
||||
|
||||
this.text = null;
|
||||
|
||||
this._mmStatusIcon = new St.BoxLayout({ style_class: 'multimonitor-status-indicators-box' });
|
||||
this._mmStatusIcon.hide();
|
||||
this.actor.add_child(this._mmStatusIcon);
|
||||
this._leftRightIcon = true;
|
||||
|
||||
this.menu.addAction(_("Preferences"), this._onPreferences.bind(this));
|
||||
|
||||
this._viewMonitorsId = Main.layoutManager.connect('monitors-changed', this._viewMonitors.bind(this));
|
||||
this._viewMonitors();
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
Main.layoutManager.disconnect(this._viewMonitorsId);
|
||||
super._onDestroy();
|
||||
}
|
||||
|
||||
_syncIndicatorsVisible() {
|
||||
this._mmStatusIcon.visible = this._mmStatusIcon.get_children().some(a => a.visible);
|
||||
}
|
||||
|
||||
_icon_name (icon, iconName) {
|
||||
icon.set_gicon(Gio.icon_new_for_string(extensionPath+"/icons/"+iconName+".svg"));
|
||||
}
|
||||
|
||||
_viewMonitors() {
|
||||
let monitors = this._mmStatusIcon.get_children();
|
||||
|
||||
let monitorChange = Main.layoutManager.monitors.length - monitors.length;
|
||||
if(monitorChange>0){
|
||||
global.log("Add Monitors ...");
|
||||
for(let idx = 0; idx<monitorChange; idx++){
|
||||
let icon;
|
||||
icon = new St.Icon({style_class: 'system-status-icon multimonitor-status-icon'});
|
||||
this._mmStatusIcon.add_child(icon);
|
||||
icon.connect('notify::visible', this._syncIndicatorsVisible.bind(this));
|
||||
|
||||
if (this._leftRightIcon)
|
||||
this._icon_name(icon, 'multi-monitors-l-symbolic');
|
||||
else
|
||||
this._icon_name(icon, 'multi-monitors-r-symbolic');
|
||||
this._leftRightIcon = !this._leftRightIcon;
|
||||
}
|
||||
this._syncIndicatorsVisible();
|
||||
}
|
||||
else if(monitorChange<0){
|
||||
global.log("Remove Monitors ...");
|
||||
monitorChange = -monitorChange;
|
||||
|
||||
for(let idx = 0; idx<monitorChange; idx++){
|
||||
let icon = this._mmStatusIcon.get_last_child();
|
||||
this._mmStatusIcon.remove_child(icon);
|
||||
icon.destroy();
|
||||
this._leftRightIcon = !this._leftRightIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_onPreferences()
|
||||
{
|
||||
Util.spawn(["gnome-shell-extension-prefs", "multi-monitors-add-on@spin83"]);
|
||||
}
|
||||
|
||||
_onInit2ndMonitor()
|
||||
{
|
||||
Util.spawn(["intel-virtual-output"]);
|
||||
}
|
||||
|
||||
_hideHello() {
|
||||
Main.uiGroup.remove_actor(this.text);
|
||||
this.text = null;
|
||||
}
|
||||
|
||||
_showHello() {
|
||||
if (!this.text) {
|
||||
this.text = new St.Label({ style_class: 'helloworld-label', text: _("Multi Monitors Add-On") });
|
||||
Main.uiGroup.add_actor(this.text);
|
||||
}
|
||||
|
||||
_onPreferences()
|
||||
{
|
||||
Util.spawn(["gnome-shell-extension-prefs", "multi-monitors-add-on@spin83"]);
|
||||
},
|
||||
this.text.opacity = 255;
|
||||
|
||||
_onInit2ndMonitor()
|
||||
{
|
||||
Util.spawn(["intel-virtual-output"]);
|
||||
},
|
||||
let monitor = Main.layoutManager.primaryMonitor;
|
||||
|
||||
_hideHello() {
|
||||
Main.uiGroup.remove_actor(this.text);
|
||||
this.text = null;
|
||||
},
|
||||
this.text.set_position(Math.floor(monitor.width / 2 - this.text.width / 2),
|
||||
Math.floor(monitor.height / 2 - this.text.height / 2));
|
||||
|
||||
_showHello() {
|
||||
if (!this.text) {
|
||||
this.text = new St.Label({ style_class: 'helloworld-label', text: _("Multi Monitors Add-On") });
|
||||
Main.uiGroup.add_actor(this.text);
|
||||
}
|
||||
|
||||
this.text.opacity = 255;
|
||||
|
||||
let monitor = Main.layoutManager.primaryMonitor;
|
||||
|
||||
this.text.set_position(Math.floor(monitor.width / 2 - this.text.width / 2),
|
||||
Math.floor(monitor.height / 2 - this.text.height / 2));
|
||||
|
||||
Tweener.addTween(this.text,
|
||||
{ opacity: 0,
|
||||
time: 4,
|
||||
transition: 'easeOutQuad',
|
||||
onComplete: this._hideHello.bind(this) });
|
||||
|
||||
},
|
||||
});
|
||||
Tweener.addTween(this.text,
|
||||
{ opacity: 0,
|
||||
time: 4,
|
||||
transition: 'easeOutQuad',
|
||||
onComplete: this._hideHello.bind(this) });
|
||||
|
||||
}
|
||||
};
|
||||
return GObject.registerClass(MultiMonitorsIndicator);
|
||||
})();
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
* New node file
|
||||
*/
|
||||
|
||||
const Lang = imports.lang;
|
||||
|
||||
const St = imports.gi.St;
|
||||
const Meta = imports.gi.Meta;
|
||||
const { St, Meta } = imports.gi;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
const Panel = imports.ui.panel;
|
||||
@@ -14,10 +11,10 @@ const Layout = imports.ui.layout;
|
||||
const Config = imports.misc.config;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const MultiMonitors = ExtensionUtils.getCurrentExtension();
|
||||
const Convenience = MultiMonitors.imports.convenience;
|
||||
|
||||
const MMPanel = MultiMonitors.imports.mmpanel;
|
||||
const CE = ExtensionUtils.getCurrentExtension();
|
||||
const Convenience = CE.imports.convenience;
|
||||
const MultiMonitors = CE.imports.extension;
|
||||
const MMPanel = CE.imports.mmpanel;
|
||||
|
||||
var SHOW_PANEL_ID = 'show-panel';
|
||||
|
||||
@@ -66,13 +63,9 @@ const MultiMonitorsPanelBox = class MultiMonitorsPanelBox {
|
||||
}
|
||||
};
|
||||
|
||||
var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
Name: 'MultiMonitorsLayoutManager',
|
||||
_init () {
|
||||
this._currentVersion = Config.PACKAGE_VERSION.split('.');
|
||||
|
||||
var MultiMonitorsLayoutManager = class MultiMonitorsLayoutManager {
|
||||
constructor() {
|
||||
this._settings = Convenience.getSettings();
|
||||
|
||||
Main.mmPanel = [];
|
||||
|
||||
this._monitorIds = [];
|
||||
@@ -85,7 +78,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
this.statusIndicatorsController = null;
|
||||
this._layoutManager_updateHotCorners = null;
|
||||
this._changedEnableHotCornersId = null;
|
||||
},
|
||||
}
|
||||
|
||||
showPanel() {
|
||||
if (this._settings.get_boolean(SHOW_PANEL_ID)) {
|
||||
@@ -104,7 +97,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
if (!this._layoutManager_updateHotCorners) {
|
||||
this._layoutManager_updateHotCorners = Main.layoutManager._updateHotCorners;
|
||||
|
||||
let enable_hot_corners = (Main.sessionMode.currentMode == 'ubuntu' && this._currentVersion[0]==3 && this._currentVersion[1]==28);
|
||||
let enable_hot_corners = (Main.sessionMode.currentMode == 'ubuntu');
|
||||
Main.layoutManager._updateHotCorners = function() {
|
||||
this.hotCorners.forEach((corner) => {
|
||||
if (corner)
|
||||
@@ -147,7 +140,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
else {
|
||||
this.hidePanel();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
hidePanel() {
|
||||
if (this._changedEnableHotCornersId) {
|
||||
@@ -183,7 +176,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
this._popPanel();
|
||||
global.log("remove: "+monitorId);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_monitorsChanged () {
|
||||
let monitorChange = Main.layoutManager.monitors.length - this._monitorIds.length -1;
|
||||
@@ -220,7 +213,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
if (tIndicators && this.statusIndicatorsController) {
|
||||
this.statusIndicatorsController.transferIndicators();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_pushPanel(i, monitor) {
|
||||
let mmPanelBox = new MultiMonitorsPanelBox(monitor);
|
||||
@@ -228,7 +221,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
|
||||
Main.mmPanel.push(panel);
|
||||
this.mmPanelBox.push(mmPanelBox);
|
||||
},
|
||||
}
|
||||
|
||||
_popPanel() {
|
||||
let panel = Main.mmPanel.pop();
|
||||
@@ -237,7 +230,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
}
|
||||
let mmPanelBox = this.mmPanelBox.pop();
|
||||
mmPanelBox.destroy();
|
||||
},
|
||||
}
|
||||
|
||||
_changeMainPanelAppMenuButton(appMenuButton) {
|
||||
let role = "appMenu";
|
||||
@@ -261,7 +254,7 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
panel.statusArea[role] = indicator;
|
||||
let box = panel._leftBox;
|
||||
panel._addToPanelBox(role, indicator, box.get_n_children()+1, box);
|
||||
},
|
||||
}
|
||||
|
||||
_showAppMenu() {
|
||||
if (this._settings.get_boolean(MMPanel.SHOW_APP_MENU_ID) && Main.mmPanel.length>0) {
|
||||
@@ -273,13 +266,12 @@ var MultiMonitorsLayoutManager = new Lang.Class({
|
||||
else {
|
||||
this._hideAppMenu();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_hideAppMenu() {
|
||||
if (this.mmappMenu) {
|
||||
this._changeMainPanelAppMenuButton(Panel.AppMenuButton);
|
||||
this.mmappMenu = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user