This commit is contained in:
oupson 2023-02-26 22:37:55 +01:00
parent b0d9a18006
commit 4591334702
Signed by: oupson
GPG Key ID: 3BD88615552EFCB7
7 changed files with 106 additions and 13 deletions

View File

@ -32,6 +32,7 @@ namespace Footerm {
};
this.add_action_entries (action_entries, this);
this.set_accels_for_action ("app.quit", {"<primary>q"});
this.set_accels_for_action ("win.new_tab", { "<Control><Shift>T", null });
}
public override void activate () {

View File

@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/fr/oupson/FooTerm">
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">pane.ui</file>
<file preprocess="xml-stripblanks">newpane.ui</file>
<file preprocess="xml-stripblanks">terminalpane.ui</file>
<file preprocess="xml-stripblanks">newserver.ui</file>

View File

@ -2,6 +2,7 @@ footerm_sources = [
'main.vala',
'application.vala',
'window.vala',
'pane.vala',
'newpane.vala',
'newserver.vala',
'terminalpane.vala',

5
src/pane.ui Normal file
View File

@ -0,0 +1,5 @@
<interface>
<template class="FooTermPane" parent="GtkBox">
</template>
</interface>

35
src/pane.vala Normal file
View File

@ -0,0 +1,35 @@
/* pane.vala
*
* Copyright 2023 oupson
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace FooTerm {
[GtkTemplate (ui = "/fr/oupson/FooTerm/pane.ui")]
public class Pane : Gtk.Box {
construct {
var new_pane = new FooTerm.NewPane();
ulong handler_id;
handler_id = new_pane.on_server_selected.connect((s) => {
new_pane.disconnect (handler_id);
this.remove(new_pane);
this.append(new FooTerm.TerminalPane(s));
});
this.append(new_pane);
}
}
}

View File

@ -11,6 +11,14 @@
<child>
<object class="GtkHeaderBar" id="header_bar">
<child type="end">
<object class="GtkBox">
<child>
<object class="GtkButton">
<property name="icon-name">tab-new-symbolic</property>
<property name="action-name">win.new_tab</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
@ -18,9 +26,17 @@
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="pane_content">
<object class="AdwTabBar" id="tab_bar">
<property name="view">view</property>
</object>
</child>
<child>
<object class="AdwTabView" id="view">
<property name="vexpand">True</property>
<property name="menu-model">tab_menu</property>
</object>
</child>
</object>
@ -42,4 +58,38 @@
</item>
</section>
</menu>
<menu id="tab_menu">
<section>
<item>
<attribute name="label" translatable="yes">P_in Tab</attribute>
<attribute name="action">tab.pin</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Unp_in Tab</attribute>
<attribute name="action">tab.unpin</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Close _Other Tabs</attribute>
<attribute name="action">tab.close-other</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Translators: “Close Tabs to the _Right” if youre translating for a language that reads from right to left">Close Tabs to the _Left</attribute>
<attribute name="action">tab.close-before</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Translators: “Close Tabs to the _Left” if youre translating for a language that reads from right to left">Close Tabs to the _Right</attribute>
<attribute name="action">tab.close-after</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Close</attribute>
<attribute name="action">tab.close</attribute>
</item>
</section>
</menu>
</interface>

View File

@ -22,21 +22,21 @@ namespace Footerm {
[GtkTemplate (ui = "/fr/oupson/FooTerm/window.ui")]
public class Window : Adw.ApplicationWindow {
[GtkChild]
private unowned Gtk.Box pane_content;
private unowned Adw.TabView view;
public Window (Gtk.Application app) {
Object (application: app);
}
construct {
var new_pane = new FooTerm.NewPane();
ulong handler_id;
handler_id = new_pane.on_server_selected.connect((s) => {
new_pane.disconnect (handler_id);
pane_content.remove(new_pane);
pane_content.append(new FooTerm.TerminalPane(s));
var action = new SimpleAction("new_tab", null);
action.activate.connect (() => {
var a = view.append (new FooTerm.Pane());
a.set_title ("New Pane");
});
pane_content.append(new_pane);
this.add_action (action);
var a = view.append (new FooTerm.Pane());
a.set_title ("New Pane");
}
}
}