Made a type allias for Arc<Mutex<SqliteConnection>.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
|
||||
use open;
|
||||
use diesel::prelude::SqliteConnection;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::models::Episode;
|
||||
use hammond_downloader::downloader;
|
||||
use hammond_data::index_feed::Database;
|
||||
|
||||
use dissolve::strip_html_tags;
|
||||
|
||||
use std::thread;
|
||||
use std::cell::RefCell;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::mpsc::{channel, Receiver};
|
||||
use std::path::Path;
|
||||
|
||||
@@ -43,11 +43,7 @@ thread_local!(
|
||||
Receiver<bool>))>> = RefCell::new(None));
|
||||
|
||||
// TODO: REFACTOR AND MODULATE ME.
|
||||
fn epidose_widget(
|
||||
db: &Arc<Mutex<SqliteConnection>>,
|
||||
episode: &mut Episode,
|
||||
pd_title: &str,
|
||||
) -> gtk::Box {
|
||||
fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::Box {
|
||||
// This is just a prototype and will be reworked probably.
|
||||
let builder = include_str!("../../gtk/episode_widget.ui");
|
||||
let builder = gtk::Builder::new_from_string(builder);
|
||||
@@ -103,7 +99,7 @@ fn epidose_widget(
|
||||
|
||||
// TODO: show notification when dl is finished and block play_bttn till then.
|
||||
fn on_dl_clicked(
|
||||
db: &Arc<Mutex<SqliteConnection>>,
|
||||
db: &Database,
|
||||
pd_title: &str,
|
||||
ep: &mut Episode,
|
||||
dl_bttn: >k::Button,
|
||||
@@ -131,7 +127,7 @@ fn on_dl_clicked(
|
||||
}));
|
||||
}
|
||||
|
||||
fn on_play_bttn_clicked(db: &Arc<Mutex<SqliteConnection>>, episode_id: i32) {
|
||||
fn on_play_bttn_clicked(db: &Database, episode_id: i32) {
|
||||
let local_uri = {
|
||||
let tempdb = db.lock().unwrap();
|
||||
dbqueries::get_episode_local_uri(&tempdb, episode_id).unwrap()
|
||||
@@ -168,7 +164,7 @@ fn receive() -> glib::Continue {
|
||||
glib::Continue(false)
|
||||
}
|
||||
|
||||
pub fn episodes_listbox(db: &Arc<Mutex<SqliteConnection>>, pd_title: &str) -> gtk::ListBox {
|
||||
pub fn episodes_listbox(db: &Database, pd_title: &str) -> gtk::ListBox {
|
||||
// TODO: handle unwraps.
|
||||
let conn = db.lock().unwrap();
|
||||
let pd = dbqueries::load_podcast_from_title(&conn, pd_title).unwrap();
|
||||
|
||||
@@ -6,13 +6,12 @@ use diesel::prelude::SqliteConnection;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::models::Podcast;
|
||||
use hammond_downloader::downloader;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use hammond_data::index_feed::Database;
|
||||
|
||||
use widgets::episode::episodes_listbox;
|
||||
|
||||
pub fn podcast_widget(
|
||||
db: &Arc<Mutex<SqliteConnection>>,
|
||||
db: &Database,
|
||||
title: Option<&str>,
|
||||
description: Option<&str>,
|
||||
image: Option<Pixbuf>,
|
||||
@@ -73,7 +72,7 @@ pub fn create_flowbox_child(title: &str, cover: Option<Pixbuf>) -> gtk::FlowBoxC
|
||||
}
|
||||
|
||||
pub fn on_flowbox_child_activate(
|
||||
db: &Arc<Mutex<SqliteConnection>>,
|
||||
db: &Database,
|
||||
stack: >k::Stack,
|
||||
parent: &Podcast,
|
||||
pixbuf: Option<Pixbuf>,
|
||||
@@ -118,7 +117,7 @@ pub fn podcast_liststore(connection: &SqliteConnection) -> gtk::ListStore {
|
||||
podcast_model
|
||||
}
|
||||
|
||||
// pub fn update_podcast_widget(db: &&Arc<Mutex<SqliteConnection>>, stack: >k::Stack, pd:
|
||||
// pub fn update_podcast_widget(db: &&Database, stack: >k::Stack, pd:
|
||||
// &Podcast){
|
||||
// let old = stack.get_child_by_name("pdw").unwrap();
|
||||
// let pdw = pd_widget_from_diesel_model(&db.clone(), pd, &stack.clone());
|
||||
@@ -129,7 +128,7 @@ pub fn podcast_liststore(connection: &SqliteConnection) -> gtk::ListStore {
|
||||
// stack.set_visible_child_name(&vis);
|
||||
// }
|
||||
|
||||
// pub fn pd_widget_from_diesel_model(db: &Arc<Mutex<SqliteConnection>>, pd: &Podcast) -> gtk::Box {
|
||||
// pub fn pd_widget_from_diesel_model(db: &Database, pd: &Podcast) -> gtk::Box {
|
||||
// let img = get_pixbuf_from_path(pd.image_uri(), pd.title());
|
||||
// podcast_widget(db, Some(pd.title()), Some(pd.description()), img)
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user