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

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

@ -1,8 +1,11 @@
mod append;
mod widget; mod widget;
use append::Append;
use widget::Widget; use widget::Widget;
use adw::{TabBar, TabView}; use adw::{TabBar, TabView};
use gtk::gio::SimpleAction;
use std::sync::Arc; use std::sync::Arc;
pub struct Tab { pub struct Tab {
@ -11,9 +14,9 @@ pub struct Tab {
impl Tab { impl Tab {
// Construct // Construct
pub fn new_arc(view: &TabView) -> Arc<Self> { pub fn new_arc(action_tab_append: SimpleAction, view: &TabView) -> Arc<Self> {
Arc::new(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 @@
use adw::{TabBar, TabView}; use adw::{TabBar, TabView};
use gtk::prelude::IsA;
use std::sync::Arc; use std::sync::Arc;
pub struct Widget { pub struct Widget {
@ -7,11 +8,12 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // 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 { Arc::new(Self {
gobject: TabBar::builder() gobject: TabBar::builder()
.autohide(false) .autohide(false)
.expand_tabs(false) .expand_tabs(false)
.start_action_widget(start_action_widget)
.view(&view) .view(&view)
.build(), .build(),
}) })

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

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

Loading…
Cancel
Save