From 0ae8e80db18b0c9859c230d344e20a066338a155 Mon Sep 17 00:00:00 2001 From: Daniel Viegas Date: Sun, 30 Nov 2025 01:27:42 +0100 Subject: [PATCH] Refactor: Extract drawing area event masks as constant - Extract DRAWING_AREA_EVENT_MASKS constant to consolidate event mask combination - Improves maintainability by centralizing event mask configuration This change makes it easier to modify event handling behavior in one place. --- MyTimeline.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/MyTimeline.py b/MyTimeline.py index cfa2033..cc67abe 100644 --- a/MyTimeline.py +++ b/MyTimeline.py @@ -89,6 +89,15 @@ CLICKABLE_AREA_HEIGHT = 30 YEAR_LABEL_WIDTH = 100 YEAR_MARKER_STEP_DIVISOR = 10 # Divisor for calculating year marker step (every Nth year) TOOLTIP_DELAY = 500 # milliseconds + +# Drawing Area Event Masks +DRAWING_AREA_EVENT_MASKS = ( + Gdk.EventMask.BUTTON_PRESS_MASK + | Gdk.EventMask.BUTTON_RELEASE_MASK + | Gdk.EventMask.POINTER_MOTION_MASK + | Gdk.EventMask.LEAVE_NOTIFY_MASK + | Gdk.EventMask.SCROLL_MASK +) TOOLTIP_MAX_WIDTH = 500 LABEL_BACKGROUND_PADDING = 8 LABEL_BACKGROUND_RADIUS = 5 @@ -644,13 +653,7 @@ class MyTimelineView(NavigationView): self.drawing_area = Gtk.DrawingArea() self.drawing_area.set_size_request(800, 600) self.drawing_area.connect("draw", self.on_draw) - self.drawing_area.add_events( - Gdk.EventMask.BUTTON_PRESS_MASK - | Gdk.EventMask.BUTTON_RELEASE_MASK - | Gdk.EventMask.POINTER_MOTION_MASK - | Gdk.EventMask.LEAVE_NOTIFY_MASK - | Gdk.EventMask.SCROLL_MASK - ) + self.drawing_area.add_events(DRAWING_AREA_EVENT_MASKS) # Connect mouse events self.drawing_area.connect("button-press-event", self.on_button_press)