Browse Source

speed up, but the grid moves the cursor out of visibility

master
Julio Biason 15 years ago
parent
commit
e45aac9130
  1. 2
      mitterlib/network/networkbase.py
  2. 5
      mitterlib/network/twitter.py
  3. 19
      mitterlib/ui/helpers/gtk_messagegrid.py

2
mitterlib/network/networkbase.py

@ -95,7 +95,7 @@ class NetworkInvalidResponseError(NetworkError):
self.name = network_name self.name = network_name
def __str__(self): def __str__(self):
return _('The server on %s return the information in an ' \ return _('The server on %s returned the information in an ' \
'unexpected way.') % (self.name) 'unexpected way.') % (self.name)
pass pass

5
mitterlib/network/twitter.py

@ -61,6 +61,7 @@ _log = logging.getLogger('mitterlib.network.Twitter')
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
_month_names = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', _month_names = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec'] 'Sep', 'Oct', 'Nov', 'Dec']
_punctuation = string.punctuation.replace('_', '')
def _unhtml(text): def _unhtml(text):
@ -173,10 +174,10 @@ class TwitterNetworkData(NetworkData):
self.message = _unhtml(data['text']) self.message = _unhtml(data['text'])
# regular expression for users # regular expression for users
self.user_regexp = r'@[^ ' + string.punctuation + ']' self.user_regexp = r'@[^ ' + _punctuation + ']+'
# regular expression for hashtags # regular expression for hashtags
self.tag_regexp = r'#[^ ' + string.punctuation + ']' self.tag_regexp = r'#[^ ' + _punctuation + ']+'
return return

19
mitterlib/ui/helpers/gtk_messagegrid.py

@ -393,14 +393,29 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
"""Update the grid with new messages.""" """Update the grid with new messages."""
self._grid.freeze_notify() self._grid.freeze_notify()
store = self._grid.get_model() store = self._grid.get_model()
# disconnect the store, so we are free to add rows without hogging the
# system. Also, save the current selection and grid position so it can
# be restore (selecting is lost when the model is connected and the
# view moves with the new elements.)
(model, iter) = self._grid.get_selection().get_selected()
self._grid.set_model(None)
for message in messages: for message in messages:
message.read = False message.read = False
store.prepend([message]) store.prepend([message])
store.sort_column_changed()
# reconnect the store and re-select the previously selected line
self._grid.set_model(store)
if iter:
self._grid.get_selection().select_iter(iter)
self._grid.thaw_notify() self._grid.thaw_notify()
self._grid.queue_draw() self._grid.queue_draw()
self.count += len(messages) new_messages = len(messages)
_log.debug('%d new messages', new_messages)
self.count += new_messages
return return
def clear_posts(self): def clear_posts(self):

Loading…
Cancel
Save