예제 #1
0
class ImitationPlugin(GObject.Object, Gedit.WindowActivatable):
    """ Plugin attached to windows
    
    Imitation is loaded per window, and applied per active-tab.
    If the active-tab for that window changes, then Imitation will be applied
    to the newly active-tab, and will lose state for the previous tab.
    This is to prevent accidental edits when returning to a previous tab.
    
    """

    window = GObject.property(type=Gedit.Window)

    def __init__(self):
        GObject.Object.__init__(self)

    def do_activate(self):
        """ Activate the plugin """
        self._active_tab = ImitationTab(self.window.get_active_tab())
        self._tab_change_handler_id = self.window.connect(
            'active-tab-changed', self._on_active_tab_changed)

    def do_deactivate(self):
        """ Deactivate the plugin """
        self.window.disconnect(self._tab_change_handler_id)
        self._active_tab.originalise()

    def _on_active_tab_changed(self, window, tab):
        """ Handle active-tab changes """
        self._active_tab.originalise()
        self._active_tab = ImitationTab(tab)
예제 #2
0
class ImitationPlugin(GObject.Object, Gedit.WindowActivatable):
    
    """ Plugin attached to windows
    
    Imitation is loaded per window, and applied per active-tab.
    If the active-tab for that window changes, then Imitation will be applied
    to the newly active-tab, and will lose state for the previous tab.
    This is to prevent accidental edits when returning to a previous tab.
    
    """
    
    window = GObject.property(type=Gedit.Window)
    
    def __init__(self):
        GObject.Object.__init__(self)
    
    def do_activate(self):
        """ Activate the plugin """
        self._active_tab = ImitationTab(self.window.get_active_tab())
        self._tab_change_handler_id = self.window.connect(
                'active-tab-changed', self._on_active_tab_changed)
    
    def do_deactivate(self):
        """ Deactivate the plugin """
        self.window.disconnect(self._tab_change_handler_id)
        self._active_tab.originalise()
    
    def _on_active_tab_changed(self, window, tab):
        """ Handle active-tab changes """
        self._active_tab.originalise()
        self._active_tab = ImitationTab(tab)
예제 #3
0
 def _on_active_tab_changed(self, window, tab):
     """ Handle active-tab changes """
     self._active_tab.originalise()
     self._active_tab = ImitationTab(tab)
예제 #4
0
 def do_activate(self):
     """ Activate the plugin """
     self._active_tab = ImitationTab(self.window.get_active_tab())
     self._tab_change_handler_id = self.window.connect(
         'active-tab-changed', self._on_active_tab_changed)
예제 #5
0
 def _on_active_tab_changed(self, window, tab):
     """ Handle active-tab changes """
     self._active_tab.originalise()
     self._active_tab = ImitationTab(tab)
예제 #6
0
 def do_activate(self):
     """ Activate the plugin """
     self._active_tab = ImitationTab(self.window.get_active_tab())
     self._tab_change_handler_id = self.window.connect(
             'active-tab-changed', self._on_active_tab_changed)