From 10b2fe69260853a74f1b3bccc02c4184af9a0376 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 5 Apr 2010 13:56:47 -0300 Subject: [PATCH] UpdateBox emits a signal when the textarea gets focus, so we can disable the message actions. --- mitterlib/ui/helpers/gtk_updatebox.py | 14 +++++++++++++- mitterlib/ui/ui_pygtk.py | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mitterlib/ui/helpers/gtk_updatebox.py b/mitterlib/ui/helpers/gtk_updatebox.py index 7d322c8..09be63a 100644 --- a/mitterlib/ui/helpers/gtk_updatebox.py +++ b/mitterlib/ui/helpers/gtk_updatebox.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import gobject import gtk import logging import gettext @@ -39,6 +40,15 @@ N_ = t.ngettext # ---------------------------------------------------------------------- class UpdateBox(gtk.VBox): """Custom update box widget.""" + + __gsignals__ = { + 'text-focus': ( + gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + () + ) + } + def __init__(self, avatar, spell_check=True): super(UpdateBox, self).__init__(False, 0) @@ -88,6 +98,7 @@ class UpdateBox(gtk.VBox): self._text.get_buffer().connect('changed', self._count_chars) self._count_chars() # To show something + return def show(self, reply_to=None): """Show the update box and all related widgets.""" @@ -101,6 +112,7 @@ class UpdateBox(gtk.VBox): self._update_info.set_text('') self._text.grab_focus() + self.emit('text-focus') return def hide(self, caller=None): @@ -139,4 +151,4 @@ class UpdateBox(gtk.VBox): """Update the avatar pixbuf.""" self.avatar.set_from_pixbuf(pixbuf) # pixbuf can only be set, not get. - pixbuf = property(None, _set_pixbuf) \ No newline at end of file + pixbuf = property(None, _set_pixbuf) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 3ad117c..fd70af1 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -147,7 +147,7 @@ class Interface(object): main_window.connect('delete-event', self._quit_app) main_window.connect('size-request', self._window_resize) - self._update_field.connect('focus-in-event', self._on_textarea_focus) + self._update_field.connect('text-focus', self._on_textarea_focus) return main_window @@ -700,6 +700,7 @@ class Interface(object): again.""" # disable the message actions (they will be activated properly when # the user leaves the textarea.) + _log.debug('Disabling message actions due focus on textarea') self._delete_action.set_property('sensitive', False) self._reply_action.set_property('sensitive', False) self._repost_action.set_property('sensitive', False)