diff options
Diffstat (limited to 'activity_review/src/View.py')
-rw-r--r-- | activity_review/src/View.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/activity_review/src/View.py b/activity_review/src/View.py index fc477b1..f9fc923 100644 --- a/activity_review/src/View.py +++ b/activity_review/src/View.py @@ -3,7 +3,7 @@ Created on 22 Oct 2012 @author: cgueret ''' -from gi.repository import Gtk, GObject +from gi.repository import Gtk, Gdk, GObject from semanticxo import graphstore from Model import ReviewModel @@ -92,9 +92,6 @@ class TalkPanel(object): # Load the comments self.update_comments(model) - # The timeout to reload the talks - self._timeout_id = GObject.timeout_add(120000, self.update_comments, model) - # Connect the mood bar buttons to the call back for mood_id in [1, 2, 3, 4]: radio = builder.get_object("radiobutton%d" % mood_id) @@ -102,7 +99,9 @@ class TalkPanel(object): # Connect the question send button to the call back button = builder.get_object("new_question_button") - button.connect("clicked", self.on_comment_button_clicked, builder.get_object("new_question")) + text_entry = builder.get_object("new_question") + button.connect("clicked", self.on_comment_button_clicked, text_entry) + text_entry.connect("key-press-event", self.on_entry_key_pressed) def get_widget(self): return self._widget @@ -125,11 +124,20 @@ class TalkPanel(object): model.add_new_comment_for_talk(talk=self._identifier, comment=entry.get_text()) entry.set_text("") self.update_comments(model) - + + def on_entry_key_pressed(self, entry, event): + ''' + If the key pressed is enter, post the comment + ''' + if event.keyval == Gdk.KEY_Return: + model = ReviewModel() + model.add_new_comment_for_talk(talk=self._identifier, comment=entry.get_text()) + entry.set_text("") + self.update_comments(model) + def update_comments(self, model): for (comment_id, message, date, author) in model.get_comments_for_talk(talk=self._identifier): if comment_id not in self._comments: self._comments_store.append([message, author.split('/')[-1], date]) self._comments.add(comment_id) - return True
\ No newline at end of file |