Show tunes in roster.

This commit is contained in:
js 2008-07-25 14:11:14 +00:00
parent 4674480e61
commit d8bd70c93b
5 changed files with 140 additions and 13 deletions

View File

@ -89,6 +89,23 @@
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="show_tunes_in_roster_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will display the tunes of contacts in the roster window</property>
<property name="label" translatable="yes">Display _tunes 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_tunes_in_roster_checkbutton_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="sort_by_show_checkbutton">
<property name="visible">True</property>
@ -103,7 +120,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
</widget>
@ -203,7 +220,7 @@ Detached roster with chat grouped by type</property>
<widget class="GtkCheckButton" id="compact_view_checkbutton">
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Hide all buttons in chat windows</property>
<property name="label" translatable="yes">_Make message windows compact</property>
<property name="label" translatable="yes">Ma_ke message windows compact</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>

View File

@ -214,6 +214,7 @@ class Config:
'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window.'), True],
'show_avatars_in_roster': [opt_bool, True, '', True],
'show_mood_in_roster': [opt_bool, True, '', True],
'show_tunes_in_roster': [opt_bool, True, '', True],
'avatar_position_in_roster': [opt_str, 'right', _('Define the position of the avatar in roster. Can be left or right'), True],
'ask_avatars_on_startup': [opt_bool, True, _('If True, Gajim will ask for avatar each contact that did not have an avatar last time or has one cached that is too old.')],
'print_status_in_chats': [opt_bool, True, _('If False, Gajim will no longer print status line in chats when a contact changes his or her status and/or his or her status message.')],

View File

@ -167,9 +167,13 @@ def user_tune(items, name, jid):
if contact.tune.has_key('length'):
del contact.tune['length']
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
if ctrl:
ctrl.update_tune()
if jid == gajim.get_jid_from_account(name):
gajim.interface.roster.draw_account(name)
else:
gajim.interface.roster.draw_tune(user, name)
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
if ctrl:
ctrl.update_tune()
def user_geoloc(items, name, jid):
pass

View File

@ -105,6 +105,11 @@ class PreferencesWindow:
self.xml.get_widget('show_mood_in_roster_checkbutton'). \
set_active(st)
# Display tunes in roster
st = gajim.config.get('show_tunes_in_roster')
self.xml.get_widget('show_tunes_in_roster_checkbutton'). \
set_active(st)
# Sort contacts by show
st = gajim.config.get('sort_by_show')
self.xml.get_widget('sort_by_show_checkbutton').set_active(st)
@ -537,6 +542,10 @@ class PreferencesWindow:
self.on_checkbutton_toggled(widget, 'show_mood_in_roster')
gajim.interface.roster.setup_and_draw_roster()
def on_show_tunes_in_roster_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'show_tunes_in_roster')
gajim.interface.roster.setup_and_draw_roster()
def on_sort_by_show_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sort_by_show')
gajim.interface.roster.setup_and_draw_roster()

View File

@ -77,9 +77,10 @@ C_TYPE, # account, group or contact?
C_JID, # the jid of the row
C_ACCOUNT, # cellrenderer text that holds account name
C_MOOD_PIXBUF,
C_TUNE_PIXBUF,
C_AVATAR_PIXBUF, # avatar_pixbuf
C_PADLOCK_PIXBUF, # use for account row only
) = range(8)
) = range(9)
class RosterWindow:
'''Class for main window of the GTK+ interface'''
@ -289,7 +290,7 @@ class RosterWindow:
self.model.append(None, [
gajim.interface.jabber_state_images['16'][show],
_('Merged accounts'), 'account', '', 'all',
None, None, None])
None, None, None, None])
else:
show = gajim.SHOW_LIST[gajim.connections[account]. \
connected]
@ -305,7 +306,7 @@ class RosterWindow:
self.model.append(None, [
gajim.interface.jabber_state_images['16'][show],
gobject.markup_escape_text(account), 'account',
our_jid, account, None, None, tls_pixbuf])
our_jid, account, None, None, None, tls_pixbuf])
self.draw_account(account)
@ -368,7 +369,8 @@ class RosterWindow:
for child_iter in parent_iters:
it = self.model.append(child_iter, (None,
contact.get_shown_name(), 'contact',
contact.jid, account, None, None, None))
contact.jid, account, None, None, None,
None))
added_iters.append(it)
else:
# We are a normal contact. Add us to our groups.
@ -387,7 +389,7 @@ class RosterWindow:
['closed'], gobject. \
markup_escape_text(group),
'group', group, account, None,
None, None])
None, None, None])
self.draw_group(group, account)
if contact.is_transport():
@ -401,7 +403,8 @@ class RosterWindow:
# for more
i_ = self.model.append(child_iterG, (None,
contact.get_shown_name(), typestr,
contact.jid, account, None, None, None))
contact.jid, account, None, None, None,
None))
added_iters.append(i_)
# Restore the group expand state
@ -609,6 +612,7 @@ class RosterWindow:
for c, acc in brothers:
self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_tune(c.jid, acc)
self.draw_avatar(c.jid, acc)
@ -650,10 +654,11 @@ class RosterWindow:
child_iterA = self._get_account_iter(account, self.model)
self.model.append(child_iterA, (None, gajim.nicks[account],
'self_contact', jid, account, None, None, None))
'self_contact', jid, account, None, None, None, None))
self.draw_contact(jid, account)
self.draw_mood(jid, account)
self.draw_tune(jid, account)
self.draw_avatar(jid, account)
self.draw_account(account)
@ -712,6 +717,7 @@ class RosterWindow:
for c, acc in contacts:
self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_tune(c.jid, acc)
self.draw_avatar(c.jid, acc)
for group in contact.get_shown_groups():
self.draw_group(group, account)
@ -769,6 +775,7 @@ class RosterWindow:
for c, acc in brothers:
self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_tune(c.jid, acc)
self.draw_avatar(c.jid, acc)
# Draw all groups of the contact
@ -989,6 +996,15 @@ class RosterWindow:
else:
self.model[child_iter][C_MOOD_PIXBUF] = None
if gajim.config.get('show_tunes_in_roster') \
and (gajim.connections[account].tune.has_key('artist') \
or gajim.connections[account].tune.has_key('title')):
self.model[child_iter][C_TUNE_PIXBUF] = \
gtk.gdk.pixbuf_new_from_file(
'../data/emoticons/static/music.png')
else:
self.model[child_iter][C_TUNE_PIXBUF] = None
return False
def draw_group(self, group, account):
@ -1233,6 +1249,24 @@ class RosterWindow:
return False
def draw_tune(self, jid, account):
iters = self._get_contact_iter(jid, account, model = self.model)
if not iters or not gajim.config.get('show_tunes_in_roster'):
return
jid = self.model[iters[0]][C_JID]
jid = jid.decode('utf-8')
contact = gajim.contacts.get_contact(account, jid)
if contact.tune.has_key('artist') \
or contact.tune.has_key('title'):
pixbuf = gtk.gdk.pixbuf_new_from_file(
'../data/emoticons/static/music.png')
else:
pixbuf = None
for child_iter in iters:
self.model[child_iter][C_TUNE_PIXBUF] = pixbuf
return False
def draw_avatar(self, jid, account):
iters = self._get_contact_iter(jid, account, model = self.model)
if not iters or not gajim.config.get('show_avatars_in_roster'):
@ -1280,6 +1314,7 @@ class RosterWindow:
for jid in jids:
self.draw_contact(jid, account)
self.draw_mood(jid, account)
self.draw_tune(jid, account)
self.draw_avatar(jid, account)
yield True
yield False
@ -1293,7 +1328,8 @@ class RosterWindow:
# (icon, name, type, jid, account, editable, mood_pixbuf,
# avatar_pixbuf, padlock_pixbuf)
self.model = gtk.TreeStore(gtk.Image, str, str, str, str,
gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, 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_column_id(1, gtk.SORT_ASCENDING)
@ -3696,6 +3732,7 @@ class RosterWindow:
for c, acc in brothers:
self.draw_contact(c.jid, acc)
self.draw_mood(c.jid, acc)
self.draw_tune(c.jid, acc)
self.draw_avatar(c.jid, acc)
old_groups.extend(c_dest.groups)
@ -4256,6 +4293,59 @@ class RosterWindow:
renderer.set_property('xalign', 1)
def _fill_tune_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_ == 'group':
renderer.set_property('visible', False)
return
# allocate space for the icon only if needed
if model[titer][C_TUNE_PIXBUF]:
renderer.set_property('visible', True)
else:
renderer.set_property('visible', False)
if type_ == 'account':
color = gajim.config.get_per('themes', theme,
'accountbgcolor')
if color:
renderer.set_property('cell-background', color)
else:
self.set_renderer_color(renderer,
gtk.STATE_ACTIVE)
# align pixbuf to the right)
renderer.set_property('xalign', 1)
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
elif type_:
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)
# align pixbuf to the right
renderer.set_property('xalign', 1)
def _fill_avatar_pixbuf_rederer(self, column, renderer, model, titer,
data = None):
'''When a row is added, set properties for avatar renderer'''
@ -6066,6 +6156,12 @@ class RosterWindow:
col.set_cell_data_func(render_pixbuf,
self._fill_mood_pixbuf_rederer, None)
render_pixbuf = gtk.CellRendererPixbuf()
col.pack_start(render_pixbuf, expand = False)
col.add_attribute(render_pixbuf, 'pixbuf', C_TUNE_PIXBUF)
col.set_cell_data_func(render_pixbuf,
self._fill_tune_pixbuf_rederer, None)
if gajim.config.get('avatar_position_in_roster') == 'right':
add_avatar_renderer()