mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
reorganize widget modules
This commit is contained in:
parent
b9b226cc54
commit
4903968309
47 changed files with 352 additions and 786 deletions
|
|
@ -1,19 +1,36 @@
|
|||
mod model;
|
||||
mod widget;
|
||||
use gtk::{gio, MenuButton};
|
||||
|
||||
pub struct Menu {
|
||||
widget: widget::Menu,
|
||||
widget: MenuButton,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
pub fn new() -> Menu {
|
||||
Self {
|
||||
widget: widget::Menu::new(model::Menu::new().model()),
|
||||
}
|
||||
// Init model
|
||||
let model_tab = gio::Menu::new();
|
||||
model_tab.append(Some("New"), Some("win.tab_append"));
|
||||
model_tab.append(Some("Pin"), Some("win.tab_pin"));
|
||||
|
||||
let model_tab_close = gio::Menu::new();
|
||||
model_tab_close.append(Some("Current"), Some("win.tab_close"));
|
||||
model_tab_close.append(Some("All"), Some("win.tab_close_all"));
|
||||
model_tab.append_submenu(Some("Close"), &model_tab_close);
|
||||
|
||||
let model = gio::Menu::new();
|
||||
model.append_submenu(Some("Tab"), &model_tab);
|
||||
model.append(Some("Debug"), Some("win.debug"));
|
||||
model.append(Some("Quit"), Some("win.quit"));
|
||||
|
||||
// Init widget
|
||||
let widget = MenuButton::builder().tooltip_text("Menu").build();
|
||||
widget.set_menu_model(Some(&model));
|
||||
|
||||
// Result
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Menu {
|
||||
pub fn widget(&self) -> &MenuButton {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
use gtk::gio;
|
||||
|
||||
pub struct Menu {
|
||||
model: gio::Menu,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
// Construct
|
||||
pub fn new() -> Menu {
|
||||
let model_tab = gio::Menu::new();
|
||||
model_tab.append(Some("New"), Some("win.tab_append"));
|
||||
model_tab.append(Some("Pin"), Some("win.tab_pin"));
|
||||
|
||||
let model_tab_close = gio::Menu::new();
|
||||
model_tab_close.append(Some("Current"), Some("win.tab_close"));
|
||||
model_tab_close.append(Some("All"), Some("win.tab_close_all"));
|
||||
model_tab.append_submenu(Some("Close"), &model_tab_close);
|
||||
|
||||
let model = gio::Menu::new();
|
||||
model.append_submenu(Some("Tab"), &model_tab);
|
||||
model.append(Some("Debug"), Some("win.debug"));
|
||||
model.append(Some("Quit"), Some("win.quit"));
|
||||
|
||||
Self { model }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn model(&self) -> &gio::Menu {
|
||||
&self.model
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
use gtk::gio;
|
||||
|
||||
pub struct Menu {
|
||||
gtk: gtk::MenuButton,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
// Construct
|
||||
pub fn new(model: &gio::Menu) -> Menu {
|
||||
let gtk = gtk::MenuButton::builder().tooltip_text("Menu").build();
|
||||
|
||||
gtk.set_menu_model(Some(model));
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::MenuButton {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,33 @@
|
|||
mod menu;
|
||||
mod tab;
|
||||
mod widget;
|
||||
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::{Box, Orientation};
|
||||
use menu::Menu;
|
||||
use tab::Tab;
|
||||
|
||||
pub struct Tray {
|
||||
widget: widget::Tray,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Tray {
|
||||
pub fn new() -> Tray {
|
||||
Self {
|
||||
widget: widget::Tray::new(
|
||||
menu::Menu::new().widget().gtk(),
|
||||
tab::Tab::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
let menu = Menu::new();
|
||||
let tab = Tab::new();
|
||||
|
||||
let widget = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.build();
|
||||
|
||||
widget.append(menu.widget());
|
||||
widget.append(tab.widget());
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Tray {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Tab {
|
||||
pub widget: widget::Tab,
|
||||
pub widget: Button,
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new() -> Tab {
|
||||
Self {
|
||||
widget: widget::Tab::new(),
|
||||
widget: Button::builder()
|
||||
.action_name("win.tab_append")
|
||||
.icon_name("tab-new-symbolic")
|
||||
.tooltip_text("New tab")
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Tab {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
pub struct Tab {
|
||||
gtk: gtk::Button,
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new() -> Tab {
|
||||
Self {
|
||||
gtk: gtk::Button::builder()
|
||||
.action_name("win.tab_append")
|
||||
.icon_name("tab-new-symbolic")
|
||||
.tooltip_text("New tab")
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Button {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Tray {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl Tray {
|
||||
// Construct
|
||||
pub fn new(menu: >k::MenuButton, tab: >k::Button) -> Tray {
|
||||
let gtk = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.build();
|
||||
|
||||
gtk.append(menu);
|
||||
gtk.append(tab);
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue