feat: update date widget

This commit is contained in:
sankalp committed 2026-07-28 10:23:04 +05:45
1 parent 98640d82c2
commit 34f9f71d62
1 file changed
+29 -3
+29 -3
View File
@@ -4,6 +4,28 @@ from fabric.widgets.datetime import DateTime
from window.desktop.registry import DesktopWidgetRegistry
class _DraggableDateTime(DateTime):
"""DateTime subclass that lets button-press events propagate to the parent
EventBox so GTK drag-and-drop works across the entire widget area.
GtkButton's class handler (do_button_press_event) returns True at
G_SIGNAL_RUN_FIRST, which stops the accumulator before DateTime's own
connected handler ever runs. Both must return False for the event to
reach the EventBox where drag_source_set lives.
"""
def do_button_press_event(self, event):
match event.button:
case 1:
self.do_cycle_next()
case 3:
self.do_cycle_prev()
return False
def do_handle_press(self, _widget, _event, *_args):
return False
class DesktopDateWidget(Box):
def __init__(self, **kwargs):
super().__init__(
@@ -24,9 +46,13 @@ class DesktopDateWidget(Box):
# Since this is just a date widget, we increase the interval to 100000ms (100 seconds)
# which easily avoids the continuous redraw glitch while keeping the date accurate.
date_interval = 100000
self.dateone = DateTime(formatters=["%a"], interval=date_interval, name="day")
self.datetwo = DateTime(formatters=["%b"], interval=date_interval, name="month")
self.datethree = DateTime(
self.dateone = _DraggableDateTime(
formatters=["%a"], interval=date_interval, name="day"
)
self.datetwo = _DraggableDateTime(
formatters=["%b"], interval=date_interval, name="month"
)
self.datethree = _DraggableDateTime(
formatters=["%-d"], interval=date_interval, name="date"
)
self.top.add(self.dateone)