diff --git a/Cargo.lock b/Cargo.lock index 257cce1..9d0d188 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "MacTypes-sys" version = "2.1.0" @@ -1022,6 +1024,47 @@ name = "libc" version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libdazzle" +version = "0.1.0" +source = "git+https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git#34658913affed0e4610575f884ad7ab6357ef69b" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libdazzle-sys 0.1.0 (git+https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git)", + "pango 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libdazzle-sys" +version = "0.1.0" +source = "git+https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git#34658913affed0e4610575f884ad7ab6357ef69b" +dependencies = [ + "cairo-sys-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libdbus-sys" version = "0.1.5" @@ -1570,6 +1613,7 @@ dependencies = [ "html2text 0.1.8 (git+https://github.com/jugglerchris/rust-html2text)", "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libdazzle 0.1.0 (git+https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git)", "libhandy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "loggerv 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2652,6 +2696,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" +"checksum libdazzle 0.1.0 (git+https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git)" = "" +"checksum libdazzle-sys 0.1.0 (git+https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git)" = "" "checksum libdbus-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "18cb88963258d00f4962205dbb5933d82780d9962c8c8a064b651d2ad7189210" "checksum libhandy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f1fd41f2216fc3894257f4b4405dec7255977ff3a292df1ec1a74bc1700178d" "checksum libhandy-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d1a46914f15afb94df8efddd8d451f60764da95a63dc4f7f3526ce71e1ef775" diff --git a/org.gnome.Podcasts.Devel.json b/org.gnome.Podcasts.Devel.json index 495da16..16609ae 100644 --- a/org.gnome.Podcasts.Devel.json +++ b/org.gnome.Podcasts.Devel.json @@ -60,6 +60,21 @@ } ] }, + { + "name" : "libdazzle", + "buildsystem" : "meson", + "cleanup" : [ + "/include", + "/lib/pkgconfig" + ], + "sources" : [ + { + "type" : "git", + "url" : "https://gitlab.gnome.org/GNOME/libdazzle.git", + "branch" : "libdazzle-3-32" + } + ] + }, { "name" : "gnome-podcasts", "buildsystem" : "meson", diff --git a/podcasts-gtk/Cargo.toml b/podcasts-gtk/Cargo.toml index 956e803..eeb1503 100644 --- a/podcasts-gtk/Cargo.toml +++ b/podcasts-gtk/Cargo.toml @@ -41,6 +41,11 @@ version = "0.6.0" features = ["v2_50"] version = "0.6.0" +[dependencies.libdazzle] +version = "0.1.0" +git = "https://gitlab.gnome.org/BrainBlasted/libdazzle-rs.git" +features = ["v3_26"] + [dependencies.libhandy] version = "0.3.0" features = [ "v0_0_7"] diff --git a/podcasts-gtk/resources/resources.xml b/podcasts-gtk/resources/resources.xml index 0ba1f91..ea804bd 100644 --- a/podcasts-gtk/resources/resources.xml +++ b/podcasts-gtk/resources/resources.xml @@ -16,5 +16,7 @@ icons/skip-forward-symbolic.svg gtk/prefs.ui gtk/style.css + themes/Adwaita.css + themes/HighContrast.css diff --git a/podcasts-gtk/resources/themes/Adwaita.css b/podcasts-gtk/resources/themes/Adwaita.css new file mode 100644 index 0000000..23132fc --- /dev/null +++ b/podcasts-gtk/resources/themes/Adwaita.css @@ -0,0 +1,4 @@ +.played { + /* Needed to reset the styling */ + background: none; +} diff --git a/podcasts-gtk/resources/themes/HighContrast.css b/podcasts-gtk/resources/themes/HighContrast.css new file mode 100644 index 0000000..3106175 --- /dev/null +++ b/podcasts-gtk/resources/themes/HighContrast.css @@ -0,0 +1,9 @@ +.played { + background: repeating-linear-gradient( + -45deg, + mix(lightgrey, @theme_bg_color, 0.3), + mix(lightgrey, @theme_bg_color, 0.3) 10px, + @theme_bg_color 10px, + @theme_bg_color 20px + ); +} diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index d7caa98..dc015a1 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -20,6 +20,8 @@ #![allow(new_without_default)] +use dazzle; +use dazzle::ThemeManagerExt; use gio::{self, prelude::*, ActionMapExt, SettingsExt}; use glib::{self, Variant}; use gtk; @@ -96,6 +98,7 @@ pub(crate) struct App { headerbar: Rc
, player: player::PlayerWrapper, updater: RefCell>, + theme_manager: dazzle::ThemeManager, sender: Sender, receiver: Receiver, } @@ -155,6 +158,11 @@ impl App { let updater = RefCell::new(None); + let theme_manager = dazzle::ThemeManager::new(); + application.get_resource_base_path().map(|path| { + theme_manager.add_resources(&format!("resource://{}", path)); + }); + window.add(&wrap); let app = App { @@ -166,6 +174,7 @@ impl App { content, player, updater, + theme_manager, sender, receiver, }; diff --git a/podcasts-gtk/src/widgets/episode.rs b/podcasts-gtk/src/widgets/episode.rs index 8601db5..1e8cdf8 100644 --- a/podcasts-gtk/src/widgets/episode.rs +++ b/podcasts-gtk/src/widgets/episode.rs @@ -232,7 +232,10 @@ impl EpisodeWidget { let weak = Rc::downgrade(&widget); widget.container.connect_draw(clone!(sender => move |_, _| { episode.borrow_mut().take().map(|ep| { - weak.upgrade().map(|w| w.info.init(&ep)); + weak.upgrade().map(|w| { + w.info.init(&ep); + w.set_styling(&ep); + }); Self::determine_buttons_state(&weak, &ep, &sender) .map_err(|err| error!("Error: {}", err)) .ok(); @@ -474,6 +477,36 @@ impl EpisodeWidget { Ok(()) } + + // Searches in the two levels above for a GtkListBoxRow + fn get_listbox_row(widget: >k::Box) -> Option { + let mut row = None; + widget.get_parent().map(|first_parent| { + match first_parent.clone().downcast::() { + Ok(r) => row = Some(r), + _ => { + first_parent.get_parent().map(|second_parent| { + second_parent + .clone() + .downcast::() + .map(|r| row = Some(r)) + }); + } + } + }); + + row + } + + fn set_styling(&self, episode: &EpisodeWidgetModel) { + if episode.played().is_some() { + Self::get_listbox_row(&self.container) + .map(|row| row.get_style_context().add_class("played")); + } else { + Self::get_listbox_row(&self.container) + .map(|row| row.get_style_context().remove_class("played")); + } + } } fn on_download_clicked(ep: &EpisodeWidgetModel, sender: &Sender) -> Result<(), Error> { @@ -504,6 +537,9 @@ fn on_play_bttn_clicked( // Grey out the title widget.info.set_title(&episode); + // Set the styling + widget.set_styling(&episode); + // Play the episode sender .send(Action::InitEpisode(episode.rowid()))