h-gtk: Use Rc instead of Arc wherever possible.
As logn we are not doing anything funny to bypass the borrow-checker, we should not be able to touch gtk wigets from other threads anyway.
This commit is contained in:
parent
509bbe25d2
commit
df417fa619
@ -14,6 +14,7 @@ use stacks::Content;
|
|||||||
use utils;
|
use utils;
|
||||||
use widgets::{mark_all_notif, remove_show_notif};
|
use widgets::{mark_all_notif, remove_show_notif};
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -43,8 +44,8 @@ pub struct App {
|
|||||||
app_instance: gtk::Application,
|
app_instance: gtk::Application,
|
||||||
window: gtk::Window,
|
window: gtk::Window,
|
||||||
overlay: gtk::Overlay,
|
overlay: gtk::Overlay,
|
||||||
header: Arc<Header>,
|
header: Rc<Header>,
|
||||||
content: Arc<Content>,
|
content: Rc<Content>,
|
||||||
receiver: Receiver<Action>,
|
receiver: Receiver<Action>,
|
||||||
sender: Sender<Action>,
|
sender: Sender<Action>,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
@ -78,10 +79,10 @@ impl App {
|
|||||||
|
|
||||||
// Create a content instance
|
// Create a content instance
|
||||||
let content =
|
let content =
|
||||||
Arc::new(Content::new(sender.clone()).expect("Content Initialization failed."));
|
Rc::new(Content::new(sender.clone()).expect("Content Initialization failed."));
|
||||||
|
|
||||||
// Create the headerbar
|
// Create the headerbar
|
||||||
let header = Arc::new(Header::new(&content, &window, sender.clone()));
|
let header = Rc::new(Header::new(&content, &window, sender.clone()));
|
||||||
|
|
||||||
// Add the content main stack to the overlay.
|
// Add the content main stack to the overlay.
|
||||||
let overlay = gtk::Overlay::new();
|
let overlay = gtk::Overlay::new();
|
||||||
|
|||||||
@ -7,22 +7,22 @@ use app::Action;
|
|||||||
use stacks::EpisodeStack;
|
use stacks::EpisodeStack;
|
||||||
use stacks::ShowStack;
|
use stacks::ShowStack;
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Content {
|
pub struct Content {
|
||||||
stack: gtk::Stack,
|
stack: gtk::Stack,
|
||||||
shows: Arc<ShowStack>,
|
shows: Rc<ShowStack>,
|
||||||
episodes: Arc<EpisodeStack>,
|
episodes: Rc<EpisodeStack>,
|
||||||
sender: Sender<Action>,
|
sender: Sender<Action>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Content {
|
impl Content {
|
||||||
pub fn new(sender: Sender<Action>) -> Result<Content, Error> {
|
pub fn new(sender: Sender<Action>) -> Result<Content, Error> {
|
||||||
let stack = gtk::Stack::new();
|
let stack = gtk::Stack::new();
|
||||||
let episodes = Arc::new(EpisodeStack::new(sender.clone())?);
|
let episodes = Rc::new(EpisodeStack::new(sender.clone())?);
|
||||||
let shows = Arc::new(ShowStack::new(sender.clone())?);
|
let shows = Rc::new(ShowStack::new(sender.clone())?);
|
||||||
|
|
||||||
stack.add_titled(&episodes.get_stack(), "episodes", "Episodes");
|
stack.add_titled(&episodes.get_stack(), "episodes", "Episodes");
|
||||||
stack.add_titled(&shows.get_stack(), "shows", "Shows");
|
stack.add_titled(&shows.get_stack(), "shows", "Shows");
|
||||||
@ -88,7 +88,7 @@ impl Content {
|
|||||||
self.stack.clone()
|
self.stack.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_shows(&self) -> Arc<ShowStack> {
|
pub fn get_shows(&self) -> Rc<ShowStack> {
|
||||||
self.shows.clone()
|
self.shows.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,4 +4,4 @@ mod show;
|
|||||||
|
|
||||||
pub use self::content::Content;
|
pub use self::content::Content;
|
||||||
pub use self::episode::{EpisodeStack, EPISODES_VIEW_VALIGNMENT};
|
pub use self::episode::{EpisodeStack, EPISODES_VIEW_VALIGNMENT};
|
||||||
pub use self::show::ShowStack;
|
pub use self::show::{ShowStack, SHOW_WIDGET_VALIGNMENT};
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use std::sync::mpsc::Sender;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref SHOW_WIDGET_VALIGNMENT: Mutex<Option<(i32, SendCell<gtk::Adjustment>)>> =
|
pub static ref SHOW_WIDGET_VALIGNMENT: Mutex<Option<(i32, SendCell<gtk::Adjustment>)>> =
|
||||||
Mutex::new(None);
|
Mutex::new(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user