Re: tab behaviour, was [gedit-list] gedit 2.15.2 released
- From: "Nigel Tao" <nigel tao gnome gmail com>
- To: "John Pye" <john pye student unsw edu au>
- Cc: gedit-list <gedit-list gnome org>, Paolo Maggi <paolo maggi gmail com>
- Subject: Re: tab behaviour, was [gedit-list] gedit 2.15.2 released
- Date: Sat, 20 May 2006 00:52:57 +1000
(and it should be ctrl-TAB or ctrl-PgUp, not
ctrl-alt-PgUp, which is a pain).
As we already explained several times, this choice is not up to us.
We are following gtk+ default.
Here is a short gedit Python plug-in that makes Ctrl-PgUp and
Ctrl-PgDn cycle through tabs, just like my GTK+ web browser (Epiphany)
does.
One issue is that, having not found a way to get from a gedit.View
object to its gedit.Window object (get_window() returns a
gtk.gdk.Window), I pass the window when I construct the helper object
but I don't watch for changes. As a consequence, Ctrl-PgUp doesn't
work when you move a tab to a new window. Any suggestions on how to
fix this?
------------------------------
# Copyright (C) 2006 - Nigel Tao <nigel tao gnome gmail com>
# This program is released under the GNU GPL version 2.
# Inspired from Elias Holzer's GPL'd autocompletion plug-in.
import gedit, gtk.gdk, types
PAGE_UP = gtk.gdk.keyval_from_name('Page_Up')
PAGE_DOWN = gtk.gdk.keyval_from_name('Page_Down')
class CtrlPageUpDownPlugin(gedit.Plugin):
handler_ids = []
def __init__(self):
gedit.Plugin.__init__(self)
def activate(self, window):
self.attach_to_window(window)
def deactivate(self, window):
for (handler_id, view) in self.handler_ids:
view.disconnect(handler_id)
def update_ui(self, window):
self.attach_to_window(window)
def attach_to_window(self, window):
view = window.get_active_view()
if type(view) != types.NoneType:
if getattr(view, 'ctrlpageupdown_plugin_helper', None) == None:
setattr(view, 'ctrlpageupdown_plugin_helper',
CtrlPageUpDownPluginHelper(window))
handler_id = view.connect(
'key-press-event',
view.ctrlpageupdown_plugin_helper.on_key_press_event)
self.handler_ids.append((handler_id, view))
class CtrlPageUpDownPluginHelper:
def __init__(self, gedit_window):
self.gedit_window = gedit_window
def on_key_press_event(self, view, event):
if event.state == gtk.gdk.CONTROL_MASK:
if event.keyval == PAGE_UP:
self.move(-1)
return True
elif event.keyval == PAGE_DOWN:
self.move(+1)
return True
return False
def move(self, delta):
documents = self.gedit_window.get_documents()
ad = self.gedit_window.get_active_document()
try:
i = documents.index(ad) + delta
except ValueError:
return
n = len(documents)
if i < 0:
i += n
elif i >= n:
i -= n
self.gedit_window.set_active_tab(
gedit.gedit_tab_get_from_document(documents[i]))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]