[hamster-applet/gnome-2-30] hide popup on attempts to exit widget. fixes bug 617781
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet/gnome-2-30] hide popup on attempts to exit widget. fixes bug 617781
- Date: Wed, 5 May 2010 20:19:23 +0000 (UTC)
commit d5c39eb5ad370fc0dc6bb5d1c29b5aec8d03a88f
Author: Toms Bauģis <toms baugis gmail com>
Date: Wed May 5 18:40:01 2010 +0100
hide popup on attempts to exit widget. fixes bug 617781
src/hamster/widgets/activityentry.py | 7 +++++++
src/hamster/widgets/dateinput.py | 20 +++++++++++++++-----
src/hamster/widgets/tags.py | 7 +++++++
src/hamster/widgets/timeinput.py | 19 ++++++++++++++-----
4 files changed, 43 insertions(+), 10 deletions(-)
---
diff --git a/src/hamster/widgets/activityentry.py b/src/hamster/widgets/activityentry.py
index 42b70b8..805c99e 100644
--- a/src/hamster/widgets/activityentry.py
+++ b/src/hamster/widgets/activityentry.py
@@ -92,6 +92,7 @@ class ActivityEntry(gtk.Entry):
self.connect("focus-out-event", self._on_focus_out_event)
self.connect("changed", self._on_text_changed)
self.connect("parent-set", self._on_parent_set)
+ self._parent_click_watcher = None # bit lame but works
runtime.dispatcher.add_handler('activity_updated', self.after_activity_update)
@@ -99,6 +100,9 @@ class ActivityEntry(gtk.Entry):
self.populate_suggestions()
def hide_popup(self):
+ if self._parent_click_watcher and self.get_toplevel().handler_is_connected(self._parent_click_watcher):
+ self.get_toplevel().disconnect(self._parent_click_watcher)
+ self._parent_click_watcher = None
self.popup.hide()
def show_popup(self):
@@ -107,6 +111,9 @@ class ActivityEntry(gtk.Entry):
self.hide_popup()
return
+ if not self._parent_click_watcher:
+ self._parent_click_watcher = self.get_toplevel().connect("button-press-event", self._on_focus_out_event)
+
activity = stuff.parse_activity_input(self.filter)
time = ''
if activity.start_time:
diff --git a/src/hamster/widgets/dateinput.py b/src/hamster/widgets/dateinput.py
index 5498e80..da38703 100644
--- a/src/hamster/widgets/dateinput.py
+++ b/src/hamster/widgets/dateinput.py
@@ -58,6 +58,8 @@ class DateInput(gtk.Entry):
self.connect("key-press-event", self._on_key_press_event)
self.connect("focus-in-event", self._on_focus_in_event)
self.connect("focus-out-event", self._on_focus_out_event)
+ self._parent_click_watcher = None # bit lame but works
+
self.connect("changed", self._on_text_changed)
self.show()
@@ -106,15 +108,23 @@ class DateInput(gtk.Entry):
self.date = dt.date(cal_date[0], cal_date[1] + 1, cal_date[2])
self.set_text(self._format_date(self.date))
- self.popup.hide()
+ self.hide_popup()
if self.news:
self.emit("date-entered")
self.news = False
+ def hide_popup(self):
+ self.popup.hide()
+ if self._parent_click_watcher and self.get_toplevel().handler_is_connected(self._parent_click_watcher):
+ self.get_toplevel().disconnect(self._parent_click_watcher)
+ self._parent_click_watcher = None
def show_popup(self):
+ if not self._parent_click_watcher:
+ self._parent_click_watcher = self.get_toplevel().connect("button-press-event", self._on_focus_out_event)
+
window = self.get_parent_window()
- x, y= window.get_origin()
+ x, y = window.get_origin()
alloc = self.get_allocation()
@@ -135,7 +145,7 @@ class DateInput(gtk.Entry):
def _on_focus_out_event(self, event, something):
- self.popup.hide()
+ self.hide_popup()
if self.news:
self.emit("date-entered")
self.news = False
@@ -159,11 +169,11 @@ class DateInput(gtk.Entry):
event.keyval == gtk.keysyms.KP_Enter):
enter_pressed = True
elif (event.keyval == gtk.keysyms.Escape):
- self.popup.hide()
+ self.hide_popup()
elif event.keyval in (gtk.keysyms.Left, gtk.keysyms.Right):
return False #keep calendar open and allow user to walk in text
else:
- self.popup.hide()
+ self.hide_popup()
return False
if enter_pressed:
diff --git a/src/hamster/widgets/tags.py b/src/hamster/widgets/tags.py
index e49583c..c6865f5 100644
--- a/src/hamster/widgets/tags.py
+++ b/src/hamster/widgets/tags.py
@@ -58,6 +58,7 @@ class TagsEntry(gtk.Entry):
self.connect("key-release-event", self._on_key_release_event)
self.connect("focus-out-event", self._on_focus_out_event)
self.connect("parent-set", self._on_parent_set)
+ self._parent_click_watcher = None # bit lame but works
runtime.dispatcher.add_handler('new_tags_added', self.refresh_tags)
self.show()
@@ -92,12 +93,18 @@ class TagsEntry(gtk.Entry):
def hide_popup(self):
self.popup.hide()
+ if self._parent_click_watcher and self.get_toplevel().handler_is_connected(self._parent_click_watcher):
+ self.get_toplevel().disconnect(self._parent_click_watcher)
+ self._parent_click_watcher = None
def show_popup(self):
if not self.filter_tags:
self.popup.hide()
return
+ if not self._parent_click_watcher:
+ self._parent_click_watcher = self.get_toplevel().connect("button-press-event", self._on_focus_out_event)
+
alloc = self.get_allocation()
x, y = self.get_parent_window().get_origin()
diff --git a/src/hamster/widgets/timeinput.py b/src/hamster/widgets/timeinput.py
index c3cc387..9004a7f 100644
--- a/src/hamster/widgets/timeinput.py
+++ b/src/hamster/widgets/timeinput.py
@@ -60,6 +60,8 @@ class TimeInput(gtk.Entry):
self.connect("key-press-event", self._on_key_press_event)
self.connect("focus-in-event", self._on_focus_in_event)
self.connect("focus-out-event", self._on_focus_out_event)
+ self._parent_click_watcher = None # bit lame but works
+
self.connect("changed", self._on_text_changed)
self.show()
@@ -119,7 +121,7 @@ class TimeInput(gtk.Entry):
self.set_text(time_text)
self.set_position(len(time_text))
- self.popup.hide()
+ self.hide_popup()
if self.news:
self.emit("time-entered")
self.news = False
@@ -142,15 +144,22 @@ class TimeInput(gtk.Entry):
self.show_popup()
def _on_focus_out_event(self, event, something):
- self.popup.hide()
+ self.hide_popup()
if self.news:
self.emit("time-entered")
self.news = False
+ def hide_popup(self):
+ if self._parent_click_watcher and self.get_toplevel().handler_is_connected(self._parent_click_watcher):
+ self.get_toplevel().disconnect(self._parent_click_watcher)
+ self._parent_click_watcher = None
+ self.popup.hide()
def show_popup(self):
- # will be going either 24 hours or from start time to start time + 12 hours
+ if not self._parent_click_watcher:
+ self._parent_click_watcher = self.get_toplevel().connect("button-press-event", self._on_focus_out_event)
+ # will be going either 24 hours or from start time to start time + 12 hours
start_time = dt.datetime.combine(dt.date.today(), self.start_time) # we will be adding things
i_time = start_time # we will be adding things
@@ -237,10 +246,10 @@ class TimeInput(gtk.Entry):
else:
self._select_time(entry.get_text())
elif (event.keyval == gtk.keysyms.Escape):
- self.popup.hide()
+ self.hide_popup()
else:
#any kind of other input
- self.popup.hide()
+ self.hide_popup()
return False
# keep it in the sane borders
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]