use tuple for actions

This commit is contained in:
yggverse 2024-11-11 15:14:32 +02:00
parent 0cf4206ebc
commit 8917d14908
4 changed files with 8 additions and 25 deletions

View File

@ -85,8 +85,7 @@ impl Content {
let text = Text::gemini( let text = Text::gemini(
data, data,
base, base,
self.window_action.clone(), (self.window_action.clone(), self.tab_action.clone()),
self.tab_action.clone(),
); );
self.gobject.append(text.gobject()); self.gobject.append(text.gobject());
text text

View File

@ -20,14 +20,9 @@ pub struct Text {
impl Text { impl Text {
// Construct // Construct
pub fn gemini( pub fn gemini(gemtext: &str, base: &Uri, actions: (Rc<WindowAction>, Rc<TabAction>)) -> Self {
gemtext: &str,
base: &Uri,
window_action: Rc<WindowAction>,
tab_action: Rc<TabAction>,
) -> Self {
// Init components // Init components
let gemini = Gemini::new(gemtext, base, window_action, tab_action); let gemini = Gemini::new(gemtext, base, actions);
// Init meta // Init meta
let meta = Meta { let meta = Meta {

View File

@ -16,14 +16,9 @@ pub struct Gemini {
impl Gemini { impl Gemini {
// Construct // Construct
pub fn new( pub fn new(gemtext: &str, base: &Uri, actions: (Rc<WindowAction>, Rc<TabAction>)) -> Self {
gemtext: &str,
base: &Uri,
window_action: Rc<WindowAction>,
tab_action: Rc<TabAction>,
) -> Self {
// Init components // Init components
let reader = Rc::new(Reader::new(gemtext, base, window_action, tab_action)); let reader = Rc::new(Reader::new(gemtext, base, actions));
let widget = Rc::new(Widget::new(reader.gobject())); let widget = Rc::new(Widget::new(reader.gobject()));
// Result // Result

View File

@ -30,12 +30,7 @@ pub struct Reader {
impl Reader { impl Reader {
// Construct // Construct
pub fn new( pub fn new(gemtext: &str, base: &Uri, actions: (Rc<WindowAction>, Rc<TabAction>)) -> Self {
gemtext: &str,
base: &Uri,
window_action: Rc<WindowAction>,
tab_action: Rc<TabAction>,
) -> Self {
// Init default values // Init default values
let mut title = None; let mut title = None;
@ -232,7 +227,6 @@ impl Reader {
// Init events // Init events
primary_button_controller.connect_released({ primary_button_controller.connect_released({
let tab_action = tab_action.clone();
let gobject = widget.gobject().clone(); let gobject = widget.gobject().clone();
let _links_ = links.clone(); // is copy let _links_ = links.clone(); // is copy
move |_, _, window_x, window_y| { move |_, _, window_x, window_y| {
@ -251,7 +245,7 @@ impl Reader {
return match uri.scheme().as_str() { return match uri.scheme().as_str() {
"gemini" => { "gemini" => {
// Open new page in browser // Open new page in browser
tab_action.load().activate(Some(&uri.to_str())); actions.1.load().activate(Some(&uri.to_str()));
} }
// Scheme not supported, delegate // Scheme not supported, delegate
_ => UriLauncher::new(&uri.to_str()).launch( _ => UriLauncher::new(&uri.to_str()).launch(
@ -288,7 +282,7 @@ impl Reader {
return match uri.scheme().as_str() { return match uri.scheme().as_str() {
"gemini" => { "gemini" => {
// Open new page in browser // Open new page in browser
window_action.append().activate_stateful_once( actions.0.append().activate_stateful_once(
None, None,
Some(uri.to_string()), Some(uri.to_string()),
false, false,