Add about a basic about dialog.
This commit is contained in:
parent
815639fe5f
commit
a2cf2357c6
@ -332,9 +332,8 @@ Tobias Bernard
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkModelButton">
|
<object class="GtkModelButton" id="about_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="sensitive">False</property>
|
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
<property name="text" translatable="yes">About</property>
|
<property name="text" translatable="yes">About</property>
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
use gio;
|
use gio::{ApplicationExt, ApplicationExtManual, ApplicationFlags};
|
||||||
use gio::{ApplicationExt, ApplicationExtManual};
|
|
||||||
use glib;
|
use glib;
|
||||||
use gtk;
|
use gtk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
@ -46,8 +45,7 @@ pub struct App {
|
|||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new() -> App {
|
pub fn new() -> App {
|
||||||
let application =
|
let application = gtk::Application::new("org.gnome.Hammond", ApplicationFlags::empty())
|
||||||
gtk::Application::new("org.gnome.Hammond", gio::ApplicationFlags::empty())
|
|
||||||
.expect("Initialization failed...");
|
.expect("Initialization failed...");
|
||||||
|
|
||||||
// Weird magic I copy-pasted that sets the Application Name in the Shell.
|
// Weird magic I copy-pasted that sets the Application Name in the Shell.
|
||||||
@ -70,10 +68,8 @@ impl App {
|
|||||||
let content = Arc::new(Content::new(sender.clone()));
|
let content = Arc::new(Content::new(sender.clone()));
|
||||||
|
|
||||||
// Create the headerbar
|
// 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.
|
// Add the content main stack to the window.
|
||||||
window.add(&content.get_stack());
|
window.add(&content.get_stack());
|
||||||
|
|
||||||
@ -98,7 +94,6 @@ impl App {
|
|||||||
let sender = self.sender.clone();
|
let sender = self.sender.clone();
|
||||||
// Auto-updater, runs every hour.
|
// Auto-updater, runs every hour.
|
||||||
// TODO: expose the interval in which it run to a user setting.
|
// TODO: expose the interval in which it run to a user setting.
|
||||||
// TODO: show notifications.
|
|
||||||
gtk::timeout_add_seconds(3600, move || {
|
gtk::timeout_add_seconds(3600, move || {
|
||||||
utils::refresh_feed(None, sender.clone());
|
utils::refresh_feed(None, sender.clone());
|
||||||
glib::Continue(true)
|
glib::Continue(true)
|
||||||
|
|||||||
@ -13,11 +13,12 @@ use content::Content;
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
pub container: gtk::HeaderBar,
|
container: gtk::HeaderBar,
|
||||||
add_toggle: gtk::MenuButton,
|
add_toggle: gtk::MenuButton,
|
||||||
switch: gtk::StackSwitcher,
|
switch: gtk::StackSwitcher,
|
||||||
back_button: gtk::Button,
|
back_button: gtk::Button,
|
||||||
show_title: gtk::Label,
|
show_title: gtk::Label,
|
||||||
|
about_button: gtk::ModelButton,
|
||||||
update_button: gtk::ModelButton,
|
update_button: gtk::ModelButton,
|
||||||
update_box: gtk::Box,
|
update_box: gtk::Box,
|
||||||
update_label: gtk::Label,
|
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_box: gtk::Box = builder.get_object("update_notification").unwrap();
|
||||||
let update_label: gtk::Label = builder.get_object("update_label").unwrap();
|
let update_label: gtk::Label = builder.get_object("update_label").unwrap();
|
||||||
let update_spinner: gtk::Spinner = builder.get_object("update_spinner").unwrap();
|
let update_spinner: gtk::Spinner = builder.get_object("update_spinner").unwrap();
|
||||||
|
let about_button: gtk::ModelButton = builder.get_object("about_button").unwrap();
|
||||||
|
|
||||||
Header {
|
Header {
|
||||||
container: header,
|
container: header,
|
||||||
@ -44,6 +46,7 @@ impl Default for Header {
|
|||||||
switch,
|
switch,
|
||||||
back_button,
|
back_button,
|
||||||
show_title,
|
show_title,
|
||||||
|
about_button,
|
||||||
update_button,
|
update_button,
|
||||||
update_box,
|
update_box,
|
||||||
update_label,
|
update_label,
|
||||||
@ -53,13 +56,13 @@ impl Default for Header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Header {
|
impl Header {
|
||||||
pub fn new(content: Arc<Content>, sender: Sender<Action>) -> Header {
|
pub fn new(content: Arc<Content>, window: >k::Window, sender: Sender<Action>) -> Header {
|
||||||
let h = Header::default();
|
let h = Header::default();
|
||||||
h.init(content, sender);
|
h.init(content, window, sender);
|
||||||
h
|
h
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self, content: Arc<Content>, sender: Sender<Action>) {
|
pub fn init(&self, content: Arc<Content>, window: >k::Window, sender: Sender<Action>) {
|
||||||
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui");
|
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui");
|
||||||
|
|
||||||
let add_popover: gtk::Popover = builder.get_object("add_popover").unwrap();
|
let add_popover: gtk::Popover = builder.get_object("add_popover").unwrap();
|
||||||
@ -83,6 +86,14 @@ impl Header {
|
|||||||
sender.send(Action::UpdateSources(None)).unwrap();
|
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 switch = &self.switch;
|
||||||
let add_toggle = &self.add_toggle;
|
let add_toggle = &self.add_toggle;
|
||||||
let show_title = &self.show_title;
|
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();
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user