2012-12-21 07:55:00 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2023-07-10 02:53:00 -07:00
|
|
|
import Clutter from 'gi://Clutter';
|
|
|
|
import St from 'gi://St';
|
2012-12-21 07:55:00 -05:00
|
|
|
|
2023-07-10 02:53:00 -07:00
|
|
|
import * as BoxPointer from './boxpointer.js';
|
|
|
|
import * as PopupMenu from './popupMenu.js';
|
2012-12-21 07:55:00 -05:00
|
|
|
|
2023-07-10 02:53:00 -07:00
|
|
|
import * as Main from './main.js';
|
|
|
|
|
|
|
|
export class BackgroundMenu extends PopupMenu.PopupMenu {
|
2017-10-31 02:19:44 +01:00
|
|
|
constructor(layoutManager) {
|
|
|
|
super(layoutManager.dummyCursor, 0, St.Side.TOP);
|
2012-12-21 07:55:00 -05:00
|
|
|
|
2023-08-07 00:34:20 +02:00
|
|
|
this.addSettingsAction(_('Change Background…'), 'gnome-background-panel.desktop');
|
2015-03-31 13:50:14 +05:30
|
|
|
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
2023-08-07 00:34:20 +02:00
|
|
|
this.addSettingsAction(_('Display Settings'), 'gnome-display-panel.desktop');
|
2022-01-21 10:24:02 -03:00
|
|
|
this.addSettingsAction(_('Settings'), 'org.gnome.Settings.desktop');
|
2012-12-21 07:55:00 -05:00
|
|
|
|
|
|
|
this.actor.add_style_class_name('background-menu');
|
|
|
|
|
2023-11-07 10:47:14 +00:00
|
|
|
layoutManager.uiGroup.add_child(this.actor);
|
2012-12-21 07:55:00 -05:00
|
|
|
this.actor.hide();
|
|
|
|
}
|
2023-07-10 02:53:00 -07:00
|
|
|
}
|
2012-12-21 07:55:00 -05:00
|
|
|
|
2023-07-30 15:56:59 +03:00
|
|
|
/**
|
|
|
|
* @param {Meta.BackgroundActor} actor
|
|
|
|
* @param {import('./layout.js').LayoutManager} layoutManager
|
|
|
|
*/
|
2023-07-10 02:53:00 -07:00
|
|
|
export function addBackgroundMenu(actor, layoutManager) {
|
2013-02-20 02:18:14 +01:00
|
|
|
actor.reactive = true;
|
2013-02-15 04:56:34 -05:00
|
|
|
actor._backgroundMenu = new BackgroundMenu(layoutManager);
|
2019-04-09 18:23:59 -05:00
|
|
|
actor._backgroundManager = new PopupMenu.PopupMenuManager(actor);
|
2012-12-21 07:55:00 -05:00
|
|
|
actor._backgroundManager.addMenu(actor._backgroundMenu);
|
|
|
|
|
2014-07-22 12:34:56 +02:00
|
|
|
function openMenu(x, y) {
|
2014-04-11 16:12:52 +02:00
|
|
|
Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0);
|
2019-09-11 22:00:39 +02:00
|
|
|
actor._backgroundMenu.open(BoxPointer.PopupAnimation.FULL);
|
2012-12-21 07:55:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
let clickAction = new Clutter.ClickAction();
|
2019-08-20 02:20:08 +02:00
|
|
|
clickAction.connect('long-press', (action, theActor, state) => {
|
2023-08-07 02:51:19 +02:00
|
|
|
if (state === Clutter.LongPressState.QUERY) {
|
|
|
|
return (action.get_button() === 0 ||
|
|
|
|
action.get_button() === 1) &&
|
2019-08-19 21:38:51 +02:00
|
|
|
!actor._backgroundMenu.isOpen;
|
2019-08-20 02:51:42 +02:00
|
|
|
}
|
2023-08-07 02:51:19 +02:00
|
|
|
if (state === Clutter.LongPressState.ACTIVATE) {
|
2014-07-22 12:34:56 +02:00
|
|
|
let [x, y] = action.get_coords();
|
|
|
|
openMenu(x, y);
|
2013-04-23 16:39:29 -04:00
|
|
|
actor._backgroundManager.ignoreRelease();
|
|
|
|
}
|
2012-12-21 07:55:00 -05:00
|
|
|
return true;
|
|
|
|
});
|
2017-10-31 01:38:18 +01:00
|
|
|
clickAction.connect('clicked', action => {
|
2023-08-07 02:51:19 +02:00
|
|
|
if (action.get_button() === 3) {
|
2014-07-22 12:34:56 +02:00
|
|
|
let [x, y] = action.get_coords();
|
|
|
|
openMenu(x, y);
|
|
|
|
}
|
2012-12-21 07:55:00 -05:00
|
|
|
});
|
|
|
|
actor.add_action(clickAction);
|
2013-04-01 23:57:55 -04:00
|
|
|
|
2017-10-31 01:38:18 +01:00
|
|
|
actor.connect('destroy', () => {
|
2013-02-15 04:56:34 -05:00
|
|
|
actor._backgroundMenu.destroy();
|
|
|
|
actor._backgroundMenu = null;
|
|
|
|
actor._backgroundManager = null;
|
|
|
|
});
|
2012-12-21 07:55:00 -05:00
|
|
|
}
|