* Better rendering of mood in roster.

(Only takes space if needed now)
* Possibility to disable display of mood in roster from preferences.
  (Also works on the fly with the new rendering method)
* Minor improvements in the translation of the moods to German.
This commit is contained in:
js 2008-07-25 00:43:01 +00:00
parent aec24f6e21
commit 0d6394b0ca
5 changed files with 104 additions and 28 deletions

View File

@ -72,6 +72,23 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkCheckButton" id="show_mood_in_roster_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will display status messages of contacts under the contact name in roster window and in group chats</property>
<property name="label" translatable="yes">Display m_ood of contacts in roster</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_show_mood_in_roster_checkbutton_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<widget class="GtkCheckButton" id="sort_by_show_checkbutton"> <widget class="GtkCheckButton" id="sort_by_show_checkbutton">
<property name="visible">True</property> <property name="visible">True</property>
@ -86,7 +103,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</widget> </widget>

View File

@ -4713,11 +4713,11 @@ msgstr "Mitglied"
#: ../src/common/helpers.py:350 #: ../src/common/helpers.py:350
msgid "afraid" msgid "afraid"
msgstr "Fürchtend" msgstr "Verängstigt"
#: ../src/common/helpers.py:350 #: ../src/common/helpers.py:350
msgid "amazed" msgid "amazed"
msgstr "Überrascht" msgstr "Verblüfft"
#: ../src/common/helpers.py:350 #: ../src/common/helpers.py:350
msgid "angry" msgid "angry"

View File

@ -62,7 +62,7 @@ def user_mood(items, name, jid):
if contact.mood.has_key('text'): if contact.mood.has_key('text'):
del contact.mood['text'] del contact.mood['text']
gajim.interface.roster.draw_contact(user, name) gajim.interface.roster.draw_mood(user, name)
ctrl = gajim.interface.msg_win_mgr.get_control(user, name) ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
if ctrl: if ctrl:
ctrl.update_mood() ctrl.update_mood()

View File

@ -92,12 +92,18 @@ class PreferencesWindow:
### General tab ### ### General tab ###
# Display avatars in roster # Display avatars in roster
st = gajim.config.get('show_avatars_in_roster') st = gajim.config.get('show_avatars_in_roster')
self.xml.get_widget('show_avatars_in_roster_checkbutton').set_active(st) self.xml.get_widget('show_avatars_in_roster_checkbutton'). \
set_active(st)
# Display status msg under contact name in roster # Display status msg under contact name in roster
st = gajim.config.get('show_status_msgs_in_roster') st = gajim.config.get('show_status_msgs_in_roster')
self.xml.get_widget('show_status_msgs_in_roster_checkbutton').set_active( self.xml.get_widget('show_status_msgs_in_roster_checkbutton'). \
st) set_active( st)
# Display mood in roster
st = gajim.config.get('show_mood_in_roster')
self.xml.get_widget('show_mood_in_roster_checkbutton'). \
set_active(st)
# Sort contacts by show # Sort contacts by show
st = gajim.config.get('sort_by_show') st = gajim.config.get('sort_by_show')
@ -527,6 +533,10 @@ class PreferencesWindow:
if ctl.type_id == message_control.TYPE_GC: if ctl.type_id == message_control.TYPE_GC:
ctl.update_ui() ctl.update_ui()
def on_show_mood_in_roster_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'show_mood_in_roster')
gajim.interface.roster.setup_and_draw_roster()
def on_sort_by_show_checkbutton_toggled(self, widget): def on_sort_by_show_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sort_by_show') self.on_checkbutton_toggled(widget, 'sort_by_show')
gajim.interface.roster.setup_and_draw_roster() gajim.interface.roster.setup_and_draw_roster()

View File

@ -76,7 +76,7 @@ C_NAME, # cellrenderer text that holds contact nickame
C_TYPE, # account, group or contact? C_TYPE, # account, group or contact?
C_JID, # the jid of the row C_JID, # the jid of the row
C_ACCOUNT, # cellrenderer text that holds account name C_ACCOUNT, # cellrenderer text that holds account name
C_MOOD, C_MOOD_PIXBUF,
C_AVATAR_PIXBUF, # avatar_pixbuf C_AVATAR_PIXBUF, # avatar_pixbuf
C_PADLOCK_PIXBUF, # use for account row only C_PADLOCK_PIXBUF, # use for account row only
) = range(8) ) = range(8)
@ -608,6 +608,7 @@ class RosterWindow:
for c, acc in brothers: for c, acc in brothers:
self.draw_contact(c.jid, acc) self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_avatar(c.jid, acc) self.draw_avatar(c.jid, acc)
@ -652,6 +653,7 @@ class RosterWindow:
'self_contact', jid, account, None, None, None)) 'self_contact', jid, account, None, None, None))
self.draw_contact(jid, account) self.draw_contact(jid, account)
self.draw_mood(jid, account)
self.draw_avatar(jid, account) self.draw_avatar(jid, account)
self.draw_account(account) self.draw_account(account)
@ -709,6 +711,7 @@ class RosterWindow:
if not self.starting: if not self.starting:
for c, acc in contacts: for c, acc in contacts:
self.draw_contact(c.jid, acc) self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_avatar(c.jid, acc) self.draw_avatar(c.jid, acc)
for group in contact.get_shown_groups(): for group in contact.get_shown_groups():
self.draw_group(group, account) self.draw_group(group, account)
@ -765,6 +768,7 @@ class RosterWindow:
brothers = self._add_metacontact_family(family, account) brothers = self._add_metacontact_family(family, account)
for c, acc in brothers: for c, acc in brothers:
self.draw_contact(c.jid, acc) self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_avatar(c.jid, acc) self.draw_avatar(c.jid, acc)
# Draw all groups of the contact # Draw all groups of the contact
@ -1175,18 +1179,6 @@ class RosterWindow:
self.model[child_iter][C_IMG] = img self.model[child_iter][C_IMG] = img
self.model[child_iter][C_NAME] = name self.model[child_iter][C_NAME] = name
if contact.mood.has_key('mood') \
and contact.mood['mood'] in MOODS:
self.model[child_iter][C_MOOD] = \
gtkgui_helpers.load_mood_icon(
contact.mood['mood'])
elif contact.mood.has_key('mood'):
self.model[child_iter][C_MOOD] = \
gtkgui_helpers.load_mood_icon(
'unknown')
else:
self.model[child_iter][C_MOOD] = None
# We are a little brother # We are a little brother
if family and not is_big_brother and not self.starting: if family and not is_big_brother and not self.starting:
self.draw_parent_contact(jid, account) self.draw_parent_contact(jid, account)
@ -1204,6 +1196,27 @@ class RosterWindow:
return False return False
def draw_mood(self, jid, account):
iters = self._get_contact_iter(jid, account, model = self.model)
if not iters or not gajim.config.get('show_mood_in_roster'):
return
jid = self.model[iters[0]][C_JID]
jid = jid.decode('utf-8')
contact = gajim.contacts.get_contact(account, jid)
if contact.mood.has_key('mood') \
and contact.mood['mood'] in MOODS:
pixbuf = gtkgui_helpers.load_mood_icon(
contact.mood['mood']).get_pixbuf()
elif contact.mood.has_key('mood'):
pixbuf = gtkgui_helpers.load_mood_image(
'unknown').get_pixbuf()
else:
pixbuf = None
for child_iter in iters:
self.model[child_iter][C_MOOD_PIXBUF] = pixbuf
return False
def draw_avatar(self, jid, account): def draw_avatar(self, jid, account):
iters = self._get_contact_iter(jid, account, model = self.model) iters = self._get_contact_iter(jid, account, model = self.model)
if not iters or not gajim.config.get('show_avatars_in_roster'): if not iters or not gajim.config.get('show_avatars_in_roster'):
@ -1250,6 +1263,7 @@ class RosterWindow:
def _draw_all_contacts(jids, account): def _draw_all_contacts(jids, account):
for jid in jids: for jid in jids:
self.draw_contact(jid, account) self.draw_contact(jid, account)
self.draw_mood(jid, account)
self.draw_avatar(jid, account) self.draw_avatar(jid, account)
yield True yield True
yield False yield False
@ -1263,7 +1277,7 @@ class RosterWindow:
# (icon, name, type, jid, account, editable, mood_pixbuf, # (icon, name, type, jid, account, editable, mood_pixbuf,
# avatar_pixbuf, padlock_pixbuf) # avatar_pixbuf, padlock_pixbuf)
self.model = gtk.TreeStore(gtk.Image, str, str, str, str, self.model = gtk.TreeStore(gtk.Image, str, str, str, str,
gtk.Image, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf)
self.model.set_sort_func(1, self._compareIters) self.model.set_sort_func(1, self._compareIters)
self.model.set_sort_column_id(1, gtk.SORT_ASCENDING) self.model.set_sort_column_id(1, gtk.SORT_ASCENDING)
@ -3665,6 +3679,7 @@ class RosterWindow:
for c, acc in brothers: for c, acc in brothers:
self.draw_contact(c.jid, acc) self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_avatar(c.jid, acc) self.draw_avatar(c.jid, acc)
old_groups.extend(c_dest.groups) old_groups.extend(c_dest.groups)
@ -4171,6 +4186,42 @@ class RosterWindow:
else: else:
renderer.set_property('xpad', 8) renderer.set_property('xpad', 8)
def _fill_mood_pixbuf_rederer(self, column, renderer, model, titer,
data = None):
'''When a row is added, set properties for avatar renderer'''
theme = gajim.config.get('roster_theme')
type_ = model[titer][C_TYPE]
if type_ in ('group', 'account'):
renderer.set_property('visible', False)
return
# allocate space for the icon only if needed
if model[titer][C_MOOD_PIXBUF]:
renderer.set_property('visible', True)
else:
renderer.set_property('visible', False)
if type_: # prevent type_ = None, see http://trac.gajim.org/ticket/2534
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
# This can append at the moment we add the row
return
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
if jid in gajim.newly_added[account]:
renderer.set_property('cell-background', gajim.config.get(
'just_connected_bg_color'))
elif jid in gajim.to_be_removed[account]:
renderer.set_property('cell-background', gajim.config.get(
'just_disconnected_bg_color'))
else:
color = gajim.config.get_per('themes', theme, 'contactbgcolor')
if color:
renderer.set_property('cell-background', color)
else:
renderer.set_property('cell-background', None)
renderer.set_property('xalign', 1) # align pixbuf to the right
def _fill_avatar_pixbuf_rederer(self, column, renderer, model, titer, def _fill_avatar_pixbuf_rederer(self, column, renderer, model, titer,
data = None): data = None):
'''When a row is added, set properties for avatar renderer''' '''When a row is added, set properties for avatar renderer'''
@ -5975,13 +6026,11 @@ class RosterWindow:
col.add_attribute(render_text, 'markup', C_NAME) # where we hold the name col.add_attribute(render_text, 'markup', C_NAME) # where we hold the name
col.set_cell_data_func(render_text, self._nameCellDataFunc, None) col.set_cell_data_func(render_text, self._nameCellDataFunc, None)
if gajim.config.get('show_mood_in_roster'): render_pixbuf = gtk.CellRendererPixbuf()
render_image = cell_renderer_image.CellRendererImage( col.pack_start(render_pixbuf, expand = False)
0, 0) col.add_attribute(render_pixbuf, 'pixbuf', C_MOOD_PIXBUF)
col.pack_start(render_image, expand = False) col.set_cell_data_func(render_pixbuf,
col.add_attribute(render_image, 'image', C_MOOD) self._fill_mood_pixbuf_rederer, None)
col.set_cell_data_func(render_image,
self._iconCellDataFunc, None)
if gajim.config.get('avatar_position_in_roster') == 'right': if gajim.config.get('avatar_position_in_roster') == 'right':
add_avatar_renderer() add_avatar_renderer()