mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-16 01:29:57 +00:00
begin window actions group implementation
This commit is contained in:
parent
5f280efaf3
commit
36b86ef5cf
@ -32,7 +32,6 @@ impl App {
|
|||||||
// @TODO
|
// @TODO
|
||||||
let default_state = (-1).to_variant();
|
let default_state = (-1).to_variant();
|
||||||
|
|
||||||
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);
|
||||||
let action_page_close_all = SimpleAction::new(&uuid_string_random(), None);
|
let action_page_close_all = SimpleAction::new(&uuid_string_random(), None);
|
||||||
@ -55,7 +54,6 @@ impl App {
|
|||||||
// Init components
|
// Init components
|
||||||
let browser = Rc::new(Browser::new(
|
let browser = Rc::new(Browser::new(
|
||||||
profile.clone(),
|
profile.clone(),
|
||||||
action_page_new.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(),
|
||||||
@ -201,8 +199,8 @@ impl App {
|
|||||||
(
|
(
|
||||||
gformat!(
|
gformat!(
|
||||||
"{}.{}",
|
"{}.{}",
|
||||||
browser.window().tab().action().id(),
|
browser.window().action().id(),
|
||||||
browser.window().tab().action().append().id()
|
browser.window().action().append().id()
|
||||||
),
|
),
|
||||||
&["<Primary>t"],
|
&["<Primary>t"],
|
||||||
),
|
),
|
||||||
|
@ -30,7 +30,6 @@ impl Browser {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new(
|
pub fn new(
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
action_page_new: SimpleAction,
|
|
||||||
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 +42,6 @@ impl Browser {
|
|||||||
let action = Rc::new(Action::new());
|
let action = Rc::new(Action::new());
|
||||||
let window = Rc::new(Window::new(
|
let window = Rc::new(Window::new(
|
||||||
action.clone(),
|
action.clone(),
|
||||||
action_page_new.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(),
|
||||||
@ -57,7 +55,6 @@ impl Browser {
|
|||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
window.gobject(),
|
window.gobject(),
|
||||||
&[
|
&[
|
||||||
action_page_new.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(),
|
||||||
@ -68,11 +65,17 @@ impl Browser {
|
|||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
|
||||||
// Connect actions to browser window
|
// Connect browser actions to window
|
||||||
widget
|
widget
|
||||||
.gobject()
|
.gobject()
|
||||||
.insert_action_group(action.id(), Some(action.gobject()));
|
.insert_action_group(action.id(), Some(action.gobject()));
|
||||||
|
|
||||||
|
// Connect tab actions to window
|
||||||
|
widget.gobject().insert_action_group(
|
||||||
|
window.tab().action().id(),
|
||||||
|
Some(window.tab().action().gobject()),
|
||||||
|
); // @TODO is really wanted to append it here?
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
action.about().connect_activate({
|
action.about().connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
@ -113,13 +116,6 @@ impl Browser {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// @TODO
|
// @TODO
|
||||||
action_page_new.connect_activate({
|
|
||||||
let window = window.clone();
|
|
||||||
move |_, _| {
|
|
||||||
window.tab_append(None);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
action_page_close.connect_activate({
|
action_page_close.connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |this, _| {
|
move |this, _| {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
mod action;
|
||||||
mod database;
|
mod database;
|
||||||
mod header;
|
mod header;
|
||||||
mod tab;
|
mod tab;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
|
use action::Action;
|
||||||
use database::Database;
|
use database::Database;
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
@ -16,6 +18,7 @@ use std::rc::Rc;
|
|||||||
pub struct Window {
|
pub struct Window {
|
||||||
//header: Rc<Header>,
|
//header: Rc<Header>,
|
||||||
tab: Rc<Tab>,
|
tab: Rc<Tab>,
|
||||||
|
action: Rc<Action>,
|
||||||
widget: Rc<Widget>,
|
widget: Rc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +27,6 @@ impl Window {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
// Actions
|
// Actions
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_new: SimpleAction,
|
|
||||||
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,
|
||||||
@ -33,9 +35,13 @@ impl Window {
|
|||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_page_pin: SimpleAction,
|
action_page_pin: SimpleAction,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
// Init local actions
|
||||||
|
let action = Rc::new(Action::new());
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Tab::new_rc(
|
let tab = Tab::new_rc(
|
||||||
browser_action.clone(),
|
browser_action.clone(),
|
||||||
|
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(),
|
||||||
@ -48,7 +54,7 @@ impl Window {
|
|||||||
let header = Header::new_rc(
|
let header = Header::new_rc(
|
||||||
// Actions
|
// Actions
|
||||||
browser_action,
|
browser_action,
|
||||||
action_page_new,
|
action.clone(),
|
||||||
action_page_close,
|
action_page_close,
|
||||||
action_page_close_all,
|
action_page_close_all,
|
||||||
action_page_home,
|
action_page_home,
|
||||||
@ -63,19 +69,24 @@ impl Window {
|
|||||||
// GTK
|
// GTK
|
||||||
let widget = Rc::new(Widget::new(header.gobject(), tab.gobject()));
|
let widget = Rc::new(Widget::new(header.gobject(), tab.gobject()));
|
||||||
|
|
||||||
|
// Init events
|
||||||
|
action.append().connect_activate({
|
||||||
|
let tab = tab.clone();
|
||||||
|
move || {
|
||||||
|
tab.append(None);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Init struct
|
// Init struct
|
||||||
Self {
|
Self {
|
||||||
//header,
|
//header,
|
||||||
tab,
|
tab,
|
||||||
|
action,
|
||||||
widget,
|
widget,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn tab_append(&self, page_position: Option<i32>) {
|
|
||||||
self.tab.append(page_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn tab_page_home(&self, page_position: Option<i32>) {
|
pub fn tab_page_home(&self, page_position: Option<i32>) {
|
||||||
self.tab.page_home(page_position);
|
self.tab.page_home(page_position);
|
||||||
}
|
}
|
||||||
@ -166,6 +177,10 @@ impl Window {
|
|||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
|
pub fn action(&self) -> &Rc<Action> {
|
||||||
|
&self.action
|
||||||
|
}
|
||||||
|
|
||||||
pub fn tab(&self) -> &Rc<Tab> {
|
pub fn tab(&self) -> &Rc<Tab> {
|
||||||
&self.tab
|
&self.tab
|
||||||
}
|
}
|
||||||
|
65
src/app/browser/window/action.rs
Normal file
65
src/app/browser/window/action.rs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
mod append;
|
||||||
|
|
||||||
|
use append::Append;
|
||||||
|
|
||||||
|
use gtk::{
|
||||||
|
gio::SimpleActionGroup,
|
||||||
|
glib::{uuid_string_random, GString},
|
||||||
|
prelude::ActionMapExt,
|
||||||
|
};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
|
||||||
|
pub struct Action {
|
||||||
|
// Actions
|
||||||
|
append: Rc<Append>,
|
||||||
|
// Group
|
||||||
|
id: GString,
|
||||||
|
gobject: SimpleActionGroup,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Action {
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/// Create new `Self`
|
||||||
|
pub fn new() -> Self {
|
||||||
|
// Init actions
|
||||||
|
let append = Rc::new(Append::new());
|
||||||
|
|
||||||
|
// Generate unique group ID
|
||||||
|
let id = uuid_string_random();
|
||||||
|
|
||||||
|
// Init group
|
||||||
|
let gobject = SimpleActionGroup::new();
|
||||||
|
|
||||||
|
// Add action to given group
|
||||||
|
gobject.add_action(append.gobject());
|
||||||
|
|
||||||
|
// Done
|
||||||
|
Self {
|
||||||
|
append,
|
||||||
|
id,
|
||||||
|
gobject,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
|
||||||
|
/// Get reference `Append` action
|
||||||
|
pub fn append(&self) -> &Rc<Append> {
|
||||||
|
&self.append
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get auto-generated name for action group
|
||||||
|
/// * useful for manual relationship with GObjects or as the `detailed_name`
|
||||||
|
/// for [Accels](https://docs.gtk.org/gtk4/method.Application.set_accels_for_action.html) or
|
||||||
|
/// [Menu](https://docs.gtk.org/gio/class.Menu.html) builder
|
||||||
|
pub fn id(&self) -> &GString {
|
||||||
|
&self.id
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get reference to [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) GObject
|
||||||
|
pub fn gobject(&self) -> &SimpleActionGroup {
|
||||||
|
&self.gobject
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,13 @@ impl Append {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
|
||||||
|
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||||
|
pub fn activate(&self) {
|
||||||
|
self.gobject.activate(None);
|
||||||
|
}
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
|
||||||
/// Define callback function for
|
/// Define callback function for
|
@ -5,6 +5,7 @@ use bar::Bar;
|
|||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use adw::{TabView, ToolbarView};
|
use adw::{TabView, ToolbarView};
|
||||||
use gtk::gio::SimpleAction;
|
use gtk::gio::SimpleAction;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -18,7 +19,7 @@ impl Header {
|
|||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
// Actions
|
// Actions
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_new: SimpleAction,
|
window_action: Rc<WindowAction>,
|
||||||
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,
|
||||||
@ -32,7 +33,7 @@ impl Header {
|
|||||||
// Init components
|
// Init components
|
||||||
let bar = Bar::new_rc(
|
let bar = Bar::new_rc(
|
||||||
browser_action,
|
browser_action,
|
||||||
action_page_new,
|
window_action,
|
||||||
action_page_close,
|
action_page_close,
|
||||||
action_page_close_all,
|
action_page_close_all,
|
||||||
action_page_home,
|
action_page_home,
|
||||||
|
@ -9,6 +9,7 @@ use tab::Tab;
|
|||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::{gio::SimpleAction, Box};
|
use gtk::{gio::SimpleAction, Box};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -21,7 +22,7 @@ impl Bar {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_new: SimpleAction,
|
window_action: Rc<WindowAction>,
|
||||||
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,
|
||||||
@ -33,10 +34,10 @@ impl Bar {
|
|||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
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(window_action.clone(), view);
|
||||||
let menu = Menu::new_rc(
|
let menu = Menu::new_rc(
|
||||||
browser_action,
|
browser_action,
|
||||||
action_page_new,
|
window_action,
|
||||||
action_page_close,
|
action_page_close,
|
||||||
action_page_close_all,
|
action_page_close_all,
|
||||||
action_page_home,
|
action_page_home,
|
||||||
|
@ -3,6 +3,7 @@ mod widget;
|
|||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::{self, SimpleAction},
|
gio::{self, SimpleAction},
|
||||||
glib::{gformat, GString},
|
glib::{gformat, GString},
|
||||||
@ -18,7 +19,7 @@ pub struct Menu {
|
|||||||
impl Menu {
|
impl Menu {
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
action_page_new: SimpleAction,
|
window_action: Rc<WindowAction>,
|
||||||
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,
|
||||||
@ -32,7 +33,12 @@ 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(&gformat!(
|
||||||
|
"{}.{}",
|
||||||
|
window_action.id(),
|
||||||
|
window_action.append().id()
|
||||||
|
)));
|
||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ mod widget;
|
|||||||
use append::Append;
|
use append::Append;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use adw::{TabBar, TabView};
|
use adw::{TabBar, TabView};
|
||||||
use gtk::gio::SimpleAction;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
@ -14,9 +14,9 @@ pub struct Tab {
|
|||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(action_page_new: SimpleAction, view: &TabView) -> Rc<Self> {
|
pub fn new_rc(window_action: Rc<WindowAction>, view: &TabView) -> Rc<Self> {
|
||||||
Rc::new(Self {
|
Rc::new(Self {
|
||||||
widget: Widget::new_rc(view, Append::new_rc(action_page_new).gobject()),
|
widget: Widget::new_rc(view, Append::new_rc(window_action).gobject()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@ mod widget;
|
|||||||
|
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use gtk::{gio::SimpleAction, Button};
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
|
use gtk::Button;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Append {
|
pub struct Append {
|
||||||
@ -11,9 +12,9 @@ pub struct Append {
|
|||||||
|
|
||||||
impl Append {
|
impl Append {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(action_page_new: SimpleAction) -> Rc<Self> {
|
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||||
Rc::new(Self {
|
Rc::new(Self {
|
||||||
widget: Widget::new_rc(action_page_new),
|
widget: Widget::new_rc(window_action),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use gtk::{
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
gio::SimpleAction,
|
use gtk::{prelude::ButtonExt, Align, Button};
|
||||||
prelude::{ActionExt, ButtonExt},
|
|
||||||
Align, Button,
|
|
||||||
};
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Widget {
|
pub struct Widget {
|
||||||
@ -11,7 +8,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(action_page_new: SimpleAction) -> Rc<Self> {
|
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||||
// Init gobject
|
// Init gobject
|
||||||
let gobject = Button::builder()
|
let gobject = Button::builder()
|
||||||
.icon_name("tab-new-symbolic")
|
.icon_name("tab-new-symbolic")
|
||||||
@ -21,9 +18,7 @@ impl Widget {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
gobject.connect_clicked(move |_| {
|
gobject.connect_clicked(move |_| window_action.append().activate());
|
||||||
action_page_new.activate(None);
|
|
||||||
});
|
|
||||||
|
|
||||||
Rc::new(Self { gobject })
|
Rc::new(Self { gobject })
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use menu::Menu;
|
|||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
@ -24,6 +25,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
|||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
// Global actions
|
// Global actions
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
|
window_action: Rc<WindowAction>,
|
||||||
// Page actions
|
// Page actions
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
@ -39,6 +41,7 @@ impl Tab {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new_rc(
|
pub fn new_rc(
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
|
window_action: Rc<WindowAction>,
|
||||||
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,
|
||||||
@ -74,6 +77,7 @@ impl Tab {
|
|||||||
let gobject = widget.gobject().clone();
|
let gobject = widget.gobject().clone();
|
||||||
// Actions
|
// Actions
|
||||||
let browser_action = browser_action.clone();
|
let browser_action = browser_action.clone();
|
||||||
|
let window_action = window_action.clone();
|
||||||
let action = action.clone();
|
let action = action.clone();
|
||||||
|
|
||||||
let action_page_home = action_page_home.clone();
|
let action_page_home = action_page_home.clone();
|
||||||
@ -87,6 +91,7 @@ impl Tab {
|
|||||||
&gobject,
|
&gobject,
|
||||||
// Global actions
|
// Global actions
|
||||||
browser_action.clone(),
|
browser_action.clone(),
|
||||||
|
window_action.clone(),
|
||||||
action.clone(),
|
action.clone(),
|
||||||
// Page actions
|
// Page actions
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
@ -174,6 +179,7 @@ impl Tab {
|
|||||||
// Return activated struct
|
// Return activated struct
|
||||||
Rc::new(Self {
|
Rc::new(Self {
|
||||||
browser_action,
|
browser_action,
|
||||||
|
window_action,
|
||||||
// Global actions
|
// Global actions
|
||||||
action_page_home,
|
action_page_home,
|
||||||
action_page_history_back,
|
action_page_history_back,
|
||||||
@ -192,6 +198,7 @@ impl Tab {
|
|||||||
let item = Item::new_rc(
|
let item = Item::new_rc(
|
||||||
self.gobject(),
|
self.gobject(),
|
||||||
self.browser_action.clone(),
|
self.browser_action.clone(),
|
||||||
|
self.window_action.clone(),
|
||||||
// Local actions
|
// Local actions
|
||||||
self.action.clone(),
|
self.action.clone(),
|
||||||
// Global actions
|
// Global actions
|
||||||
@ -337,6 +344,7 @@ impl Tab {
|
|||||||
transaction,
|
transaction,
|
||||||
&record.id,
|
&record.id,
|
||||||
self.browser_action.clone(),
|
self.browser_action.clone(),
|
||||||
|
self.window_action.clone(),
|
||||||
self.action.clone(),
|
self.action.clone(),
|
||||||
self.action_page_home.clone(),
|
self.action_page_home.clone(),
|
||||||
self.action_page_history_back.clone(),
|
self.action_page_history_back.clone(),
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
mod append;
|
|
||||||
mod open;
|
mod open;
|
||||||
|
|
||||||
use append::Append;
|
|
||||||
use open::Open;
|
use open::Open;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
@ -14,7 +12,6 @@ use std::rc::Rc;
|
|||||||
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
|
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
|
||||||
pub struct Action {
|
pub struct Action {
|
||||||
// Actions
|
// Actions
|
||||||
append: Rc<Append>,
|
|
||||||
open: Rc<Open>,
|
open: Rc<Open>,
|
||||||
// Group
|
// Group
|
||||||
id: GString,
|
id: GString,
|
||||||
@ -27,7 +24,6 @@ impl Action {
|
|||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// Init actions
|
// Init actions
|
||||||
let append = Rc::new(Append::new());
|
|
||||||
let open = Rc::new(Open::new());
|
let open = Rc::new(Open::new());
|
||||||
|
|
||||||
// Generate unique group ID
|
// Generate unique group ID
|
||||||
@ -37,25 +33,14 @@ impl Action {
|
|||||||
let gobject = SimpleActionGroup::new();
|
let gobject = SimpleActionGroup::new();
|
||||||
|
|
||||||
// Add action to given group
|
// Add action to given group
|
||||||
gobject.add_action(append.gobject());
|
|
||||||
gobject.add_action(open.gobject());
|
gobject.add_action(open.gobject());
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
Self {
|
Self { open, id, gobject }
|
||||||
append,
|
|
||||||
open,
|
|
||||||
id,
|
|
||||||
gobject,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
/// Get reference `Append` action
|
|
||||||
pub fn append(&self) -> &Rc<Append> {
|
|
||||||
&self.append
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get reference `Open` action
|
/// Get reference `Open` action
|
||||||
pub fn open(&self) -> &Rc<Open> {
|
pub fn open(&self) -> &Rc<Open> {
|
||||||
&self.open
|
&self.open
|
||||||
|
@ -7,6 +7,7 @@ use page::Page;
|
|||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use crate::app::browser::window::tab::action::Action as TabAction;
|
use crate::app::browser::window::tab::action::Action as TabAction;
|
||||||
use adw::{TabPage, TabView};
|
use adw::{TabPage, TabView};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
@ -31,6 +32,7 @@ impl Item {
|
|||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
// Global actions
|
// Global actions
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
|
window_action: Rc<WindowAction>,
|
||||||
tab_action: Rc<TabAction>,
|
tab_action: Rc<TabAction>,
|
||||||
// @TODO
|
// @TODO
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
@ -132,6 +134,7 @@ impl Item {
|
|||||||
app_browser_window_tab_id: &i64,
|
app_browser_window_tab_id: &i64,
|
||||||
// Actions
|
// Actions
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
|
window_action: Rc<WindowAction>,
|
||||||
tab_action: Rc<TabAction>,
|
tab_action: Rc<TabAction>,
|
||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
@ -148,6 +151,7 @@ impl Item {
|
|||||||
tab_view,
|
tab_view,
|
||||||
// Actions
|
// Actions
|
||||||
browser_action.clone(),
|
browser_action.clone(),
|
||||||
|
window_action.clone(),
|
||||||
tab_action.clone(),
|
tab_action.clone(),
|
||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
|
@ -33,25 +33,25 @@ impl Input {
|
|||||||
// Setters
|
// Setters
|
||||||
pub fn set_new_response(
|
pub fn set_new_response(
|
||||||
&self,
|
&self,
|
||||||
tab_action: Rc<TabAction>,
|
action: Rc<TabAction>,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
size_limit: Option<usize>,
|
size_limit: Option<usize>,
|
||||||
) {
|
) {
|
||||||
self.widget.update(Some(
|
self.widget.update(Some(
|
||||||
Response::new_rc(tab_action, base, title, size_limit).gobject(),
|
Response::new_rc(action, base, title, size_limit).gobject(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_new_sensitive(
|
pub fn set_new_sensitive(
|
||||||
&self,
|
&self,
|
||||||
tab_action: Rc<TabAction>,
|
action: Rc<TabAction>,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
max_length: Option<i32>,
|
max_length: Option<i32>,
|
||||||
) {
|
) {
|
||||||
self.widget.update(Some(
|
self.widget.update(Some(
|
||||||
Sensitive::new_rc(tab_action, base, title, max_length).gobject(),
|
Sensitive::new_rc(action, base, title, max_length).gobject(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user