diff options
author | Jamie Murphy <hello@itsjamie.dev> | 2023-02-11 19:08:55 -0800 |
---|---|---|
committer | Jamie Murphy <hello@itsjamie.dev> | 2023-02-12 07:14:41 +0000 |
commit | a6219af540f65602783a2b80407991b4cfbf3de5 (patch) | |
tree | 458cd5c1add0212e800a3b76903cdaff96ba1430 | |
parent | 2f205761cee1c1e2bc88313f257644829c455c5a (diff) | |
download | gnome-todo-a6219af540f65602783a2b80407991b4cfbf3de5.tar.gz |
provider: Switch to making Provider subclassable
Instead of storing something that implements ProviderImpl, Provider
itself should be the lower-level class, and an actual provider should
subclass Provider
-rw-r--r-- | src/engine/provider.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/engine/provider.rs b/src/engine/provider.rs index 0de328cf..a0d9bcbc 100644 --- a/src/engine/provider.rs +++ b/src/engine/provider.rs @@ -1,12 +1,11 @@ -use gtk::{ - gio::Icon, - glib::{self, Object}, - prelude::*, - subclass::prelude::*, -}; +use gtk::{gio::Icon, glib, prelude::*, subclass::prelude::*}; + +pub mod prelude { + pub use super::{Provider, ProviderImpl}; +} /// Provider-specific functions -pub trait ProviderImpl { +pub trait ProviderImpl: ObjectImpl { // TODO: Add actual functions here (stuff like modifying tasks and related) } @@ -31,8 +30,6 @@ mod imp { pub description: RefCell<String>, #[property(get, set)] pub icon: RefCell<Icon>, - // Private handler for a Provider - pub handler: Option<Box<dyn ProviderImpl>>, } impl Default for Provider { @@ -43,7 +40,6 @@ mod imp { description: RefCell::new(String::new()), // TODO check this is appropriate icon: RefCell::new(ThemedIcon::new("applications-internet").upcast::<Icon>()), - handler: None, } } } @@ -74,11 +70,6 @@ glib::wrapper! { pub struct Provider(ObjectSubclass<imp::Provider>); } -impl Provider { - #![allow(clippy::new_without_default)] +impl Provider {} - /// Create a new Provider - pub fn new() -> Self { - Object::new::<Self>() - } -} +unsafe impl<T: ProviderImpl> IsSubclassable<T> for Provider {} |