mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-05 07:54:14 +00:00
add request text argument for new tab action
This commit is contained in:
parent
404da1fa74
commit
5ce6090d7a
@ -29,8 +29,8 @@ impl Main {
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn tab_append(&self) {
|
||||
self.tab.append(true);
|
||||
pub fn tab_append(&self, tab_page_navigation_request_text: Option<GString>) {
|
||||
self.tab.append(tab_page_navigation_request_text, true);
|
||||
}
|
||||
|
||||
pub fn tab_page_reload(&self) {
|
||||
|
@ -43,13 +43,17 @@ impl Tab {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn append(&self, is_current_page: bool) -> u32 {
|
||||
pub fn append(
|
||||
&self,
|
||||
page_navigation_request_text: Option<GString>,
|
||||
is_current_page: bool,
|
||||
) -> u32 {
|
||||
// Generate unique ID for new page components
|
||||
let id = uuid_string_random();
|
||||
|
||||
// Init new tab components
|
||||
let label = Arc::new(Label::new(id.clone(), false));
|
||||
let page = Arc::new(Page::new(id.clone()));
|
||||
let page = Arc::new(Page::new(id.clone(), page_navigation_request_text));
|
||||
|
||||
// Register dynamically created tab components in the HashMap index
|
||||
self.labels.borrow_mut().insert(id.clone(), label.clone());
|
||||
|
@ -32,10 +32,10 @@ pub struct Page {
|
||||
|
||||
impl Page {
|
||||
// Construct
|
||||
pub fn new(name: GString) -> Page {
|
||||
pub fn new(name: GString, navigation_request_text: Option<GString>) -> Page {
|
||||
// Init components
|
||||
let content = Arc::new(Content::new());
|
||||
let navigation = Arc::new(Navigation::new());
|
||||
let navigation = Arc::new(Navigation::new(navigation_request_text));
|
||||
|
||||
// Init widget
|
||||
let widget = Box::builder()
|
||||
|
@ -24,12 +24,12 @@ pub struct Navigation {
|
||||
}
|
||||
|
||||
impl Navigation {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(request_text: Option<GString>) -> Self {
|
||||
// Init components
|
||||
let base = Base::new();
|
||||
let history = History::new();
|
||||
let reload = Reload::new();
|
||||
let request = Request::new();
|
||||
let request = Request::new(request_text);
|
||||
let bookmark = Bookmark::new();
|
||||
|
||||
// Init widget
|
||||
|
@ -10,13 +10,17 @@ pub struct Request {
|
||||
|
||||
impl Request {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
pub fn new(text: Option<GString>) -> Self {
|
||||
// GTK
|
||||
let widget = Entry::builder()
|
||||
.placeholder_text("URL or search term...")
|
||||
.hexpand(true)
|
||||
.progress_fraction(0.0)
|
||||
.progress_pulse_step(0.1)
|
||||
.text(match text {
|
||||
Some(text) => text,
|
||||
None => GString::new(),
|
||||
})
|
||||
.build();
|
||||
|
||||
// Connect events
|
||||
|
@ -68,7 +68,7 @@ impl Browser {
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
move |_, _, _| {
|
||||
main.tab_append();
|
||||
main.tab_append(None);
|
||||
}
|
||||
})
|
||||
.build(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user