Browse Source

Closing the updatebox works.

master
Julio Biason 14 years ago
parent
commit
c1587c3ceb
  1. 42
      mitterlib/ui/helpers/gtk_updatebox.py
  2. 4
      mitterlib/ui/ui_pygtk.py

42
mitterlib/ui/helpers/gtk_updatebox.py

@ -19,9 +19,24 @@
import gtk
import logging
import gettext
# ----------------------------------------------------------------------
# Logging
# ----------------------------------------------------------------------
_log = logging.getLogger('ui.pygtk.updatebox')
# ----------------------------------------------------------------------
# I18n bits
# ----------------------------------------------------------------------
t = gettext.translation('ui_pygtk', fallback=True)
# Still mark translations inside ui_pygtk
_ = t.gettext
N_ = t.ngettext
# ----------------------------------------------------------------------
# UpdateBox class
# ----------------------------------------------------------------------
class UpdateBox(gtk.VBox):
"""Custom update box widget."""
def __init__(self, avatar, spell_check=True):
@ -37,13 +52,16 @@ class UpdateBox(gtk.VBox):
status_bar = gtk.HBox(False, 0)
self._update_status = gtk.Label()
self._update_info = gtk.Label()
close_button = gtk.Button(stock=gtk.STOCK_CLOSE)
close_button.set_relief(gtk.RELIEF_NONE)
close_button.connect('clicked', self.hide)
status_bar = gtk.HBox(False, 0)
status_bar.pack_start(self._update_status, expand=True, fill=True,
status_bar.pack_start(self._update_status, expand=True, fill=False,
padding=0)
status_bar.pack_start(self._update_info, expand=True, fill=False,
padding=0)
status_bar.pack_start(close_button, expand=False, fill=False,
padding=0)
@ -70,12 +88,19 @@ class UpdateBox(gtk.VBox):
_log.debug('Error initializing spell checking: ' \
'spell checking disabled')
self._text.get_buffer().connect('changed', self._count_chars)
self._count_chars() # To show something
def show(self, reply_to=None):
"""Show the update box and all related widgets."""
super(UpdateBox, self).show()
self._reply_to = reply_to
self.show_all()
_log.debug('show')
if reply_to:
info = _('(replying to %s)') % (self._reply_to)
self._update_info.set_text(info)
else:
self._update_info.set_text('')
return
def hide(self, caller=None):
@ -85,19 +110,12 @@ class UpdateBox(gtk.VBox):
self.hide_all()
return
def _count_chars(self, text_buffer):
def _count_chars(self, text_buffer=None):
"""Count the number of chars in the edit field and update the
label that shows the available space."""
count = len(self.text)
if self._reply_to:
suffix = _('(replying to %s)') % (self._reply_to)
else:
suffix = ''
# TODO: gettext to properly use "characters"/"character"
text = N_('%d character %s', '%d characters %s', count) % (count,
suffix)
text = N_('%d character', '%d characters', count) % (count)
self._update_status.set_text(text)
return True

4
mitterlib/ui/ui_pygtk.py

@ -625,11 +625,9 @@ class Interface(object):
def _clear_text(self, widget):
"""Clear the text field."""
self._update_text.get_buffer().set_text('')
self._delete_info = None
self._clear_reply()
self._hide_update_box()
self._update_field.hide()
# change the focus to the grid.
page = self._main_tabs.get_current_page()

Loading…
Cancel
Save