2012-12-21 07:55:00 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
|
|
|
|
const BoxPointer = imports.ui.boxpointer;
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
|
|
|
|
|
|
|
const BackgroundMenu = new Lang.Class({
|
|
|
|
Name: 'BackgroundMenu',
|
|
|
|
Extends: PopupMenu.PopupMenu,
|
|
|
|
|
|
|
|
_init: function(source) {
|
|
|
|
this.parent(source, 0, St.Side.TOP);
|
|
|
|
|
2013-02-20 13:43:13 -05:00
|
|
|
this.addSettingsAction(_("Settings"), 'gnome-control-center.desktop');
|
2012-12-21 07:55:00 -05:00
|
|
|
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
2013-02-20 13:43:13 -05:00
|
|
|
this.addSettingsAction(_("Change Background…"), 'gnome-background-panel.desktop');
|
2012-12-21 07:55:00 -05:00
|
|
|
|
|
|
|
this.actor.add_style_class_name('background-menu');
|
|
|
|
|
|
|
|
Main.uiGroup.add_actor(this.actor);
|
|
|
|
this.actor.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function addBackgroundMenu(actor) {
|
|
|
|
let cursor = new St.Bin({ opacity: 0 });
|
|
|
|
Main.uiGroup.add_actor(cursor);
|
|
|
|
|
2013-02-19 20:18:14 -05:00
|
|
|
actor.reactive = true;
|
2012-12-21 07:55:00 -05:00
|
|
|
actor._backgroundMenu = new BackgroundMenu(cursor);
|
|
|
|
actor._backgroundManager = new PopupMenu.PopupMenuManager({ actor: actor });
|
|
|
|
actor._backgroundManager.addMenu(actor._backgroundMenu);
|
|
|
|
|
|
|
|
function openMenu() {
|
|
|
|
let [x, y] = global.get_pointer();
|
|
|
|
cursor.set_position(x, y);
|
2013-02-18 15:51:48 -05:00
|
|
|
actor._backgroundMenu.open(BoxPointer.PopupAnimation.NONE);
|
2012-12-21 07:55:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
let clickAction = new Clutter.ClickAction();
|
|
|
|
clickAction.connect('long-press', function(action, actor, state) {
|
|
|
|
if (state == Clutter.LongPressState.QUERY)
|
|
|
|
return action.get_button() == 1 && !actor._backgroundMenu.isOpen;
|
|
|
|
if (state == Clutter.LongPressState.ACTIVATE)
|
|
|
|
openMenu();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
clickAction.connect('clicked', function(action) {
|
|
|
|
if (action.get_button() == 3)
|
|
|
|
openMenu();
|
|
|
|
});
|
|
|
|
actor.add_action(clickAction);
|
|
|
|
}
|