Change tab name

This commit is contained in:
oupson 2023-03-06 07:54:37 +01:00
parent ef8f570ba5
commit 533617d59f
Signed by: oupson
GPG Key ID: 3BD88615552EFCB7
3 changed files with 25 additions and 6 deletions

View File

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

View File

@ -37,6 +37,8 @@ namespace Footerm {
private int old_terminal_width = 0;
private int old_terminal_height = 0;
public signal void title_changed(string new_title);
construct {
this.configure_terminal();
}
@ -83,6 +85,13 @@ namespace Footerm {
this.terminal.set_enable_sixel(true);
this.terminal.char_size_changed.connect(this.terminal_appearance_changed);
this.terminal.contents_changed.connect(this.terminal_appearance_changed);
this.terminal.window_title_changed.connect((t) => {
var terminal_title = t.window_title;
if (terminal_title.length == 0) {
terminal_title = this.server.name;
}
this.title_changed(terminal_title);
});
this.setup_terminal_theme();
}

View File

@ -32,13 +32,19 @@ namespace Footerm {
this.view.close_page.connect (this.close_page);
var action = new SimpleAction ("new_tab", null);
action.activate.connect (() => {
var a = view.append (new Footerm.Pane ());
a.set_title ("New Pane");
view.set_selected_page (a);
this.create_new_pane ();
});
this.add_action (action);
var a = view.append (new Footerm.Pane ());
a.set_title ("New Pane");
this.create_new_pane ();
}
private void create_new_pane () {
var pane = new Footerm.Pane ();
var tab_page = this.view.append (pane);
tab_page.set_title ("New Pane");
pane.title_changed.connect ((title) => {
tab_page.set_title (title);
});
}
private bool close_page (Adw.TabView tab_view, Adw.TabPage page) {