main: Use Params for optional parameters to pushModal()

As the number of optional parameters grows, it gets more convenient
to use Params instead of passing in a lot of undefined/null/0 values.

https://bugzilla.gnome.org/show_bug.cgi?id=688202
This commit is contained in:
Florian Müllner 2012-08-10 17:54:39 +02:00
parent 034408971d
commit c2065cc3e2
3 changed files with 15 additions and 13 deletions

View File

@ -172,7 +172,7 @@ const AltTabPopup = new Lang.Class({
if (!Main.pushModal(this.actor)) {
// Probably someone else has a pointer grab, try again with keyboard only
if (!Main.pushModal(this.actor, global.get_current_time(), Meta.ModalOptions.POINTER_ALREADY_GRABBED)) {
if (!Main.pushModal(this.actor, { options: Meta.ModalOptions.POINTER_ALREADY_GRABBED })) {
return false;
}
}

View File

@ -20,6 +20,7 @@ const Keyboard = imports.ui.keyboard;
const MessageTray = imports.ui.messageTray;
const Overview = imports.ui.overview;
const Panel = imports.ui.panel;
const Params = imports.misc.params;
const RunDialog = imports.ui.runDialog;
const Layout = imports.ui.layout;
const LookingGlass = imports.ui.lookingGlass;
@ -478,7 +479,7 @@ function isInModalStack(actor) {
/**
* pushModal:
* @actor: #ClutterActor which will be given keyboard focus
* @timestamp: optional timestamp
* @params: optional parameters
*
* Ensure we are in a mode where all keyboard and mouse input goes to
* the stage, and focus @actor. Multiple calls to this function act in
@ -489,21 +490,22 @@ function isInModalStack(actor) {
* modal stack returns to this actor, reset the focus to the actor
* which was focused at the time pushModal() was invoked.
*
* @timestamp is optionally used to associate the call with a specific user
* initiated event. If not provided then the value of
* global.get_current_time() is assumed.
* @params may be used to provide the following parameters:
* - timestamp: used to associate the call with a specific user initiated
* event. If not provided then the value of
* global.get_current_time() is assumed.
*
* @options: optional Meta.ModalOptions flags to indicate that the
* pointer is alrady grabbed
* - options: Meta.ModalOptions flags to indicate that the pointer is
* already grabbed
*
* Returns: true iff we successfully acquired a grab or already had one
*/
function pushModal(actor, timestamp, options) {
if (timestamp == undefined)
timestamp = global.get_current_time();
function pushModal(actor, params) {
params = Params.parse(params, { timestamp: global.get_current_time(),
options: 0 });
if (modalCount == 0) {
if (!global.begin_modal(timestamp, options ? options : 0)) {
if (!global.begin_modal(params.timestamp, params.options)) {
log('pushModal: invocation of begin_modal failed');
return false;
}

View File

@ -226,7 +226,7 @@ const ModalDialog = new Lang.Class({
if (this.state == State.OPENED || this.state == State.OPENING)
return true;
if (!this.pushModal(timestamp))
if (!this.pushModal({ timestamp: timestamp }))
return false;
this._fadeOpen(onPrimary);
@ -276,7 +276,7 @@ const ModalDialog = new Lang.Class({
pushModal: function (timestamp) {
if (this._hasModal)
return true;
if (!Main.pushModal(this._group, timestamp))
if (!Main.pushModal(this._group, { timestamp: timestamp }))
return false;
this._hasModal = true;