Skip to content

Commit

Permalink
Cancel widget popdown on calendar nav events
Browse files Browse the repository at this point in the history
In order to get single-click day selection, we close the
window on day-selected, but that also occurs on the calendar
navigation events (like next-month, etc.).  This patch
cancels the popdown on the nav events.

Signed-off-by: Darren Hart <darren@dvhart.com>
  • Loading branch information
dvhart committed Mar 7, 2009
1 parent f9ec6d0 commit 59a8db9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gui/date_select.py
Expand Up @@ -39,6 +39,8 @@ class _DateSelectPopup(gtk.Window):
def __init__(self):
gtk.Window.__init__(self, gtk.WINDOW_POPUP)

self.__cancel_popdown = False

frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self.add(frame)
Expand Down Expand Up @@ -66,6 +68,10 @@ def __init__(self):
self.connect("button-press-event", self._on_button_press)
self.connect("key-press-event", self._on_key_press)
self._calendar.connect("day-selected", self._on_day_selected)
self._calendar.connect("next-month", self._cancel_popdown)
self._calendar.connect("prev-month", self._cancel_popdown)
self._calendar.connect("next-month", self._cancel_popdown)
self._calendar.connect("prev-month", self._cancel_popdown)

# private interface
def _grab_window(self):
Expand Down Expand Up @@ -117,13 +123,17 @@ def _on_key_press(self, popup, event):
return True

def _on_day_selected(self, cal):
if self.get_property("visible"):
if self.get_property("visible") and not self.__cancel_popdown:
self.__cancel_popdown = False
self.popdown()
year, month, day = cal.get_date()
datetime_val = datetime(year, month + 1, day)
datetime_val = datetime_ceiling(datetime_val)
self.emit("date-selected", datetime_val)

def _cancel_popdown(self, cal):
self.__cancel_popdown = True

def _on_date_button_clicked(self, btn, friendly_str):
self.popdown()
datetime_val = friendly_to_datetime(friendly_str)
Expand Down

0 comments on commit 59a8db9

Please sign in to comment.