mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
begin action collections implementation (to reduce argument size by clippy)
This commit is contained in:
parent
7c7e91ca31
commit
ec7a668cd9
2
src/action.rs
Normal file
2
src/action.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mod browser;
|
||||||
|
pub use browser::Browser;
|
45
src/action/browser.rs
Normal file
45
src/action/browser.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
use gtk::{gio::SimpleAction, glib::uuid_string_random, prelude::StaticVariantType};
|
||||||
|
|
||||||
|
pub struct Browser {
|
||||||
|
about: SimpleAction,
|
||||||
|
debug: SimpleAction,
|
||||||
|
profile: SimpleAction,
|
||||||
|
quit: SimpleAction,
|
||||||
|
update: SimpleAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Browser {
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
about: SimpleAction::new(&uuid_string_random(), None),
|
||||||
|
debug: SimpleAction::new(&uuid_string_random(), None),
|
||||||
|
profile: SimpleAction::new(&uuid_string_random(), None),
|
||||||
|
quit: SimpleAction::new(&uuid_string_random(), None),
|
||||||
|
update: SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
|
||||||
|
pub fn about(&self) -> &SimpleAction {
|
||||||
|
&self.about
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn debug(&self) -> &SimpleAction {
|
||||||
|
&self.debug
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn profile(&self) -> &SimpleAction {
|
||||||
|
&self.profile
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn quit(&self) -> &SimpleAction {
|
||||||
|
&self.quit
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(&self) -> &SimpleAction {
|
||||||
|
&self.update
|
||||||
|
}
|
||||||
|
}
|
40
src/app.rs
40
src/app.rs
@ -4,13 +4,13 @@ mod database;
|
|||||||
use browser::Browser;
|
use browser::Browser;
|
||||||
use database::Database;
|
use database::Database;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use adw::Application;
|
use adw::Application;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{gformat, uuid_string_random, ExitCode},
|
glib::{gformat, uuid_string_random, ExitCode},
|
||||||
prelude::{
|
prelude::{
|
||||||
ActionExt, ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt,
|
ActionExt, ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt, ToVariant,
|
||||||
StaticVariantType, ToVariant,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use sqlite::{Connection, Transaction};
|
use sqlite::{Connection, Transaction};
|
||||||
@ -27,16 +27,13 @@ pub struct App {
|
|||||||
impl App {
|
impl App {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(profile_database_connection: Rc<RwLock<Connection>>, profile_path: PathBuf) -> Self {
|
pub fn new(profile_database_connection: Rc<RwLock<Connection>>, profile_path: PathBuf) -> Self {
|
||||||
|
// Init actions
|
||||||
|
let browser_action = Rc::new(BrowserAction::new());
|
||||||
|
|
||||||
// Init defaults
|
// Init defaults
|
||||||
let default_state = (-1).to_variant();
|
let default_state = (-1).to_variant();
|
||||||
|
|
||||||
// Init actions
|
// Init actions
|
||||||
let action_about = SimpleAction::new(&uuid_string_random(), None);
|
|
||||||
let action_debug = SimpleAction::new(&uuid_string_random(), None);
|
|
||||||
let action_profile = SimpleAction::new(&uuid_string_random(), None);
|
|
||||||
let action_quit = SimpleAction::new(&uuid_string_random(), None);
|
|
||||||
let action_update =
|
|
||||||
SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type()));
|
|
||||||
let action_page_new = SimpleAction::new(&uuid_string_random(), None);
|
let action_page_new = SimpleAction::new(&uuid_string_random(), None);
|
||||||
let action_page_close =
|
let action_page_close =
|
||||||
SimpleAction::new_stateful(&uuid_string_random(), None, &default_state);
|
SimpleAction::new_stateful(&uuid_string_random(), None, &default_state);
|
||||||
@ -59,11 +56,24 @@ impl App {
|
|||||||
|
|
||||||
// Init accels
|
// Init accels
|
||||||
let accels_config = &[
|
let accels_config = &[
|
||||||
|
// Browser actions
|
||||||
|
(
|
||||||
|
gformat!("win.{}", browser_action.debug().name()),
|
||||||
|
&["<Primary>i"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
gformat!("win.{}", browser_action.quit().name()),
|
||||||
|
&["<Primary>Escape"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
gformat!("win.{}", browser_action.update().name()),
|
||||||
|
&["<Primary>u"],
|
||||||
|
),
|
||||||
|
// Other
|
||||||
(
|
(
|
||||||
gformat!("win.{}", action_page_reload.name()),
|
gformat!("win.{}", action_page_reload.name()),
|
||||||
&["<Primary>r"],
|
&["<Primary>r"],
|
||||||
),
|
),
|
||||||
(gformat!("win.{}", action_debug.name()), &["<Primary>i"]),
|
|
||||||
(
|
(
|
||||||
gformat!("win.{}", action_page_close.name()),
|
gformat!("win.{}", action_page_close.name()),
|
||||||
&["<Primary>q"],
|
&["<Primary>q"],
|
||||||
@ -79,8 +89,6 @@ impl App {
|
|||||||
(gformat!("win.{}", action_page_home.name()), &["<Primary>h"]),
|
(gformat!("win.{}", action_page_home.name()), &["<Primary>h"]),
|
||||||
(gformat!("win.{}", action_page_new.name()), &["<Primary>t"]),
|
(gformat!("win.{}", action_page_new.name()), &["<Primary>t"]),
|
||||||
(gformat!("win.{}", action_page_pin.name()), &["<Primary>p"]),
|
(gformat!("win.{}", action_page_pin.name()), &["<Primary>p"]),
|
||||||
(gformat!("win.{}", action_quit.name()), &["<Primary>Escape"]),
|
|
||||||
(gformat!("win.{}", action_update.name()), &["<Primary>u"]),
|
|
||||||
]; // @TODO config
|
]; // @TODO config
|
||||||
|
|
||||||
for (detailed_action_name, &accels) in accels_config {
|
for (detailed_action_name, &accels) in accels_config {
|
||||||
@ -90,11 +98,7 @@ impl App {
|
|||||||
// Init components
|
// Init components
|
||||||
let browser = Rc::new(Browser::new(
|
let browser = Rc::new(Browser::new(
|
||||||
profile_path,
|
profile_path,
|
||||||
action_about.clone(),
|
browser_action.clone(),
|
||||||
action_debug.clone(),
|
|
||||||
action_profile.clone(),
|
|
||||||
action_quit.clone(),
|
|
||||||
action_update.clone(),
|
|
||||||
action_page_new.clone(),
|
action_page_new.clone(),
|
||||||
action_page_close.clone(),
|
action_page_close.clone(),
|
||||||
action_page_close_all.clone(),
|
action_page_close_all.clone(),
|
||||||
@ -107,10 +111,10 @@ impl App {
|
|||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
gobject.connect_activate({
|
gobject.connect_activate({
|
||||||
let action_update = action_update.clone();
|
let update = browser_action.update().clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
// Make initial update
|
// Make initial update
|
||||||
action_update.activate(Some(&"".to_variant())); // @TODO
|
update.activate(Some(&"".to_variant())); // @TODO
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use database::Database;
|
|||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
use window::Window;
|
use window::Window;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use adw::ApplicationWindow;
|
use adw::ApplicationWindow;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::{Cancellable, File, SimpleAction},
|
gio::{Cancellable, File, SimpleAction},
|
||||||
@ -19,8 +20,6 @@ use sqlite::Transaction;
|
|||||||
use std::{path::PathBuf, rc::Rc};
|
use std::{path::PathBuf, rc::Rc};
|
||||||
|
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
// Components
|
|
||||||
// header: Rc<Header>,
|
|
||||||
window: Rc<Window>,
|
window: Rc<Window>,
|
||||||
widget: Rc<Widget>,
|
widget: Rc<Widget>,
|
||||||
}
|
}
|
||||||
@ -31,11 +30,7 @@ impl Browser {
|
|||||||
// Extras
|
// Extras
|
||||||
profile_path: PathBuf,
|
profile_path: PathBuf,
|
||||||
// Actions
|
// Actions
|
||||||
action_about: SimpleAction,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_debug: SimpleAction,
|
|
||||||
action_profile: SimpleAction,
|
|
||||||
action_quit: SimpleAction,
|
|
||||||
action_update: SimpleAction,
|
|
||||||
action_page_new: SimpleAction,
|
action_page_new: SimpleAction,
|
||||||
action_page_close: SimpleAction,
|
action_page_close: SimpleAction,
|
||||||
action_page_close_all: SimpleAction,
|
action_page_close_all: SimpleAction,
|
||||||
@ -47,11 +42,7 @@ impl Browser {
|
|||||||
) -> Browser {
|
) -> Browser {
|
||||||
// Init components
|
// Init components
|
||||||
let window = Rc::new(Window::new(
|
let window = Rc::new(Window::new(
|
||||||
action_about.clone(),
|
browser_action.clone(),
|
||||||
action_debug.clone(),
|
|
||||||
action_profile.clone(),
|
|
||||||
action_quit.clone(),
|
|
||||||
action_update.clone(),
|
|
||||||
action_page_new.clone(),
|
action_page_new.clone(),
|
||||||
action_page_close.clone(),
|
action_page_close.clone(),
|
||||||
action_page_close_all.clone(),
|
action_page_close_all.clone(),
|
||||||
@ -66,11 +57,11 @@ impl Browser {
|
|||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
window.gobject(),
|
window.gobject(),
|
||||||
&[
|
&[
|
||||||
action_about.clone(),
|
browser_action.about().clone(),
|
||||||
action_debug.clone(),
|
browser_action.debug().clone(),
|
||||||
action_profile.clone(),
|
browser_action.profile().clone(),
|
||||||
action_quit.clone(),
|
browser_action.quit().clone(),
|
||||||
action_update.clone(),
|
browser_action.update().clone(),
|
||||||
action_page_new.clone(),
|
action_page_new.clone(),
|
||||||
action_page_close.clone(),
|
action_page_close.clone(),
|
||||||
action_page_close_all.clone(),
|
action_page_close_all.clone(),
|
||||||
@ -83,21 +74,23 @@ impl Browser {
|
|||||||
));
|
));
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
action_about.connect_activate({
|
|
||||||
|
// Browser actions
|
||||||
|
browser_action.about().connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
About::new().present(Some(window.gobject()));
|
About::new().present(Some(window.gobject()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
action_debug.connect_activate({
|
browser_action.debug().connect_activate({
|
||||||
let widget = widget.clone();
|
let widget = widget.clone();
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
widget.gobject().emit_enable_debugging(true);
|
widget.gobject().emit_enable_debugging(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
action_profile.connect_activate({
|
browser_action.profile().connect_activate({
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
FileLauncher::new(Some(&File::for_path(&profile_path))).launch(
|
FileLauncher::new(Some(&File::for_path(&profile_path))).launch(
|
||||||
None::<>k::Window>,
|
None::<>k::Window>,
|
||||||
@ -112,18 +105,19 @@ impl Browser {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
action_quit.connect_activate({
|
browser_action.quit().connect_activate({
|
||||||
let widget = widget.clone();
|
let widget = widget.clone();
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
widget.gobject().close();
|
widget.gobject().close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
action_update.connect_activate({
|
browser_action.update().connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, this| window.update(string_from_variant(this).as_str())
|
move |_, this| window.update(string_from_variant(this).as_str())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Other
|
||||||
action_page_new.connect_activate({
|
action_page_new.connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
|
@ -9,9 +9,9 @@ use sqlite::Transaction;
|
|||||||
use tab::Tab;
|
use tab::Tab;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use crate::action::Browser as BrowserAction;
|
||||||
|
|
||||||
use gtk::{gio::SimpleAction, Box};
|
use gtk::{gio::SimpleAction, Box};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
//header: Rc<Header>,
|
//header: Rc<Header>,
|
||||||
@ -23,11 +23,7 @@ impl Window {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new(
|
pub fn new(
|
||||||
// Actions
|
// Actions
|
||||||
action_about: SimpleAction,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_debug: SimpleAction,
|
|
||||||
action_profile: SimpleAction,
|
|
||||||
action_quit: SimpleAction,
|
|
||||||
action_update: SimpleAction,
|
|
||||||
action_page_new: SimpleAction,
|
action_page_new: SimpleAction,
|
||||||
action_page_close: SimpleAction,
|
action_page_close: SimpleAction,
|
||||||
action_page_close_all: SimpleAction,
|
action_page_close_all: SimpleAction,
|
||||||
@ -39,6 +35,7 @@ impl Window {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Tab::new_rc(
|
let tab = Tab::new_rc(
|
||||||
|
browser_action.clone(),
|
||||||
action_page_close.clone(),
|
action_page_close.clone(),
|
||||||
action_page_close_all.clone(),
|
action_page_close_all.clone(),
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
@ -46,15 +43,11 @@ impl Window {
|
|||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
action_page_pin.clone(),
|
action_page_pin.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
action_update.clone(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let header = Header::new_rc(
|
let header = Header::new_rc(
|
||||||
// Actions
|
// Actions
|
||||||
action_about,
|
browser_action,
|
||||||
action_debug,
|
|
||||||
action_profile,
|
|
||||||
action_quit,
|
|
||||||
action_page_new,
|
action_page_new,
|
||||||
action_page_close,
|
action_page_close,
|
||||||
action_page_close_all,
|
action_page_close_all,
|
||||||
|
@ -4,6 +4,7 @@ mod widget;
|
|||||||
use bar::Bar;
|
use bar::Bar;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use adw::{TabView, ToolbarView};
|
use adw::{TabView, ToolbarView};
|
||||||
use gtk::gio::SimpleAction;
|
use gtk::gio::SimpleAction;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -16,10 +17,7 @@ impl Header {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
// Actions
|
// Actions
|
||||||
action_about: SimpleAction,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_debug: SimpleAction,
|
|
||||||
action_profile: SimpleAction,
|
|
||||||
action_quit: SimpleAction,
|
|
||||||
action_page_new: SimpleAction,
|
action_page_new: SimpleAction,
|
||||||
action_page_close: SimpleAction,
|
action_page_close: SimpleAction,
|
||||||
action_page_close_all: SimpleAction,
|
action_page_close_all: SimpleAction,
|
||||||
@ -33,10 +31,7 @@ impl Header {
|
|||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
let bar = Bar::new_rc(
|
let bar = Bar::new_rc(
|
||||||
action_about,
|
browser_action,
|
||||||
action_debug,
|
|
||||||
action_profile,
|
|
||||||
action_quit,
|
|
||||||
action_page_new,
|
action_page_new,
|
||||||
action_page_close,
|
action_page_close,
|
||||||
action_page_close_all,
|
action_page_close_all,
|
||||||
|
@ -8,6 +8,7 @@ use menu::Menu;
|
|||||||
use tab::Tab;
|
use tab::Tab;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::{gio::SimpleAction, Box};
|
use gtk::{gio::SimpleAction, Box};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -19,10 +20,7 @@ pub struct Bar {
|
|||||||
impl Bar {
|
impl Bar {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
action_about: SimpleAction,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_debug: SimpleAction,
|
|
||||||
action_profile: SimpleAction,
|
|
||||||
action_quit: SimpleAction,
|
|
||||||
action_page_new: SimpleAction,
|
action_page_new: SimpleAction,
|
||||||
action_page_close: SimpleAction,
|
action_page_close: SimpleAction,
|
||||||
action_page_close_all: SimpleAction,
|
action_page_close_all: SimpleAction,
|
||||||
@ -37,10 +35,7 @@ impl Bar {
|
|||||||
let control = Control::new_rc();
|
let control = Control::new_rc();
|
||||||
let tab = Tab::new_rc(action_page_new.clone(), view);
|
let tab = Tab::new_rc(action_page_new.clone(), view);
|
||||||
let menu = Menu::new_rc(
|
let menu = Menu::new_rc(
|
||||||
action_about,
|
browser_action,
|
||||||
action_debug,
|
|
||||||
action_profile,
|
|
||||||
action_quit,
|
|
||||||
action_page_new,
|
action_page_new,
|
||||||
action_page_close,
|
action_page_close,
|
||||||
action_page_close_all,
|
action_page_close_all,
|
||||||
|
@ -2,13 +2,13 @@ mod widget;
|
|||||||
|
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::{self, SimpleAction},
|
gio::{self, SimpleAction},
|
||||||
glib::{gformat, GString},
|
glib::{gformat, GString},
|
||||||
prelude::ActionExt,
|
prelude::ActionExt,
|
||||||
MenuButton,
|
MenuButton,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Menu {
|
pub struct Menu {
|
||||||
@ -17,10 +17,7 @@ pub struct Menu {
|
|||||||
#[rustfmt::skip] // @TODO template builder?
|
#[rustfmt::skip] // @TODO template builder?
|
||||||
impl Menu {
|
impl Menu {
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
action_about: SimpleAction,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_debug: SimpleAction,
|
|
||||||
action_profile: SimpleAction,
|
|
||||||
action_quit: SimpleAction,
|
|
||||||
action_page_new: SimpleAction,
|
action_page_new: SimpleAction,
|
||||||
action_page_close: SimpleAction,
|
action_page_close: SimpleAction,
|
||||||
action_page_close_all: SimpleAction,
|
action_page_close_all: SimpleAction,
|
||||||
@ -35,18 +32,18 @@ impl Menu {
|
|||||||
|
|
||||||
// Main > Page
|
// Main > Page
|
||||||
let main_page = gio::Menu::new();
|
let main_page = gio::Menu::new();
|
||||||
main_page.append(Some("New"), Some(&detailed_action_name(action_page_new)));
|
main_page.append(Some("New"), Some(&detailed_action_name(&action_page_new)));
|
||||||
main_page.append(Some("Reload"), Some(&detailed_action_name(action_page_reload)));
|
main_page.append(Some("Reload"), Some(&detailed_action_name(&action_page_reload)));
|
||||||
main_page.append(Some("Pin"), Some(&detailed_action_name(action_page_pin)));
|
main_page.append(Some("Pin"), Some(&detailed_action_name(&action_page_pin)));
|
||||||
|
|
||||||
// Main > Page > Navigation
|
// Main > Page > Navigation
|
||||||
let main_page_navigation = gio::Menu::new();
|
let main_page_navigation = gio::Menu::new();
|
||||||
main_page_navigation.append(Some("Home"), Some(&detailed_action_name(action_page_home)));
|
main_page_navigation.append(Some("Home"), Some(&detailed_action_name(&action_page_home)));
|
||||||
|
|
||||||
// Main > Page > Navigation > History
|
// Main > Page > Navigation > History
|
||||||
let main_page_navigation_history = gio::Menu::new();
|
let main_page_navigation_history = gio::Menu::new();
|
||||||
main_page_navigation_history.append(Some("Back"), Some(&detailed_action_name(action_page_history_back)));
|
main_page_navigation_history.append(Some("Back"), Some(&detailed_action_name(&action_page_history_back)));
|
||||||
main_page_navigation_history.append(Some("Forward"), Some(&detailed_action_name(action_page_history_forward)));
|
main_page_navigation_history.append(Some("Forward"), Some(&detailed_action_name(&action_page_history_forward)));
|
||||||
|
|
||||||
main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history);
|
main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history);
|
||||||
|
|
||||||
@ -54,8 +51,8 @@ impl Menu {
|
|||||||
|
|
||||||
// Main > Page > Close
|
// Main > Page > Close
|
||||||
let main_page_close = gio::Menu::new();
|
let main_page_close = gio::Menu::new();
|
||||||
main_page_close.append(Some("Current"), Some(&detailed_action_name(action_page_close)));
|
main_page_close.append(Some("Current"), Some(&detailed_action_name(&action_page_close)));
|
||||||
main_page_close.append(Some("All"), Some(&detailed_action_name(action_page_close_all)));
|
main_page_close.append(Some("All"), Some(&detailed_action_name(&action_page_close_all)));
|
||||||
|
|
||||||
main_page.append_submenu(Some("Close"), &main_page_close);
|
main_page.append_submenu(Some("Close"), &main_page_close);
|
||||||
|
|
||||||
@ -63,13 +60,13 @@ impl Menu {
|
|||||||
|
|
||||||
// Main > Tool
|
// Main > Tool
|
||||||
let main_tool = gio::Menu::new();
|
let main_tool = gio::Menu::new();
|
||||||
main_tool.append(Some("Debug"), Some(&detailed_action_name(action_debug)));
|
main_tool.append(Some("Debug"), Some(&detailed_action_name(browser_action.debug())));
|
||||||
main_tool.append(Some("Profile"), Some(&detailed_action_name(action_profile)));
|
main_tool.append(Some("Profile"), Some(&detailed_action_name(browser_action.profile())));
|
||||||
main_tool.append(Some("About"), Some(&detailed_action_name(action_about)));
|
main_tool.append(Some("About"), Some(&detailed_action_name(browser_action.about())));
|
||||||
|
|
||||||
main.append_submenu(Some("Tool"), &main_tool);
|
main.append_submenu(Some("Tool"), &main_tool);
|
||||||
|
|
||||||
main.append(Some("Quit"), Some(&detailed_action_name(action_quit)));
|
main.append(Some("Quit"), Some(&detailed_action_name(browser_action.quit())));
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Rc::new(Self { widget:Widget::new_rc(&main) })
|
Rc::new(Self { widget:Widget::new_rc(&main) })
|
||||||
@ -82,7 +79,7 @@ impl Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Private helpers
|
// Private helpers
|
||||||
fn detailed_action_name(action: 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
|
||||||
|
@ -8,6 +8,7 @@ use item::Item;
|
|||||||
use menu::Menu;
|
use menu::Menu;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
@ -19,14 +20,15 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
|||||||
|
|
||||||
// Main
|
// Main
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
|
// Global actions
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
// Local actions
|
// Local actions
|
||||||
action_tab_open: SimpleAction,
|
action_tab_open: SimpleAction,
|
||||||
// Global actions
|
// Page actions
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
// Dynamically allocated reference index
|
// Dynamically allocated reference index
|
||||||
index: Rc<RefCell<HashMap<GString, Rc<Item>>>>,
|
index: Rc<RefCell<HashMap<GString, Rc<Item>>>>,
|
||||||
// GTK
|
// GTK
|
||||||
@ -36,6 +38,7 @@ pub struct Tab {
|
|||||||
impl Tab {
|
impl Tab {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_close: SimpleAction,
|
action_page_close: SimpleAction,
|
||||||
action_page_close_all: SimpleAction,
|
action_page_close_all: SimpleAction,
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
@ -43,7 +46,6 @@ impl Tab {
|
|||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_pin: SimpleAction,
|
action_page_pin: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
// Init local actions
|
// Init local actions
|
||||||
let action_tab_open =
|
let action_tab_open =
|
||||||
@ -72,24 +74,27 @@ impl Tab {
|
|||||||
let index = index.clone();
|
let index = index.clone();
|
||||||
let gobject = widget.gobject().clone();
|
let gobject = widget.gobject().clone();
|
||||||
// Actions
|
// Actions
|
||||||
|
let browser_action = browser_action.clone();
|
||||||
|
|
||||||
let action_tab_open = action_tab_open.clone();
|
let action_tab_open = action_tab_open.clone();
|
||||||
let action_page_home = action_page_home.clone();
|
let action_page_home = action_page_home.clone();
|
||||||
let action_page_history_back = action_page_history_back.clone();
|
let action_page_history_back = action_page_history_back.clone();
|
||||||
let action_page_history_forward = action_page_history_forward.clone();
|
let action_page_history_forward = action_page_history_forward.clone();
|
||||||
let action_page_reload = action_page_reload.clone();
|
let action_page_reload = action_page_reload.clone();
|
||||||
let action_update = action_update.clone();
|
|
||||||
move |_, request| {
|
move |_, request| {
|
||||||
// Init new tab item
|
// Init new tab item
|
||||||
let item = Item::new_rc(
|
let item = Item::new_rc(
|
||||||
&gobject,
|
&gobject,
|
||||||
|
// Global actions
|
||||||
|
browser_action.clone(),
|
||||||
// Local actions
|
// Local actions
|
||||||
action_tab_open.clone(),
|
action_tab_open.clone(),
|
||||||
// Global actions
|
// Page actions
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
action_update.clone(),
|
|
||||||
// Options
|
// Options
|
||||||
gobject
|
gobject
|
||||||
.selected_page()
|
.selected_page()
|
||||||
@ -172,6 +177,7 @@ impl Tab {
|
|||||||
|
|
||||||
// Return activated struct
|
// Return activated struct
|
||||||
Rc::new(Self {
|
Rc::new(Self {
|
||||||
|
browser_action,
|
||||||
// Local actions
|
// Local actions
|
||||||
action_tab_open,
|
action_tab_open,
|
||||||
// Global actions
|
// Global actions
|
||||||
@ -179,7 +185,6 @@ impl Tab {
|
|||||||
action_page_history_back,
|
action_page_history_back,
|
||||||
action_page_history_forward,
|
action_page_history_forward,
|
||||||
action_page_reload,
|
action_page_reload,
|
||||||
action_update,
|
|
||||||
// Init empty HashMap index as no tabs appended yet
|
// Init empty HashMap index as no tabs appended yet
|
||||||
index,
|
index,
|
||||||
// GTK
|
// GTK
|
||||||
@ -192,6 +197,7 @@ impl Tab {
|
|||||||
// Init new tab item
|
// Init new tab item
|
||||||
let item = Item::new_rc(
|
let item = Item::new_rc(
|
||||||
self.gobject(),
|
self.gobject(),
|
||||||
|
self.browser_action.clone(),
|
||||||
// Local actions
|
// Local actions
|
||||||
self.action_tab_open.clone(),
|
self.action_tab_open.clone(),
|
||||||
// Global actions
|
// Global actions
|
||||||
@ -199,7 +205,6 @@ impl Tab {
|
|||||||
self.action_page_history_back.clone(),
|
self.action_page_history_back.clone(),
|
||||||
self.action_page_history_forward.clone(),
|
self.action_page_history_forward.clone(),
|
||||||
self.action_page_reload.clone(),
|
self.action_page_reload.clone(),
|
||||||
self.action_update.clone(),
|
|
||||||
// Options
|
// Options
|
||||||
position,
|
position,
|
||||||
false,
|
false,
|
||||||
@ -332,12 +337,12 @@ impl Tab {
|
|||||||
self.gobject(),
|
self.gobject(),
|
||||||
transaction,
|
transaction,
|
||||||
&record.id,
|
&record.id,
|
||||||
|
self.browser_action.clone(),
|
||||||
self.action_tab_open.clone(),
|
self.action_tab_open.clone(),
|
||||||
self.action_page_home.clone(),
|
self.action_page_home.clone(),
|
||||||
self.action_page_history_back.clone(),
|
self.action_page_history_back.clone(),
|
||||||
self.action_page_history_forward.clone(),
|
self.action_page_history_forward.clone(),
|
||||||
self.action_page_reload.clone(),
|
self.action_page_reload.clone(),
|
||||||
self.action_update.clone(),
|
|
||||||
) {
|
) {
|
||||||
Ok(items) => {
|
Ok(items) => {
|
||||||
for item in items {
|
for item in items {
|
||||||
|
@ -6,6 +6,7 @@ use database::Database;
|
|||||||
use page::Page;
|
use page::Page;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use adw::{TabPage, TabView};
|
use adw::{TabPage, TabView};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
@ -27,13 +28,14 @@ impl Item {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
// Actions
|
// Global actions
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
|
// @TODO
|
||||||
action_tab_open: SimpleAction,
|
action_tab_open: SimpleAction,
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
// Options
|
// Options
|
||||||
position: Option<i32>,
|
position: Option<i32>,
|
||||||
is_pinned: bool,
|
is_pinned: bool,
|
||||||
@ -46,12 +48,12 @@ impl Item {
|
|||||||
let page = Page::new_rc(
|
let page = Page::new_rc(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
// Actions
|
// Actions
|
||||||
|
browser_action,
|
||||||
action_tab_open.clone(),
|
action_tab_open.clone(),
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
action_update.clone(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let widget = Widget::new_rc(
|
let widget = Widget::new_rc(
|
||||||
@ -128,12 +130,12 @@ impl Item {
|
|||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_id: &i64,
|
app_browser_window_tab_id: &i64,
|
||||||
// Actions
|
// Actions
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
action_tab_open: SimpleAction,
|
action_tab_open: SimpleAction,
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
) -> Result<Vec<Rc<Item>>, String> {
|
) -> Result<Vec<Rc<Item>>, String> {
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
|
|
||||||
@ -144,12 +146,12 @@ impl Item {
|
|||||||
let item = Item::new_rc(
|
let item = Item::new_rc(
|
||||||
tab_view,
|
tab_view,
|
||||||
// Actions
|
// Actions
|
||||||
|
browser_action.clone(),
|
||||||
action_tab_open.clone(),
|
action_tab_open.clone(),
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
action_update.clone(),
|
|
||||||
// Options
|
// Options
|
||||||
None,
|
None,
|
||||||
record.is_pinned,
|
record.is_pinned,
|
||||||
|
@ -8,11 +8,11 @@ mod widget;
|
|||||||
use content::Content;
|
use content::Content;
|
||||||
use database::Database;
|
use database::Database;
|
||||||
use input::Input;
|
use input::Input;
|
||||||
|
use meta::{Meta, Status};
|
||||||
use navigation::Navigation;
|
use navigation::Navigation;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use meta::{Meta, Status};
|
use crate::action::Browser as BrowserAction;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gdk_pixbuf::Pixbuf,
|
gdk_pixbuf::Pixbuf,
|
||||||
gio::{
|
gio::{
|
||||||
@ -34,9 +34,9 @@ use std::{rc::Rc, time::Duration};
|
|||||||
pub struct Page {
|
pub struct Page {
|
||||||
id: GString,
|
id: GString,
|
||||||
// Actions
|
// Actions
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_load: SimpleAction,
|
action_page_load: SimpleAction,
|
||||||
action_page_open: SimpleAction,
|
action_page_open: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
// Components
|
// Components
|
||||||
navigation: Rc<Navigation>,
|
navigation: Rc<Navigation>,
|
||||||
content: Rc<Content>,
|
content: Rc<Content>,
|
||||||
@ -53,12 +53,12 @@ impl Page {
|
|||||||
/// Create new activated `Rc<Self>`
|
/// Create new activated `Rc<Self>`
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
id: GString,
|
id: GString,
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
action_tab_open: SimpleAction,
|
action_tab_open: SimpleAction,
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
// Init local actions
|
// Init local actions
|
||||||
let action_page_load = SimpleAction::new(&uuid_string_random(), None);
|
let action_page_load = SimpleAction::new(&uuid_string_random(), None);
|
||||||
@ -69,12 +69,12 @@ impl Page {
|
|||||||
let content = Content::new_rc(action_tab_open.clone(), action_page_open.clone());
|
let content = Content::new_rc(action_tab_open.clone(), action_page_open.clone());
|
||||||
|
|
||||||
let navigation = Navigation::new_rc(
|
let navigation = Navigation::new_rc(
|
||||||
|
browser_action.clone(),
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
action_page_open.clone(),
|
action_page_open.clone(),
|
||||||
action_update.clone(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let input = Input::new_rc();
|
let input = Input::new_rc();
|
||||||
@ -93,9 +93,9 @@ impl Page {
|
|||||||
let this = Rc::new(Self {
|
let this = Rc::new(Self {
|
||||||
id,
|
id,
|
||||||
// Actions
|
// Actions
|
||||||
|
browser_action,
|
||||||
action_page_load: action_page_load.clone(),
|
action_page_load: action_page_load.clone(),
|
||||||
action_page_open: action_page_open.clone(),
|
action_page_open: action_page_open.clone(),
|
||||||
action_update,
|
|
||||||
// Components
|
// Components
|
||||||
content,
|
content,
|
||||||
navigation,
|
navigation,
|
||||||
@ -233,7 +233,7 @@ impl Page {
|
|||||||
|
|
||||||
// Update
|
// Update
|
||||||
self.meta.set_status(Status::Reload).set_title("Loading..");
|
self.meta.set_status(Status::Reload).set_title("Loading..");
|
||||||
self.action_update.activate(Some(&id));
|
self.browser_action.update().activate(Some(&id));
|
||||||
|
|
||||||
// Route by request
|
// Route by request
|
||||||
match Uri::parse(&request, UriFlags::NONE) {
|
match Uri::parse(&request, UriFlags::NONE) {
|
||||||
@ -259,7 +259,7 @@ impl Page {
|
|||||||
self.meta.set_status(status).set_title(title);
|
self.meta.set_status(status).set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
self.action_update.activate(Some(&id));
|
self.browser_action.update().activate(Some(&id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,9 +429,9 @@ impl Page {
|
|||||||
// use gemini::client::response::
|
// use gemini::client::response::
|
||||||
|
|
||||||
// Init shared objects (async)
|
// Init shared objects (async)
|
||||||
|
let update = self.browser_action.update().clone();
|
||||||
let action_page_load = self.action_page_load.clone();
|
let action_page_load = self.action_page_load.clone();
|
||||||
let action_page_open = self.action_page_open.clone();
|
let action_page_open = self.action_page_open.clone();
|
||||||
let action_update = self.action_update.clone();
|
|
||||||
let content = self.content.clone();
|
let content = self.content.clone();
|
||||||
let id = self.id.to_variant();
|
let id = self.id.to_variant();
|
||||||
let input = self.input.clone();
|
let input = self.input.clone();
|
||||||
@ -447,7 +447,7 @@ impl Page {
|
|||||||
|
|
||||||
// Listen for connection status updates
|
// Listen for connection status updates
|
||||||
client.connect_event({
|
client.connect_event({
|
||||||
let action_update = action_update.clone();
|
let update = update.clone();
|
||||||
let id = id.clone();
|
let id = id.clone();
|
||||||
let meta = meta.clone();
|
let meta = meta.clone();
|
||||||
move |_, event, _, _| {
|
move |_, event, _, _| {
|
||||||
@ -463,7 +463,7 @@ impl Page {
|
|||||||
SocketClientEvent::Complete => Status::Complete,
|
SocketClientEvent::Complete => Status::Complete,
|
||||||
_ => todo!(), // notice on API change
|
_ => todo!(), // notice on API change
|
||||||
});
|
});
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -525,7 +525,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update page
|
// Update page
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
},
|
},
|
||||||
gemini::client::response::meta::Status::Success => {
|
gemini::client::response::meta::Status::Success => {
|
||||||
// Route by MIME
|
// Route by MIME
|
||||||
@ -555,7 +555,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window components
|
// Update window components
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
}
|
}
|
||||||
Err((reason, message)) => {
|
Err((reason, message)) => {
|
||||||
// Define common data
|
// Define common data
|
||||||
@ -581,7 +581,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,7 +628,7 @@ impl Page {
|
|||||||
content.to_image(&buffer);
|
content.to_image(&buffer);
|
||||||
|
|
||||||
// Update window components
|
// Update window components
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
}
|
}
|
||||||
Err(reason) => {
|
Err(reason) => {
|
||||||
// Define common data
|
// Define common data
|
||||||
@ -686,7 +686,7 @@ impl Page {
|
|||||||
// content.to_stream();
|
// content.to_stream();
|
||||||
|
|
||||||
// Update window components
|
// Update window components
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
}, */
|
}, */
|
||||||
_ => {
|
_ => {
|
||||||
// Define common data
|
// Define common data
|
||||||
@ -705,7 +705,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -817,7 +817,7 @@ impl Page {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
// Define common data
|
// Define common data
|
||||||
@ -835,7 +835,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -901,7 +901,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
} // Header::from_socket_connection_async
|
} // Header::from_socket_connection_async
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -922,7 +922,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -943,7 +943,7 @@ impl Page {
|
|||||||
.set_title(title);
|
.set_title(title);
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
action_update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -14,9 +14,9 @@ use reload::Reload;
|
|||||||
use request::Request;
|
use request::Request;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use gtk::{gio::SimpleAction, glib::GString, prelude::WidgetExt, Box};
|
use gtk::{gio::SimpleAction, glib::GString, prelude::WidgetExt, Box};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Navigation {
|
pub struct Navigation {
|
||||||
@ -30,18 +30,18 @@ pub struct Navigation {
|
|||||||
|
|
||||||
impl Navigation {
|
impl Navigation {
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_page_open: SimpleAction,
|
action_page_open: SimpleAction,
|
||||||
action_update: SimpleAction,
|
|
||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
let home = Home::new_rc(action_page_home);
|
let home = Home::new_rc(action_page_home);
|
||||||
let history = History::new_rc(action_page_history_back, action_page_history_forward);
|
let history = History::new_rc(action_page_history_back, action_page_history_forward);
|
||||||
let reload = Reload::new_rc(action_page_reload.clone());
|
let reload = Reload::new_rc(action_page_reload.clone());
|
||||||
let request = Request::new_rc(action_update.clone(), action_page_open.clone());
|
let request = Request::new_rc(browser_action, action_page_open.clone());
|
||||||
let bookmark = Bookmark::new_rc();
|
let bookmark = Bookmark::new_rc();
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
|
@ -4,6 +4,7 @@ mod widget;
|
|||||||
use database::Database;
|
use database::Database;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{GString, Uri, UriFlags},
|
glib::{GString, Uri, UriFlags},
|
||||||
@ -21,11 +22,11 @@ impl Request {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
// Actions
|
// Actions
|
||||||
action_update: SimpleAction,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_reload: SimpleAction, // @TODO local `action_page_open`?
|
action_page_reload: SimpleAction, // @TODO local `action_page_open`?
|
||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
Rc::new(Self {
|
Rc::new(Self {
|
||||||
widget: Widget::new_rc(action_update, action_page_reload),
|
widget: Widget::new_rc(browser_action, action_page_reload),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ mod database;
|
|||||||
|
|
||||||
use database::Database;
|
use database::Database;
|
||||||
|
|
||||||
|
use crate::action::Browser as BrowserAction;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{timeout_add_local, ControlFlow, GString, SourceId},
|
glib::{timeout_add_local, ControlFlow, GString, SourceId},
|
||||||
@ -29,7 +30,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(action_update: SimpleAction, action_page_open: SimpleAction) -> Rc<Self> {
|
pub fn new_rc(browser_action: Rc<BrowserAction>, action_page_open: SimpleAction) -> Rc<Self> {
|
||||||
// Init animated progress bar state
|
// Init animated progress bar state
|
||||||
let progress = Rc::new(Progress {
|
let progress = Rc::new(Progress {
|
||||||
fraction: RefCell::new(0.0),
|
fraction: RefCell::new(0.0),
|
||||||
@ -44,7 +45,7 @@ impl Widget {
|
|||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
gobject.connect_changed(move |_| {
|
gobject.connect_changed(move |_| {
|
||||||
action_update.activate(Some(&"".to_variant())); // @TODO
|
browser_action.update().activate(Some(&"".to_variant())); // @TODO
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_activate(move |this| {
|
gobject.connect_activate(move |this| {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
mod action;
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
use app::App;
|
use app::App;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user