Use gtk-rs 0.7.0

This commit is contained in:
Zander Brown
2019-09-02 23:55:56 +03:00
committed by Jordan Petridis
parent f07ac1f322
commit c8a194cf32
10 changed files with 256 additions and 247 deletions
+18 -13
View File
@@ -7,11 +7,12 @@ edition = "2018"
[dependencies]
chrono = "0.4.6"
crossbeam-channel = "0.3.8"
gdk = "0.10.0"
gdk-pixbuf = "0.6.0"
glib = "0.7.1"
gst = { version = "0.13.0", package = "gstreamer" }
gst-player = { version = "0.13.0", package = "gstreamer-player" }
gdk = "0.11.0"
gdk-pixbuf = "0.7.0"
gobject-sys = "0.9.0"
glib-sys = "0.9.0"
gst = { version = "0.14.0", package = "gstreamer" }
gst-player = { version = "0.14.0", package = "gstreamer-player" }
humansize = "1.1.0"
lazy_static = "1.3.0"
log = "0.4.6"
@@ -33,20 +34,24 @@ git = "https://github.com/danigm/gettext-rs"
branch = "no-gettext"
features = ["gettext-system"]
[dependencies.gtk]
features = ["v3_24"]
version = "0.6.0"
[dependencies.glib]
features = ["subclassing"]
version = "0.8.1"
[dependencies.gio]
features = ["v2_50"]
version = "0.6.0"
features = ["v2_50", "subclassing"]
version = "0.7.0"
[dependencies.gtk]
features = ["v3_24", "subclassing"]
version = "0.7.0"
[dependencies.libhandy]
version = "0.3.0"
features = [ "v0_0_7"]
version = "0.4.0"
features = [ "v0_0_10"]
[dependencies.mpris-player]
version = "0.3.0"
version = "0.4.0"
# git = "https://gitlab.gnome.org/World/Rust/mpris-player"
[dependencies.podcasts-data]
+4 -4
View File
@@ -52,7 +52,7 @@ use crate::i18n::i18n;
fn action<T, F>(thing: &T, name: &str, action: F)
where
T: ActionMapExt,
for<'r, 's> F: Fn(&'r gio::SimpleAction, &'s Option<Variant>) + 'static,
for<'r, 's> F: Fn(&'r gio::SimpleAction, Option<&Variant>) + 'static,
{
// Create a stateless, parameterless action
let act = gio::SimpleAction::new(name, None);
@@ -138,7 +138,7 @@ impl App {
// Create the headerbar
let header = Header::new(&content, &sender);
// Add the Headerbar to the window.
window.set_titlebar(&header.container);
window.set_titlebar(Some(&header.container));
// Add the content main stack to the overlay.
let overlay = gtk::Overlay::new();
@@ -401,9 +401,9 @@ impl App {
bindtextdomain("gnome-podcasts", LOCALEDIR);
textdomain("gnome-podcasts");
let application = gtk::Application::new(APP_ID, gio::ApplicationFlags::empty())
let application = gtk::Application::new(Some(APP_ID), gio::ApplicationFlags::empty())
.expect("Application initialization failed...");
application.set_resource_base_path("/org/gnome/Podcasts");
application.set_resource_base_path(Some("/org/gnome/Podcasts"));
let weak_app = application.downgrade();
application.connect_startup(move |_| {
+5 -5
View File
@@ -120,11 +120,11 @@ impl AddPopover {
.add_class(&gtk::STYLE_CLASS_ERROR);
self.entry.set_icon_from_icon_name(
gtk::EntryIconPosition::Secondary,
"dialog-error-symbolic",
Some("dialog-error-symbolic"),
);
self.entry.set_icon_tooltip_text(
gtk::EntryIconPosition::Secondary,
i18n("You are already subscribed to this show").as_str(),
Some(i18n("You are already subscribed to this show").as_str()),
);
self.add.set_sensitive(false);
}
@@ -138,11 +138,11 @@ impl AddPopover {
.add_class(&gtk::STYLE_CLASS_ERROR);
self.entry.set_icon_from_icon_name(
gtk::EntryIconPosition::Secondary,
"dialog-error-symbolic",
Some("dialog-error-symbolic"),
);
self.entry.set_icon_tooltip_text(
gtk::EntryIconPosition::Secondary,
i18n("Invalid URL").as_str(),
Some(i18n("Invalid URL").as_str()),
);
error!("Error: {}", err);
} else {
@@ -210,7 +210,7 @@ impl Header {
pub(crate) fn init(s: &Rc<Self>, content: &Content, sender: &Sender<Action>) {
let weak = Rc::downgrade(s);
s.switch.set_stack(&content.get_stack());
s.switch.set_stack(Some(&content.get_stack()));
s.add.entry.connect_changed(clone!(weak => move |_| {
weak.upgrade().map(|h| {
+5 -6
View File
@@ -19,7 +19,6 @@
#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
use gdk::FrameClockExt;
use gdk_pixbuf::{Object, Pixbuf};
use glib::{self, object::WeakRef};
use gtk;
@@ -155,10 +154,10 @@ pub(crate) fn smooth_scroll_to(view: &gtk::ScrolledWindow, target: &gtk::Adjustm
let mut t = (now - start_time) as f64 / (end_time - start_time) as f64;
t = ease_out_cubic(t);
adj.set_value(start + t * (end - start));
true
Continue(true)
} else {
adj.set_value(end);
false
Continue(false)
}
});
}
@@ -285,7 +284,7 @@ pub(crate) fn set_image_from_path(
.and_then(|fragile| {
fragile
.try_get()
.map(|px| image.set_from_pixbuf(px))
.map(|px| image.set_from_pixbuf(Some(px)))
.map_err(From::from)
})?;
@@ -343,13 +342,13 @@ pub(crate) fn set_image_from_path(
if let Ok(mut hashmap) = CACHED_PIXBUFS.write() {
hashmap
.insert((show_id, size), Mutex::new(Fragile::new(px.clone())));
image.set_from_pixbuf(&px);
image.set_from_pixbuf(Some(&px));
}
}
}
Err(DownloadError::NoImageLocation) => {
image.set_from_icon_name(
"image-x-generic-symbolic",
Some("image-x-generic-symbolic"),
gtk::IconSize::__Unknown(s),
);
}
+8 -8
View File
@@ -47,20 +47,20 @@ pub(crate) fn about_dialog(window: &gtk::ApplicationWindow) {
];
let dialog = gtk::AboutDialog::new();
dialog.set_logo_icon_name(APP_ID);
dialog.set_comments(i18n("Podcast Client for the GNOME Desktop.").as_str());
dialog.set_copyright("© 2017, 2018 Jordan Petridis");
dialog.set_logo_icon_name(Some(APP_ID));
dialog.set_comments(Some(i18n("Podcast Client for the GNOME Desktop.").as_str()));
dialog.set_copyright(Some("© 2017, 2018 Jordan Petridis"));
dialog.set_license_type(gtk::License::Gpl30);
dialog.set_modal(true);
dialog.set_version(VERSION);
dialog.set_version(Some(VERSION));
dialog.set_program_name(&i18n("Podcasts"));
dialog.set_website("https://wiki.gnome.org/Apps/Podcasts");
dialog.set_website_label(i18n("Learn more about GNOME Podcasts").as_str());
dialog.set_transient_for(window);
dialog.set_website(Some("https://wiki.gnome.org/Apps/Podcasts"));
dialog.set_website_label(Some(i18n("Learn more about GNOME Podcasts").as_str()));
dialog.set_transient_for(Some(window));
dialog.set_artists(&["Tobias Bernard", "Sam Hewitt"]);
dialog.set_authors(authors);
dialog.set_translator_credits(i18n("translator-credits").as_str());
dialog.set_translator_credits(Some(i18n("translator-credits").as_str()));
dialog.connect_response(|dlg, _| dlg.destroy());
+1 -1
View File
@@ -37,7 +37,7 @@ impl Default for EmptyView {
let view: gtk::Box = builder.get_object("empty_view").unwrap();
let image: gtk::Image = builder.get_object("image").unwrap();
image.set_from_icon_name(
format!("{}-symbolic", APP_ID).as_str(),
Some(format!("{}-symbolic", APP_ID).as_str()),
gtk::IconSize::__Unknown(256),
);
EmptyView(view)
+7 -8
View File
@@ -94,12 +94,12 @@ impl PlayerInfo {
fn set_episode_title(&self, episode: &EpisodeWidgetModel) {
self.episode.set_text(episode.title());
self.episode.set_tooltip_text(episode.title());
self.episode.set_tooltip_text(Some(episode.title()));
}
fn set_show_title(&self, show: &ShowCoverModel) {
self.show.set_text(show.title());
self.show.set_tooltip_text(show.title());
self.show.set_tooltip_text(Some(show.title()));
}
fn set_cover_image(&self, show: &ShowCoverModel) {
@@ -323,12 +323,11 @@ impl PlayerWidget {
// path is an absolute fs path ex. "foo/bar/baz".
// Convert it so it will have a "file:///"
// FIXME: convert it properly
if let Some(uri) = File::new_for_path(path).get_uri() {
// play the file
self.player.set_uri(&uri);
self.play();
return Ok(());
}
let uri = File::new_for_path(path).get_uri();
// play the file
self.player.set_uri(uri.as_str());
self.play();
return Ok(());
}
// TODO: log an error
}
+2 -2
View File
@@ -128,7 +128,7 @@ struct ShowsChild {
impl Default for ShowsChild {
fn default() -> Self {
let cover = gtk::Image::new_from_icon_name(
"image-x-generic-symbolic",
Some("image-x-generic-symbolic"),
gtk::IconSize::__Unknown(-1),
);
let child = gtk::FlowBoxChild::new();
@@ -149,7 +149,7 @@ impl ShowsChild {
}
fn init(&self, pd: &Show) {
self.child.set_tooltip_text(pd.title());
self.child.set_tooltip_text(Some(pd.title()));
WidgetExt::set_name(&self.child, &pd.id().to_string());
self.set_cover(pd.id())