Skip to content

Commit

Permalink
panel header
Browse files Browse the repository at this point in the history
  • Loading branch information
vhdirk committed Feb 20, 2024
1 parent 1c98951 commit 1676ba8
Show file tree
Hide file tree
Showing 27 changed files with 1,571 additions and 119 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ libc = "0.2.153"
thiserror = "1.0.56"
anyhow = "1.0.79"
zbus = "3.14.1"
num-traits = "0.2.18"
approx = "0.5.1"

[build-dependencies]
glib-build-tools = "0.19.0"
Expand Down
24 changes: 24 additions & 0 deletions data/resources/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
# Resources
fs = import('fs')
subdir('icons')

# stylesheet_deps = []
# sassc = find_program('sassc')

# if sassc.found()
# sassc_opts = [ '-a', '-M', '-t', 'compact' ]

# scss_files = [
# 'style',
# 'style-dark',
# ]

# foreach scss: scss_files
# stylesheet_deps += custom_target('@[email protected]'.format(scss),
# input: '@[email protected]'.format(scss),
# output: '@[email protected]'.format(scss),
# command: [
# sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
# ],
# )
# endforeach
# endif


resources = gnome.compile_resources(
'resources',
'resources.gresource.xml',
Expand Down
1 change: 1 addition & 0 deletions data/resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</gresource>

<gresource prefix="/io/github/vhdirk/Twl/gtk">
<file compressed="true" preprocess="xml-stripblanks" alias="panel_header.ui">../../src/twl/panel_header.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="zoom_controls.ui">../../src/twl/zoom_controls.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="style_switcher.ui">../../src/twl/style_switcher.ui</file>
</gresource>
Expand Down
45 changes: 34 additions & 11 deletions data/resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@define-color root_context_color shade(@red_1, 1.38);
@define-color ssh_context_color shade(@purple_1, 1.28);
/* @define-color panel_border_color alpha(@shade_color, 1); */

/* terms_main_windowwith-borders:not(.fullscreen):backdrop {
border-color: alpha(@borders, 0.5);
Expand All @@ -22,6 +23,7 @@ window:not(.about) headerbar,
margin-bottom: -6px;
}


/* #terms_main_window.context-root .custom-headerbar {
background-color: @root_context_color;
}
Expand Down Expand Up @@ -83,11 +85,20 @@ window:not(.about) headerbar,
padding: 12px;
}

#twl_style_switcher {


/******************************** TWL ************************************/

panel_grid paned separator {
background-color: @headerbar_bg_color;
border-color: @headerbar_bg_color;
}

style_switcher {
padding: 6px;
}

#twl_style_switcher .check {
style_switcher .check {
background: @accent_bg_color;
color: @accent_fg_color;
padding: 2px;
Expand All @@ -97,12 +108,12 @@ window:not(.about) headerbar,

/* Adapted from https://gitlab.gnome.org/GNOME/gnome-text-editor/-/blob/bf8c0c249f06a0be69e65aed3b786ba02a9f999e/src/TextEditor.css#L51 */

#twl_style_switcher checkbutton {
style_switcher checkbutton {
outline-offset: 1px;
transition: none;
}

#twl_style_switcher checkbutton radio {
style_switcher checkbutton radio {
-gtk-icon-source: none;
background: none;
padding: 12px;
Expand All @@ -114,25 +125,37 @@ window:not(.about) headerbar,
box-shadow: inset 0 0 0 1px @borders;
}

#twl_style_switcher checkbutton radio:checked {
style_switcher checkbutton radio:checked {
box-shadow: inset 0 0 0 2px @accent_bg_color;
}

#twl_style_switcher checkbutton.system radio {
style_switcher checkbutton.system radio {
background: linear-gradient(-45deg, #1e1e1e 49.99%, white 50.01%);
}

#twl_style_switcher checkbutton.light radio {
style_switcher checkbutton.light radio {
color: alpha(black, 0.8);
background-color: white;
}

#twl_style_switcher checkbutton.dark radio {
style_switcher checkbutton.dark radio {
color: white;
background-color: #1e1e1e;
}

paned separator {
background-color: @window_bg_color;
border-color: @window_bg_color;

panel_header {
-gtk-icon-size: 12px;
}


panel_header.toolbar {
padding: 0px;
border-spacing: 0px;
}


panel_header button {
min-height: 16px;
min-width: 16px;
}
15 changes: 10 additions & 5 deletions src/components/terminal_tab/terminal_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ impl TerminalTab {
}));
self.panel_grid.set_wide_handle(self.settings.use_wide_panel_resize_handle());

self.settings.connect_show_panel_headers_changed(clone!(@weak self as this => move |s| {
this.panel_grid.set_show_panel_headers(s.show_panel_headers());
}));
self.panel_grid.set_show_panel_headers(self.settings.show_panel_headers());

self.panel_grid.connect_selected_panel_notify(clone!(@weak self as this => move |s| {
this.on_selected_panel_change();
}));
Expand Down Expand Up @@ -163,7 +168,7 @@ impl TerminalTab {
}

fn get_selected(&self) -> Option<Terminal> {
self.panel_grid.selected_panel().and_then(|p| p.child()).and_downcast()
self.panel_grid.selected_panel().and_then(|p| p.content()).and_downcast()
}

fn set_selected(&self, terminal: Option<Terminal>) {
Expand All @@ -176,7 +181,7 @@ impl TerminalTab {
debug!("on panel changed: {:?}", panel);
self.selected_panel_signals.set_target(panel.as_ref());
if let Some(panel) = panel.as_ref() {
let term = panel.child().and_downcast::<Terminal>();
let term = panel.content().and_downcast::<Terminal>();
debug!("Set active term {:?}", term);
self.active_term_signals.set_target(term.as_ref());
if let Some(term) = term.as_ref() {
Expand All @@ -188,7 +193,7 @@ impl TerminalTab {

pub fn split(&self, orientation: Option<gtk::Orientation>) {
let term = Terminal::new(self.directory.borrow().clone(), self.command.borrow().clone(), self.env.borrow().clone());
term.grab_focus();
// term.grab_focus();

let panel = self.panel_grid.split(&term, orientation);
self.connect_terminal_signals(&term, &panel);
Expand All @@ -201,14 +206,14 @@ impl TerminalTab {
}));

terminal.connect_title_notify(clone!(@weak self as this, @weak panel as panel => move |term| {
panel.set_title(term.title());
panel.header().set_title(term.title());
}));
}

pub fn on_panel_close_request(&self, panel: &Panel) -> glib::Propagation {
info!("on_panel_close_request: {:?}", panel);
// TODO: test if process is still running
if let Some(terminal) = panel.child().and_downcast_ref::<Terminal>() {}
if let Some(terminal) = panel.content().and_downcast_ref::<Terminal>() {}

glib::Propagation::Proceed
}
Expand Down
22 changes: 22 additions & 0 deletions src/twl/bin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use glib::{prelude::*, subclass::prelude::*};

use super::{bin_imp as imp, utils::TwlWidgetExt};

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

impl Bin {
pub fn new(child: &impl IsA<gtk::Widget>) -> Self {
glib::Object::builder().property("child", child).build()
}
}

impl Default for Bin {
fn default() -> Self {
glib::Object::builder().build()
}
}
impl TwlWidgetExt for Bin {}
Loading

0 comments on commit 1676ba8

Please sign in to comment.