Browse Source

UpdateBox emits a signal when the textarea gets focus, so we can disable

the message actions.
master
Julio Biason 14 years ago
parent
commit
10b2fe6926
  1. 14
      mitterlib/ui/helpers/gtk_updatebox.py
  2. 3
      mitterlib/ui/ui_pygtk.py

14
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 <http://www.gnu.org/licenses/>.
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)
pixbuf = property(None, _set_pixbuf)

3
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)

Loading…
Cancel
Save