Change way title is handled in window.vala to avoid cyclic references

This commit is contained in:
oupson 2023-03-09 08:10:32 +01:00
parent ec55437898
commit e15dbaed1b
Signed by: oupson
GPG Key ID: 3BD88615552EFCB7
2 changed files with 10 additions and 7 deletions

View File

@ -30,14 +30,14 @@ namespace Footerm {
[GtkChild] [GtkChild]
private unowned Footerm.TerminalPane terminal_pane; private unowned Footerm.TerminalPane terminal_pane;
public signal void title_changed (string new_title); public signal void title_changed (Footerm.Pane pane, string new_title);
construct { construct {
this.new_pane.title_changed.connect ((s) => this.title_changed (s)); this.new_pane.title_changed.connect ((s) => this.title_changed (this, s));
this.new_pane.on_server_selected.connect ((s) => { this.new_pane.on_server_selected.connect ((s) => {
this.footerm_pane_stack.set_visible_child (this.terminal_pane); this.footerm_pane_stack.set_visible_child (this.terminal_pane);
this.title_changed (s.name); this.title_changed (this, s.name);
this.terminal_pane.title_changed.connect ((s) => this.title_changed (s)); this.terminal_pane.title_changed.connect ((s) => this.title_changed (this, s));
this.terminal_pane.connect_to_server_async (s); this.terminal_pane.connect_to_server_async (s);
}); });
} }

View File

@ -42,9 +42,12 @@ namespace Footerm {
var pane = new Footerm.Pane (); var pane = new Footerm.Pane ();
var tab_page = this.view.append (pane); var tab_page = this.view.append (pane);
tab_page.set_title ("New Pane"); tab_page.set_title ("New Pane");
pane.title_changed.connect ((title) => { pane.title_changed.connect (on_page_title_changed);
tab_page.set_title (title); }
});
private void on_page_title_changed (Footerm.Pane pane, string title) {
var tab_page = this.view.get_page (pane);
tab_page.set_title (title);
} }
private bool close_page (Adw.TabView tab_view, Adw.TabPage page) { private bool close_page (Adw.TabView tab_view, Adw.TabPage page) {