[hamster-applet] fixed bug 617297 - allow properly combining clicking and typing in autocomplete and correct cursor p
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] fixed bug 617297 - allow properly combining clicking and typing in autocomplete and correct cursor p
- Date: Thu, 6 May 2010 01:31:17 +0000 (UTC)
commit 05d69359bd7f3c8651adea6e7d9e2fe80cd065bd
Author: Toms Bauģis <toms baugis gmail com>
Date: Thu May 6 02:23:27 2010 +0100
fixed bug 617297 - allow properly combining clicking and typing in autocomplete and correct cursor position
src/hamster/widgets/tags.py | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/hamster/widgets/tags.py b/src/hamster/widgets/tags.py
index 6eda0a2..2ebd989 100644
--- a/src/hamster/widgets/tags.py
+++ b/src/hamster/widgets/tags.py
@@ -73,14 +73,23 @@ class TagsEntry(gtk.Entry):
return [tag.strip() for tag in self.get_text().decode('utf8', 'replace').split(",") if tag.strip()]
def on_tag_selected(self, tag_box, tag):
- tags = self.get_tags()
- tags.append(tag)
+ cursor_tag = self.get_cursor_tag()
+ if cursor_tag and tag.startswith(cursor_tag):
+ self.replace_tag(cursor_tag, tag)
+ tags = self.get_tags()
+ else:
+ tags = self.get_tags()
+ tags.append(tag)
self.tag_box.selected_tags = tags
- self.set_text(", ".join(tags))
+
+ self.set_text("%s, " % ", ".join(tags))
self.set_position(len(self.get_text()))
+ self.populate_suggestions()
+ self.show_popup()
+
def on_tag_unselected(self, tag_box, tag):
tags = self.get_tags()
while tag in tags: #it could be that dear user is mocking us and entering same tag over and over again
@@ -88,7 +97,7 @@ class TagsEntry(gtk.Entry):
self.tag_box.selected_tags = tags
- self.set_text(", ".join(tags))
+ self.set_text("%s, " % ", ".join(tags))
self.set_position(len(self.get_text()))
@@ -199,7 +208,7 @@ class TagsEntry(gtk.Entry):
cursor = self.get_position()
self.set_text(", ".join(tags))
- self.set_position(cursor + len(new_tag)-len(old_tag)) # put the cursor back
+ self.set_position(len(self.get_text()))
def _on_key_press_event(self, entry, event):
if event.keyval == gtk.keysyms.Tab:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]