Browse Source

move new tab button into the tabs start widget

master
yggverse 1 month ago
parent
commit
6aee2edd75
  1. 12
      src/app/browser/window/header/bar.rs
  2. 7
      src/app/browser/window/header/bar/tab.rs
  3. 0
      src/app/browser/window/header/bar/tab/append.rs
  4. 0
      src/app/browser/window/header/bar/tab/append/widget.rs
  5. 4
      src/app/browser/window/header/bar/tab/widget.rs
  6. 10
      src/app/browser/window/header/bar/widget.rs

12
src/app/browser/window/header/bar.rs

@ -1,10 +1,8 @@ @@ -1,10 +1,8 @@
mod append;
mod control;
mod menu;
mod tab;
mod widget;
use append::Append;
use control::Control;
use menu::Menu;
use tab::Tab;
@ -36,8 +34,7 @@ impl Bar { @@ -36,8 +34,7 @@ impl Bar {
) -> Arc<Self> {
// Init components
let control = Control::new_arc();
let tab = Tab::new_arc(view);
let append = Append::new_arc(action_tab_append.clone());
let tab = Tab::new_arc(action_tab_append.clone(), view);
let menu = Menu::new_arc(
action_tool_debug,
action_tool_profile,
@ -54,12 +51,7 @@ impl Bar { @@ -54,12 +51,7 @@ impl Bar {
// Build result
Arc::new(Self {
widget: Widget::new_arc(
control.gobject(),
append.gobject(),
menu.gobject(),
tab.gobject(),
),
widget: Widget::new_arc(control.gobject(), menu.gobject(), tab.gobject()),
})
}

7
src/app/browser/window/header/bar/tab.rs

@ -1,8 +1,11 @@ @@ -1,8 +1,11 @@
mod append;
mod widget;
use append::Append;
use widget::Widget;
use adw::{TabBar, TabView};
use gtk::gio::SimpleAction;
use std::sync::Arc;
pub struct Tab {
@ -11,9 +14,9 @@ pub struct Tab { @@ -11,9 +14,9 @@ pub struct Tab {
impl Tab {
// Construct
pub fn new_arc(view: &TabView) -> Arc<Self> {
pub fn new_arc(action_tab_append: SimpleAction, view: &TabView) -> Arc<Self> {
Arc::new(Self {
widget: Widget::new_arc(view),
widget: Widget::new_arc(view, Append::new_arc(action_tab_append).gobject()),
})
}

0
src/app/browser/window/header/bar/append.rs → src/app/browser/window/header/bar/tab/append.rs

0
src/app/browser/window/header/bar/append/widget.rs → src/app/browser/window/header/bar/tab/append/widget.rs

4
src/app/browser/window/header/bar/tab/widget.rs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
use adw::{TabBar, TabView};
use gtk::prelude::IsA;
use std::sync::Arc;
pub struct Widget {
@ -7,11 +8,12 @@ pub struct Widget { @@ -7,11 +8,12 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(view: &TabView) -> Arc<Self> {
pub fn new_arc(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Arc<Self> {
Arc::new(Self {
gobject: TabBar::builder()
.autohide(false)
.expand_tabs(false)
.start_action_widget(start_action_widget)
.view(&view)
.build(),
})

10
src/app/browser/window/header/bar/widget.rs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
use adw::TabBar;
use gtk::{prelude::BoxExt, Box, Button, MenuButton, Orientation, WindowControls};
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
use std::sync::Arc;
pub struct Widget {
@ -8,19 +8,13 @@ pub struct Widget { @@ -8,19 +8,13 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
control: &WindowControls,
append: &Button,
menu: &MenuButton,
tab: &TabBar,
) -> Arc<Self> {
pub fn new_arc(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Arc<Self> {
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(8)
.build();
gobject.append(tab);
gobject.append(append);
gobject.append(menu);
gobject.append(control);

Loading…
Cancel
Save