Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Search = imports.ui.search;
const SearchDisplay = imports.ui.searchDisplay;
const IconGrid = imports.ui.iconGrid;
const GLib = imports.gi.GLib;
const Lang = imports.lang;

const MAX_SEARCH_RESULTS_ROWS = 1;
const ICON_SIZE = 81;
Expand Down Expand Up @@ -70,15 +71,11 @@ CalcResult.prototype = {

};

function CalcProvider() {
this._init.apply(this, arguments);
}

CalcProvider.prototype = {
__proto__: Search.SearchProvider.prototype,
const CalcProvider = new Lang.Class({
Name: 'CalcProvider',

_init: function(title) {
Search.SearchProvider.prototype._init.call(this, title);
this.id = title;
},

_convertTable : ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"],
Expand Down Expand Up @@ -124,9 +121,9 @@ CalcProvider.prototype = {
expr = expr.replace(changeBase, "");
}
try {
let [success, out, err, error] = GLib.spawn_sync(null, ["gcalctool", "-s", expr], null, 4, null)
let [success, out, err, error] = GLib.spawn_sync(null, ["gnome-calculator", "-s", expr], null, 4, null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon, seems to have been missing though before these changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatic semicolon insertion generally is a bitch but it has rendered this a non-issue. One should be more alarmed by the call to spawn_sync, since it may introduce lag if gnome-calculater needs some miliseconds to be launched and to calculate the expression.

if(error == 0) {
let result = out.toString();
let result = out.toString();
if(finalBase != 10) {
let neg = false;
// \u2212 is a minus sign. Since it's unicode javascript doesn't recognize
Expand All @@ -143,15 +140,14 @@ CalcProvider.prototype = {
}
this._lastResult = result;
this.searchSystem.pushResults(this,
[{'expr': expr, 'result': result}]);
return [{'expr': expr, 'result': result}];
[{'id': expr, 'expr': expr, 'result': result}]);
return;
}
} catch(exp) {
}
}

this.searchSystem.pushResults(this, []);
return [];
},

getSubsearchResultSet: function(prevResults, terms) {
Expand Down Expand Up @@ -187,7 +183,7 @@ CalcProvider.prototype = {
}
return true;
}
}
});

function init() {
calcProvider = new CalcProvider('CALCULATOR');
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"shell-version": ["3.5", "3.6"],
"shell-version": ["3.8"],
"uuid": "gcalc-search@wrowclif.org",
"name": "GCalcSearch",
"description": "Search provider using gcalctool to perform calculations",
Expand Down