Skip to content

Commit

Permalink
pathsViewer: Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
A6GibKm committed Mar 31, 2023
1 parent 1c67aff commit 7522827
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/widgets/pathsViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ var FlatsealPathsViewer = GObject.registerClass({
FlatsealOverrideStatus.ORIGINAL),
},
}, class FlatsealPathsViewer extends Gtk.Box {
rows = Array();
n_items = 0;

_init(rowClass) {
this._status = FlatsealOverrideStatus.ORIGINAL;
super._init({});
Expand All @@ -56,21 +53,17 @@ var FlatsealPathsViewer = GObject.registerClass({

_remove(row) {
this.remove(row);
this.n_items -= 1;
if (this.n_items == 0)
if (this.get_first_child() == null)
this.visible = false;

this._changed();
}

_update(text) {
for (let row of this.rows) {
this.rows = this.rows.filter((rowwy) => rowwy != row);
for (const row of this) {
this.remove(row);
this.n_items -= 1;
if (this.n_items == 0)
this.visible = false;
}
this.visible = false;
const paths = text.split(';');

paths.forEach(path => {
Expand All @@ -87,7 +80,7 @@ var FlatsealPathsViewer = GObject.registerClass({
const statuses = this._status
.split(';')
.filter(s => s.length !== 0);
const rows = Array.from(this.rows).reverse();
const rows = Array.from(this).reverse();

/* if it's still out of sync, bail out */
if (statuses.length !== rows.length)
Expand All @@ -99,7 +92,7 @@ var FlatsealPathsViewer = GObject.registerClass({
}

set text(text) {
if (this._box && text === '') {
if (text === '') {
this._update(text);
return;
}
Expand All @@ -112,19 +105,13 @@ var FlatsealPathsViewer = GObject.registerClass({
}

get text() {
if (!this._box)
return '';

return this.rows
.map((row) => row.text)
return Array.from(this)
.map(row => row.text)
.reverse()
.join(';');
}

set status(status) {
if (!this._box)
return;

this._status = status;
this._updateStatus();
}
Expand All @@ -139,9 +126,7 @@ var FlatsealPathsViewer = GObject.registerClass({
row.connect('remove-requested', this._remove.bind(this, row));
row.connect('notify::text', this._changed.bind(this));

this.rows.push(row);
this.append(row);
this.n_items += 1;
this.visible = true;
}
});

0 comments on commit 7522827

Please sign in to comment.