فهرست منبع

Add default implementations for widget methods

Thomas Dy 7 سال پیش
والد
کامیت
9f30f24bd2
2فایلهای تغییر یافته به همراه5 افزوده شده و 6 حذف شده
  1. 0 3
      src/ui/tray.rs
  2. 5 3
      src/ui/widget.rs

+ 0 - 3
src/ui/tray.rs

@@ -83,9 +83,6 @@ impl Tray {
 }
 
 impl widget::Widget for Tray {
-    fn init(&mut self) {
-    }
-
     fn width(&mut self) -> u16 {
         (self.children.len() * 20) as u16
     }

+ 5 - 3
src/ui/widget.rs

@@ -5,11 +5,13 @@ use std::rc::Rc;
 use std::sync::Arc;
 
 pub trait Widget {
-    fn init(&mut self);
+    fn init(&mut self) {}
     fn render(&mut self, x: u16);
     fn width(&mut self) -> u16;
-    fn handle_event(&mut self, event: &xcb::GenericEvent, is_finishing: bool) -> bool;
-    fn finish(&mut self);
+    fn handle_event(&mut self, _event: &xcb::GenericEvent, _is_finishing: bool) -> bool {
+        false
+    }
+    fn finish(&mut self) {}
 }
 
 pub struct DrawContext {