Show
Ignore:
Timestamp:
06/03/08 15:40:27 (6 months ago)
Author:
vardo
Message:

Added plug-in deactivation mechanism, which allows plug-ins to clean up after themselves (eg. disconnecting handlers made in GUI); GUI extension points handlers are removed from list.

Updated Length Notifier plug-in so that it can be properly deactivated.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/plugin-system/plugins/length_notifier.py

    r9737 r9754  
    7575                        d = {'prev_color' : None} 
    7676                        tv = chat_control.msg_textview 
    77                         b = tv.get_buffer() 
    78                         h_id = b.connect('changed', self.textview_length_warning, chat_control) 
     77                        tb = tv.get_buffer() 
     78                        h_id = tb.connect('changed', self.textview_length_warning, chat_control) 
    7979                        d['h_id'] = h_id 
     80                         
     81                        t = tb.get_text(tb.get_start_iter(), tb.get_end_iter()) 
     82                        if t: 
     83                                len_t = len(t) 
     84                                if len_t>self.MESSAGE_WARNING_LENGTH: 
     85                                        d['prev_color'] = tv.style.copy().base[gtk.STATE_NORMAL] 
     86                                        tv.modify_base(gtk.STATE_NORMAL, self.WARNING_COLOR) 
     87                                 
    8088                        chat_control.length_notifier_plugin_data = d 
    8189                         
     
    8795        def disconnect_from_chat_control(self, chat_control): 
    8896                d = chat_control.length_notifier_plugin_data 
    89                 chat_control.msg_textview.get_buffer().disconnect(d['h_id']) 
     97                tv = chat_control.msg_textview 
     98                tv.get_buffer().disconnect(d['h_id']) 
    9099                if d['prev_color']: 
    91                         tv.modify_base(gtk.STATE_NORMAL, self.PREV_COLOR) 
     100                        tv.modify_base(gtk.STATE_NORMAL, d['prev_color']) 
    92101         
    93102        @log_calls('LengthNotifierPlugin')