mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-16 01:29:57 +00:00
register new local action
This commit is contained in:
parent
7fdc053051
commit
ab73b9de5b
@ -38,7 +38,6 @@ impl Window {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Tab::new_arc(
|
let tab = Tab::new_arc(
|
||||||
action_tab_append.clone(),
|
|
||||||
action_tab_page_navigation_base.clone(),
|
action_tab_page_navigation_base.clone(),
|
||||||
action_tab_page_navigation_history_back.clone(),
|
action_tab_page_navigation_history_back.clone(),
|
||||||
action_tab_page_navigation_history_forward.clone(),
|
action_tab_page_navigation_history_forward.clone(),
|
||||||
|
@ -17,8 +17,9 @@ use std::{cell::RefCell, collections::HashMap, sync::Arc};
|
|||||||
|
|
||||||
// Main
|
// Main
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
// Actions
|
// Local actions
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
|
// Global actions
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
||||||
@ -34,7 +35,6 @@ impl Tab {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_append: Arc<SimpleAction>,
|
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
||||||
@ -73,10 +73,45 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
action_tab_open.connect_activate({
|
||||||
|
let index = index.clone();
|
||||||
|
let gobject = widget.gobject().clone();
|
||||||
|
// Actions
|
||||||
|
let action_tab_open = action_tab_open.clone();
|
||||||
|
let action_tab_page_navigation_base = action_tab_page_navigation_base.clone();
|
||||||
|
let action_tab_page_navigation_history_back =
|
||||||
|
action_tab_page_navigation_history_back.clone();
|
||||||
|
let action_tab_page_navigation_history_forward =
|
||||||
|
action_tab_page_navigation_history_forward.clone();
|
||||||
|
let action_tab_page_navigation_reload = action_tab_page_navigation_reload.clone();
|
||||||
|
let action_update = action_update.clone();
|
||||||
|
move |_, _| {
|
||||||
|
// Init new tab item
|
||||||
|
let item = Item::new_arc(
|
||||||
|
&gobject,
|
||||||
|
// Local actions
|
||||||
|
action_tab_open.clone(),
|
||||||
|
// Global actions
|
||||||
|
action_tab_page_navigation_base.clone(),
|
||||||
|
action_tab_page_navigation_history_back.clone(),
|
||||||
|
action_tab_page_navigation_history_forward.clone(),
|
||||||
|
action_tab_page_navigation_reload.clone(),
|
||||||
|
action_update.clone(),
|
||||||
|
// Options
|
||||||
|
false,
|
||||||
|
false, // open on background
|
||||||
|
);
|
||||||
|
|
||||||
|
// Register dynamically created tab components in the HashMap index
|
||||||
|
index.borrow_mut().insert(item.id(), item.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Return activated struct
|
// Return activated struct
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
// Define action links
|
// Local actions
|
||||||
action_tab_append,
|
action_tab_open,
|
||||||
|
// Global actions
|
||||||
action_tab_page_navigation_base,
|
action_tab_page_navigation_base,
|
||||||
action_tab_page_navigation_history_back,
|
action_tab_page_navigation_history_back,
|
||||||
action_tab_page_navigation_history_forward,
|
action_tab_page_navigation_history_forward,
|
||||||
@ -94,8 +129,9 @@ impl Tab {
|
|||||||
// Init new tab item
|
// Init new tab item
|
||||||
let item = Item::new_arc(
|
let item = Item::new_arc(
|
||||||
self.gobject(),
|
self.gobject(),
|
||||||
// Actions
|
// Local actions
|
||||||
self.action_tab_append.clone(),
|
self.action_tab_open.clone(),
|
||||||
|
// Global actions
|
||||||
self.action_tab_page_navigation_base.clone(),
|
self.action_tab_page_navigation_base.clone(),
|
||||||
self.action_tab_page_navigation_history_back.clone(),
|
self.action_tab_page_navigation_history_back.clone(),
|
||||||
self.action_tab_page_navigation_history_forward.clone(),
|
self.action_tab_page_navigation_history_forward.clone(),
|
||||||
@ -217,7 +253,7 @@ impl Tab {
|
|||||||
self.gobject(),
|
self.gobject(),
|
||||||
transaction,
|
transaction,
|
||||||
&record.id,
|
&record.id,
|
||||||
self.action_tab_append.clone(),
|
self.action_tab_open.clone(),
|
||||||
self.action_tab_page_navigation_base.clone(),
|
self.action_tab_page_navigation_base.clone(),
|
||||||
self.action_tab_page_navigation_history_back.clone(),
|
self.action_tab_page_navigation_history_back.clone(),
|
||||||
self.action_tab_page_navigation_history_forward.clone(),
|
self.action_tab_page_navigation_history_forward.clone(),
|
||||||
|
@ -28,7 +28,7 @@ impl Item {
|
|||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
||||||
@ -44,7 +44,8 @@ impl Item {
|
|||||||
// Init components
|
// Init components
|
||||||
let page = Page::new_arc(
|
let page = Page::new_arc(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
action_tab_append.clone(),
|
// Actions
|
||||||
|
action_tab_open.clone(),
|
||||||
action_tab_page_navigation_base.clone(),
|
action_tab_page_navigation_base.clone(),
|
||||||
action_tab_page_navigation_history_back.clone(),
|
action_tab_page_navigation_history_back.clone(),
|
||||||
action_tab_page_navigation_history_forward.clone(),
|
action_tab_page_navigation_history_forward.clone(),
|
||||||
@ -125,7 +126,7 @@ impl Item {
|
|||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_id: &i64,
|
app_browser_window_tab_id: &i64,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
||||||
@ -141,7 +142,7 @@ impl Item {
|
|||||||
let item = Item::new_arc(
|
let item = Item::new_arc(
|
||||||
tab_view,
|
tab_view,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_append.clone(),
|
action_tab_open.clone(),
|
||||||
action_tab_page_navigation_base.clone(),
|
action_tab_page_navigation_base.clone(),
|
||||||
action_tab_page_navigation_history_back.clone(),
|
action_tab_page_navigation_history_back.clone(),
|
||||||
action_tab_page_navigation_history_forward.clone(),
|
action_tab_page_navigation_history_forward.clone(),
|
||||||
|
@ -44,7 +44,7 @@ impl Page {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
id: GString,
|
id: GString,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_base: Arc<SimpleAction>,
|
action_tab_page_navigation_base: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
action_tab_page_navigation_history_back: Arc<SimpleAction>,
|
||||||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
||||||
@ -59,7 +59,7 @@ impl Page {
|
|||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let content = Arc::new(Content::new(
|
let content = Arc::new(Content::new(
|
||||||
action_tab_append.clone(),
|
action_tab_open.clone(),
|
||||||
action_page_open.clone(),
|
action_page_open.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -25,16 +25,16 @@ pub struct Content {
|
|||||||
// GTK
|
// GTK
|
||||||
widget: Box,
|
widget: Box,
|
||||||
// Actions
|
// Actions
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: Arc<SimpleAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Content {
|
impl Content {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(action_tab_append: Arc<SimpleAction>, action_page_open: Arc<SimpleAction>) -> Self {
|
pub fn new(action_tab_open: Arc<SimpleAction>, action_page_open: Arc<SimpleAction>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
||||||
action_tab_append,
|
action_tab_open,
|
||||||
action_page_open,
|
action_page_open,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ impl Content {
|
|||||||
let child = Text::gemini(
|
let child = Text::gemini(
|
||||||
data,
|
data,
|
||||||
base,
|
base,
|
||||||
self.action_tab_append.clone(),
|
self.action_tab_open.clone(),
|
||||||
self.action_page_open.clone(),
|
self.action_page_open.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ impl Gemini {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
gemtext: &str,
|
gemtext: &str,
|
||||||
base: &Uri,
|
base: &Uri,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: Arc<SimpleAction>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let reader = Reader::new_arc(gemtext, base, action_tab_append, action_page_open);
|
let reader = Reader::new_arc(gemtext, base, action_tab_open, action_page_open);
|
||||||
|
|
||||||
let widget = Widget::new_arc(&reader.gobject());
|
let widget = Widget::new_arc(&reader.gobject());
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ impl Reader {
|
|||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
gemtext: &str,
|
gemtext: &str,
|
||||||
base: &Uri,
|
base: &Uri,
|
||||||
action_tab_append: Arc<SimpleAction>,
|
action_tab_open: Arc<SimpleAction>,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: Arc<SimpleAction>,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init default values
|
// Init default values
|
||||||
@ -197,7 +197,7 @@ impl Reader {
|
|||||||
for tag in iter.tags() {
|
for tag in iter.tags() {
|
||||||
// Tag is link
|
// Tag is link
|
||||||
if let Some(_) = _links_.get(&tag) {
|
if let Some(_) = _links_.get(&tag) {
|
||||||
return action_tab_append.activate(None); // @TODO implement URI option
|
return action_tab_open.activate(None); // @TODO implement URI option
|
||||||
// @TODO action does not work after focus out
|
// @TODO action does not work after focus out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user