Browse Source

Update works; stil trying to find why we have some message drawing problems (the message is being selected correctly)

master
Julio Biason 16 years ago
parent
commit
ac684434ba
  1. 44
      mitterlib/ui/ui_pygtk.py

44
mitterlib/ui/ui_pygtk.py

@ -106,7 +106,7 @@ class _WorkerThread(threading.Thread, _IdleObject):
try:
result = self._function(*args, **kwargs)
except Exception, exc: # Catch ALL exceptions
# XXX: Check if this catch all warnins too!
# TODO: Check if this catch all warnins too!
_log.debug('Exception %s', str(exc))
self.emit("exception", exc)
return
@ -498,7 +498,7 @@ class Interface(object):
time = timesince.timesince(data.message_time)
# unescape escaped entities that pango is okay with
message = re.sub(r'&(?!(amp;|gt;|lt;|quot;|apos;))', r'&', message)
#message = re.sub(r'&(?!(amp;|gt;|lt;|quot;|apos;))', r'&', message)
# highlight URLs
mask = r'<span foreground="%s">\1</span>' % (
@ -516,6 +516,17 @@ class Interface(object):
return
# ------------------------------------------------------------
# Helper functions
# ------------------------------------------------------------
def _update_sensitivity(self, enabled):
"""Set the "sensitive" property of the update action and button. Both
should have the same property, so whenever you need to disable/enable
them, use this function."""
self._update_button.set_property('sensitive', enabled)
self._update_action.set_property('sensitive', enabled)
return
# ------------------------------------------------------------
# Widget callback functions
@ -528,10 +539,7 @@ class Interface(object):
count = len(text)
self._char_count.set_text('(%d)' % (140 - count))
self._update_button.set_property('sensitive', not (count == 0))
self._update_action.set_property('sensitive', not (count == 0))
self._update_sensitivity(not (count == 0))
return True
def _update_status(self, widget):
@ -543,9 +551,13 @@ class Interface(object):
return
_log.debug('Status: %s', status)
#self._update_text.set_sensitive(False)
#self.statusbar.push(self.statusbar_context, 'Updating your status...')
self._update_sensitivity(False)
self._threads.add_work(self._post_update_status,
self._exception_update_status,
self._connection.update,
status)
# TODO: We are not dealing with replies here yet
return
def _quit_app(self, widget=None, user_data=None):
"""Callback when the window is destroyed or the user selects
@ -666,6 +678,20 @@ class Interface(object):
_log.debug(str(exception))
return
### Results for the update status call
def _post_update_status(self, widget, data):
"""Called when the status is updated correctly."""
self._update_sensitivity(True)
self._update_text.get_buffer().set_text('')
return
def _exception_update_status(self, widget, exception):
"""Called when there is an exception updating the status."""
# TODO: Need the check the type of exception we got.
_log.debug('Update error')
_log.debug(str(exception))
return
# ------------------------------------------------------------
# Required functions for all interfaces
# ------------------------------------------------------------

Loading…
Cancel
Save