Skip to content

Commit

Permalink
appIndicators: use arrow functions in lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Feb 21, 2019
1 parent 9fe53c4 commit da4c63b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
12 changes: 6 additions & 6 deletions appIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var AppIndicator = new Lang.Class({
g_name: bus_name,
g_object_path: object,
g_flags: Gio.DBusProxyFlags.GET_INVALIDATED_PROPERTIES })
this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, (function(initable, result) {
this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, ((initable, result) => {
try {
initable.init_finish(result);

Expand All @@ -75,7 +75,7 @@ var AppIndicator = new Lang.Class({
} catch(e) {
Util.Logger.warn("While intializing proxy for "+bus_name+object+": "+e)
}
}).bind(this))
}))

this._proxyPropertyList = interface_info.properties.map((propinfo) => { return propinfo.name })
this._addExtraProperty('XAyatanaLabel');
Expand Down Expand Up @@ -166,7 +166,7 @@ var AppIndicator = new Lang.Class({
_onPropertiesChanged: function(proxy, changed, invalidated) {
let props = Object.keys(changed.deep_unpack())

props.forEach(function(property) {
props.forEach((property) => {
// some property changes require updates on our part,
// a few need to be passed down to the displaying code

Expand Down Expand Up @@ -308,7 +308,7 @@ var IconActor = new Lang.Class({
// we try to avoid messing with the default icon theme, so we'll create a new one if needed
if (themePath) {
var icon_theme = new Gtk.IconTheme()
Gtk.IconTheme.get_default().get_search_path().forEach(function(path) {
Gtk.IconTheme.get_default().get_search_path().forEach((path) => {
icon_theme.append_search_path(path)
});
icon_theme.append_search_path(themePath)
Expand Down Expand Up @@ -357,15 +357,15 @@ var IconActor = new Lang.Class({
if (!iconPixmapArray || iconPixmapArray.length < 1)
return null

let sortedIconPixmapArray = iconPixmapArray.sort(function(pixmapA, pixmapB) {
let sortedIconPixmapArray = iconPixmapArray.sort((pixmapA, pixmapB) => {
// we sort biggest to smallest
let areaA = pixmapA[0] * pixmapA[1]
let areaB = pixmapB[0] * pixmapB[1]

return areaB - areaA
})

let qualifiedIconPixmapArray = sortedIconPixmapArray.filter(function(pixmap) {
let qualifiedIconPixmapArray = sortedIconPixmapArray.filter((pixmap) => {
// we disqualify any pixmap that is bigger than our requested size
return pixmap[0] <= iconSize && pixmap[1] <= iconSize
})
Expand Down
28 changes: 14 additions & 14 deletions dbusMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const DbusMenuItem = new Lang.Class({
},

get_children: function() {
return this._children_ids.map(function(el) {
return this._children_ids.map((el) => {
return this._client.get_item(el)
}, this)
},
Expand Down Expand Up @@ -238,7 +238,7 @@ const DBusClient = new Lang.Class({
if (this._propertiesRequestedFor.length < 1)
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, this._beginRequestProperties.bind(this))

if (this._propertiesRequestedFor.filter(function(e) { return e === id }).length == 0)
if (this._propertiesRequestedFor.filter((e) => { return e === id }).length == 0)
this._propertiesRequestedFor.push(id)

},
Expand All @@ -258,7 +258,7 @@ const DBusClient = new Lang.Class({
}

// for some funny reason, the result array is hidden in an array
result[0].forEach(function([id, properties]) {
result[0].forEach(([id, properties]) => {
if (!(id in this._items))
return

Expand Down Expand Up @@ -314,8 +314,8 @@ const DBusClient = new Lang.Class({
_doLayoutUpdate: function(item) {
let [ id, properties, children ] = item

let children_unpacked = children.map(function(child) { return child.deep_unpack() })
let children_ids = children_unpacked.map(function(child) { return child[0] })
let children_unpacked = children.map((child) => { return child.deep_unpack() })
let children_ids = children_unpacked.map((child) => { return child[0] })

// make sure all our children exist
children_unpacked.forEach(this._doLayoutUpdate, this)
Expand Down Expand Up @@ -349,7 +349,7 @@ const DBusClient = new Lang.Class({
}

// remove any old children that weren't reused
old_children_ids.forEach(function(child_id) { this._items[id].remove_child(child_id) }, this)
old_children_ids.forEach((child_id) => { this._items[id].remove_child(child_id) }, this)
} else {
// we don't, so let's create us
this._items[id] = new DbusMenuItem(this, id, properties, children_ids)
Expand Down Expand Up @@ -382,12 +382,12 @@ const DBusClient = new Lang.Class({

// we don't need to cache and burst-send that since it will not happen that frequently
send_about_to_show: function(id) {
this._proxy.AboutToShowRemote(id, (function(result, error) {
this._proxy.AboutToShowRemote(id, ((result, error) => {
if (error)
Util.Logger.warn("while calling AboutToShow: "+error)
else if (result && result[0])
this._requestLayoutUpdate()
}).bind(this))
}))
},

send_event: function(id, event, params, timestamp) {
Expand All @@ -402,18 +402,18 @@ const DBusClient = new Lang.Class({
},

_onPropertiesUpdated: function(proxy, name, [changed, removed]) {
changed.forEach(function([id, props]) {
changed.forEach(([id, props]) => {
if (!(id in this._items))
return

for (let prop in props)
this._items[id].property_set(prop, props[prop])
}, this)
removed.forEach(function([id, propNames]) {
removed.forEach(([id, propNames]) => {
if (!(id in this._items))
return

propNames.forEach(function(propName) {
propNames.forEach((propName) => {
this._items[id].property_set(propName, null)
}, this)
}, this)
Expand Down Expand Up @@ -556,7 +556,7 @@ const MenuItemFactory = {
MenuItemFactory._replaceSelf.call(this)
} else {
// find it!
this.menu._getMenuItems().forEach(function(item) {
this.menu._getMenuItems().forEach((item) => {
if (item._dbusItem == child)
item.destroy()
})
Expand Down Expand Up @@ -703,7 +703,7 @@ var Client = new Lang.Class({
this._rootItem.send_about_to_show()

// fill the menu for the first time
this._rootItem.get_children().forEach(function(child) {
this._rootItem.get_children().forEach((child) => {
this._rootMenu.addMenuItem(MenuItemFactory.createItem(this, child))
}, this)
},
Expand Down Expand Up @@ -731,7 +731,7 @@ var Client = new Lang.Class({
_onRootChildRemoved: function(dbusItem, child) {
// children like to play hide and seek
// but we know how to find it for sure!
this._rootMenu._getMenuItems().forEach(function(item) {
this._rootMenu._getMenuItems().forEach((item) => {
if (item._dbusItem == child)
item.destroy()
})
Expand Down
2 changes: 1 addition & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function init() {
if (typeof global['--appindicator-extension-on-reload'] == 'function')
global['--appindicator-extension-on-reload']()

global['--appindicator-extension-on-reload'] = function() {
global['--appindicator-extension-on-reload'] = () => {
Util.Logger.debug("Reload detected, destroying old watchdog")
NameWatchdog.destroy()
}
Expand Down
18 changes: 9 additions & 9 deletions indicator-test-tool/testTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ const Gtk = imports.gi.Gtk;
const AppIndicator = imports.gi.AppIndicator3;
const GLib = imports.gi.GLib;

(function() {
(() => {

var app = new Gtk.Application({
application_id: null
});

var window = null;

app.connect("activate", function(){
app.connect("activate", () => {
window.present();
});

app.connect("startup", function() {
app.connect("startup", () => {
window = new Gtk.ApplicationWindow({
title: "test",
application: app
Expand Down Expand Up @@ -97,13 +97,13 @@ app.connect("startup", function() {
menu.append(item);

item = Gtk.MenuItem.new_with_label("Set Label");
item.connect('activate', function() {
item.connect('activate', () => {
indicator.set_label(''+new Date().getSeconds(), 'Blub');
});
menu.append(item);

item = Gtk.MenuItem.new_with_label("Unset Label");
item.connect('activate', function() {
item.connect('activate', () => {
indicator.set_label('', '');
})
menu.append(item);
Expand All @@ -112,18 +112,18 @@ app.connect("startup", function() {
menu.append(item);

item = Gtk.MenuItem.new_with_label("Hide for some time");
item.connect('activate', function() {
item.connect('activate', () => {
indicator.set_status(AppIndicator.IndicatorStatus.PASSIVE);
GLib.timeout_add(0, 5000, function() {
GLib.timeout_add(0, 5000, () => {
indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE);
return false;
});
});
menu.append(item);

item = Gtk.MenuItem.new_with_label("Close in 5 seconds");
item.connect('activate', function() {
GLib.timeout_add(0, 5000, function() {
item.connect('activate', () => {
GLib.timeout_add(0, 5000, () => {
app.quit();
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion statusNotifierWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var StatusNotifierWatcher = new Lang.Class({
this._nameWatcher = { };

this._seekStatusNotifierItems();
},
}

_acquiredName: function() {
this._everAcquiredName = true;
Expand Down
4 changes: 2 additions & 2 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const connectSmart3A = function(src, signal, handler) {
let id = src.connect(signal, handler)

if (src.connect && (!(src instanceof GObject.Object) || GObject.signal_lookup('destroy', src))) {
let destroy_id = src.connect('destroy', function() {
let destroy_id = src.connect('destroy', () => {
src.disconnect(id)
src.disconnect(destroy_id)
})
Expand Down Expand Up @@ -171,7 +171,7 @@ const connectSmart4A = function(src, signal, target, method) {
* Usage:
* Util.connectSmart(srcOb, 'signal', tgtObj, 'handler')
* or
* Util.connectSmart(srcOb, 'signal', function() { ... })
* Util.connectSmart(srcOb, 'signal', () => { ... })
*/
var connectSmart = function() {
if (arguments.length == 4)
Expand Down

0 comments on commit da4c63b

Please sign in to comment.