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:
Jordan Petridis 2018-04-19 06:34:02 +03:00
parent 509bbe25d2
commit df417fa619
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
4 changed files with 13 additions and 12 deletions

View File

@ -14,6 +14,7 @@ use stacks::Content;
use utils;
use widgets::{mark_all_notif, remove_show_notif};
use std::rc::Rc;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;
@ -43,8 +44,8 @@ pub struct App {
app_instance: gtk::Application,
window: gtk::Window,
overlay: gtk::Overlay,
header: Arc<Header>,
content: Arc<Content>,
header: Rc<Header>,
content: Rc<Content>,
receiver: Receiver<Action>,
sender: Sender<Action>,
settings: Settings,
@ -78,10 +79,10 @@ impl App {
// Create a content instance
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
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.
let overlay = gtk::Overlay::new();

View File

@ -7,22 +7,22 @@ use app::Action;
use stacks::EpisodeStack;
use stacks::ShowStack;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct Content {
stack: gtk::Stack,
shows: Arc<ShowStack>,
episodes: Arc<EpisodeStack>,
shows: Rc<ShowStack>,
episodes: Rc<EpisodeStack>,
sender: Sender<Action>,
}
impl Content {
pub fn new(sender: Sender<Action>) -> Result<Content, Error> {
let stack = gtk::Stack::new();
let episodes = Arc::new(EpisodeStack::new(sender.clone())?);
let shows = Arc::new(ShowStack::new(sender.clone())?);
let episodes = Rc::new(EpisodeStack::new(sender.clone())?);
let shows = Rc::new(ShowStack::new(sender.clone())?);
stack.add_titled(&episodes.get_stack(), "episodes", "Episodes");
stack.add_titled(&shows.get_stack(), "shows", "Shows");
@ -88,7 +88,7 @@ impl Content {
self.stack.clone()
}
pub fn get_shows(&self) -> Arc<ShowStack> {
pub fn get_shows(&self) -> Rc<ShowStack> {
self.shows.clone()
}
}

View File

@ -4,4 +4,4 @@ mod show;
pub use self::content::Content;
pub use self::episode::{EpisodeStack, EPISODES_VIEW_VALIGNMENT};
pub use self::show::ShowStack;
pub use self::show::{ShowStack, SHOW_WIDGET_VALIGNMENT};

View File

@ -17,7 +17,7 @@ use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
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);
}