Changeset 10030

Show
Ignore:
Timestamp:
07/25/08 16:11:14 (4 months ago)
Author:
js
Message:

Show tunes in roster.

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/data/glade/preferences_window.glade

    r10024 r10030  
    9191                            </child> 
    9292                            <child> 
    93                               <widget class="GtkCheckButton" id="sort_by_show_checkbutton"> 
    94                                 <property name="visible">True</property> 
    95                                 <property name="can_focus">True</property> 
    96                                 <property name="tooltip" translatable="yes">If checked, Gajim will sort contacts in roster window and groupchats by their status and not by the shown name</property> 
    97                                 <property name="label" translatable="yes">_Sort contacts by status</property> 
     93                              <widget class="GtkCheckButton" id="show_tunes_in_roster_checkbutton"> 
     94                                <property name="visible">True</property> 
     95                                <property name="can_focus">True</property> 
     96                                <property name="tooltip" translatable="yes">If checked, Gajim will display the tunes of contacts in the roster window</property> 
     97                                <property name="label" translatable="yes">Display _tunes of contacts in roster</property> 
    9898                                <property name="use_underline">True</property> 
    9999                                <property name="response_id">0</property> 
    100100                                <property name="draw_indicator">True</property> 
    101                                 <signal name="toggled" handler="on_sort_by_show_checkbutton_toggled"/> 
     101                                <signal name="toggled" handler="on_show_tunes_in_roster_checkbutton_toggled"/> 
    102102                              </widget> 
    103103                              <packing> 
     
    105105                                <property name="fill">False</property> 
    106106                                <property name="position">3</property> 
     107                              </packing> 
     108                            </child> 
     109                            <child> 
     110                              <widget class="GtkCheckButton" id="sort_by_show_checkbutton"> 
     111                                <property name="visible">True</property> 
     112                                <property name="can_focus">True</property> 
     113                                <property name="tooltip" translatable="yes">If checked, Gajim will sort contacts in roster window and groupchats by their status and not by the shown name</property> 
     114                                <property name="label" translatable="yes">_Sort contacts by status</property> 
     115                                <property name="use_underline">True</property> 
     116                                <property name="response_id">0</property> 
     117                                <property name="draw_indicator">True</property> 
     118                                <signal name="toggled" handler="on_sort_by_show_checkbutton_toggled"/> 
     119                              </widget> 
     120                              <packing> 
     121                                <property name="expand">False</property> 
     122                                <property name="fill">False</property> 
     123                                <property name="position">4</property> 
    107124                              </packing> 
    108125                            </child> 
     
    204221                                <property name="can_focus">True</property> 
    205222                                <property name="tooltip" translatable="yes">Hide all buttons in chat windows</property> 
    206                                 <property name="label" translatable="yes">_Make message windows compact</property> 
     223                                <property name="label" translatable="yes">Ma_ke message windows compact</property> 
    207224                                <property name="use_underline">True</property> 
    208225                                <property name="response_id">0</property> 
  • trunk/src/common/config.py

    r10022 r10030  
    215215                'show_avatars_in_roster': [opt_bool, True, '', True], 
    216216                'show_mood_in_roster': [opt_bool, True, '', True], 
     217                'show_tunes_in_roster': [opt_bool, True, '', True], 
    217218                'avatar_position_in_roster': [opt_str, 'right', _('Define the position of the avatar in roster. Can be left or right'), True], 
    218219                '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.')], 
  • trunk/src/common/pep.py

    r10025 r10030  
    168168                                del contact.tune['length'] 
    169169 
    170         ctrl = gajim.interface.msg_win_mgr.get_control(user, name) 
    171         if ctrl: 
    172                 ctrl.update_tune() 
     170        if jid == gajim.get_jid_from_account(name): 
     171                gajim.interface.roster.draw_account(name) 
     172        else: 
     173                gajim.interface.roster.draw_tune(user, name) 
     174                ctrl = gajim.interface.msg_win_mgr.get_control(user, name) 
     175                if ctrl: 
     176                        ctrl.update_tune() 
    173177 
    174178def user_geoloc(items, name, jid): 
  • trunk/src/config.py

    r10023 r10030  
    104104                st = gajim.config.get('show_mood_in_roster') 
    105105                self.xml.get_widget('show_mood_in_roster_checkbutton'). \ 
     106                        set_active(st) 
     107 
     108                # Display tunes in roster 
     109                st = gajim.config.get('show_tunes_in_roster') 
     110                self.xml.get_widget('show_tunes_in_roster_checkbutton'). \ 
    106111                        set_active(st) 
    107112 
     
    536541        def on_show_mood_in_roster_checkbutton_toggled(self, widget): 
    537542                self.on_checkbutton_toggled(widget, 'show_mood_in_roster') 
     543                gajim.interface.roster.setup_and_draw_roster() 
     544 
     545        def on_show_tunes_in_roster_checkbutton_toggled(self, widget): 
     546                self.on_checkbutton_toggled(widget, 'show_tunes_in_roster') 
    538547                gajim.interface.roster.setup_and_draw_roster() 
    539548 
  • trunk/src/roster_window.py

    r10027 r10030  
    7878C_ACCOUNT, # cellrenderer text that holds account name 
    7979C_MOOD_PIXBUF, 
     80C_TUNE_PIXBUF, 
    8081C_AVATAR_PIXBUF, # avatar_pixbuf 
    8182C_PADLOCK_PIXBUF, # use for account row only 
    82 ) = range(8) 
     83) = range(9) 
    8384 
    8485class RosterWindow: 
     
    290291                                gajim.interface.jabber_state_images['16'][show], 
    291292                                _('Merged accounts'), 'account', '', 'all', 
    292                                 None, None, None]) 
     293                                None, None, None, None]) 
    293294                else: 
    294295                        show = gajim.SHOW_LIST[gajim.connections[account]. \ 
     
    306307                                gajim.interface.jabber_state_images['16'][show], 
    307308                                gobject.markup_escape_text(account), 'account', 
    308                                 our_jid, account, None, None, tls_pixbuf]) 
     309                                our_jid, account, None, None, None, tls_pixbuf]) 
    309310 
    310311                self.draw_account(account) 
     
    369370                                it = self.model.append(child_iter, (None, 
    370371                                        contact.get_shown_name(), 'contact', 
    371                                         contact.jid, account, None, None, None)) 
     372                                        contact.jid, account, None, None, None, 
     373                                        None)) 
    372374                                added_iters.append(it) 
    373375                else: 
     
    388390                                                markup_escape_text(group), 
    389391                                                'group', group, account, None, 
    390                                                 None, None]) 
     392                                                None, None, None]) 
    391393                                        self.draw_group(group, account) 
    392394 
     
    402404                                i_ = self.model.append(child_iterG, (None, 
    403405                                        contact.get_shown_name(), typestr, 
    404                                         contact.jid, account, None, None, None)) 
     406                                        contact.jid, account, None, None, None, 
     407                                        None)) 
    405408                                added_iters.append(i_) 
    406409 
     
    610613                                self.draw_contact(c.jid, acc) 
    611614                                self.draw_mood(c.jid, acc) 
     615                                self.draw_tune(c.jid, acc) 
    612616                                self.draw_avatar(c.jid, acc) 
    613617 
     
    651655                child_iterA = self._get_account_iter(account, self.model) 
    652656                self.model.append(child_iterA, (None, gajim.nicks[account], 
    653                         'self_contact', jid, account, None, None, None)) 
     657                        'self_contact', jid, account, None, None, None, None)) 
    654658 
    655659                self.draw_contact(jid, account) 
    656660                self.draw_mood(jid, account) 
     661                self.draw_tune(jid, account) 
    657662                self.draw_avatar(jid, account) 
    658663                self.draw_account(account) 
     
    713718                                self.draw_contact(c.jid, acc) 
    714719                                self.draw_mood(c.jid, acc) 
     720                                self.draw_tune(c.jid, acc) 
    715721                                self.draw_avatar(c.jid, acc) 
    716722                        for group in contact.get_shown_groups(): 
     
    770776                                                self.draw_contact(c.jid, acc) 
    771777                                                self.draw_mood(c.jid, acc) 
     778                                                self.draw_tune(c.jid, acc) 
    772779                                                self.draw_avatar(c.jid, acc) 
    773780 
     
    989996                else: 
    990997                        self.model[child_iter][C_MOOD_PIXBUF] = None 
     998 
     999                if gajim.config.get('show_tunes_in_roster') \ 
     1000                and (gajim.connections[account].tune.has_key('artist') \ 
     1001                or gajim.connections[account].tune.has_key('title')): 
     1002                        self.model[child_iter][C_TUNE_PIXBUF] = \ 
     1003                                gtk.gdk.pixbuf_new_from_file( 
     1004                                '../data/emoticons/static/music.png') 
     1005                else: 
     1006                        self.model[child_iter][C_TUNE_PIXBUF] = None 
    9911007 
    9921008                return False 
     
    12341250 
    12351251 
     1252        def draw_tune(self, jid, account): 
     1253                iters = self._get_contact_iter(jid, account, model = self.model) 
     1254                if not iters or not gajim.config.get('show_tunes_in_roster'): 
     1255                        return 
     1256                jid = self.model[iters[0]][C_JID] 
     1257                jid = jid.decode('utf-8') 
     1258                contact = gajim.contacts.get_contact(account, jid) 
     1259                if contact.tune.has_key('artist') \ 
     1260                or contact.tune.has_key('title'): 
     1261                        pixbuf = gtk.gdk.pixbuf_new_from_file( 
     1262                                '../data/emoticons/static/music.png') 
     1263                else: 
     1264                        pixbuf = None 
     1265                for child_iter in iters: 
     1266                        self.model[child_iter][C_TUNE_PIXBUF] = pixbuf 
     1267                return False 
     1268 
     1269 
    12361270        def draw_avatar(self, jid, account): 
    12371271                iters = self._get_contact_iter(jid, account, model = self.model) 
     
    12811315                                self.draw_contact(jid, account) 
    12821316                                self.draw_mood(jid, account) 
     1317                                self.draw_tune(jid, account) 
    12831318                                self.draw_avatar(jid, account) 
    12841319                                yield True 
     
    12941329                # avatar_pixbuf, padlock_pixbuf) 
    12951330                self.model = gtk.TreeStore(gtk.Image, str, str, str, str, 
    1296                         gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) 
     1331                        gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, 
     1332                        gtk.gdk.Pixbuf) 
    12971333 
    12981334                self.model.set_sort_func(1, self._compareIters) 
     
    36973733                                self.draw_contact(c.jid, acc) 
    36983734                                self.draw_mood(c.jid, acc) 
     3735                                self.draw_tune(c.jid, acc) 
    36993736                                self.draw_avatar(c.jid, acc) 
    37003737 
     
    42574294 
    42584295 
     4296        def _fill_tune_pixbuf_rederer(self, column, renderer, model, titer, 
     4297        data = None): 
     4298                '''When a row is added, set properties for avatar renderer''' 
     4299                theme = gajim.config.get('roster_theme') 
     4300                type_ = model[titer][C_TYPE] 
     4301                if type_ == 'group': 
     4302                        renderer.set_property('visible', False) 
     4303                        return 
     4304 
     4305                # allocate space for the icon only if needed 
     4306                if model[titer][C_TUNE_PIXBUF]: 
     4307                        renderer.set_property('visible', True) 
     4308                else: 
     4309                        renderer.set_property('visible', False) 
     4310                if type_ == 'account': 
     4311                        color = gajim.config.get_per('themes', theme, 
     4312                                'accountbgcolor') 
     4313                        if color: 
     4314                                renderer.set_property('cell-background', color) 
     4315                        else: 
     4316                                self.set_renderer_color(renderer, 
     4317                                        gtk.STATE_ACTIVE) 
     4318                        # align pixbuf to the right) 
     4319                        renderer.set_property('xalign', 1) 
     4320                # prevent type_ = None, see http://trac.gajim.org/ticket/2534 
     4321                elif type_: 
     4322                        if not model[titer][C_JID] \ 
     4323                        or not model[titer][C_ACCOUNT]: 
     4324                                # This can append at the moment we add the row 
     4325                                return 
     4326                        jid = model[titer][C_JID].decode('utf-8') 
     4327                        account = model[titer][C_ACCOUNT].decode('utf-8') 
     4328                        if jid in gajim.newly_added[account]: 
     4329                                renderer.set_property('cell-background', 
     4330                                        gajim.config.get( 
     4331                                        'just_connected_bg_color')) 
     4332                        elif jid in gajim.to_be_removed[account]: 
     4333                                renderer.set_property('cell-background', 
     4334                                        gajim.config.get( 
     4335                                        'just_disconnected_bg_color')) 
     4336                        else: 
     4337                                color = gajim.config.get_per('themes', 
     4338                                        theme, 'contactbgcolor') 
     4339                                if color: 
     4340                                        renderer.set_property( 
     4341                                                'cell-background', color) 
     4342                                else: 
     4343                                        renderer.set_property( 
     4344                                                'cell-background', None) 
     4345                        # align pixbuf to the right 
     4346                        renderer.set_property('xalign', 1) 
     4347 
     4348 
    42594349        def _fill_avatar_pixbuf_rederer(self, column, renderer, model, titer, 
    42604350        data = None): 
     
    60676157                        self._fill_mood_pixbuf_rederer, None) 
    60686158 
     6159                render_pixbuf = gtk.CellRendererPixbuf() 
     6160                col.pack_start(render_pixbuf, expand = False) 
     6161                col.add_attribute(render_pixbuf, 'pixbuf', C_TUNE_PIXBUF) 
     6162                col.set_cell_data_func(render_pixbuf, 
     6163                        self._fill_tune_pixbuf_rederer, None) 
     6164 
    60696165                if gajim.config.get('avatar_position_in_roster') == 'right': 
    60706166                        add_avatar_renderer()