mirror of https://github.com/YGGverse/Yoda.git
yggverse
2 months ago
16 changed files with 269 additions and 156 deletions
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
mod widget; |
||||
|
||||
use widget::Widget; |
||||
|
||||
use gtk::{gio::SimpleAction, Button}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Append { |
||||
pub widget: Arc<Widget>, |
||||
} |
||||
|
||||
impl Append { |
||||
// Construct
|
||||
pub fn new_arc(action_tab_append: Arc<SimpleAction>) -> Arc<Self> { |
||||
Arc::new(Self { |
||||
widget: Widget::new_arc(action_tab_append), |
||||
}) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Button { |
||||
&self.widget.gobject() |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
mod widget; |
||||
|
||||
use widget::Widget; |
||||
|
||||
use gtk::WindowControls; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Control { |
||||
widget: Arc<Widget>, |
||||
} |
||||
|
||||
impl Control { |
||||
// Construct
|
||||
pub fn new_arc() -> Arc<Self> { |
||||
Arc::new(Self { |
||||
widget: Widget::new_arc(), |
||||
}) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &WindowControls { |
||||
&self.widget.gobject() |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
use gtk::{PackType, WindowControls}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: WindowControls, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new_arc() -> Arc<Self> { |
||||
Arc::new(Self { |
||||
gobject: WindowControls::new(PackType::End), |
||||
}) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &WindowControls { |
||||
&self.gobject |
||||
} |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
use gtk::{gio::Menu, Align, MenuButton}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: MenuButton, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new_arc(model: &Menu) -> Arc<Self> { |
||||
Arc::new(Self { |
||||
gobject: MenuButton::builder() |
||||
.css_classes(["flat"]) |
||||
.icon_name("open-menu-symbolic") |
||||
.menu_model(model) |
||||
.tooltip_text("Menu") |
||||
.valign(Align::Center) |
||||
.build(), |
||||
}) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &MenuButton { |
||||
&self.gobject |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
mod widget; |
||||
|
||||
use widget::Widget; |
||||
|
||||
use adw::{TabBar, TabView}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Tab { |
||||
widget: Arc<Widget>, |
||||
} |
||||
|
||||
impl Tab { |
||||
// Construct
|
||||
pub fn new_arc(view: &TabView) -> Arc<Self> { |
||||
Arc::new(Self { |
||||
widget: Widget::new_arc(view), |
||||
}) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &TabBar { |
||||
&self.widget.gobject() |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
use adw::{TabBar, TabView}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: TabBar, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new_arc(view: &TabView) -> Arc<Self> { |
||||
Arc::new(Self { |
||||
gobject: TabBar::builder().view(&view).build(), |
||||
}) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &TabBar { |
||||
&self.gobject |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
use adw::TabBar; |
||||
use gtk::{prelude::BoxExt, Box, Button, MenuButton, Orientation, WindowControls}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: Box, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new_arc( |
||||
control: &WindowControls, |
||||
append: &Button, |
||||
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); |
||||
|
||||
Arc::new(Self { gobject }) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Box { |
||||
&self.gobject |
||||
} |
||||
} |
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
use adw::WindowTitle; |
||||
|
||||
const DEFAULT_TITLE: &str = "Yoda"; // @TODO
|
||||
const DEFAULT_SUBTITLE: &str = ""; |
||||
|
||||
pub struct Title { |
||||
gobject: WindowTitle, |
||||
} |
||||
|
||||
impl Title { |
||||
// Construct
|
||||
pub fn new() -> Self { |
||||
Self { |
||||
gobject: WindowTitle::new(DEFAULT_TITLE, DEFAULT_SUBTITLE), |
||||
} |
||||
} |
||||
|
||||
// Actions
|
||||
pub fn update(&self, title: &str, subtitle: &str) { |
||||
// Update title
|
||||
let mut parts = Vec::new(); |
||||
|
||||
if !title.is_empty() { |
||||
parts.push(title); |
||||
} |
||||
|
||||
parts.push(DEFAULT_TITLE); |
||||
|
||||
self.gobject.set_title(&parts.join(" - ")); |
||||
|
||||
// Update subtitle
|
||||
self.gobject.set_subtitle(subtitle); |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &WindowTitle { |
||||
&self.gobject |
||||
} |
||||
} |
@ -1,23 +1,23 @@
@@ -1,23 +1,23 @@
|
||||
use adw::{HeaderBar, WindowTitle}; |
||||
use adw::ToolbarView; |
||||
use gtk::Box; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: HeaderBar, |
||||
gobject: ToolbarView, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new(pack_start: &Box, title_widget: Option<&WindowTitle>) -> Self { |
||||
let gobject = HeaderBar::builder().build(); |
||||
pub fn new_arc(top_bar: &Box) -> Arc<Self> { |
||||
let gobject = ToolbarView::builder().build(); |
||||
|
||||
gobject.pack_start(pack_start); |
||||
gobject.set_title_widget(title_widget); |
||||
gobject.add_top_bar(top_bar); |
||||
|
||||
Self { gobject } |
||||
Arc::new(Self { gobject }) |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &HeaderBar { |
||||
pub fn gobject(&self) -> &ToolbarView { |
||||
&self.gobject |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue