mirror of https://github.com/oupson/FooTerm.git
Add tabs
This commit is contained in:
parent
b0d9a18006
commit
4591334702
|
@ -32,6 +32,7 @@ namespace Footerm {
|
||||||
};
|
};
|
||||||
this.add_action_entries (action_entries, this);
|
this.add_action_entries (action_entries, this);
|
||||||
this.set_accels_for_action ("app.quit", {"<primary>q"});
|
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 () {
|
public override void activate () {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/fr/oupson/FooTerm">
|
<gresource prefix="/fr/oupson/FooTerm">
|
||||||
<file preprocess="xml-stripblanks">window.ui</file>
|
<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">newpane.ui</file>
|
||||||
<file preprocess="xml-stripblanks">terminalpane.ui</file>
|
<file preprocess="xml-stripblanks">terminalpane.ui</file>
|
||||||
<file preprocess="xml-stripblanks">newserver.ui</file>
|
<file preprocess="xml-stripblanks">newserver.ui</file>
|
||||||
|
|
|
@ -2,6 +2,7 @@ footerm_sources = [
|
||||||
'main.vala',
|
'main.vala',
|
||||||
'application.vala',
|
'application.vala',
|
||||||
'window.vala',
|
'window.vala',
|
||||||
|
'pane.vala',
|
||||||
'newpane.vala',
|
'newpane.vala',
|
||||||
'newserver.vala',
|
'newserver.vala',
|
||||||
'terminalpane.vala',
|
'terminalpane.vala',
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<interface>
|
||||||
|
<template class="FooTermPane" parent="GtkBox">
|
||||||
|
|
||||||
|
</template>
|
||||||
|
</interface>
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,14 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHeaderBar" id="header_bar">
|
<object class="GtkHeaderBar" id="header_bar">
|
||||||
<child type="end">
|
<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">
|
<object class="GtkMenuButton">
|
||||||
<property name="icon-name">open-menu-symbolic</property>
|
<property name="icon-name">open-menu-symbolic</property>
|
||||||
<property name="menu-model">primary_menu</property>
|
<property name="menu-model">primary_menu</property>
|
||||||
|
@ -18,9 +26,17 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -42,4 +58,38 @@
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</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 you’re 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 you’re 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>
|
</interface>
|
||||||
|
|
|
@ -22,21 +22,21 @@ namespace Footerm {
|
||||||
[GtkTemplate (ui = "/fr/oupson/FooTerm/window.ui")]
|
[GtkTemplate (ui = "/fr/oupson/FooTerm/window.ui")]
|
||||||
public class Window : Adw.ApplicationWindow {
|
public class Window : Adw.ApplicationWindow {
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
private unowned Gtk.Box pane_content;
|
private unowned Adw.TabView view;
|
||||||
|
|
||||||
public Window (Gtk.Application app) {
|
public Window (Gtk.Application app) {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
}
|
}
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
var new_pane = new FooTerm.NewPane();
|
var action = new SimpleAction("new_tab", null);
|
||||||
ulong handler_id;
|
action.activate.connect (() => {
|
||||||
handler_id = new_pane.on_server_selected.connect((s) => {
|
var a = view.append (new FooTerm.Pane());
|
||||||
new_pane.disconnect (handler_id);
|
a.set_title ("New Pane");
|
||||||
pane_content.remove(new_pane);
|
|
||||||
pane_content.append(new FooTerm.TerminalPane(s));
|
|
||||||
});
|
});
|
||||||
pane_content.append(new_pane);
|
this.add_action (action);
|
||||||
|
var a = view.append (new FooTerm.Pane());
|
||||||
|
a.set_title ("New Pane");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue