Changeset 9960 for trunk/src/dialogs.py

Show
Ignore:
Timestamp:
07/19/08 19:36:21 (4 months ago)
Author:
steve-e
Message:

Improved groupchat minimization:

  • partly rewrote join_room because it was hard to read
  • Correctly handle invites from anonymous rooms. Fixes #4057
  • Use HIG dialog for invitation requests
  • Fix bug where minimized groupchats where hidden after a reconnect
  • Removed some duplicated code
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dialogs.py

    r9903 r9960  
    22152215 
    22162216        def set_cursor_to_end(self): 
    2217                         end_iter = self.message_tv_buffer.get_end_iter() 
    2218                         self.message_tv_buffer.place_cursor(end_iter) 
     2217                end_iter = self.message_tv_buffer.get_end_iter() 
     2218                self.message_tv_buffer.place_cursor(end_iter) 
    22192219 
    22202220        def save_pos(self): 
     
    29212921                self.password = password 
    29222922                self.is_continued = is_continued 
    2923                 xml = gtkgui_helpers.get_glade('invitation_received_dialog.glade') 
    2924                 self.dialog = xml.get_widget('invitation_received_dialog') 
    2925  
     2923 
     2924                pritext = _('''You are invited to a groupchat''') 
    29262925                #Don't translate $Contact 
    29272926                if is_continued: 
    2928                         pritext = _('$Contact has invited you to join a discussion') 
    2929                 else: 
    2930                         pritext = _('$Contact has invited you to group chat %(room_jid)s')\ 
     2927                        sectext = _('$Contact has invited you to join a discussion') 
     2928                else: 
     2929                        sectext = _('$Contact has invited you to group chat %(room_jid)s')\ 
    29312930                                % {'room_jid': room_jid} 
    29322931                contact = gajim.contacts.get_first_contact_from_jid(account, contact_jid) 
    2933                 if contact and contact.name: 
    2934                         contact_text = '%s (%s)' % (contact.name, contact_jid) 
    2935                 else: 
    2936                         contact_text = contact_jid 
    2937                 pritext = pritext.replace('$Contact', contact_text) 
    2938  
    2939                 label_text = '<big><b>%s</b></big>' % pritext 
     2932                contact_text = contact and contact.name or contact_jid 
     2933                sectext = sectext.replace('$Contact', contact_text) 
    29402934 
    29412935                if comment: # only if not None and not '' 
    29422936                        comment = gobject.markup_escape_text(comment) 
    2943                         sectext = _('Comment: %s') % comment 
    2944                         label_text += '\n\n%s' % sectext 
    2945  
    2946                 xml.get_widget('label').set_markup(label_text) 
    2947  
    2948                 xml.get_widget('deny_button').connect('clicked', 
    2949                         self.on_deny_button_clicked) 
    2950                 xml.get_widget('accept_button').connect('clicked', 
    2951                         self.on_accept_button_clicked) 
    2952                 self.dialog.show_all() 
    2953  
    2954         def on_deny_button_clicked(self, widget): 
    2955                 self.dialog.destroy() 
    2956  
    2957         def on_accept_button_clicked(self, widget): 
    2958                 self.dialog.destroy() 
    2959                 try: 
    2960                         if self.is_continued: 
    2961                                 gajim.interface.join_gc_room(self.account, self.room_jid, 
    2962                                         gajim.nicks[self.account], None, is_continued=True) 
    2963                         else: 
    2964                                 JoinGroupchatWindow(self.account, self.room_jid) 
    2965                 except GajimGeneralException: 
    2966                         pass 
     2937                        comment = _('Comment: %s') % comment 
     2938                        sectext += '\n\n%s' % comment 
     2939                sectext += '\n\n' + _('Do you want to accept the invitation?') 
     2940                 
     2941                dialog = YesNoDialog(pritext, sectext) 
     2942                if dialog.get_response() == gtk.RESPONSE_YES: 
     2943                        try: 
     2944                                if self.is_continued: 
     2945                                        gajim.interface.join_gc_room(self.account, self.room_jid, 
     2946                                                gajim.nicks[self.account], None, is_continued=True) 
     2947                                else: 
     2948                                        JoinGroupchatWindow(self.account, self.room_jid) 
     2949                        except GajimGeneralException: 
     2950                                pass 
    29672951 
    29682952class ProgressDialog: