shell-dbus: factor screenshot callback into a separate function

Share the screenshot methods callback into a factored out function.

https://bugzilla.gnome.org/show_bug.cgi?id=668618
This commit is contained in:
Cosimo Cecchi 2012-01-25 10:46:30 -05:00
parent 049a561466
commit ef56a78544

View File

@ -113,11 +113,14 @@ const GnomeShell = new Lang.Class({
return [success, returnValue]; return [success, returnValue];
}, },
_handleScreenshotFlash: function(flash, area) { _onScreenshotComplete: function(obj, result, area, flash, invocation) {
if (flash) { if (flash) {
let flashspot = new Flashspot.Flashspot(area); let flashspot = new Flashspot.Flashspot(area);
flashspot.fire(); flashspot.fire();
} }
let retval = GLib.Variant.new('(b)', [result]);
invocation.return_value(retval);
}, },
/** /**
@ -135,13 +138,9 @@ const GnomeShell = new Lang.Class({
*/ */
ScreenshotAreaAsync : function (params, invocation) { ScreenshotAreaAsync : function (params, invocation) {
let [x, y, width, height, flash, filename, callback] = params; let [x, y, width, height, flash, filename, callback] = params;
global.screenshot_area (x, y, width, height, filename, Lang.bind(this, global.screenshot_area (x, y, width, height, filename,
function (obj, result, area) { Lang.bind(this, this._onScreenshotComplete,
this._handleScreenshotFlash(flash, area); flash, invocation));
let retval = GLib.Variant.new('(b)', [result]);
invocation.return_value(retval);
}));
}, },
/** /**
@ -156,13 +155,9 @@ const GnomeShell = new Lang.Class({
*/ */
ScreenshotWindowAsync : function (params, invocation) { ScreenshotWindowAsync : function (params, invocation) {
let [include_frame, flash, filename] = params; let [include_frame, flash, filename] = params;
global.screenshot_window (include_frame, filename, Lang.bind(this, global.screenshot_window (include_frame, filename,
function (obj, result, area) { Lang.bind(this, this._onScreenshotComplete,
this._handleScreenshotFlash(flash, area); flash, invocation));
let retval = GLib.Variant.new('(b)', [result]);
invocation.return_value(retval);
}));
}, },
/** /**
@ -176,13 +171,9 @@ const GnomeShell = new Lang.Class({
*/ */
ScreenshotAsync : function (params, invocation) { ScreenshotAsync : function (params, invocation) {
let [flash, filename] = params; let [flash, filename] = params;
global.screenshot(filename, Lang.bind(this, global.screenshot(filename,
function (obj, result, area) { Lang.bind(this, this._onScreenshotComplete,
this._handleScreenshotFlash(flash, area); flash, invocation));
let retval = GLib.Variant.new('(b)', [result]);
invocation.return_value(retval);
}));
}, },
ListExtensions: function() { ListExtensions: function() {