Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (39 sloc) 1.97 KB
# -*- coding: utf-8 -*-
#
# Make HOME and END keys move to first/last characters on line first before
# going to the start/end of the line. (It's just a gksourceview2 property.)
#
# Copyright (C) 2009 David Lynch (kemayo@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import GObject, Gedit
from gi.repository.GtkSource import SmartHomeEndType
class SmartHomePlugin(GObject.Object, Gedit.WindowActivatable):
__gtype_name__ = "SmartHomePlugin"
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
def do_activate(self):
for view in self.window.get_views():
view.set_data("SmartHomePluginOriginalValue",
view.get_property('smart-home-end'))
view.set_property('smart-home-end', SmartHomeEndType.BEFORE)
tab_added_id = self.window.connect("tab_added",
lambda w, t: t.get_view().set_smart_home_end(True))
self.window.set_data("SmartHomePluginHandlerId", tab_added_id)
def deactivate(self):
tab_added_id = self.window.get_data("SmartHomePluginHandlerId")
self.window.disconnect(tab_added_id)
self.window.set_data("SmartHomePluginHandlerId", None)
for view in self.window.get_views():
view.set_property('smart-home-end',
view.get_data("SmartHomePluginOriginalValue"))