add new tab item action group, delegate history handle to action implementation

This commit is contained in:
yggverse 2025-01-25 17:28:05 +02:00
parent 5145a53bfa
commit 913030a955
29 changed files with 409 additions and 232 deletions

View file

@ -4,4 +4,4 @@ pub mod identity;
pub mod loading;
pub mod mime;
use super::TabAction;
use super::ItemAction;

View file

@ -1,11 +1,11 @@
use super::TabAction;
use super::ItemAction;
use adw::StatusPage;
use gtk::{glib::Uri, prelude::ButtonExt, Align, Button};
use std::rc::Rc;
/// Create new default `GObject` preset for mime issue
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
pub fn build(mime: &str, download: Option<(&Rc<TabAction>, &Uri)>) -> StatusPage {
pub fn build(mime: &str, download: Option<(&Rc<ItemAction>, &Uri)>) -> StatusPage {
let status_page = StatusPage::builder()
.description(format!("Content type `{mime}` not supported!"))
.icon_name("dialog-question-symbolic")

View file

@ -4,7 +4,7 @@ mod source;
use gemini::Gemini;
use source::Source;
use super::{TabAction, WindowAction};
use super::{ItemAction, WindowAction};
use gtk::{
glib::Uri,
prelude::{BoxExt, Cast},
@ -28,10 +28,10 @@ impl Text {
pub fn new_gemini(
gemtext: &str,
base: &Uri,
(window_action, tab_action): (&Rc<WindowAction>, &Rc<TabAction>),
(window_action, item_action): (&Rc<WindowAction>, &Rc<ItemAction>),
) -> Self {
// Init components
let gemini = Gemini::new(gemtext, base, (window_action, tab_action));
let gemini = Gemini::new(gemtext, base, (window_action, item_action));
// Init main widget
let g_box = Box::builder().orientation(Orientation::Vertical).build();

View file

@ -4,7 +4,7 @@ mod widget;
use reader::Reader;
use widget::Widget;
use crate::app::browser::window::{tab::item::Action as TabAction, Action as WindowAction};
use crate::app::browser::window::{tab::item::Action as ItemAction, Action as WindowAction};
use gtk::glib::Uri;
use std::rc::Rc;
@ -18,11 +18,11 @@ impl Gemini {
pub fn new(
gemtext: &str,
base: &Uri,
(window_action, tab_action): (&Rc<WindowAction>, &Rc<TabAction>),
(window_action, item_action): (&Rc<WindowAction>, &Rc<ItemAction>),
) -> Self {
// Init components
let reader = Rc::new(
Reader::new(gemtext, base, (window_action.clone(), tab_action.clone())).unwrap(),
Reader::new(gemtext, base, (window_action.clone(), item_action.clone())).unwrap(),
); // @TODO handle errors
let widget = Rc::new(Widget::new(&reader.widget.text_view));

View file

@ -9,7 +9,7 @@ use syntax::Syntax;
use tag::Tag;
use widget::Widget;
use super::{TabAction, WindowAction};
use super::{ItemAction, WindowAction};
use crate::app::browser::window::action::Position;
use ggemtext::line::{
code::{Inline, Multiline},
@ -43,7 +43,7 @@ impl Reader {
pub fn new(
gemtext: &str,
base: &Uri,
(window_action, tab_action): (Rc<WindowAction>, Rc<TabAction>),
(window_action, item_action): (Rc<WindowAction>, Rc<ItemAction>),
) -> Result<Self, Error> {
// Init default values
let mut title = None;
@ -332,7 +332,7 @@ impl Reader {
return match uri.scheme().as_str() {
"gemini" | "titan" => {
// Open new page in browser
tab_action.load.activate(Some(&uri.to_str()), true);
item_action.load.activate(Some(&uri.to_str()), true);
}
// Scheme not supported, delegate
_ => UriLauncher::new(&uri.to_str()).launch(