mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
drop Arc from SimpleAction #1
This commit is contained in:
parent
08ad677ba4
commit
920721412e
@ -27,7 +27,7 @@ pub struct App {
|
|||||||
profile_database_connection: Arc<RwLock<Connection>>,
|
profile_database_connection: Arc<RwLock<Connection>>,
|
||||||
// database: Arc<Database>,
|
// database: Arc<Database>,
|
||||||
// Actions
|
// Actions
|
||||||
// action_update: Arc<SimpleAction>,
|
// action_update: SimpleAction,
|
||||||
// Components
|
// Components
|
||||||
// browser: Arc<Browser>,
|
// browser: Arc<Browser>,
|
||||||
// GTK
|
// GTK
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// and replace them with objects (to follow encapsulation for children mods)
|
// and replace them with objects (to follow encapsulation for children mods)
|
||||||
// @TODO find alternative implementation, if exist for GTK 4
|
// @TODO find alternative implementation, if exist for GTK 4
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{gformat, uuid_string_random, GString, VariantTy},
|
glib::{gformat, uuid_string_random, GString, VariantTy},
|
||||||
@ -12,14 +10,14 @@ use gtk::{
|
|||||||
|
|
||||||
pub struct Action {
|
pub struct Action {
|
||||||
group: GString,
|
group: GString,
|
||||||
simple: Arc<SimpleAction>,
|
simple: SimpleAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl Action {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(group: &str, is_enabled: bool, parameter_type: Option<&VariantTy>) -> Self {
|
pub fn new(group: &str, is_enabled: bool, parameter_type: Option<&VariantTy>) -> Self {
|
||||||
// Create random action name as no static values should be in use
|
// Create random action name as no static values should be in use
|
||||||
let simple = Arc::new(SimpleAction::new(&uuid_string_random(), parameter_type));
|
let simple = SimpleAction::new(&uuid_string_random(), parameter_type);
|
||||||
simple.set_enabled(is_enabled);
|
simple.set_enabled(is_enabled);
|
||||||
|
|
||||||
// Assign action to the group
|
// Assign action to the group
|
||||||
@ -36,7 +34,7 @@ impl Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// App mods work with simple and system-wide data types, let them take it
|
// App mods work with simple and system-wide data types, let them take it
|
||||||
pub fn simple(&self) -> Arc<SimpleAction> {
|
pub fn simple(&self) -> SimpleAction {
|
||||||
self.simple.clone()
|
self.simple.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,18 @@ impl Browser {
|
|||||||
// Extras
|
// Extras
|
||||||
profile_path: PathBuf,
|
profile_path: PathBuf,
|
||||||
// Actions
|
// Actions
|
||||||
action_tool_debug: Arc<SimpleAction>,
|
action_tool_debug: SimpleAction,
|
||||||
action_tool_profile: Arc<SimpleAction>,
|
action_tool_profile: SimpleAction,
|
||||||
action_quit: Arc<SimpleAction>,
|
action_quit: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_append: SimpleAction,
|
||||||
action_tab_close: Arc<SimpleAction>,
|
action_tab_close: SimpleAction,
|
||||||
action_tab_close_all: Arc<SimpleAction>,
|
action_tab_close_all: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_tab_pin: Arc<SimpleAction>,
|
action_tab_pin: SimpleAction,
|
||||||
) -> Browser {
|
) -> Browser {
|
||||||
let window = Arc::new(Window::new(
|
let window = Arc::new(Window::new(
|
||||||
action_tool_debug.clone(),
|
action_tool_debug.clone(),
|
||||||
@ -60,26 +60,26 @@ impl Browser {
|
|||||||
let widget = Arc::new(Widget::new(window.gobject()));
|
let widget = Arc::new(Widget::new(window.gobject()));
|
||||||
|
|
||||||
// Assign actions
|
// Assign actions
|
||||||
widget.gobject().add_action(action_tool_debug.as_ref());
|
widget.gobject().add_action(&action_tool_debug);
|
||||||
widget.gobject().add_action(action_tool_profile.as_ref());
|
widget.gobject().add_action(&action_tool_profile);
|
||||||
widget.gobject().add_action(action_quit.as_ref());
|
widget.gobject().add_action(&action_quit);
|
||||||
widget.gobject().add_action(action_update.as_ref());
|
widget.gobject().add_action(&action_update);
|
||||||
widget.gobject().add_action(action_tab_append.as_ref());
|
widget.gobject().add_action(&action_tab_append);
|
||||||
widget.gobject().add_action(action_tab_close.as_ref());
|
widget.gobject().add_action(&action_tab_close);
|
||||||
widget.gobject().add_action(action_tab_close_all.as_ref());
|
widget.gobject().add_action(&action_tab_close_all);
|
||||||
widget
|
widget
|
||||||
.gobject()
|
.gobject()
|
||||||
.add_action(action_tab_page_navigation_base.as_ref());
|
.add_action(&action_tab_page_navigation_base);
|
||||||
widget
|
widget
|
||||||
.gobject()
|
.gobject()
|
||||||
.add_action(action_tab_page_navigation_history_back.as_ref());
|
.add_action(&action_tab_page_navigation_history_back);
|
||||||
widget
|
widget
|
||||||
.gobject()
|
.gobject()
|
||||||
.add_action(action_tab_page_navigation_history_forward.as_ref());
|
.add_action(&action_tab_page_navigation_history_forward);
|
||||||
widget
|
widget
|
||||||
.gobject()
|
.gobject()
|
||||||
.add_action(action_tab_page_navigation_reload.as_ref());
|
.add_action(&action_tab_page_navigation_reload);
|
||||||
widget.gobject().add_action(action_tab_pin.as_ref());
|
widget.gobject().add_action(&action_tab_pin);
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
action_tool_debug.connect_activate({
|
action_tool_debug.connect_activate({
|
||||||
|
@ -23,18 +23,18 @@ impl Window {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new(
|
pub fn new(
|
||||||
// Actions
|
// Actions
|
||||||
action_tool_debug: Arc<SimpleAction>,
|
action_tool_debug: SimpleAction,
|
||||||
action_tool_profile: Arc<SimpleAction>,
|
action_tool_profile: SimpleAction,
|
||||||
action_quit: Arc<SimpleAction>,
|
action_quit: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_append: SimpleAction,
|
||||||
action_tab_close: Arc<SimpleAction>,
|
action_tab_close: SimpleAction,
|
||||||
action_tab_close_all: Arc<SimpleAction>,
|
action_tab_close_all: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_tab_pin: Arc<SimpleAction>,
|
action_tab_pin: SimpleAction,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Tab::new_arc(
|
let tab = Tab::new_arc(
|
||||||
|
@ -16,17 +16,17 @@ impl Header {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
// Actions
|
// Actions
|
||||||
action_tool_debug: Arc<SimpleAction>,
|
action_tool_debug: SimpleAction,
|
||||||
action_tool_profile: Arc<SimpleAction>,
|
action_tool_profile: SimpleAction,
|
||||||
action_quit: Arc<SimpleAction>,
|
action_quit: SimpleAction,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_append: SimpleAction,
|
||||||
action_tab_close: Arc<SimpleAction>,
|
action_tab_close: SimpleAction,
|
||||||
action_tab_close_all: Arc<SimpleAction>,
|
action_tab_close_all: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_tab_pin: Arc<SimpleAction>,
|
action_tab_pin: SimpleAction,
|
||||||
// Widgets
|
// Widgets
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
|
@ -21,17 +21,17 @@ pub struct Bar {
|
|||||||
impl Bar {
|
impl Bar {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_tool_debug: Arc<SimpleAction>,
|
action_tool_debug: SimpleAction,
|
||||||
action_tool_profile: Arc<SimpleAction>,
|
action_tool_profile: SimpleAction,
|
||||||
action_quit: Arc<SimpleAction>,
|
action_quit: SimpleAction,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_append: SimpleAction,
|
||||||
action_tab_close: Arc<SimpleAction>,
|
action_tab_close: SimpleAction,
|
||||||
action_tab_close_all: Arc<SimpleAction>,
|
action_tab_close_all: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_tab_pin: Arc<SimpleAction>,
|
action_tab_pin: SimpleAction,
|
||||||
view: &TabView,
|
view: &TabView,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
|
@ -11,7 +11,7 @@ pub struct Append {
|
|||||||
|
|
||||||
impl Append {
|
impl Append {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_append: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_append: SimpleAction) -> Arc<Self> {
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
widget: Widget::new_arc(action_tab_append),
|
widget: Widget::new_arc(action_tab_append),
|
||||||
})
|
})
|
||||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_append: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_append: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
.icon_name("tab-new-symbolic")
|
.icon_name("tab-new-symbolic")
|
||||||
|
@ -17,17 +17,17 @@ pub struct Menu {
|
|||||||
#[rustfmt::skip] // @TODO template builder?
|
#[rustfmt::skip] // @TODO template builder?
|
||||||
impl Menu {
|
impl Menu {
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_tool_debug: Arc<SimpleAction>,
|
action_tool_debug: SimpleAction,
|
||||||
action_tool_profile: Arc<SimpleAction>,
|
action_tool_profile: SimpleAction,
|
||||||
action_quit: Arc<SimpleAction>,
|
action_quit: SimpleAction,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_append: SimpleAction,
|
||||||
action_tab_close: Arc<SimpleAction>,
|
action_tab_close: SimpleAction,
|
||||||
action_tab_close_all: Arc<SimpleAction>,
|
action_tab_close_all: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_tab_pin: Arc<SimpleAction>,
|
action_tab_pin: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init model
|
// Init model
|
||||||
let model = gio::Menu::new();
|
let model = gio::Menu::new();
|
||||||
@ -80,7 +80,7 @@ impl Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Private helpers
|
// Private helpers
|
||||||
fn detailed_action_name(action: Arc<SimpleAction>) -> GString {
|
fn detailed_action_name(action: SimpleAction) -> GString {
|
||||||
gformat!("win.{}", action.name()) // @TODO find the way to ident parent group
|
gformat!("win.{}", action.name()) // @TODO find the way to ident parent group
|
||||||
// without application-wide dependencies import
|
// without application-wide dependencies import
|
||||||
// see also src/app/action.rs
|
// see also src/app/action.rs
|
||||||
|
@ -18,13 +18,13 @@ use std::{cell::RefCell, collections::HashMap, sync::Arc};
|
|||||||
// Main
|
// Main
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
// Local actions
|
// Local actions
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
// Global actions
|
// Global actions
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
// Dynamically allocated reference index
|
// Dynamically allocated reference index
|
||||||
index: Arc<RefCell<HashMap<GString, Arc<Item>>>>,
|
index: Arc<RefCell<HashMap<GString, Arc<Item>>>>,
|
||||||
// GTK
|
// GTK
|
||||||
@ -35,17 +35,15 @@ impl Tab {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init local actions
|
// Init local actions
|
||||||
let action_tab_open = Arc::new(SimpleAction::new(
|
let action_tab_open =
|
||||||
&uuid_string_random(),
|
SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type()));
|
||||||
Some(&String::static_variant_type()),
|
|
||||||
));
|
|
||||||
|
|
||||||
// Init empty HashMap index as no tabs appended yet
|
// Init empty HashMap index as no tabs appended yet
|
||||||
let index = Arc::new(RefCell::new(HashMap::new()));
|
let index = Arc::new(RefCell::new(HashMap::new()));
|
||||||
|
@ -28,12 +28,12 @@ impl Item {
|
|||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
// Options
|
// Options
|
||||||
position: Option<i32>,
|
position: Option<i32>,
|
||||||
is_pinned: bool,
|
is_pinned: bool,
|
||||||
@ -128,12 +128,12 @@ impl Item {
|
|||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_id: &i64,
|
app_browser_window_tab_id: &i64,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
) -> Result<Vec<Arc<Item>>, String> {
|
) -> Result<Vec<Arc<Item>>, String> {
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ use std::{cell::RefCell, sync::Arc};
|
|||||||
pub struct Page {
|
pub struct Page {
|
||||||
id: GString,
|
id: GString,
|
||||||
// Actions
|
// Actions
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
// Components
|
// Components
|
||||||
navigation: Arc<Navigation>,
|
navigation: Arc<Navigation>,
|
||||||
content: Arc<Content>,
|
content: Arc<Content>,
|
||||||
@ -52,18 +52,16 @@ impl Page {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
id: GString,
|
id: GString,
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init local actions
|
// Init local actions
|
||||||
let action_page_open = Arc::new(SimpleAction::new(
|
let action_page_open =
|
||||||
&uuid_string_random(),
|
SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type()));
|
||||||
Some(&String::static_variant_type()),
|
|
||||||
));
|
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let content = Arc::new(Content::new(
|
let content = Arc::new(Content::new(
|
||||||
|
@ -13,20 +13,17 @@ use gtk::{
|
|||||||
prelude::{BoxExt, WidgetExt},
|
prelude::{BoxExt, WidgetExt},
|
||||||
Box, Orientation,
|
Box, Orientation,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Content {
|
pub struct Content {
|
||||||
// GTK
|
// GTK
|
||||||
gobject: Box,
|
gobject: Box,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Content {
|
impl Content {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(action_tab_open: Arc<SimpleAction>, action_page_open: Arc<SimpleAction>) -> Self {
|
pub fn new(action_tab_open: SimpleAction, action_page_open: SimpleAction) -> Self {
|
||||||
Self {
|
Self {
|
||||||
gobject: Box::builder().orientation(Orientation::Vertical).build(),
|
gobject: Box::builder().orientation(Orientation::Vertical).build(),
|
||||||
action_tab_open,
|
action_tab_open,
|
||||||
|
@ -8,8 +8,6 @@ use gtk::{
|
|||||||
ScrolledWindow,
|
ScrolledWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Meta {
|
pub struct Meta {
|
||||||
title: Option<GString>,
|
title: Option<GString>,
|
||||||
}
|
}
|
||||||
@ -24,8 +22,8 @@ impl Text {
|
|||||||
pub fn gemini(
|
pub fn gemini(
|
||||||
gemtext: &str,
|
gemtext: &str,
|
||||||
base: &Uri,
|
base: &Uri,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_append: SimpleAction,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let gemini = Gemini::new(gemtext, base, action_tab_append, action_page_open);
|
let gemini = Gemini::new(gemtext, base, action_tab_append, action_page_open);
|
||||||
|
@ -23,8 +23,8 @@ impl Gemini {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
gemtext: &str,
|
gemtext: &str,
|
||||||
base: &Uri,
|
base: &Uri,
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let reader = Reader::new_arc(gemtext, base, action_tab_open, action_page_open);
|
let reader = Reader::new_arc(gemtext, base, action_tab_open, action_page_open);
|
||||||
|
@ -33,8 +33,8 @@ impl Reader {
|
|||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
gemtext: &str,
|
gemtext: &str,
|
||||||
base: &Uri,
|
base: &Uri,
|
||||||
action_tab_open: Arc<SimpleAction>,
|
action_tab_open: SimpleAction,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init default values
|
// Init default values
|
||||||
let mut title = None;
|
let mut title = None;
|
||||||
|
@ -32,7 +32,7 @@ impl Input {
|
|||||||
// Setters
|
// Setters
|
||||||
pub fn set_new_response(
|
pub fn set_new_response(
|
||||||
&self,
|
&self,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
size_limit: Option<usize>,
|
size_limit: Option<usize>,
|
||||||
@ -44,7 +44,7 @@ impl Input {
|
|||||||
|
|
||||||
pub fn set_new_sensitive(
|
pub fn set_new_sensitive(
|
||||||
&self,
|
&self,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
max_length: Option<i32>,
|
max_length: Option<i32>,
|
||||||
|
@ -24,14 +24,14 @@ pub struct Response {
|
|||||||
impl Response {
|
impl Response {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
size_limit: Option<usize>,
|
size_limit: Option<usize>,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init local actions
|
// Init local actions
|
||||||
let action_update = Arc::new(SimpleAction::new(&uuid_string_random(), None));
|
let action_update = SimpleAction::new(&uuid_string_random(), None);
|
||||||
let action_send = Arc::new(SimpleAction::new(&uuid_string_random(), None));
|
let action_send = SimpleAction::new(&uuid_string_random(), None);
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let control = Control::new_arc(action_send.clone());
|
let control = Control::new_arc(action_send.clone());
|
||||||
|
@ -17,7 +17,7 @@ pub struct Control {
|
|||||||
|
|
||||||
impl Control {
|
impl Control {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_send: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
let counter = Counter::new_arc();
|
let counter = Counter::new_arc();
|
||||||
let send = Send::new_arc(action_send);
|
let send = Send::new_arc(action_send);
|
||||||
|
@ -11,7 +11,7 @@ pub struct Send {
|
|||||||
|
|
||||||
impl Send {
|
impl Send {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_send: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Widget::new_arc(action_send);
|
let widget = Widget::new_arc(action_send);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_send: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
//.css_classes(["accent"])
|
//.css_classes(["accent"])
|
||||||
|
@ -11,7 +11,7 @@ pub struct Form {
|
|||||||
|
|
||||||
impl Form {
|
impl Form {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_update: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_update: SimpleAction) -> Arc<Self> {
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Widget::new_arc(action_update);
|
let widget = Widget::new_arc(action_update);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_update: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_update: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = TextView::builder()
|
let gobject = TextView::builder()
|
||||||
.bottom_margin(MARGIN)
|
.bottom_margin(MARGIN)
|
||||||
|
@ -20,13 +20,13 @@ pub struct Sensitive {
|
|||||||
impl Sensitive {
|
impl Sensitive {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
max_length: Option<i32>,
|
max_length: Option<i32>,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init local actions
|
// Init local actions
|
||||||
let action_send = Arc::new(SimpleAction::new(&uuid_string_random(), None));
|
let action_send = SimpleAction::new(&uuid_string_random(), None);
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let form = Form::new_arc(
|
let form = Form::new_arc(
|
||||||
|
@ -13,7 +13,7 @@ pub struct Form {
|
|||||||
impl Form {
|
impl Form {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_send: Arc<SimpleAction>,
|
action_send: SimpleAction,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
max_length: Option<i32>,
|
max_length: Option<i32>,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
|
@ -16,7 +16,7 @@ pub struct Widget {
|
|||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_send: Arc<SimpleAction>,
|
action_send: SimpleAction,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
max_length: Option<i32>,
|
max_length: Option<i32>,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
|
@ -30,11 +30,11 @@ pub struct Navigation {
|
|||||||
|
|
||||||
impl Navigation {
|
impl Navigation {
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
let base = Base::new_arc(action_tab_page_navigation_base);
|
let base = Base::new_arc(action_tab_page_navigation_base);
|
||||||
|
@ -10,14 +10,14 @@ use gtk::{
|
|||||||
use std::{cell::RefCell, sync::Arc};
|
use std::{cell::RefCell, sync::Arc};
|
||||||
|
|
||||||
pub struct Base {
|
pub struct Base {
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: SimpleAction,
|
||||||
uri: RefCell<Option<Uri>>,
|
uri: RefCell<Option<Uri>>,
|
||||||
widget: Arc<Widget>,
|
widget: Arc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Base {
|
impl Base {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_base: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_base: SimpleAction) -> Arc<Self> {
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
action_tab_page_navigation_base: action_tab_page_navigation_base.clone(),
|
action_tab_page_navigation_base: action_tab_page_navigation_base.clone(),
|
||||||
uri: RefCell::new(None),
|
uri: RefCell::new(None),
|
||||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_base: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_base: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
.icon_name("go-home-symbolic")
|
.icon_name("go-home-symbolic")
|
||||||
|
@ -28,8 +28,8 @@ pub struct History {
|
|||||||
impl History {
|
impl History {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// init components
|
// init components
|
||||||
let back = Back::new_arc(action_tab_page_navigation_history_back);
|
let back = Back::new_arc(action_tab_page_navigation_history_back);
|
||||||
|
@ -6,13 +6,13 @@ use gtk::{gio::SimpleAction, Button};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Back {
|
pub struct Back {
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: SimpleAction,
|
||||||
widget: Arc<Widget>,
|
widget: Arc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Back {
|
impl Back {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_history_back: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_history_back: SimpleAction) -> Arc<Self> {
|
||||||
// Return activated struct
|
// Return activated struct
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
action_tab_page_navigation_history_back: action_tab_page_navigation_history_back
|
action_tab_page_navigation_history_back: action_tab_page_navigation_history_back
|
||||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_history_back: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_history_back: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
.icon_name("go-previous-symbolic")
|
.icon_name("go-previous-symbolic")
|
||||||
|
@ -6,13 +6,13 @@ use gtk::{gio::SimpleAction, Button};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Forward {
|
pub struct Forward {
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: SimpleAction,
|
||||||
widget: Arc<Widget>,
|
widget: Arc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Forward {
|
impl Forward {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_history_forward: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_history_forward: SimpleAction) -> Arc<Self> {
|
||||||
// Return activated struct
|
// Return activated struct
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
action_tab_page_navigation_history_forward: action_tab_page_navigation_history_forward
|
action_tab_page_navigation_history_forward: action_tab_page_navigation_history_forward
|
||||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_history_forward: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_history_forward: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
.icon_name("go-next-symbolic")
|
.icon_name("go-next-symbolic")
|
||||||
|
@ -6,13 +6,13 @@ use gtk::{gio::SimpleAction, Button};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Reload {
|
pub struct Reload {
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: SimpleAction,
|
||||||
widget: Arc<Widget>,
|
widget: Arc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reload {
|
impl Reload {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_reload: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_reload: SimpleAction) -> Arc<Self> {
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
action_tab_page_navigation_reload: action_tab_page_navigation_reload.clone(),
|
action_tab_page_navigation_reload: action_tab_page_navigation_reload.clone(),
|
||||||
widget: Widget::new_arc(action_tab_page_navigation_reload),
|
widget: Widget::new_arc(action_tab_page_navigation_reload),
|
||||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_tab_page_navigation_reload: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_tab_page_navigation_reload: SimpleAction) -> Arc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
.icon_name("view-refresh-symbolic")
|
.icon_name("view-refresh-symbolic")
|
||||||
|
@ -21,8 +21,8 @@ impl Request {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
// Actions
|
// Actions
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>, // @TODO local `action_page_open`?
|
action_tab_page_navigation_reload: SimpleAction, // @TODO local `action_page_open`?
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
widget: Widget::new_arc(action_update, action_tab_page_navigation_reload),
|
widget: Widget::new_arc(action_update, action_tab_page_navigation_reload),
|
||||||
|
@ -30,8 +30,8 @@ pub struct Widget {
|
|||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: SimpleAction,
|
||||||
action_tab_page_navigation_reload: Arc<SimpleAction>, // @TODO local `action_page_open`?
|
action_tab_page_navigation_reload: SimpleAction, // @TODO local `action_page_open`?
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init animated progress bar state
|
// Init animated progress bar state
|
||||||
let progress = Arc::new(Progress {
|
let progress = Arc::new(Progress {
|
||||||
|
@ -16,7 +16,7 @@ impl Widget {
|
|||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
name: &str,
|
name: &str,
|
||||||
// Actions
|
// Actions
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: SimpleAction,
|
||||||
// Components
|
// Components
|
||||||
navigation: &Box,
|
navigation: &Box,
|
||||||
content: &Box,
|
content: &Box,
|
||||||
@ -24,7 +24,7 @@ impl Widget {
|
|||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init additional action group
|
// Init additional action group
|
||||||
let action_group = SimpleActionGroup::new();
|
let action_group = SimpleActionGroup::new();
|
||||||
action_group.add_action(action_page_open.as_ref());
|
action_group.add_action(&action_page_open);
|
||||||
|
|
||||||
// Init self
|
// Init self
|
||||||
let gobject = Box::builder()
|
let gobject = Box::builder()
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::{Icon, SimpleAction, SimpleActionGroup},
|
gio::{Icon, SimpleAction, SimpleActionGroup},
|
||||||
@ -13,10 +11,10 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(action_tab_append: Arc<SimpleAction>) -> Self {
|
pub fn new(action_tab_append: SimpleAction) -> Self {
|
||||||
// Init additional action group
|
// Init additional action group
|
||||||
let action_group = SimpleActionGroup::new();
|
let action_group = SimpleActionGroup::new();
|
||||||
action_group.add_action(action_tab_append.as_ref());
|
action_group.add_action(&action_tab_append);
|
||||||
|
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = TabView::new();
|
let gobject = TabView::new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user