Use connectObject() and adopt to style in search.js

This commit is contained in:
Bruce Leidl 2022-11-13 09:15:36 -05:00
parent b02a173a69
commit ef436c6ffb

View File

@ -17,16 +17,22 @@ class RealmProviderInfo extends St.Button {
y_align: Clutter.ActorAlign.START, y_align: Clutter.ActorAlign.START,
}); });
this._content = new St.BoxLayout({ vertical: false, this._content = new St.BoxLayout({
style_class: 'list-search-provider-content' }); vertical: false,
style_class: 'list-search-provider-content'
});
this.set_child(this._content); this.set_child(this._content);
let icon = new St.Icon({ icon_size: this.PROVIDER_ICON_SIZE, let icon = new St.Icon({
icon_name: 'computer' }); icon_size: this.PROVIDER_ICON_SIZE,
icon_name: 'computer'
});
let detailsBox = new St.BoxLayout({ style_class: 'list-search-provider-details', let detailsBox = new St.BoxLayout({
style_class: 'list-search-provider-details',
vertical: true, vertical: true,
x_expand: true }); x_expand: true
});
let nameLabel = new St.Label({ let nameLabel = new St.Label({
text: "Realms", text: "Realms",
@ -72,8 +78,6 @@ class ListSearchResult extends Search.SearchResult {
}); });
this.set_child(content); this.set_child(content);
this._termsChangedId = 0;
let titleBox = new St.BoxLayout({ let titleBox = new St.BoxLayout({
style_class: 'list-search-result-title', style_class: 'list-search-result-title',
y_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER,
@ -104,13 +108,16 @@ class ListSearchResult extends Search.SearchResult {
this._descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; this._descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
content.add_child(this._descriptionLabel); content.add_child(this._descriptionLabel);
this._termsChangedId = this._resultsView.connectObject(
this._resultsView.connect('terms-changed', 'terms-changed', this._highlightTerms.bind(this), this);
this._highlightTerms.bind(this));
this._highlightTerms(); this._highlightTerms();
} }
this._createConfigButton(content);
}
_createConfigButton(content) {
let id = this.metaInfo['id']; let id = this.metaInfo['id'];
if (id != ':new:') { if (id != ':new:') {
@ -129,10 +136,9 @@ class ListSearchResult extends Search.SearchResult {
Main.overview.toggle(); Main.overview.toggle();
Util.spawn(['/usr/libexec/realm-config-ui', id]); Util.spawn(['/usr/libexec/realm-config-ui', id]);
}); });
content.add_child(this.configButton); content.add_child(this.configButton);
} }
this.connect('destroy', this._onDestroy.bind(this));
} }
get ICON_SIZE() { get ICON_SIZE() {
@ -143,12 +149,6 @@ class ListSearchResult extends Search.SearchResult {
let markup = this._resultsView.highlightTerms(this.metaInfo['description'].split('\n')[0]); let markup = this._resultsView.highlightTerms(this.metaInfo['description'].split('\n')[0]);
this._descriptionLabel.clutter_text.set_markup(markup); this._descriptionLabel.clutter_text.set_markup(markup);
} }
_onDestroy() {
if (this._termsChangedId)
this._resultsView.disconnect(this._termsChangedId);
this._termsChangedId = 0;
}
}); });
// Based on ListSearchResults in search.js // Based on ListSearchResults in search.js
@ -203,7 +203,6 @@ class RealmSearchResults extends Search.SearchResultsBase {
else else
return null; return null;
} }
}); });
var RealmSearchProvider = class RealmSearchProvider { var RealmSearchProvider = class RealmSearchProvider {