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

4
src/browser/header.rs

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

4
src/browser/header/tray.rs

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

4
src/browser/main.rs

@ -14,11 +14,11 @@ pub struct Main {
impl Main { impl Main {
// Construct // Construct
pub fn new( pub fn new(
action_tab_page_reload: Arc<SimpleAction>, action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>, action_update: Arc<SimpleAction>,
) -> Self { ) -> Self {
// Init components // 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.activate(tab.clone());
tab.append(Some(GString::from("gemini://geminiprotocol.net/")), true); // demo tab @TODO replace with session restore feature 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 {
// GTK // GTK
widget: Notebook, widget: Notebook,
// Keep action links in memory to not require them on every tab append // 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>, action_update: Arc<SimpleAction>,
// Dynamically allocated reference index // Dynamically allocated reference index
labels: RefCell<HashMap<GString, Arc<Label>>>, labels: RefCell<HashMap<GString, Arc<Label>>>,
@ -27,7 +27,7 @@ pub struct Tab {
impl Tab { impl Tab {
// Construct // Construct
pub fn new( pub fn new(
action_tab_page_reload: Arc<SimpleAction>, action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>, action_update: Arc<SimpleAction>,
) -> Self { ) -> Self {
// Init widget // Init widget
@ -38,7 +38,7 @@ impl Tab {
// GTK // GTK
widget, widget,
// Define action links // Define action links
action_tab_page_reload, action_tab_page_navigation_reload,
action_update, action_update,
// Init empty HashMap index as no tabs appended yet // Init empty HashMap index as no tabs appended yet
labels: RefCell::new(HashMap::new()), labels: RefCell::new(HashMap::new()),
@ -76,7 +76,7 @@ impl Tab {
let page = Arc::new(Page::new( let page = Arc::new(Page::new(
id.clone(), id.clone(),
page_navigation_request_text.clone(), page_navigation_request_text.clone(),
self.action_tab_page_reload.clone(), self.action_tab_page_navigation_reload.clone(),
self.action_update.clone(), self.action_update.clone(),
)); ));

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

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

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

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

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

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

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

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

4
src/main.rs

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

Loading…
Cancel
Save