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:
Jasper St. Pierre 2012-05-29 20:36:45 -04:00
parent c7b4022283
commit c9296191a8
10 changed files with 20 additions and 25 deletions

View File

@ -448,7 +448,7 @@ const Calendar = new Lang.Class({
}
// 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) {

View File

@ -31,7 +31,6 @@ const St = imports.gi.St;
const Shell = imports.gi.Shell;
const GnomeSession = imports.misc.gnomeSession;
const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main;
const ModalDialog = imports.ui.modalDialog;
const Tweener = imports.ui.tweener;
@ -288,13 +287,13 @@ const EndSessionDialog = new Lang.Class({
this._applicationList.connect('actor-added',
Lang.bind(this, function() {
if (this._applicationList.get_children().length == 1)
if (this._applicationList.get_n_children() == 1)
scrollView.show();
}));
this._applicationList.connect('actor-removed',
Lang.bind(this, function() {
if (this._applicationList.get_children().length == 0)
if (this._applicationList.get_n_children() == 0)
scrollView.hide();
}));

View File

@ -310,9 +310,7 @@ const IconGrid = new Lang.Class({
},
removeAll: function() {
this._grid.get_children().forEach(Lang.bind(this, function (child) {
child.destroy();
}));
this._grid.destroy_all_children();
},
addItem: function(actor) {
@ -320,10 +318,10 @@ const IconGrid = new Lang.Class({
},
getItemAtIndex: function(index) {
return this._grid.get_children()[index];
return this._grid.get_child_at_index(index);
},
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();
}
});

View File

@ -320,7 +320,7 @@ const WindowList = new Lang.Class({
},
_updateWindowList: function() {
this.actor.get_children().forEach(function (actor) { actor.destroy(); });
this.actor.destroy_all_children();
let windows = global.get_window_actors();
let tracker = Shell.WindowTracker.get_default();
for (let i = 0; i < windows.length; i++) {
@ -378,7 +378,7 @@ const ObjInspector = new Lang.Class({
this._previousObj = null;
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' });
this._container.add_actor(hbox);

View File

@ -756,7 +756,7 @@ const Notification = new Lang.Class({
button.label = label;
}
if (this._buttonBox.get_children().length > 0)
if (this._buttonBox.get_n_children() > 0)
this._buttonFocusManager.remove_group(this._buttonBox);
this._buttonBox.add(button);
@ -1284,7 +1284,7 @@ const SummaryItem = new Lang.Class({
},
prepareNotificationStackForShowing: function() {
if (this.notificationStack.get_children().length > 0)
if (this.notificationStack.get_n_children() > 0)
return;
for (let i = 0; i < this.source.notifications.length; i++) {
@ -1293,7 +1293,6 @@ const SummaryItem = new Lang.Class({
},
doneShowingNotificationStack: function() {
let notificationActors = this.notificationStack.get_children();
for (let i = 0; i < this._stackedNotifications.length; i++) {
let stackedNotification = this._stackedNotifications[i];
let notification = stackedNotification.notification;
@ -1323,7 +1322,7 @@ const SummaryItem = new Lang.Class({
this._stackedNotifications.push(stackedNotification);
if (!this.source.isChat)
notification.enableScrolling(false);
if (this.notificationStack.get_children().length > 0)
if (this.notificationStack.get_n_children() > 0)
notification.setIconVisible(false);
this.notificationStack.add(notification.actor);
notification.expand(false);
@ -2436,7 +2435,7 @@ const MessageTray = new Lang.Class({
},
_onSummaryBoxPointerContentUpdated: function() {
if (this._summaryBoxPointerItem.notificationStack.get_children().length == 0)
if (this._summaryBoxPointerItem.notificationStack.get_n_children() == 0)
this._hideSummaryBoxPointer();
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
// it is hiding, so that we don't show an an animation of an empty blob being hidden.
if (this._summaryBoxPointerState == State.HIDING &&
this._summaryBoxPointerItem.notificationStack.get_children().length == 0) {
this._summaryBoxPointerItem.notificationStack.get_n_children() == 0) {
this._summaryBoxPointer.actor.hide();
return;
}

View File

@ -14,7 +14,6 @@ const AppDisplay = imports.ui.appDisplay;
const ContactDisplay = imports.ui.contactDisplay;
const Dash = imports.ui.dash;
const DND = imports.ui.dnd;
const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const Panel = imports.ui.panel;

View File

@ -906,7 +906,7 @@ const PopupMenuBase = new Lang.Class({
},
isEmpty: function() {
return this.box.get_children().length == 0;
return this.box.get_n_children() == 0;
},
isChildMenu: function(menu) {

View File

@ -51,7 +51,7 @@ const SearchResultDisplay = new Lang.Class({
* Remove all results from this display.
*/
clear: function() {
this.actor.get_children().forEach(function (actor) { actor.destroy(); });
this.actor.destroy_all_children();
},
/**

View File

@ -347,13 +347,13 @@ const ShellProcessesDialog = new Lang.Class({
this._applicationList.connect('actor-added',
Lang.bind(this, function() {
if (this._applicationList.get_children().length == 1)
if (this._applicationList.get_n_children() == 1)
scrollView.show();
}));
this._applicationList.connect('actor-removed',
Lang.bind(this, function() {
if (this._applicationList.get_children().length == 0)
if (this._applicationList.get_n_children() == 0)
scrollView.hide();
}));
},

View File

@ -802,7 +802,7 @@ const ChatNotification = new Lang.Class({
let groups = this._contentArea.get_children();
for (let i = 0; i < groups.length; i++) {
let group = groups[i];
if (group.get_children().length == 0)
if (group.get_n_children() == 0)
group.destroy();
}
},