Browse Source

rename action

master
yggverse 2 months ago
parent
commit
5769dcf8fe
  1. 10
      src/browser.rs
  2. 4
      src/browser/header.rs
  3. 4
      src/browser/header/tray.rs
  4. 4
      src/browser/main.rs
  5. 8
      src/browser/main/tab.rs
  6. 8
      src/browser/main/tab/page.rs
  7. 6
      src/browser/main/tab/page/navigation.rs
  8. 13
      src/browser/main/tab/page/navigation/reload.rs
  9. 4
      src/browser/main/tab/page/navigation/request.rs
  10. 4
      src/main.rs

10
src/browser.rs

@ -36,7 +36,7 @@ impl Browser { @@ -36,7 +36,7 @@ impl Browser {
action_tab_append: Arc<SimpleAction>,
action_tab_close: Arc<SimpleAction>,
action_tab_close_all: Arc<SimpleAction>,
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_tab_pin: Arc<SimpleAction>,
) -> Browser {
// Init database
@ -49,12 +49,12 @@ impl Browser { @@ -49,12 +49,12 @@ impl Browser {
action_tab_append.clone(),
action_tab_close.clone(),
action_tab_close_all.clone(),
action_tab_page_reload.clone(),
action_tab_page_navigation_reload.clone(),
action_tab_pin.clone(),
));
let main = Arc::new(Main::new(
action_tab_page_reload.clone(),
action_tab_page_navigation_reload.clone(),
action_update.clone(),
));
@ -74,7 +74,7 @@ impl Browser { @@ -74,7 +74,7 @@ impl Browser {
widget.add_action(action_tab_append.as_ref());
widget.add_action(action_tab_close.as_ref());
widget.add_action(action_tab_close_all.as_ref());
widget.add_action(action_tab_page_reload.as_ref());
widget.add_action(action_tab_page_navigation_reload.as_ref());
widget.add_action(action_tab_pin.as_ref());
// Init events
@ -122,7 +122,7 @@ impl Browser { @@ -122,7 +122,7 @@ impl Browser {
}
});
action_tab_page_reload.connect_activate({
action_tab_page_navigation_reload.connect_activate({
let main = main.clone();
move |_, _| {
main.tab_page_reload();

4
src/browser/header.rs

@ -21,7 +21,7 @@ impl Header { @@ -21,7 +21,7 @@ impl Header {
action_tab_append: Arc<SimpleAction>,
action_tab_close: Arc<SimpleAction>,
action_tab_close_all: Arc<SimpleAction>,
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_tab_pin: Arc<SimpleAction>,
) -> Self {
// Init components
@ -31,7 +31,7 @@ impl Header { @@ -31,7 +31,7 @@ impl Header {
action_tab_append,
action_tab_close,
action_tab_close_all,
action_tab_page_reload,
action_tab_page_navigation_reload,
action_tab_pin,
);

4
src/browser/header/tray.rs

@ -23,7 +23,7 @@ impl Tray { @@ -23,7 +23,7 @@ impl Tray {
action_tab_append: Arc<SimpleAction>,
action_tab_close: Arc<SimpleAction>,
action_tab_close_all: Arc<SimpleAction>,
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_tab_pin: Arc<SimpleAction>,
) -> Self {
// Init components
@ -35,7 +35,7 @@ impl Tray { @@ -35,7 +35,7 @@ impl Tray {
action_tab_append,
action_tab_close,
action_tab_close_all,
action_tab_page_reload,
action_tab_page_navigation_reload,
action_tab_pin,
);

4
src/browser/main.rs

@ -14,11 +14,11 @@ pub struct Main { @@ -14,11 +14,11 @@ pub struct Main {
impl Main {
// Construct
pub fn new(
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
) -> Self {
// Init components
let tab = Arc::new(Tab::new(action_tab_page_reload, action_update));
let tab = Arc::new(Tab::new(action_tab_page_navigation_reload, action_update));
tab.activate(tab.clone());
tab.append(Some(GString::from("gemini://geminiprotocol.net/")), true); // demo tab @TODO replace with session restore feature

8
src/browser/main/tab.rs

@ -17,7 +17,7 @@ pub struct Tab { @@ -17,7 +17,7 @@ pub struct Tab {
// GTK
widget: Notebook,
// Keep action links in memory to not require them on every tab append
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
// Dynamically allocated reference index
labels: RefCell<HashMap<GString, Arc<Label>>>,
@ -27,7 +27,7 @@ pub struct Tab { @@ -27,7 +27,7 @@ pub struct Tab {
impl Tab {
// Construct
pub fn new(
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
) -> Self {
// Init widget
@ -38,7 +38,7 @@ impl Tab { @@ -38,7 +38,7 @@ impl Tab {
// GTK
widget,
// Define action links
action_tab_page_reload,
action_tab_page_navigation_reload,
action_update,
// Init empty HashMap index as no tabs appended yet
labels: RefCell::new(HashMap::new()),
@ -76,7 +76,7 @@ impl Tab { @@ -76,7 +76,7 @@ impl Tab {
let page = Arc::new(Page::new(
id.clone(),
page_navigation_request_text.clone(),
self.action_tab_page_reload.clone(),
self.action_tab_page_navigation_reload.clone(),
self.action_update.clone(),
));

8
src/browser/main/tab/page.rs

@ -24,7 +24,7 @@ pub struct Page { @@ -24,7 +24,7 @@ pub struct Page {
// GTK
widget: Box,
// Actions
// action_tab_page_reload: Arc<SimpleAction>,
// action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
// Components
navigation: Arc<Navigation>,
@ -38,7 +38,7 @@ impl Page { @@ -38,7 +38,7 @@ impl Page {
pub fn new(
name: GString,
navigation_request_text: Option<GString>,
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
) -> Page {
// Init actions
@ -55,7 +55,7 @@ impl Page { @@ -55,7 +55,7 @@ impl Page {
let content = Arc::new(Content::new(action_page_open.clone()));
let navigation = Arc::new(Navigation::new(
navigation_request_text,
action_tab_page_reload.clone(),
action_tab_page_navigation_reload.clone(),
action_update.clone(),
));
@ -94,7 +94,7 @@ impl Page { @@ -94,7 +94,7 @@ impl Page {
// GTK
widget,
// Actions
// action_tab_page_reload,
// action_tab_page_navigation_reload,
action_update,
// Components
content,

6
src/browser/main/tab/page/navigation.rs

@ -33,17 +33,17 @@ pub struct Navigation { @@ -33,17 +33,17 @@ pub struct Navigation {
impl Navigation {
pub fn new(
request_text: Option<GString>,
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
) -> Self {
// Init components
let base = Base::new();
let history = History::new();
let reload = Reload::new(action_tab_page_reload.clone());
let reload = Reload::new(action_tab_page_navigation_reload.clone());
let request = Request::new(
request_text,
action_update.clone(),
action_tab_page_reload.clone(),
action_tab_page_navigation_reload.clone(),
);
let bookmark = Bookmark::new();

13
src/browser/main/tab/page/navigation/reload.rs

@ -6,13 +6,13 @@ use gtk::{ @@ -6,13 +6,13 @@ use gtk::{
use std::sync::Arc;
pub struct Reload {
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
widget: Button,
}
impl Reload {
// Construct
pub fn new(action_tab_page_reload: Arc<SimpleAction>) -> Self {
pub fn new(action_tab_page_navigation_reload: Arc<SimpleAction>) -> Self {
// Init widget
let widget = Button::builder()
.icon_name("view-refresh-symbolic")
@ -22,22 +22,23 @@ impl Reload { @@ -22,22 +22,23 @@ impl Reload {
// Init events
widget.connect_clicked({
let action_tab_page_reload = action_tab_page_reload.clone();
let action_tab_page_navigation_reload = action_tab_page_navigation_reload.clone();
move |_| {
action_tab_page_reload.activate(None);
action_tab_page_navigation_reload.activate(None);
}
});
// Return activated struct
Self {
action_tab_page_reload,
action_tab_page_navigation_reload,
widget,
}
}
// Actions
pub fn update(&self, is_enabled: bool) {
self.action_tab_page_reload.set_enabled(is_enabled);
self.action_tab_page_navigation_reload
.set_enabled(is_enabled);
self.widget.set_sensitive(is_enabled);
}

4
src/browser/main/tab/page/navigation/request.rs

@ -28,7 +28,7 @@ impl Request { @@ -28,7 +28,7 @@ impl Request {
text: Option<GString>,
// Actions
action_update: Arc<SimpleAction>,
action_tab_page_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
) -> Self {
// GTK
let widget = Entry::builder()
@ -46,7 +46,7 @@ impl Request { @@ -46,7 +46,7 @@ impl Request {
});
widget.connect_activate(move |_| {
action_tab_page_reload.activate(None);
action_tab_page_navigation_reload.activate(None);
});
// Init animated progressbar state

4
src/main.rs

@ -25,7 +25,7 @@ fn main() -> ExitCode { @@ -25,7 +25,7 @@ fn main() -> ExitCode {
let action_tab_append = Arc::new(SimpleAction::new("tab_append", None));
let action_tab_close = Arc::new(SimpleAction::new("tab_close", None));
let action_tab_close_all = Arc::new(SimpleAction::new("tab_close_all", None));
let action_tab_page_reload = Arc::new(SimpleAction::new("tab_page_reload", None));
let action_tab_page_navigation_reload = Arc::new(SimpleAction::new("tab_page_reload", None));
let action_tab_pin = Arc::new(SimpleAction::new("tab_pin", None));
// Init accels
@ -74,7 +74,7 @@ fn main() -> ExitCode { @@ -74,7 +74,7 @@ fn main() -> ExitCode {
action_tab_append.clone(),
action_tab_close.clone(),
action_tab_close_all.clone(),
action_tab_page_reload.clone(),
action_tab_page_navigation_reload.clone(),
action_tab_pin.clone(),
)
.widget()

Loading…
Cancel
Save