[gnome-characters: 6/10] Use ES6 classes
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters: 6/10] Use ES6 classes
- Date: Wed, 20 Jun 2018 04:15:39 +0000 (UTC)
commit 233192cf1ca0628ccddb27e0861272a00244a9f2
Author: tommy <tommyshem485 gmail com>
Date: Mon Jun 18 23:12:03 2018 +0100
Use ES6 classes
src/searchProvider.js | 58 +++++++++++++++++++++++++--------------------------
1 file changed, 28 insertions(+), 30 deletions(-)
---
diff --git a/src/searchProvider.js b/src/searchProvider.js
index d0d5ce7..6db9267 100644
--- a/src/searchProvider.js
+++ b/src/searchProvider.js
@@ -17,36 +17,34 @@
// with Gnome Weather; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-const Gdk = imports.gi.Gdk;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
+const {Gc, Gdk, Gio, GLib, GObject} = imports.gi;
+
const Lang = imports.lang;
-const Gc = imports.gi.Gc;
const Util = imports.util;
-const MAX_SEARCH_RESULTS = 100
+const MAX_SEARCH_RESULTS = 100;
const SearchProviderInterface = Gio.resources_lookup_data('/org/gnome/shell/ShellSearchProvider2.xml',
0).toArray().toString();
-const SearchProvider = new Lang.Class({
+const SearchProvider = GObject.registerClass({
Name: 'CharactersSearchProvider',
-
- _init: function(application) {
+}, class SearchProvider extends GObject.Object {
+ _init(application) {
this._app = application;
this._impl = Gio.DBusExportedObject.wrapJSObject(SearchProviderInterface, this);
this._cancellable = new Gio.Cancellable();
- },
+ }
- export: function(connection, path) {
+ export(connection, path) {
return this._impl.export(connection, path);
- },
+ }
- unexport: function(connection) {
+ unexport(connection) {
return this._impl.unexport_from_connection(connection);
- },
+ }
- _runQuery: function(keywords, invocation) {
+ _runQuery(keywords, invocation) {
this._cancellable.cancel();
this._cancellable.reset();
@@ -63,25 +61,25 @@ const SearchProvider = new Lang.Class({
let result = context.search_finish(res);
characters = Util.searchResultToArray(result);
} catch (e) {
- log("Failed to search by keywords: " + e.message);
+ log(`Failed to search by keywords: ${e.message}`);
}
invocation.return_value(new GLib.Variant('(as)', [characters]));
this._app.release();
}));
- },
+ }
- GetInitialResultSetAsync: function(params, invocation) {
+ GetInitialResultSetAsync(params, invocation) {
this._app.hold();
this._runQuery(params[0], invocation);
- },
+ }
- GetSubsearchResultSetAsync: function(params, invocation) {
+ GetSubsearchResultSetAsync(params, invocation) {
this._app.hold();
this._runQuery(params[1], invocation);
- },
+ }
- GetResultMetas: function(identifiers) {
+ GetResultMetas(identifiers) {
this._app.hold();
let ret = [];
@@ -109,14 +107,14 @@ const SearchProvider = new Lang.Class({
this._app.release();
return ret;
- },
+ }
- ActivateResult: function(id, terms, timestamp) {
+ ActivateResult(id, terms, timestamp) {
let clipboard = Gc.gtk_clipboard_get();
clipboard.set_text(id, -1);
- },
+ }
- _getPlatformData: function(timestamp) {
+ _getPlatformData(timestamp) {
let display = Gdk.Display.get_default();
let context = display.get_app_launch_context();
context.set_timestamp(timestamp);
@@ -124,9 +122,9 @@ const SearchProvider = new Lang.Class({
let app = Gio.DesktopAppInfo.new('org.gnome.Characters.desktop');
let id = context.get_startup_notify_id(app, []);
return {'desktop-startup-id': new GLib.Variant('s', id) };
- },
+ }
- _activateAction: function(action, parameter, timestamp) {
+ _activateAction(action, parameter, timestamp) {
let wrappedParam;
if (parameter)
wrappedParam = [parameter];
@@ -145,14 +143,14 @@ const SearchProvider = new Lang.Class({
try {
connection.call_finish(result);
} catch(e) {
- log('Failed to launch application: ' + e.message);
+ log(`Failed to launch application: ${e.message}`);
}
this._app.release();
}));
- },
+ }
- LaunchSearch: function(terms, timestamp) {
+ LaunchSearch(terms, timestamp) {
this._activateAction('search', new GLib.Variant('as', terms),
timestamp);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]