move new tab button into the tabs start widget

This commit is contained in:
yggverse 2024-10-31 16:16:02 +02:00
parent 1ffc5c1edb
commit 6aee2edd75
6 changed files with 12 additions and 21 deletions

View file

@ -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(),
),
}) })
} }

View file

@ -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()),
}) })
} }

View file

@ -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(),
}) })

View file

@ -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);