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)) { if (!Main.pushModal(this.actor)) {
// Probably someone else has a pointer grab, try again with keyboard only // 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; return false;
} }
} }

View File

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

View File

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