Show
Ignore:
Timestamp:
05/11/08 15:17:28 (7 months ago)
Author:
js
Message:

Reverted r9614 and r9615.

Sorry, bct, but I think it is to early to merge that as it completely
breaks. It seems nobody in gajim@… considers it
usable yet.
I don't know if you got asterix' ok for it and I'm sorry if I reverted
it now although you had his ok, but having broken trunk is very
contra-productive. I think it was just too early to merge.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chat_control.py

    r9614 r9616  
    77## Copyright (C) 2007 Lukas Petrovicky <lukas@petrovicky.net> 
    88##                    Julien Pivotto <roidelapluie@gmail.com> 
    9 ##                    Stephan Erb <steve-e@h3c.de> 
     9##                    Stephan Erb <steve-e@h3c.de>  
    1010## 
    1111## This file is part of Gajim. 
     
    105105 
    106106        def draw_banner(self): 
    107                 '''Draw the fat line at the top of the window that 
    108                 houses the icon, jid, ... 
     107                '''Draw the fat line at the top of the window that  
     108                houses the icon, jid, ...  
    109109                ''' 
    110110                self.draw_banner_text() 
     
    134134                helpers.launch_browser_mailer('url', url) 
    135135 
    136         def __init__(self, type_id, parent_win, widget_name, contact, acct, 
     136        def __init__(self, type_id, parent_win, widget_name, contact, acct,  
    137137        resource = None): 
    138138                MessageControl.__init__(self, type_id, parent_win, widget_name, 
     
    239239                        gtk.DEST_DEFAULT_HIGHLIGHT, 
    240240                        self.dnd_list, gtk.gdk.ACTION_COPY) 
    241  
     241         
    242242                self.update_font() 
    243243 
     
    267267                                # iterating on a copy 
    268268                                for lang in dict(langs): 
    269                                         try: 
     269                                        try:  
    270270                                                spell.set_language(langs[lang]) 
    271271                                        except: 
     
    331331                menu.show_all() 
    332332 
    333         # moved from ChatControl 
     333        # moved from ChatControl  
    334334        def _on_banner_eventbox_button_press_event(self, widget, event): 
    335335                '''If right-clicked, show popup''' 
     
    363363                self.disconnect_style_event(self.banner_status_label) 
    364364                if bgcolor: 
    365                         banner_eventbox.modify_bg(gtk.STATE_NORMAL, 
     365                        banner_eventbox.modify_bg(gtk.STATE_NORMAL,  
    366366                                gtk.gdk.color_parse(bgcolor)) 
    367367                        default_bg = False 
     
    392392                        widget.disconnect(id) 
    393393                        del self.handlers[id] 
    394  
     394         
    395395        def connect_style_event(self, widget, set_fg = False, set_bg = False): 
    396396                self.disconnect_style_event(widget) 
     
    399399 
    400400        def _on_style_set_event(self, widget, style, *opts): 
    401                 '''set style of widget from style class *.Frame.Eventbox 
     401                '''set style of widget from style class *.Frame.Eventbox  
    402402                        opts[0] == True -> set fg color 
    403403                        opts[1] == True -> set bg color''' 
     
    565565                                else: # ENTER 
    566566                                        send_message = True 
    567  
     567                                 
    568568                        if gajim.connections[self.account].connected < 2: # we are not connected 
    569569                                dialogs.ErrorDialog(_('A connection is not available'), 
     
    645645                max_size = gajim.config.get('key_up_lines') 
    646646                if size >= max_size: 
    647                         for i in xrange(0, size - 1): 
     647                        for i in xrange(0, size - 1):  
    648648                                self.sent_history[i] = self.sent_history[i + 1] 
    649649                        self.sent_history[max_size - 1] = message 
     
    694694                                # we want to have save this message in events list 
    695695                                # other_tags_for_text == ['marked'] --> highlighted gc message 
     696                                type_ = 'printed_' + self.type_id 
     697                                event = 'message_received' 
    696698                                if gc_message: 
    697699                                        if 'marked' in other_tags_for_text: 
     
    700702                                                type_ = 'printed_gc_msg' 
    701703                                        event = 'gc_message_received' 
    702                                 else: 
    703                                         type_ = 'printed_' + self.type_id 
    704                                         event = 'message_received' 
    705704                                show_in_roster = notify.get_show_in_roster(event, 
    706                                         self.account, self.contact, self.session) 
     705                                        self.account, self.contact) 
    707706                                show_in_systray = notify.get_show_in_systray(event, 
    708707                                        self.account, self.contact, type_) 
    709  
    710708                                event = gajim.events.create_event(type_, None, 
    711709                                        show_in_roster = show_in_roster, 
     
    725723                kind in ('incoming', 'incoming_queue'): 
    726724                        self.parent_win.redraw_tab(self) 
     725                        ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account) 
    727726                        if not self.parent_win.is_active(): 
    728                                 self.parent_win.show_title(True, self) # Enabled Urgent hint 
     727                                self.parent_win.show_title(True, ctrl) # Enabled Urgent hint 
    729728                        else: 
    730                                 self.parent_win.show_title(False, self) # Disabled Urgent hint 
     729                                self.parent_win.show_title(False, ctrl) # Disabled Urgent hint 
    731730 
    732731        def toggle_emoticons(self): 
     
    858857                # we don't want to always resize in height the message_textview 
    859858                # so we have minimum on conversation_textview's scrolled window 
    860                 # but we also want to avoid window resizing so if we reach that 
     859                # but we also want to avoid window resizing so if we reach that  
    861860                # minimum for conversation_textview and maximum for message_textview 
    862861                # we set to automatic the scrollbar policy 
     
    869868                                        # scroll only when scrollbar appear 
    870869                                        if policy != gtk.POLICY_AUTOMATIC: 
    871                                                 self.msg_scrolledwindow.set_property('vscrollbar-policy', 
     870                                                self.msg_scrolledwindow.set_property('vscrollbar-policy',  
    872871                                                        gtk.POLICY_AUTOMATIC) 
    873                                                 self.msg_scrolledwindow.set_property('height-request', 
     872                                                self.msg_scrolledwindow.set_property('height-request',  
    874873                                                        message_height + conversation_height - min_height) 
    875874                                                self.bring_scroll_to_end(msg_textview) 
    876875                        else: 
    877                                 self.msg_scrolledwindow.set_property('vscrollbar-policy', 
     876                                self.msg_scrolledwindow.set_property('vscrollbar-policy',  
    878877                                        gtk.POLICY_NEVER) 
    879878                                self.msg_scrolledwindow.set_property('height-request', -1) 
     
    885884                # if message we have in message_textview is too big 
    886885                if requisition.width > message_width: 
    887                         self.msg_scrolledwindow.set_property('hscrollbar-policy', 
     886                        self.msg_scrolledwindow.set_property('hscrollbar-policy',  
    888887                                gtk.POLICY_AUTOMATIC) 
    889888                else: 
    890                         self.msg_scrolledwindow.set_property('hscrollbar-policy', 
     889                        self.msg_scrolledwindow.set_property('hscrollbar-policy',  
    891890                                gtk.POLICY_NEVER) 
    892891 
     
    918917 
    919918                if not len(gajim.events.get_events(self.account, jid, types_list)): 
    920                         return 
     919                        return  
    921920                if not self.parent_win: 
    922921                        return 
     
    925924                self.parent_win.window.is_active(): 
    926925                        # we are at the end 
    927                         if not self.session.remove_events(types_list): 
     926                        if not gajim.events.remove_events(self.account, self.get_full_jid(), 
     927                        types = types_list): 
    928928                                # There were events to remove 
    929929                                self.redraw_after_event_removed(jid) 
    930930 
    931931        def redraw_after_event_removed(self, jid): 
    932                 ''' We just removed a 'printed_*' event, redraw contact in roster or 
     932                ''' We just removed a 'printed_*' event, redraw contact in roster or  
    933933                gc_roster and titles in roster and msg_win ''' 
    934934                self.parent_win.redraw_tab(self) 
     
    937937                if self.type_id == message_control.TYPE_PM: 
    938938                        room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
    939                         groupchat_control = gajim.interface.msg_win_mgr.get_gc_control( 
     939                        groupchat_control = gajim.interface.msg_win_mgr.get_control( 
    940940                                room_jid, self.account) 
    941941                        if room_jid in gajim.interface.minimized_controls[self.account]: 
     
    948948                                gajim.interface.roster.draw_contact(room_jid, self.account) 
    949949                        groupchat_control.draw_contact(nick) 
    950                         if groupchat_control.parent_win: 
    951                                 groupchat_control.parent_win.redraw_tab(groupchat_control) 
     950                        mw = gajim.interface.msg_win_mgr.get_window(room_jid, self.account) 
     951                        if mw: 
     952                                mw.redraw_tab(groupchat_control) 
    952953                else: 
    953954                        gajim.interface.roster.draw_contact(jid, self.account) 
     
    955956 
    956957        def sent_messages_scroll(self, direction, conv_buf): 
    957                 size = len(self.sent_history) 
     958                size = len(self.sent_history)  
    958959                if self.orig_msg is None: 
    959960                        # user was typing something and then went into history, so save 
     
    10531054                self.widget_set_visible(self.xml.get_widget('banner_eventbox'), 
    10541055                        gajim.config.get('hide_chat_banner')) 
    1055  
     1056                 
    10561057                # Add lock image to show chat encryption 
    10571058                self.lock_image = self.xml.get_widget('lock_image') 
     
    10801081                gajim.connections[self.account].is_zeroconf: 
    10811082                        convert_to_gc_button.set_sensitive(False) 
    1082  
     1083                 
    10831084                # keep timeout id and window obj for possible big avatar 
    10841085                # it is on enter-notify and leave-notify so no need to be per jid 
     
    11261127                        msg = _('GPG encryption enabled') 
    11271128                        ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 
    1128  
     1129                         
    11291130                        if self.session: 
    11301131                                self.session.loggable = gajim.config.get('log_encrypted_sessions') 
    11311132                        self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 
    11321133                                        self.session.is_loggable()) 
    1133  
     1134                 
    11341135                self.status_tooltip = gtk.Tooltips() 
    11351136 
     
    11541155                avatar_w = avatar_pixbuf.get_width() 
    11551156                avatar_h = avatar_pixbuf.get_height() 
    1156  
     1157                 
    11571158                scaled_buf = self.xml.get_widget('avatar_image').get_pixbuf() 
    11581159                scaled_buf_w = scaled_buf.get_width() 
    11591160                scaled_buf_h = scaled_buf.get_height() 
    1160  
     1161                 
    11611162                # do we have something bigger to show? 
    11621163                if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h: 
     
    11641165                        self.show_bigger_avatar_timeout_id = gobject.timeout_add(500, 
    11651166                                self.show_bigger_avatar, widget) 
    1166  
     1167                 
    11671168        def on_avatar_eventbox_leave_notify_event(self, widget, event): 
    11681169                '''we left the eventbox area that holds the avatar img''' 
     
    11761177                        menu = gtk.Menu() 
    11771178                        menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) 
    1178                         id = menuitem.connect('activate', 
     1179                        id = menuitem.connect('activate',  
    11791180                                gtkgui_helpers.on_avatar_save_as_menuitem_activate, 
    11801181                                self.contact.jid, self.account, self.contact.get_shown_name() + \ 
     
    11831184                        menu.append(menuitem) 
    11841185                        menu.show_all() 
    1185                         menu.connect('selection-done', lambda w:w.destroy()) 
     1186                        menu.connect('selection-done', lambda w:w.destroy())     
    11861187                        # show the menu 
    11871188                        menu.show_all() 
     
    12681269 
    12691270        def draw_banner_text(self): 
    1270                 '''Draw the text in the fat line at the top of the window that 
    1271                 houses the name, jid. 
     1271                '''Draw the text in the fat line at the top of the window that  
     1272                houses the name, jid.  
    12721273                ''' 
    12731274                contact = self.contact 
     
    12761277                banner_name_label = self.xml.get_widget('banner_name_label') 
    12771278                banner_eventbox = self.xml.get_widget('banner_eventbox') 
    1278  
     1279                 
    12791280                name = contact.get_shown_name() 
    12801281                if self.resource: 
     
    13631364                        self.gpg_is_active = False 
    13641365                        msg = _('GPG encryption disabled') 
    1365                         ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 
     1366                        ChatControlBase.print_conversation_line(self, msg, 'status', '', None)   
    13661367                        if self.session: 
    13671368                                self.session.loggable = True 
     
    13881389                gajim.config.set_per('contacts', self.contact.jid, 'gpg_enabled', 
    13891390                        self.gpg_is_active) 
    1390  
     1391                 
    13911392                self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 
    13921393                                self.session.is_loggable()) 
    1393  
     1394         
    13941395        def _show_lock_image(self, visible, enc_type = '', enc_enabled = False, chat_logged = False): 
    1395                 '''Set lock icon visibiity and create tooltip''' 
     1396                '''Set lock icon visibiity and create tooltip'''  
    13961397                status_string = enc_enabled and 'is' or 'is NOT' 
    13971398                logged_string = chat_logged and 'will' or 'will NOT' 
     
    15491550                # True refresh 30 seconds vars too or else it's 30 - 5 = 25 seconds! 
    15501551                self.reset_kbd_mouse_timeout_vars() 
    1551                 return True # loop forever 
     1552                return True # loop forever               
    15521553 
    15531554        def check_for_possible_inactive_chatstate(self, arg): 
     
    16011602                        ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 
    16021603                self._show_lock_image(e2e_is_active, 'E2E', e2e_is_active, self.session and \ 
    1603                                 self.session.is_loggable()) 
     1604                                self.session.is_loggable())  
    16041605 
    16051606        def print_conversation(self, text, frm='', tim=None, encrypted=False, 
     
    16251626                                if not encrypted: 
    16261627                                        msg = _('The following message was NOT encrypted') 
    1627                                         ChatControlBase.print_conversation_line(self, msg, 
     1628                                        ChatControlBase.print_conversation_line(self, msg,  
    16281629                                                'status', '', tim) 
    16291630                        else: 
     
    16311632                                if encrypted and not self.gpg_is_active: 
    16321633                                        msg = _('The following message was encrypted') 
    1633                                         ChatControlBase.print_conversation_line(self, msg, 
     1634                                        ChatControlBase.print_conversation_line(self, msg,  
    16341635                                                'status', '', tim) 
    16351636                                        self._toggle_gpg() 
     
    16721673                        unread = '[' + unicode(num_unread) + ']' 
    16731674 
    1674                 # Draw tab label using chatstate 
     1675                # Draw tab label using chatstate  
    16751676                theme = gajim.config.get('roster_theme') 
    16761677                color = None 
     
    17001701                else: # active or not chatstate, get color from gtk 
    17011702                        color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] 
    1702  
     1703                 
    17031704 
    17041705                name = self.contact.get_shown_name() 
     
    17191720                # Set tab image (always 16x16); unread messages show the 'event' image 
    17201721                tab_img = None 
    1721  
     1722                 
    17221723                if num_unread and gajim.config.get('show_unread_tab_icon'): 
    17231724                        img_16 = gajim.interface.roster.get_appropriate_state_images( 
     
    17601761                muc_icon = gtkgui_helpers.load_icon('muc_active') 
    17611762                if muc_icon: 
    1762                         convert_to_gc_menuitem.set_image(muc_icon) 
     1763                        convert_to_gc_menuitem.set_image(muc_icon)  
    17631764 
    17641765                ag = gtk.accel_groups_from_object(self.parent_win.window)[0] 
     
    17741775                contact = self.parent_win.get_active_contact() 
    17751776                jid = contact.jid 
    1776  
     1777                 
    17771778                # check if we support and use gpg 
    17781779                if not gajim.config.get_per('accounts', self.account, 'keyid') or\ 
     
    18141815 
    18151816                # connect signals 
    1816                 id = history_menuitem.connect('activate', 
     1817                id = history_menuitem.connect('activate',  
    18171818                        self._on_history_menuitem_activate) 
    18181819                self.handlers[id] = history_menuitem 
    1819                 id = send_file_menuitem.connect('activate', 
     1820                id = send_file_menuitem.connect('activate',  
    18201821                        self._on_send_file_menuitem_activate) 
    1821                 self.handlers[id] = send_file_menuitem 
     1822                self.handlers[id] = send_file_menuitem  
    18221823                id = add_to_roster_menuitem.connect('activate', 
    18231824                        self._on_add_to_roster_menuitem_activate) 
     
    18261827                        self._on_toggle_gpg_menuitem_activate) 
    18271828                self.handlers[id] = toggle_gpg_menuitem 
    1828                 id = toggle_e2e_menuitem.connect('activate', 
     1829                id = toggle_e2e_menuitem.connect('activate',  
    18291830                        self._on_toggle_e2e_menuitem_activate) 
    1830                 self.handlers[id] = toggle_e2e_menuitem 
    1831                 id = information_menuitem.connect('activate', 
     1831                self.handlers[id] = toggle_e2e_menuitem  
     1832                id = information_menuitem.connect('activate',  
    18321833                        self._on_contact_information_menuitem_activate) 
    18331834                self.handlers[id] = information_menuitem 
     
    18851886                # this function checks for that and just returns so it's safe to call it 
    18861887                # with same state. 
    1887  
     1888                 
    18881889                # This functions also checks for violation in state transitions 
    18891890                # and raises RuntimeException with appropriate message 
     
    19141915                        return 
    19151916 
    1916                 # if the new state we wanna send (state) equals 
     1917                # if the new state we wanna send (state) equals  
    19171918                # the current state (contact.our_chatstate) then return 
    19181919                if contact.our_chatstate == state: 
     
    19261927                        # for that procedure so return to make sure we send only once 
    19271928                        # 'active' until we know peer supports jep85 
    1928                         return 
     1929                        return  
    19291930 
    19301931                if contact.our_chatstate == 'ask': 
     
    19461947                        contact.our_chatstate = 'active' 
    19471948                        self.reset_kbd_mouse_timeout_vars() 
    1948  
     1949                 
    19491950                # if we're inactive prevent composing (JEP violation) 
    19501951                elif contact.our_chatstate == 'inactive' and state == 'composing': 
     
    19631964                # destroy banner tooltip - bug #pygtk for that! 
    19641965                self.status_tooltip.destroy() 
    1965  
    19661966                # Send 'gone' chatstate 
    19671967                self.send_chatstate('gone', self.contact) 
    19681968                self.contact.chatstate = None 
    19691969                self.contact.our_chatstate = None 
    1970  
    1971                 # terminate session 
    1972                 self.session.control = None 
    1973  
    19741970                # Disconnect timer callbacks 
    19751971                gobject.source_remove(self.possible_paused_timeout_id) 
     
    19911987 
    19921988        def allow_shutdown(self, method): 
    1993                 print repr(self.get_full_jid()) 
    1994                 print repr(gajim.last_message_time[self.account]) 
    19951989                if time.time() - gajim.last_message_time[self.account]\ 
    19961990                [self.get_full_jid()] < 2: 
     
    21802174                        self.print_esession_details() 
    21812175 
     2176                # Is it a pm ? 
     2177                is_pm = False 
     2178                room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
     2179                control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) 
     2180                if control and control.type_id == message_control.TYPE_GC: 
     2181                        is_pm = True 
    21822182                # list of message ids which should be marked as read 
    21832183                message_ids = [] 
     
    22042204 
    22052205                typ = 'chat' # Is it a normal chat or a pm ? 
    2206  
    22072206                # reset to status image in gc if it is a pm 
    2208                 # Is it a pm ? 
    2209                 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
    2210                 control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, 
    2211                         self.account) 
    2212                 if control and control.type_id == message_control.TYPE_GC: 
     2207                if is_pm: 
    22132208                        control.update_ui() 
    22142209                        control.parent_win.show_title() 
     
    22712266                if gtk.gtk_version >= (2, 10, 0) and gtk.pygtk_version >= (2, 10, 0): 
    22722267                        window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP) 
    2273  
     2268                 
    22742269                window.realize() 
    22752270                window.window.set_back_pixmap(pixmap, False) # make it transparent 
    22762271                window.window.shape_combine_mask(mask, 0, 0) 
    22772272 
    2278                 # make the bigger avatar window show up centered 
     2273                # make the bigger avatar window show up centered  
    22792274                x0, y0 = small_avatar.window.get_origin() 
    22802275                x0 += small_avatar.allocation.x 
     
    22822277                center_x= x0 + (small_avatar.allocation.width / 2) 
    22832278                center_y = y0 + (small_avatar.allocation.height / 2)