From ef56a7854436340e786a32c56ba0a4b7018a9b96 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 25 Jan 2012 10:46:30 -0500 Subject: [PATCH] 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 --- js/ui/shellDBus.js | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index 63d91012d..779a173b1 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -113,11 +113,14 @@ const GnomeShell = new Lang.Class({ return [success, returnValue]; }, - _handleScreenshotFlash: function(flash, area) { + _onScreenshotComplete: function(obj, result, area, flash, invocation) { if (flash) { let flashspot = new Flashspot.Flashspot(area); 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) { let [x, y, width, height, flash, filename, callback] = params; - global.screenshot_area (x, y, width, height, filename, Lang.bind(this, - function (obj, result, area) { - this._handleScreenshotFlash(flash, area); - - let retval = GLib.Variant.new('(b)', [result]); - invocation.return_value(retval); - })); + global.screenshot_area (x, y, width, height, filename, + Lang.bind(this, this._onScreenshotComplete, + flash, invocation)); }, /** @@ -156,13 +155,9 @@ const GnomeShell = new Lang.Class({ */ ScreenshotWindowAsync : function (params, invocation) { let [include_frame, flash, filename] = params; - global.screenshot_window (include_frame, filename, Lang.bind(this, - function (obj, result, area) { - this._handleScreenshotFlash(flash, area); - - let retval = GLib.Variant.new('(b)', [result]); - invocation.return_value(retval); - })); + global.screenshot_window (include_frame, filename, + Lang.bind(this, this._onScreenshotComplete, + flash, invocation)); }, /** @@ -176,13 +171,9 @@ const GnomeShell = new Lang.Class({ */ ScreenshotAsync : function (params, invocation) { let [flash, filename] = params; - global.screenshot(filename, Lang.bind(this, - function (obj, result, area) { - this._handleScreenshotFlash(flash, area); - - let retval = GLib.Variant.new('(b)', [result]); - invocation.return_value(retval); - })); + global.screenshot(filename, + Lang.bind(this, this._onScreenshotComplete, + flash, invocation)); }, ListExtensions: function() {