Resolve some comments
This commit is contained in:
parent
793cafd294
commit
e7128a57db
@ -9,7 +9,6 @@ use gtk;
|
|||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::SettingsExt as GtkSettingsExt;
|
use gtk::SettingsExt as GtkSettingsExt;
|
||||||
|
|
||||||
use hammond_data::opml;
|
|
||||||
use hammond_data::Podcast;
|
use hammond_data::Podcast;
|
||||||
|
|
||||||
use appnotif::{InAppNotification, UndoState};
|
use appnotif::{InAppNotification, UndoState};
|
||||||
@ -17,14 +16,12 @@ use headerbar::Header;
|
|||||||
use settings::{self, WindowGeometry};
|
use settings::{self, WindowGeometry};
|
||||||
use stacks::{Content, PopulatedState};
|
use stacks::{Content, PopulatedState};
|
||||||
use utils;
|
use utils;
|
||||||
use widgets::{mark_all_notif, remove_show_notif};
|
use widgets::{about_dialog, mark_all_notif, remove_show_notif};
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{channel, Sender};
|
use std::sync::mpsc::{channel, Sender};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use rayon;
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -82,7 +79,7 @@ impl App {
|
|||||||
let import = SimpleAction::new("import", None);
|
let import = SimpleAction::new("import", None);
|
||||||
import.connect_activate(clone!(sender, app => move |_, _| {
|
import.connect_activate(clone!(sender, app => move |_, _| {
|
||||||
let window = app.get_active_window().expect("Failed to get active window");
|
let window = app.get_active_window().expect("Failed to get active window");
|
||||||
on_import_clicked(&window, &sender);
|
utils::on_import_clicked(&window, &sender);
|
||||||
}));
|
}));
|
||||||
app.add_action(&import);
|
app.add_action(&import);
|
||||||
|
|
||||||
@ -258,98 +255,3 @@ impl App {
|
|||||||
ApplicationExtManual::run(&self.app_instance, &[]);
|
ApplicationExtManual::run(&self.app_instance, &[]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Totally copied it from fractal.
|
|
||||||
// https://gitlab.gnome.org/danigm/fractal/blob/503e311e22b9d7540089d735b92af8e8f93560c5/fractal-gtk/src/app.rs#L1883-1912
|
|
||||||
fn about_dialog(window: >k::Window) {
|
|
||||||
// Feel free to add yourself if you contribured.
|
|
||||||
let authors = &[
|
|
||||||
"Constantin Nickel",
|
|
||||||
"Gabriele Musco",
|
|
||||||
"James Wykeham-Martin",
|
|
||||||
"Jordan Petridis",
|
|
||||||
"Julian Sparber",
|
|
||||||
"Rowan Lewis",
|
|
||||||
"Zander Brown",
|
|
||||||
];
|
|
||||||
|
|
||||||
let dialog = gtk::AboutDialog::new();
|
|
||||||
// Waiting for a logo.
|
|
||||||
// dialog.set_logo_icon_name("org.gnome.Hammond");
|
|
||||||
dialog.set_logo_icon_name("multimedia-player");
|
|
||||||
dialog.set_comments("Podcast Client for the GNOME Desktop.");
|
|
||||||
dialog.set_copyright("© 2017, 2018 Jordan Petridis");
|
|
||||||
dialog.set_license_type(gtk::License::Gpl30);
|
|
||||||
dialog.set_modal(true);
|
|
||||||
// TODO: make it show it fetches the commit hash from which it was built
|
|
||||||
// and the version number is kept in sync automaticly
|
|
||||||
dialog.set_version("0.3.4");
|
|
||||||
dialog.set_program_name("Hammond");
|
|
||||||
// TODO: Need a wiki page first.
|
|
||||||
// dialog.set_website("https://wiki.gnome.org/Design/Apps/Potential/Podcasts");
|
|
||||||
// dialog.set_website_label("Learn more about Hammond");
|
|
||||||
dialog.set_transient_for(window);
|
|
||||||
|
|
||||||
dialog.set_artists(&["Tobias Bernard"]);
|
|
||||||
dialog.set_authors(authors);
|
|
||||||
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_import_clicked(window: >k::Window, sender: &Sender<Action>) {
|
|
||||||
use glib::translate::ToGlib;
|
|
||||||
use gtk::{FileChooserAction, FileChooserNative, FileFilter, ResponseType};
|
|
||||||
|
|
||||||
// let dialog = FileChooserDialog::new(title, Some(&window), FileChooserAction::Open);
|
|
||||||
// TODO: It might be better to use a FileChooserNative widget.
|
|
||||||
// Create the FileChooser Dialog
|
|
||||||
let dialog = FileChooserNative::new(
|
|
||||||
Some("Select the file from which to you want to Import Shows."),
|
|
||||||
Some(window),
|
|
||||||
FileChooserAction::Open,
|
|
||||||
Some("_Import"),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Do not show hidden(.thing) files
|
|
||||||
dialog.set_show_hidden(false);
|
|
||||||
|
|
||||||
// Set a filter to show only xml files
|
|
||||||
let filter = FileFilter::new();
|
|
||||||
FileFilterExt::set_name(&filter, Some("OPML file"));
|
|
||||||
filter.add_mime_type("application/xml");
|
|
||||||
filter.add_mime_type("text/xml");
|
|
||||||
dialog.add_filter(&filter);
|
|
||||||
|
|
||||||
dialog.connect_response(clone!(sender => move |dialog, resp| {
|
|
||||||
debug!("Dialong Response {}", resp);
|
|
||||||
if resp == ResponseType::Accept.to_glib() {
|
|
||||||
// TODO: Show an in-app notifictaion if the file can not be accessed
|
|
||||||
if let Some(filename) = dialog.get_filename() {
|
|
||||||
debug!("File selected: {:?}", filename);
|
|
||||||
|
|
||||||
rayon::spawn(clone!(sender => move || {
|
|
||||||
// Parse the file and import the feeds
|
|
||||||
if let Ok(sources) = opml::import_from_file(filename) {
|
|
||||||
// Refresh the succesfully parsed feeds to index them
|
|
||||||
utils::refresh(Some(sources), sender)
|
|
||||||
} else {
|
|
||||||
let text = String::from("Failed to parse the Imported file");
|
|
||||||
sender.send(Action::ErrorNotification(text))
|
|
||||||
.map_err(|err| error!("Action Sender: {}", err))
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
let text = String::from("Selected File could not be accessed.");
|
|
||||||
sender.send(Action::ErrorNotification(text))
|
|
||||||
.map_err(|err| error!("Action Sender: {}", err))
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.destroy();
|
|
||||||
}));
|
|
||||||
|
|
||||||
dialog.run();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ use serde_json::Value;
|
|||||||
|
|
||||||
// use hammond_data::feed;
|
// use hammond_data::feed;
|
||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
|
use hammond_data::opml;
|
||||||
use hammond_data::pipeline;
|
use hammond_data::pipeline;
|
||||||
use hammond_data::utils::checkup;
|
use hammond_data::utils::checkup;
|
||||||
use hammond_data::Source;
|
use hammond_data::Source;
|
||||||
@ -333,6 +334,64 @@ fn lookup_id(id: u32) -> Result<String, Error> {
|
|||||||
.ok_or_else(|| format_err!("Failed to get url from itunes response"))
|
.ok_or_else(|| format_err!("Failed to get url from itunes response"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn on_import_clicked(window: >k::Window, sender: &Sender<Action>) {
|
||||||
|
use glib::translate::ToGlib;
|
||||||
|
use gtk::{FileChooserAction, FileChooserNative, FileFilter, ResponseType};
|
||||||
|
|
||||||
|
// let dialog = FileChooserDialog::new(title, Some(&window), FileChooserAction::Open);
|
||||||
|
// TODO: It might be better to use a FileChooserNative widget.
|
||||||
|
// Create the FileChooser Dialog
|
||||||
|
let dialog = FileChooserNative::new(
|
||||||
|
Some("Select the file from which to you want to Import Shows."),
|
||||||
|
Some(window),
|
||||||
|
FileChooserAction::Open,
|
||||||
|
Some("_Import"),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Do not show hidden(.thing) files
|
||||||
|
dialog.set_show_hidden(false);
|
||||||
|
|
||||||
|
// Set a filter to show only xml files
|
||||||
|
let filter = FileFilter::new();
|
||||||
|
FileFilterExt::set_name(&filter, Some("OPML file"));
|
||||||
|
filter.add_mime_type("application/xml");
|
||||||
|
filter.add_mime_type("text/xml");
|
||||||
|
dialog.add_filter(&filter);
|
||||||
|
|
||||||
|
dialog.connect_response(clone!(sender => move |dialog, resp| {
|
||||||
|
debug!("Dialong Response {}", resp);
|
||||||
|
if resp == ResponseType::Accept.to_glib() {
|
||||||
|
// TODO: Show an in-app notifictaion if the file can not be accessed
|
||||||
|
if let Some(filename) = dialog.get_filename() {
|
||||||
|
debug!("File selected: {:?}", filename);
|
||||||
|
|
||||||
|
rayon::spawn(clone!(sender => move || {
|
||||||
|
// Parse the file and import the feeds
|
||||||
|
if let Ok(sources) = opml::import_from_file(filename) {
|
||||||
|
// Refresh the succesfully parsed feeds to index them
|
||||||
|
refresh(Some(sources), sender)
|
||||||
|
} else {
|
||||||
|
let text = String::from("Failed to parse the Imported file");
|
||||||
|
sender.send(Action::ErrorNotification(text))
|
||||||
|
.map_err(|err| error!("Action Sender: {}", err))
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
let text = String::from("Selected File could not be accessed.");
|
||||||
|
sender.send(Action::ErrorNotification(text))
|
||||||
|
.map_err(|err| error!("Action Sender: {}", err))
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.destroy();
|
||||||
|
}));
|
||||||
|
|
||||||
|
dialog.run();
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
39
hammond-gtk/src/widgets/aboutdialog.rs
Normal file
39
hammond-gtk/src/widgets/aboutdialog.rs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
use gtk;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
|
||||||
|
// Totally copied it from fractal.
|
||||||
|
// https://gitlab.gnome.org/danigm/fractal/blob/503e311e22b9d7540089d735b92af8e8f93560c5/fractal-gtk/src/app.rs#L1883-1912
|
||||||
|
pub fn about_dialog(window: >k::Window) {
|
||||||
|
// Feel free to add yourself if you contribured.
|
||||||
|
let authors = &[
|
||||||
|
"Constantin Nickel",
|
||||||
|
"Gabriele Musco",
|
||||||
|
"James Wykeham-Martin",
|
||||||
|
"Jordan Petridis",
|
||||||
|
"Julian Sparber",
|
||||||
|
"Rowan Lewis",
|
||||||
|
"Zander Brown",
|
||||||
|
];
|
||||||
|
|
||||||
|
let dialog = gtk::AboutDialog::new();
|
||||||
|
// Waiting for a logo.
|
||||||
|
// dialog.set_logo_icon_name("org.gnome.Hammond");
|
||||||
|
dialog.set_logo_icon_name("multimedia-player");
|
||||||
|
dialog.set_comments("Podcast Client for the GNOME Desktop.");
|
||||||
|
dialog.set_copyright("© 2017, 2018 Jordan Petridis");
|
||||||
|
dialog.set_license_type(gtk::License::Gpl30);
|
||||||
|
dialog.set_modal(true);
|
||||||
|
// TODO: make it show it fetches the commit hash from which it was built
|
||||||
|
// and the version number is kept in sync automaticly
|
||||||
|
dialog.set_version("0.3.4");
|
||||||
|
dialog.set_program_name("Hammond");
|
||||||
|
// TODO: Need a wiki page first.
|
||||||
|
// dialog.set_website("https://wiki.gnome.org/Design/Apps/Potential/Podcasts");
|
||||||
|
// dialog.set_website_label("Learn more about Hammond");
|
||||||
|
dialog.set_transient_for(window);
|
||||||
|
|
||||||
|
dialog.set_artists(&["Tobias Bernard"]);
|
||||||
|
dialog.set_authors(authors);
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
mod aboutdialog;
|
||||||
mod empty;
|
mod empty;
|
||||||
mod episode;
|
mod episode;
|
||||||
mod episode_states;
|
mod episode_states;
|
||||||
@ -5,6 +6,7 @@ mod home_view;
|
|||||||
mod show;
|
mod show;
|
||||||
mod shows_view;
|
mod shows_view;
|
||||||
|
|
||||||
|
pub use self::aboutdialog::about_dialog;
|
||||||
pub use self::empty::EmptyView;
|
pub use self::empty::EmptyView;
|
||||||
pub use self::episode::EpisodeWidget;
|
pub use self::episode::EpisodeWidget;
|
||||||
pub use self::home_view::HomeView;
|
pub use self::home_view::HomeView;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user