[hamster-applet] 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] hide popup on attempts to exit widget. fixes bug 617781
- Date: Wed, 5 May 2010 17:40:09 +0000 (UTC)
commit e34035080b5561eb12ddb45a0e5891bf593210ea
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 | 10 ++++++++++
src/hamster/widgets/timeinput.py | 19 ++++++++++++++-----
4 files changed, 46 insertions(+), 10 deletions(-)
---
diff --git a/src/hamster/widgets/activityentry.py b/src/hamster/widgets/activityentry.py
index 7491cec..777df6d 100644
--- a/src/hamster/widgets/activityentry.py
+++ b/src/hamster/widgets/activityentry.py
@@ -91,6 +91,7 @@ class ActivityEntry(gtk.Entry):
self.connect("key-release-event", self._on_key_release_event)
self.connect("focus-out-event", self._on_focus_out_event)
self.connect("changed", self._on_text_changed)
+ self._parent_click_watcher = None # bit lame but works
runtime.storage.connect('activities-changed',self.after_activity_update)
@@ -98,6 +99,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):
@@ -106,6 +110,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 a724b35..582e754 100644
--- a/src/hamster/widgets/tags.py
+++ b/src/hamster/widgets/tags.py
@@ -58,10 +58,13 @@ 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._parent_click_watcher = None # bit lame but works
+
runtime.storage.connect('tags-changed', self.refresh_tags)
self.show()
self.populate_suggestions()
+
def refresh_tags(self, event):
self.tags = None
@@ -91,12 +94,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()
@@ -111,6 +120,7 @@ class TagsEntry(gtk.Entry):
self.popup.show_all()
+
def complete_inline(self):
return
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]