mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
add auth navbar button
This commit is contained in:
parent
ec95ae2580
commit
f1b7fc9ac0
@ -1,3 +1,4 @@
|
|||||||
|
mod auth;
|
||||||
mod bookmark;
|
mod bookmark;
|
||||||
mod database;
|
mod database;
|
||||||
mod history;
|
mod history;
|
||||||
@ -6,6 +7,7 @@ mod reload;
|
|||||||
mod request;
|
mod request;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
|
use auth::Auth;
|
||||||
use bookmark::Bookmark;
|
use bookmark::Bookmark;
|
||||||
use history::History;
|
use history::History;
|
||||||
use home::Home;
|
use home::Home;
|
||||||
@ -22,6 +24,7 @@ use sqlite::Transaction;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Navigation {
|
pub struct Navigation {
|
||||||
|
auth: Rc<Auth>,
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
bookmark: Rc<Bookmark>,
|
bookmark: Rc<Bookmark>,
|
||||||
history: Rc<History>,
|
history: Rc<History>,
|
||||||
@ -37,6 +40,7 @@ impl Navigation {
|
|||||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>),
|
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>),
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
|
let auth = Rc::new(Auth::new(action.1.clone()));
|
||||||
let home = Rc::new(Home::new(action.1.clone()));
|
let home = Rc::new(Home::new(action.1.clone()));
|
||||||
let history = Rc::new(History::new(action.1.clone()));
|
let history = Rc::new(History::new(action.1.clone()));
|
||||||
let reload = Rc::new(Reload::new(action.1.clone()));
|
let reload = Rc::new(Reload::new(action.1.clone()));
|
||||||
@ -45,6 +49,7 @@ impl Navigation {
|
|||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
|
auth.widget().gobject(),
|
||||||
home.widget().gobject(),
|
home.widget().gobject(),
|
||||||
history.widget().gobject(),
|
history.widget().gobject(),
|
||||||
reload.widget().gobject(),
|
reload.widget().gobject(),
|
||||||
@ -54,6 +59,7 @@ impl Navigation {
|
|||||||
|
|
||||||
// Done
|
// Done
|
||||||
Self {
|
Self {
|
||||||
|
auth,
|
||||||
profile,
|
profile,
|
||||||
bookmark,
|
bookmark,
|
||||||
history,
|
history,
|
||||||
@ -69,6 +75,7 @@ impl Navigation {
|
|||||||
pub fn update(&self, progress_fraction: Option<f64>) {
|
pub fn update(&self, progress_fraction: Option<f64>) {
|
||||||
let request = self.request.widget().gobject().text();
|
let request = self.request.widget().gobject().text();
|
||||||
|
|
||||||
|
self.auth.update();
|
||||||
self.bookmark
|
self.bookmark
|
||||||
.update(self.profile.bookmark.get(&request).is_ok());
|
.update(self.profile.bookmark.get(&request).is_ok());
|
||||||
self.history.update();
|
self.history.update();
|
||||||
|
30
src/app/browser/window/tab/item/page/navigation/auth.rs
Normal file
30
src/app/browser/window/tab/item/page/navigation/auth.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
mod widget;
|
||||||
|
|
||||||
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::app::browser::window::Action;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
pub struct Auth {
|
||||||
|
widget: Rc<Widget>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Auth {
|
||||||
|
// Construct
|
||||||
|
pub fn new(action: Rc<Action>) -> Self {
|
||||||
|
Self {
|
||||||
|
widget: Rc::new(Widget::new(action.clone())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
pub fn update(&self) {
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
|
||||||
|
pub fn widget(&self) -> &Rc<Widget> {
|
||||||
|
&self.widget
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
use crate::app::browser::window::Action;
|
||||||
|
use gtk::{
|
||||||
|
prelude::{ButtonExt, WidgetExt},
|
||||||
|
Button,
|
||||||
|
};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
pub struct Widget {
|
||||||
|
gobject: Button,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Widget {
|
||||||
|
// Construct
|
||||||
|
pub fn new(action: Rc<Action>) -> Self {
|
||||||
|
// Init gobject
|
||||||
|
let gobject = Button::builder()
|
||||||
|
.icon_name("avatar-default-symbolic")
|
||||||
|
.tooltip_text("Auth")
|
||||||
|
.sensitive(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Init events @TODO
|
||||||
|
// gobject.connect_clicked(move |_| action.auth().activate());
|
||||||
|
|
||||||
|
// Return activated `Self`
|
||||||
|
Self { gobject }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
pub fn update(&self, is_sensitive: bool) {
|
||||||
|
self.gobject.set_sensitive(is_sensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
pub fn gobject(&self) -> &Button {
|
||||||
|
&self.gobject
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ pub struct Widget {
|
|||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
auth: &impl IsA<gtk::Widget>,
|
||||||
base: &impl IsA<gtk::Widget>,
|
base: &impl IsA<gtk::Widget>,
|
||||||
history: &impl IsA<gtk::Widget>,
|
history: &impl IsA<gtk::Widget>,
|
||||||
reload: &impl IsA<gtk::Widget>,
|
reload: &impl IsA<gtk::Widget>,
|
||||||
@ -32,6 +33,7 @@ impl Widget {
|
|||||||
gobject.append(reload);
|
gobject.append(reload);
|
||||||
gobject.append(request);
|
gobject.append(request);
|
||||||
gobject.append(bookmark);
|
gobject.append(bookmark);
|
||||||
|
gobject.append(auth);
|
||||||
|
|
||||||
Self { gobject }
|
Self { gobject }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user