Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vhdirk committed Jan 26, 2024
1 parent 2063073 commit 6662d2a
Show file tree
Hide file tree
Showing 31 changed files with 756 additions and 385 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Terms uses GTK4 and is written in Rust. The latter has no added value aside from
- [x] Settings
- [x] Theming. Compatible with Gogh
- [x] Flatpak support
- [x] Shortcuts
- [ ] Tabs
- [ ] Tiling
- [ ] Profiles
Expand Down
29 changes: 21 additions & 8 deletions data/io.github.vhdirk.Terms.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
<default>false</default>
</key>

<key name="show-menu-button" type="b">
<default>true</default>
<summary>Whether or not to display a menu button in the headerbar</summary>
</key>

<key name="show-scrollbars" type="b">
<default>true</default>
<summary>Whether or not to show scrollbars</summary>
Expand Down Expand Up @@ -81,7 +76,6 @@
<description>If true, whenever there's new output the terminal will scroll to the bottom.</description>
</key>


<key name="use-sixel" type="b">
<default>false</default>
<summary>If enabled, terminals will render sixel escape sequences</summary>
Expand All @@ -99,9 +93,28 @@
<default>400</default>
<summary>Delay time before showing floating controls</summary>
</key>
<key name="fill-tabs" type="b">
<default>true</default>
<summary>Whether or not tabs should expand to fill tab bar</summary>
</key>
<key name="show-headerbar" type="b">
<default>true</default>
<summary>Whether the headerbar should be shown or not</summary>
</key>
<key name="context-aware-header-bar" type="b">
<default>true</default>
<summary>If enabled, the header bar will be colored differently for root and ssh contexts</summary>
</key>
<key name="show-menu-button" type="b">
<default>true</default>
<summary>Whether or not to display a menu button in the headerbar</summary>
</key>
<key name="headerbar-drag-area" type="b">
<default>false</default>
<summary>Whether or not to reserve an area for dragging the header bar</summary>
</key>


<key name="system-font" type="b">
<key name="use-system-font" type="b">
<default>true</default>
<summary>If enabled, uses the system font for terminal</summary>
</key>
Expand Down
2 changes: 1 addition & 1 deletion src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ mod imp {
let app = self.obj();

// TODO: if init_args is none, we have to get them from the last terminal?

info!("Window init args: {:?}", init_args);
let window = Window::new(&*app, init_args.unwrap());

// Ask the window manager/compositor to present the window
Expand Down
89 changes: 81 additions & 8 deletions src/components/header_bar/header_bar.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
use std::cell::{Cell, RefCell};

use adw::subclass::prelude::*;
use gtk::glib;
use glib::{self, Properties, StaticTypeExt};
use glib::{clone, prelude::*};
use vte::WidgetExt;

use crate::components::StyleSwitcher;
use crate::settings::Settings;

#[derive(Debug, Default, gtk::CompositeTemplate)]
#[derive(Debug, Default, gtk::CompositeTemplate, Properties)]
#[template(resource = "/io/github/vhdirk/Terms/gtk/header_bar.ui")]
#[properties(wrapper_type = super::HeaderBar)]
pub struct HeaderBar {
// #[template_child]
// pub revealer: TemplateChild<gtk::Revealer>,
pub settings: Settings,

#[template_child]
pub revealer: TemplateChild<gtk::Revealer>,

#[template_child]
pub title_widget: TemplateChild<adw::WindowTitle>,

#[template_child]
pub header_bar: TemplateChild<adw::HeaderBar>,

#[template_child]
pub style_switcher: TemplateChild<StyleSwitcher>,
// #[template_child]
// pub theme_selector: TemplateChild<panel::ThemeSelector>,
pub menu_button: TemplateChild<gtk::MenuButton>,

#[property(get, set)]
pub fullscreened: Cell<bool>,

#[property(get, set, nullable)]
pub overlay: RefCell<Option<gtk::Overlay>>,

#[property(get, set, nullable)]
pub container: RefCell<Option<gtk::Box>>,
}

#[glib::object_subclass]
Expand All @@ -23,6 +43,7 @@ impl ObjectSubclass for HeaderBar {
type ParentType = adw::Bin;

fn class_init(klass: &mut Self::Class) {
StyleSwitcher::ensure_type();
klass.bind_template();
klass.set_css_name("headerbar");
}
Expand All @@ -32,6 +53,58 @@ impl ObjectSubclass for HeaderBar {
}
}

impl ObjectImpl for HeaderBar {}
#[glib::derived_properties]
impl ObjectImpl for HeaderBar {
fn constructed(&self) {
self.parent_constructed();

self.setup();
}
}

impl WidgetImpl for HeaderBar {}
impl BinImpl for HeaderBar {}

impl HeaderBar {
fn setup(&self) {
self.settings.bind_show_menu_button(&*self.menu_button, "visible").get_only().build();

self.obj()
.bind_property("fullscreened", &*self.header_bar, "show-end-title-buttons")
.invert_boolean()
.sync_create()
.build();

self.settings.bind_show_headerbar(&*self.revealer, "reveal-child").get_only().build();

self.revealer.connect_child_revealed_notify(clone!(@weak self as this => move |r| {
this.on_reveal_changed(r.is_child_revealed());
}));
}

fn on_reveal_changed(&self, revealed: bool) {
println!("on reveal changed: {:?}", revealed);
}

fn set_floating(&self, float: bool) {
// if (self.is_floating.get() && float) {
// return;
// }

// this.setting_header_bar_to_floating = true;

// if (should_float && this.header_bar_revealer.parent != this.overlay) {
// // ...
// yield this.wait_for_header_bar_animation ();
// this.layout_box.remove (this.header_bar_revealer);
// this.overlay.add_overlay (this.header_bar_revealer);
// }
// else if (!should_float && this.header_bar_revealer.parent != this.layout_box) {
// // ...
// this.overlay.remove_overlay (this.header_bar_revealer);
// this.layout_box.prepend (this.header_bar_revealer);
// }

// this.setting_header_bar_to_floating = false;
}
}
132 changes: 37 additions & 95 deletions src/components/header_bar/header_bar.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,72 +61,47 @@
<class name="flat" />
</style>

<!-- <child>
<child>
<object class="GtkRevealer" id="revealer">
<property name="reveal-child">True</property>
<property name="transition-duration">250</property> -->
<child>
<object class="GtkWindowHandle">
<property name="hexpand">true</property>
<property name="transition-duration">250</property>
<child>
<object class="GtkBox">

<object class="AdwHeaderBar" id="header_bar">
<property name="hexpand">true</property>

<child>
<object class="GtkStack" id="hb_stack">
<property name="hhomogeneous">true</property>
<property name="transition-type">none</property>
<property name="vhomogeneous">true</property>
<property name="hexpand">true</property>

<child>
<object class="GtkStackPage">
<property name="name">single-tab-page</property>
<property name="child">
<object class="GtkCenterBox" id="single_tab_content">
<child type="start">
<object class="GtkWindowControls" id="left_controls"></object>
</child>

<child type="center">
<object class="AdwWindowTitle" id="title_widget"></object>
</child>

<child type="end">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">0</property>
<property name="valign">center</property>


<child>
<object class="GtkMenuButton">
<property name="tooltip-text" translatable="yes">Menu</property>
<property name="icon-name">open-menu-symbolic</property>

<property name="popover">
<object class="GtkPopoverMenu">
<property name="menu-model">main-menu</property>
<child type="style-switcher">
<object class="TermsStyleSwitcher" id="style_switcher">
</object>
</child>
</object>
</property>

<!-- <binding name="visible">
<lookup name="show-menu-button">
<lookup name="settings">TerminalHeaderBar</lookup>
</lookup>
</binding> -->
</object>
</child>
<!-- <child type="start"></child> -->

<child>
<property name="title-widget">
<object class="AdwWindowTitle" id="title_widget">
<property name="title">Terms</property>
</object>
</property>

<child type="end">
<object class="GtkMenuButton" id="menu_button">
<property name="tooltip-text" translatable="yes">Menu</property>
<property name="icon-name">open-menu-symbolic</property>

<property name="popover">
<object class="GtkPopoverMenu">
<property name="menu-model">main-menu</property>
<child type="style-switcher">
<object class="TermsStyleSwitcher" id="style_switcher"></object>
</child>
</object>
</property>
</object>
</child>

</object>


<!-- <child>
<object class="GtkWindowControls">
<property name="side">end</property>
<!-- <binding name="visible">
<!- <binding name="visible">
<closure type="gboolean" function="show_window_controls">
<lookup name="fullscreened">
<lookup name="window">TerminalHeaderBar</lookup>
Expand All @@ -135,57 +110,24 @@
<lookup name="single-tab-mode">TerminalHeaderBar</lookup>
<constant type="gboolean">false</constant>
</closure>
</binding> -->
</binding> ->
</object>
</child>
</object>
</child>
<!-- <object class="AdwHeaderBar">
</child> -->
<!-- <object class="AdwHeaderBar">
<property name="hexpand">true</property>
<property name="title-widget">
<object class="AdwWindowTitle" id="title_widget">
<property name="title">Terms</property>
</object>
</property>
<child type="end">
<object class="GtkMenuButton">
<property name="tooltip-text" translatable="yes">Menu</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="popover">
<object class="GtkPopoverMenu">
<property name="menu-model">main-menu</property>
<child type="style-switcher">
<object class="TermsStyleSwitcher" id="style_switcher"></object>
</child>
</object>
</property> -->

<!--<binding
name="visible">
<lookup name="show-menu-button">
<lookup name="settings">TerminalHeaderBar</lookup>
</lookup>
</binding> -->
<!-- </object>
</child>
</object> -->
</object>
</property>
<property name="name">single-tab-page</property>
</object>
</child>
</object>
</child>
</object>
-->
</child>
</object>

</child>
<!-- </object>
</child> -->


</template>
Expand Down
5 changes: 1 addition & 4 deletions src/components/header_bar/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
mod header_bar;
use gtk::prelude::*;
use header_bar as imp;

use crate::{application::AppProfile, config::PROFILE};

glib::wrapper! {
pub struct HeaderBar(ObjectSubclass<imp::HeaderBar>)
@extends gtk::Widget, gtk::Window, gtk::HeaderBar,
@extends gtk::Widget, adw::Bin,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
}

Expand Down
2 changes: 2 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod header_bar;
mod preferences_window;
mod process_manager;
mod search_toolbar;
mod session;
mod shortcut_dialog;
Expand All @@ -14,6 +15,7 @@ mod window;

pub use header_bar::*;
pub use preferences_window::*;
pub use process_manager::*;
pub use search_toolbar::*;
pub use session::*;
pub use shortcut_dialog::*;
Expand Down
Loading

0 comments on commit 6662d2a

Please sign in to comment.