[gnome-maps/wip/mlundblad/cleanup-gtk-deprecations: 8/8] transitItineraryRow: Stop using GtkContainer add method
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/cleanup-gtk-deprecations: 8/8] transitItineraryRow: Stop using GtkContainer add method
- Date: Fri, 26 Mar 2021 21:43:35 +0000 (UTC)
commit f892ed09a8e95da3b4f5b2a7cf9c374636f01f18
Author: Marcus Lundblad <ml update uu se>
Date: Fri Mar 26 22:41:53 2021 +0100
transitItineraryRow: Stop using GtkContainer add method
In preparation for GTK 4 use class-specific methods
to add and remove children when possible.
src/transitItineraryRow.js | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/src/transitItineraryRow.js b/src/transitItineraryRow.js
index 8d97e8cf..0ec2db3f 100644
--- a/src/transitItineraryRow.js
+++ b/src/transitItineraryRow.js
@@ -66,27 +66,39 @@ var TransitItineraryRow = GObject.registerClass({
/* ellipsize list with horizontal dots to avoid overflowing and
* expanding the sidebar
*/
- this._renderLegs(this._itinerary.legs.slice(0, MAX_LEGS_SHOWN / 2),
- true, true);
- this._summaryGrid.add(new Gtk.Label({ visible: true,
- label: '\u22ef' } ));
- this._renderLegs(this._itinerary.legs.slice(-MAX_LEGS_SHOWN / 2),
- true, true);
+ let firstPart = this._itinerary.legs.slice(0, MAX_LEGS_SHOWN / 2);
+ let lastPart = this._itinerary.legs.slice(-MAX_LEGS_SHOWN / 2);
+
+ this._renderLegs(firstPart, 0, true, true);
+ this._summaryGrid.attach(new Gtk.Label({ visible: true,
+ label: '\u22ef' } ),
+ firstPart.length * 2, 0, 1, 1);
+ this._renderLegs(lastPart, firstPart.length * 2 + 1, true, true);
} else {
- this._renderLegs(this._itinerary.legs, useCompact,
+ this._renderLegs(this._itinerary.legs, 0, useCompact,
useContractedLabels);
}
}
- _renderLegs(legs, useCompact, useContractedLabels) {
+ /*
+ * Render a list of legs.
+ * legs: array of legs to render
+ * startPosition: start position in grid to render at
+ * useCompact: true if compact rendering (without route designations)
+ * useContractedLabels: true to use contracted route labels, if possible
+ */
+ _renderLegs(legs, startPosition, useCompact, useContractedLabels) {
let length = legs.length;
legs.forEach((leg, i) => {
- this._summaryGrid.add(this._createLeg(leg, useCompact,
- useContractedLabels));
+ this._summaryGrid.attach(this._createLeg(leg, useCompact,
+ useContractedLabels),
+ startPosition + i * 2, 0, 1, 1);
+ // render a separator label unless the last leg to render
if (i !== length - 1)
- this._summaryGrid.add(new Gtk.Label({ visible: true,
- label: '-' }));
+ this._summaryGrid.attach(new Gtk.Label({ visible: true,
+ label: '-' }),
+ startPosition + i * 2 + 1, 0, 1, 1);
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]