Codebase list gnome-shell-extension-appindicator / da4c63b
appIndicators: use arrow functions in lambdas Marco Trevisan (TreviƱo) authored 5 years ago Marco Trevisan committed 5 years ago
6 changed file(s) with 33 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
6565 g_name: bus_name,
6666 g_object_path: object,
6767 g_flags: Gio.DBusProxyFlags.GET_INVALIDATED_PROPERTIES })
68 this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, (function(initable, result) {
68 this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, ((initable, result) => {
6969 try {
7070 initable.init_finish(result);
7171
7474 } catch(e) {
7575 Util.Logger.warn("While intializing proxy for "+bus_name+object+": "+e)
7676 }
77 }).bind(this))
77 }))
7878
7979 this._proxyPropertyList = interface_info.properties.map((propinfo) => { return propinfo.name })
8080 this._addExtraProperty('XAyatanaLabel');
165165 _onPropertiesChanged: function(proxy, changed, invalidated) {
166166 let props = Object.keys(changed.deep_unpack())
167167
168 props.forEach(function(property) {
168 props.forEach((property) => {
169169 // some property changes require updates on our part,
170170 // a few need to be passed down to the displaying code
171171
307307 // we try to avoid messing with the default icon theme, so we'll create a new one if needed
308308 if (themePath) {
309309 var icon_theme = new Gtk.IconTheme()
310 Gtk.IconTheme.get_default().get_search_path().forEach(function(path) {
310 Gtk.IconTheme.get_default().get_search_path().forEach((path) => {
311311 icon_theme.append_search_path(path)
312312 });
313313 icon_theme.append_search_path(themePath)
356356 if (!iconPixmapArray || iconPixmapArray.length < 1)
357357 return null
358358
359 let sortedIconPixmapArray = iconPixmapArray.sort(function(pixmapA, pixmapB) {
359 let sortedIconPixmapArray = iconPixmapArray.sort((pixmapA, pixmapB) => {
360360 // we sort biggest to smallest
361361 let areaA = pixmapA[0] * pixmapA[1]
362362 let areaB = pixmapB[0] * pixmapB[1]
364364 return areaB - areaA
365365 })
366366
367 let qualifiedIconPixmapArray = sortedIconPixmapArray.filter(function(pixmap) {
367 let qualifiedIconPixmapArray = sortedIconPixmapArray.filter((pixmap) => {
368368 // we disqualify any pixmap that is bigger than our requested size
369369 return pixmap[0] <= iconSize && pixmap[1] <= iconSize
370370 })
177177 },
178178
179179 get_children: function() {
180 return this._children_ids.map(function(el) {
180 return this._children_ids.map((el) => {
181181 return this._client.get_item(el)
182182 }, this)
183183 },
237237 if (this._propertiesRequestedFor.length < 1)
238238 GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, this._beginRequestProperties.bind(this))
239239
240 if (this._propertiesRequestedFor.filter(function(e) { return e === id }).length == 0)
240 if (this._propertiesRequestedFor.filter((e) => { return e === id }).length == 0)
241241 this._propertiesRequestedFor.push(id)
242242
243243 },
257257 }
258258
259259 // for some funny reason, the result array is hidden in an array
260 result[0].forEach(function([id, properties]) {
260 result[0].forEach(([id, properties]) => {
261261 if (!(id in this._items))
262262 return
263263
313313 _doLayoutUpdate: function(item) {
314314 let [ id, properties, children ] = item
315315
316 let children_unpacked = children.map(function(child) { return child.deep_unpack() })
317 let children_ids = children_unpacked.map(function(child) { return child[0] })
316 let children_unpacked = children.map((child) => { return child.deep_unpack() })
317 let children_ids = children_unpacked.map((child) => { return child[0] })
318318
319319 // make sure all our children exist
320320 children_unpacked.forEach(this._doLayoutUpdate, this)
348348 }
349349
350350 // remove any old children that weren't reused
351 old_children_ids.forEach(function(child_id) { this._items[id].remove_child(child_id) }, this)
351 old_children_ids.forEach((child_id) => { this._items[id].remove_child(child_id) }, this)
352352 } else {
353353 // we don't, so let's create us
354354 this._items[id] = new DbusMenuItem(this, id, properties, children_ids)
381381
382382 // we don't need to cache and burst-send that since it will not happen that frequently
383383 send_about_to_show: function(id) {
384 this._proxy.AboutToShowRemote(id, (function(result, error) {
384 this._proxy.AboutToShowRemote(id, ((result, error) => {
385385 if (error)
386386 Util.Logger.warn("while calling AboutToShow: "+error)
387387 else if (result && result[0])
388388 this._requestLayoutUpdate()
389 }).bind(this))
389 }))
390390 },
391391
392392 send_event: function(id, event, params, timestamp) {
401401 },
402402
403403 _onPropertiesUpdated: function(proxy, name, [changed, removed]) {
404 changed.forEach(function([id, props]) {
404 changed.forEach(([id, props]) => {
405405 if (!(id in this._items))
406406 return
407407
408408 for (let prop in props)
409409 this._items[id].property_set(prop, props[prop])
410410 }, this)
411 removed.forEach(function([id, propNames]) {
411 removed.forEach(([id, propNames]) => {
412412 if (!(id in this._items))
413413 return
414414
415 propNames.forEach(function(propName) {
415 propNames.forEach((propName) => {
416416 this._items[id].property_set(propName, null)
417417 }, this)
418418 }, this)
555555 MenuItemFactory._replaceSelf.call(this)
556556 } else {
557557 // find it!
558 this.menu._getMenuItems().forEach(function(item) {
558 this.menu._getMenuItems().forEach((item) => {
559559 if (item._dbusItem == child)
560560 item.destroy()
561561 })
702702 this._rootItem.send_about_to_show()
703703
704704 // fill the menu for the first time
705 this._rootItem.get_children().forEach(function(child) {
705 this._rootItem.get_children().forEach((child) => {
706706 this._rootMenu.addMenuItem(MenuItemFactory.createItem(this, child))
707707 }, this)
708708 },
730730 _onRootChildRemoved: function(dbusItem, child) {
731731 // children like to play hide and seek
732732 // but we know how to find it for sure!
733 this._rootMenu._getMenuItems().forEach(function(item) {
733 this._rootMenu._getMenuItems().forEach((item) => {
734734 if (item._dbusItem == child)
735735 item.destroy()
736736 })
3333 if (typeof global['--appindicator-extension-on-reload'] == 'function')
3434 global['--appindicator-extension-on-reload']()
3535
36 global['--appindicator-extension-on-reload'] = function() {
36 global['--appindicator-extension-on-reload'] = () => {
3737 Util.Logger.debug("Reload detected, destroying old watchdog")
3838 NameWatchdog.destroy()
3939 }
88 const AppIndicator = imports.gi.AppIndicator3;
99 const GLib = imports.gi.GLib;
1010
11 (function() {
11 (() => {
1212
1313 var app = new Gtk.Application({
1414 application_id: null
1616
1717 var window = null;
1818
19 app.connect("activate", function(){
19 app.connect("activate", () => {
2020 window.present();
2121 });
2222
23 app.connect("startup", function() {
23 app.connect("startup", () => {
2424 window = new Gtk.ApplicationWindow({
2525 title: "test",
2626 application: app
9696 menu.append(item);
9797
9898 item = Gtk.MenuItem.new_with_label("Set Label");
99 item.connect('activate', function() {
99 item.connect('activate', () => {
100100 indicator.set_label(''+new Date().getSeconds(), 'Blub');
101101 });
102102 menu.append(item);
103103
104104 item = Gtk.MenuItem.new_with_label("Unset Label");
105 item.connect('activate', function() {
105 item.connect('activate', () => {
106106 indicator.set_label('', '');
107107 })
108108 menu.append(item);
111111 menu.append(item);
112112
113113 item = Gtk.MenuItem.new_with_label("Hide for some time");
114 item.connect('activate', function() {
114 item.connect('activate', () => {
115115 indicator.set_status(AppIndicator.IndicatorStatus.PASSIVE);
116 GLib.timeout_add(0, 5000, function() {
116 GLib.timeout_add(0, 5000, () => {
117117 indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE);
118118 return false;
119119 });
121121 menu.append(item);
122122
123123 item = Gtk.MenuItem.new_with_label("Close in 5 seconds");
124 item.connect('activate', function() {
125 GLib.timeout_add(0, 5000, function() {
124 item.connect('activate', () => {
125 GLib.timeout_add(0, 5000, () => {
126126 app.quit();
127127 return false;
128128 });
5858 this._nameWatcher = { };
5959
6060 this._seekStatusNotifierItems();
61 },
61 }
6262
6363 _acquiredName: function() {
6464 this._everAcquiredName = true;
136136 let id = src.connect(signal, handler)
137137
138138 if (src.connect && (!(src instanceof GObject.Object) || GObject.signal_lookup('destroy', src))) {
139 let destroy_id = src.connect('destroy', function() {
139 let destroy_id = src.connect('destroy', () => {
140140 src.disconnect(id)
141141 src.disconnect(destroy_id)
142142 })
170170 * Usage:
171171 * Util.connectSmart(srcOb, 'signal', tgtObj, 'handler')
172172 * or
173 * Util.connectSmart(srcOb, 'signal', function() { ... })
173 * Util.connectSmart(srcOb, 'signal', () => { ... })
174174 */
175175 var connectSmart = function() {
176176 if (arguments.length == 4)