Show correct color of status_messages in roster in more cases.

This is only a simple port of the old non-modelfilter method. Functionality not restored yet: Custom colors are lost when refiltering the model.
This commit is contained in:
Stephan Erb 2008-04-21 19:57:48 +00:00
parent b56c0c94af
commit 7d8f72d663
1 changed files with 30 additions and 35 deletions

View File

@ -862,10 +862,6 @@ class RosterWindow:
'''draw the correct state image, name BUT not avatar''' '''draw the correct state image, name BUT not avatar'''
# focus is about if the roster window has toplevel-focus or not # focus is about if the roster window has toplevel-focus or not
# FIXME Remove functionality but check before if all cases
# are handled by GTK
selected = False
child_iters = self._get_contact_iter(jid, account, self.model) child_iters = self._get_contact_iter(jid, account, self.model)
if not child_iters: if not child_iters:
return False return False
@ -939,6 +935,7 @@ class RosterWindow:
if status != '': if status != '':
status = helpers.reduce_chars_newlines(status, max_lines = 1) status = helpers.reduce_chars_newlines(status, max_lines = 1)
# escape markup entities and make them small italic and fg color # escape markup entities and make them small italic and fg color
# color is calcuted to be always readable
color = gtkgui_helpers._get_fade_color(self.tree, selected, focus) color = gtkgui_helpers._get_fade_color(self.tree, selected, focus)
colorstring = '#%04x%04x%04x' % (color.red, color.green, color.blue) colorstring = '#%04x%04x%04x' % (color.red, color.green, color.blue)
name += \ name += \
@ -3423,35 +3420,34 @@ class RosterWindow:
# Prevent endless loops # Prevent endless loops
gobject.idle_add(self.draw_contact, jid, account) gobject.idle_add(self.draw_contact, jid, account)
def on_treeview_selection_changed(self, selection):
'''Called when selection in TreeView has changed.
# FIXME: Looks like it is unneeded: If yes, remove it Redraw unselected rows to make status message readable
on all possible backgrounds.
'''
# Selection can change when the model is filtered
# Only write to the model when filtering is finished!
#def on_treeview_selection_changed(self, selection): # FIXME: When we are filtering our custom colors are somehow lost
# if self.filtering:
# print "async problem" model, list_of_paths = selection.get_selected_rows()
# return if len(self._last_selected_contact):
# model, list_of_paths = selection.get_selected_rows() # update unselected rows
# if len(self._last_selected_contact): for (jid, account) in self._last_selected_contact:
# # update unselected rows gobject.idle_add(self.draw_contact, jid, account)
# for (jid, account) in self._last_selected_contact: self._last_selected_contact = []
# #try: if len(list_of_paths) == 0:
# self.draw_contact(jid, account) return
# #except: for path in list_of_paths:
# # This can fail when last selected row was on an account we just row = model[path]
# # removed. So we don't care if that fail if row[C_TYPE] != 'contact':
# # pass self._last_selected_contact = []
# self._last_selected_contact = [] return
# if len(list_of_paths) == 0: jid = row[C_JID].decode('utf-8')
# return account = row[C_ACCOUNT].decode('utf-8')
# for path in list_of_paths: self._last_selected_contact.append((jid, account))
# row = model[path] gobject.idle_add(self.draw_contact, jid, account, True)
# if row[C_TYPE] != 'contact':
# self._last_selected_contact = []
# return
# jid = row[C_JID].decode('utf-8')
# account = row[C_ACCOUNT].decode('utf-8')
# self._last_selected_contact.append((jid, account))
# self.draw_contact(jid, account, selected = True)
def on_service_disco_menuitem_activate(self, widget, account): def on_service_disco_menuitem_activate(self, widget, account):
server_jid = gajim.config.get_per('accounts', account, 'hostname') server_jid = gajim.config.get_per('accounts', account, 'hostname')
@ -5651,9 +5647,8 @@ class RosterWindow:
self.tree = self.xml.get_widget('roster_treeview') self.tree = self.xml.get_widget('roster_treeview')
sel = self.tree.get_selection() sel = self.tree.get_selection()
sel.set_mode(gtk.SELECTION_MULTIPLE) sel.set_mode(gtk.SELECTION_MULTIPLE)
#FIXME: talk to asterix, why is this needed? sel.connect('changed',
#sel.connect('changed', self.on_treeview_selection_changed)
# self.on_treeview_selection_changed)
self._last_selected_contact = [] # holds a list of (jid, account) tupples self._last_selected_contact = [] # holds a list of (jid, account) tupples
self.transports_state_images = {'16': {}, '32': {}, 'opened': {}, self.transports_state_images = {'16': {}, '32': {}, 'opened': {},