diff --git a/hammond-gtk/resources/gtk/headerbar.ui b/hammond-gtk/resources/gtk/headerbar.ui index 7718695..ca28a3d 100644 --- a/hammond-gtk/resources/gtk/headerbar.ui +++ b/hammond-gtk/resources/gtk/headerbar.ui @@ -332,9 +332,8 @@ Tobias Bernard - + True - False True False About diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index ae2c224..8bb95f5 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -1,5 +1,4 @@ -use gio; -use gio::{ApplicationExt, ApplicationExtManual}; +use gio::{ApplicationExt, ApplicationExtManual, ApplicationFlags}; use glib; use gtk; use gtk::prelude::*; @@ -46,9 +45,8 @@ pub struct App { impl App { pub fn new() -> App { - let application = - gtk::Application::new("org.gnome.Hammond", gio::ApplicationFlags::empty()) - .expect("Initialization failed..."); + let application = gtk::Application::new("org.gnome.Hammond", ApplicationFlags::empty()) + .expect("Initialization failed..."); // Weird magic I copy-pasted that sets the Application Name in the Shell. glib::set_application_name("Hammond"); @@ -70,10 +68,8 @@ impl App { let content = Arc::new(Content::new(sender.clone())); // Create the headerbar - let header = Arc::new(Header::new(content.clone(), sender.clone())); + let header = Arc::new(Header::new(content.clone(), &window, sender.clone())); - // Add the Headerbar to the window. - window.set_titlebar(&header.container); // Add the content main stack to the window. window.add(&content.get_stack()); @@ -98,7 +94,6 @@ impl App { let sender = self.sender.clone(); // Auto-updater, runs every hour. // TODO: expose the interval in which it run to a user setting. - // TODO: show notifications. gtk::timeout_add_seconds(3600, move || { utils::refresh_feed(None, sender.clone()); glib::Continue(true) diff --git a/hammond-gtk/src/headerbar.rs b/hammond-gtk/src/headerbar.rs index 657c9c7..6648e46 100644 --- a/hammond-gtk/src/headerbar.rs +++ b/hammond-gtk/src/headerbar.rs @@ -13,11 +13,12 @@ use content::Content; #[derive(Debug, Clone)] pub struct Header { - pub container: gtk::HeaderBar, + container: gtk::HeaderBar, add_toggle: gtk::MenuButton, switch: gtk::StackSwitcher, back_button: gtk::Button, show_title: gtk::Label, + about_button: gtk::ModelButton, update_button: gtk::ModelButton, update_box: gtk::Box, update_label: gtk::Label, @@ -37,6 +38,7 @@ impl Default for Header { let update_box: gtk::Box = builder.get_object("update_notification").unwrap(); let update_label: gtk::Label = builder.get_object("update_label").unwrap(); let update_spinner: gtk::Spinner = builder.get_object("update_spinner").unwrap(); + let about_button: gtk::ModelButton = builder.get_object("about_button").unwrap(); Header { container: header, @@ -44,6 +46,7 @@ impl Default for Header { switch, back_button, show_title, + about_button, update_button, update_box, update_label, @@ -53,13 +56,13 @@ impl Default for Header { } impl Header { - pub fn new(content: Arc, sender: Sender) -> Header { + pub fn new(content: Arc, window: >k::Window, sender: Sender) -> Header { let h = Header::default(); - h.init(content, sender); + h.init(content, window, sender); h } - pub fn init(&self, content: Arc, sender: Sender) { + pub fn init(&self, content: Arc, window: >k::Window, sender: Sender) { let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui"); let add_popover: gtk::Popover = builder.get_object("add_popover").unwrap(); @@ -83,6 +86,14 @@ impl Header { sender.send(Action::UpdateSources(None)).unwrap(); }); + self.about_button + .connect_clicked(clone!(window => move |_| { + about_dialog(&window); + })); + + // Add the Headerbar to the window. + window.set_titlebar(&self.container); + let switch = &self.switch; let add_toggle = &self.add_toggle; let show_title = &self.show_title; @@ -174,3 +185,36 @@ fn on_url_change(entry: >k::Entry, result: >k::Label, add_button: >k::Butt } } } + +// 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 = &[ + "Jordan Petridis", + "Julian Sparber", + "Gabriele Musco", + "Constantin Nickel", + ]; + + let dialog = gtk::AboutDialog::new(); + // Waiting for a logo. + dialog.set_logo_icon_name("org.gnome.Hammond"); + dialog.set_comments("A 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"); + 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(); +}