js: Remove unnecessary versions of clutter_actor_get_children
clutter_actor_get_children requires making a temporary GSList from a linked list structure, and then creating a JS Array from that GSList. For simple cases like the number of children, use clutter_actor_get_n_children. https://bugzilla.gnome.org/show_bug.cgi?id=677426
This commit is contained in:
parent
c7b4022283
commit
c9296191a8
@ -448,7 +448,7 @@ const Calendar = new Lang.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All the children after this are days, and get removed when we update the calendar
|
// All the children after this are days, and get removed when we update the calendar
|
||||||
this._firstDayIndex = this.actor.get_children().length;
|
this._firstDayIndex = this.actor.get_n_children();
|
||||||
},
|
},
|
||||||
|
|
||||||
_onStyleChange: function(actor, event) {
|
_onStyleChange: function(actor, event) {
|
||||||
|
@ -31,7 +31,6 @@ const St = imports.gi.St;
|
|||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
|
|
||||||
const GnomeSession = imports.misc.gnomeSession;
|
const GnomeSession = imports.misc.gnomeSession;
|
||||||
const Lightbox = imports.ui.lightbox;
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const ModalDialog = imports.ui.modalDialog;
|
const ModalDialog = imports.ui.modalDialog;
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
@ -288,13 +287,13 @@ const EndSessionDialog = new Lang.Class({
|
|||||||
|
|
||||||
this._applicationList.connect('actor-added',
|
this._applicationList.connect('actor-added',
|
||||||
Lang.bind(this, function() {
|
Lang.bind(this, function() {
|
||||||
if (this._applicationList.get_children().length == 1)
|
if (this._applicationList.get_n_children() == 1)
|
||||||
scrollView.show();
|
scrollView.show();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._applicationList.connect('actor-removed',
|
this._applicationList.connect('actor-removed',
|
||||||
Lang.bind(this, function() {
|
Lang.bind(this, function() {
|
||||||
if (this._applicationList.get_children().length == 0)
|
if (this._applicationList.get_n_children() == 0)
|
||||||
scrollView.hide();
|
scrollView.hide();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -309,10 +309,8 @@ const IconGrid = new Lang.Class({
|
|||||||
this._grid.queue_relayout();
|
this._grid.queue_relayout();
|
||||||
},
|
},
|
||||||
|
|
||||||
removeAll: function () {
|
removeAll: function() {
|
||||||
this._grid.get_children().forEach(Lang.bind(this, function (child) {
|
this._grid.destroy_all_children();
|
||||||
child.destroy();
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addItem: function(actor) {
|
addItem: function(actor) {
|
||||||
@ -320,10 +318,10 @@ const IconGrid = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getItemAtIndex: function(index) {
|
getItemAtIndex: function(index) {
|
||||||
return this._grid.get_children()[index];
|
return this._grid.get_child_at_index(index);
|
||||||
},
|
},
|
||||||
|
|
||||||
visibleItemsCount: function() {
|
visibleItemsCount: function() {
|
||||||
return this._grid.get_children().length - this._grid.get_n_skip_paint();
|
return this._grid.get_n_children() - this._grid.get_n_skip_paint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ var commandHeader = 'const Clutter = imports.gi.Clutter; ' +
|
|||||||
'const stage = global.stage; ' +
|
'const stage = global.stage; ' +
|
||||||
'const color = function(pixel) { let c= new Clutter.Color(); c.from_pixel(pixel); return c; }; ' +
|
'const color = function(pixel) { let c= new Clutter.Color(); c.from_pixel(pixel); return c; }; ' +
|
||||||
/* Special lookingGlass functions */
|
/* Special lookingGlass functions */
|
||||||
'const it = Main.lookingGlass.getIt(); ' +
|
'const it = Main.lookingGlass.getIt(); ' +
|
||||||
'const r = Lang.bind(Main.lookingGlass, Main.lookingGlass.getResult); ';
|
'const r = Lang.bind(Main.lookingGlass, Main.lookingGlass.getResult); ';
|
||||||
|
|
||||||
const HISTORY_KEY = 'looking-glass-history';
|
const HISTORY_KEY = 'looking-glass-history';
|
||||||
@ -320,7 +320,7 @@ const WindowList = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateWindowList: function() {
|
_updateWindowList: function() {
|
||||||
this.actor.get_children().forEach(function (actor) { actor.destroy(); });
|
this.actor.destroy_all_children();
|
||||||
let windows = global.get_window_actors();
|
let windows = global.get_window_actors();
|
||||||
let tracker = Shell.WindowTracker.get_default();
|
let tracker = Shell.WindowTracker.get_default();
|
||||||
for (let i = 0; i < windows.length; i++) {
|
for (let i = 0; i < windows.length; i++) {
|
||||||
@ -378,7 +378,7 @@ const ObjInspector = new Lang.Class({
|
|||||||
this._previousObj = null;
|
this._previousObj = null;
|
||||||
this._obj = obj;
|
this._obj = obj;
|
||||||
|
|
||||||
this._container.get_children().forEach(function (child) { child.destroy(); });
|
this._container.destroy_all_children();
|
||||||
|
|
||||||
let hbox = new St.BoxLayout({ style_class: 'lg-obj-inspector-title' });
|
let hbox = new St.BoxLayout({ style_class: 'lg-obj-inspector-title' });
|
||||||
this._container.add_actor(hbox);
|
this._container.add_actor(hbox);
|
||||||
|
@ -756,7 +756,7 @@ const Notification = new Lang.Class({
|
|||||||
button.label = label;
|
button.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._buttonBox.get_children().length > 0)
|
if (this._buttonBox.get_n_children() > 0)
|
||||||
this._buttonFocusManager.remove_group(this._buttonBox);
|
this._buttonFocusManager.remove_group(this._buttonBox);
|
||||||
|
|
||||||
this._buttonBox.add(button);
|
this._buttonBox.add(button);
|
||||||
@ -1284,7 +1284,7 @@ const SummaryItem = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
prepareNotificationStackForShowing: function() {
|
prepareNotificationStackForShowing: function() {
|
||||||
if (this.notificationStack.get_children().length > 0)
|
if (this.notificationStack.get_n_children() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (let i = 0; i < this.source.notifications.length; i++) {
|
for (let i = 0; i < this.source.notifications.length; i++) {
|
||||||
@ -1293,7 +1293,6 @@ const SummaryItem = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
doneShowingNotificationStack: function() {
|
doneShowingNotificationStack: function() {
|
||||||
let notificationActors = this.notificationStack.get_children();
|
|
||||||
for (let i = 0; i < this._stackedNotifications.length; i++) {
|
for (let i = 0; i < this._stackedNotifications.length; i++) {
|
||||||
let stackedNotification = this._stackedNotifications[i];
|
let stackedNotification = this._stackedNotifications[i];
|
||||||
let notification = stackedNotification.notification;
|
let notification = stackedNotification.notification;
|
||||||
@ -1323,7 +1322,7 @@ const SummaryItem = new Lang.Class({
|
|||||||
this._stackedNotifications.push(stackedNotification);
|
this._stackedNotifications.push(stackedNotification);
|
||||||
if (!this.source.isChat)
|
if (!this.source.isChat)
|
||||||
notification.enableScrolling(false);
|
notification.enableScrolling(false);
|
||||||
if (this.notificationStack.get_children().length > 0)
|
if (this.notificationStack.get_n_children() > 0)
|
||||||
notification.setIconVisible(false);
|
notification.setIconVisible(false);
|
||||||
this.notificationStack.add(notification.actor);
|
this.notificationStack.add(notification.actor);
|
||||||
notification.expand(false);
|
notification.expand(false);
|
||||||
@ -2436,7 +2435,7 @@ const MessageTray = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onSummaryBoxPointerContentUpdated: function() {
|
_onSummaryBoxPointerContentUpdated: function() {
|
||||||
if (this._summaryBoxPointerItem.notificationStack.get_children().length == 0)
|
if (this._summaryBoxPointerItem.notificationStack.get_n_children() == 0)
|
||||||
this._hideSummaryBoxPointer();
|
this._hideSummaryBoxPointer();
|
||||||
this._adjustSummaryBoxPointerPosition();
|
this._adjustSummaryBoxPointerPosition();
|
||||||
|
|
||||||
@ -2470,7 +2469,7 @@ const MessageTray = new Lang.Class({
|
|||||||
// We should be sure to hide the box pointer if all notifications in it are destroyed while
|
// We should be sure to hide the box pointer if all notifications in it are destroyed while
|
||||||
// it is hiding, so that we don't show an an animation of an empty blob being hidden.
|
// it is hiding, so that we don't show an an animation of an empty blob being hidden.
|
||||||
if (this._summaryBoxPointerState == State.HIDING &&
|
if (this._summaryBoxPointerState == State.HIDING &&
|
||||||
this._summaryBoxPointerItem.notificationStack.get_children().length == 0) {
|
this._summaryBoxPointerItem.notificationStack.get_n_children() == 0) {
|
||||||
this._summaryBoxPointer.actor.hide();
|
this._summaryBoxPointer.actor.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ const AppDisplay = imports.ui.appDisplay;
|
|||||||
const ContactDisplay = imports.ui.contactDisplay;
|
const ContactDisplay = imports.ui.contactDisplay;
|
||||||
const Dash = imports.ui.dash;
|
const Dash = imports.ui.dash;
|
||||||
const DND = imports.ui.dnd;
|
const DND = imports.ui.dnd;
|
||||||
const Lightbox = imports.ui.lightbox;
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const MessageTray = imports.ui.messageTray;
|
const MessageTray = imports.ui.messageTray;
|
||||||
const Panel = imports.ui.panel;
|
const Panel = imports.ui.panel;
|
||||||
|
@ -906,7 +906,7 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
isEmpty: function() {
|
isEmpty: function() {
|
||||||
return this.box.get_children().length == 0;
|
return this.box.get_n_children() == 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
isChildMenu: function(menu) {
|
isChildMenu: function(menu) {
|
||||||
|
@ -51,7 +51,7 @@ const SearchResultDisplay = new Lang.Class({
|
|||||||
* Remove all results from this display.
|
* Remove all results from this display.
|
||||||
*/
|
*/
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.actor.get_children().forEach(function (actor) { actor.destroy(); });
|
this.actor.destroy_all_children();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,13 +347,13 @@ const ShellProcessesDialog = new Lang.Class({
|
|||||||
|
|
||||||
this._applicationList.connect('actor-added',
|
this._applicationList.connect('actor-added',
|
||||||
Lang.bind(this, function() {
|
Lang.bind(this, function() {
|
||||||
if (this._applicationList.get_children().length == 1)
|
if (this._applicationList.get_n_children() == 1)
|
||||||
scrollView.show();
|
scrollView.show();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._applicationList.connect('actor-removed',
|
this._applicationList.connect('actor-removed',
|
||||||
Lang.bind(this, function() {
|
Lang.bind(this, function() {
|
||||||
if (this._applicationList.get_children().length == 0)
|
if (this._applicationList.get_n_children() == 0)
|
||||||
scrollView.hide();
|
scrollView.hide();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
@ -802,7 +802,7 @@ const ChatNotification = new Lang.Class({
|
|||||||
let groups = this._contentArea.get_children();
|
let groups = this._contentArea.get_children();
|
||||||
for (let i = 0; i < groups.length; i++) {
|
for (let i = 0; i < groups.length; i++) {
|
||||||
let group = groups[i];
|
let group = groups[i];
|
||||||
if (group.get_children().length == 0)
|
if (group.get_n_children() == 0)
|
||||||
group.destroy();
|
group.destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user