Changes made by pygi-convert.sh

This commit is contained in:
Stephen Boddy 2014-09-19 16:08:08 +02:00
parent 0091b59150
commit 7ca6dd96c6
21 changed files with 513 additions and 513 deletions

View File

@ -27,12 +27,12 @@ except OSError:
# Check we have simple basics like Gtk+ and a valid $DISPLAY
try:
import pygtk
pygtk.require ("2.0")
import gi
pyGtk.require ("2.0")
# pylint: disable-msg=W0611
import gtk, pango, gobject
if gtk.gdk.display_get_default() == None:
if Gdk.Display.get_default() == None:
print('You need to run terminator in an X environment. ' \
'Make sure $DISPLAY is properly set')
sys.exit(1)
@ -115,12 +115,12 @@ if __name__ == '__main__':
# pylint: disable-msg=W0611
import threading
gtk.gdk.threads_init()
Gdk.threads_init()
(DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals())
TERMINATOR.debug_address = DEBUGSVR.server_address
try:
gtk.main()
Gtk.main()
except KeyboardInterrupt:
pass

View File

@ -70,7 +70,7 @@ from borg import Borg
from util import dbg, err, DEBUG, get_config_dir, dict_diff
try:
import gconf
from gi.repository import GConf
except ImportError:
dbg('Unable to import gconf, GNOME defaults unavailable')
@ -344,12 +344,12 @@ class Config(object):
return
else:
if self.gconf is None:
self.gconf = gconf.client_get_default()
self.gconf = GConf.Client.get_default()
value = self.gconf.get(
value = self.GConf.get(
'/desktop/gnome/interface/monospace_font_name')
self.system_font = value.get_string()
self.gconf.notify_add(
self.GConf.notify_add(
'/desktop/gnome/interface/monospace_font_name',
self.on_gconf_notify)
return(self.system_font)
@ -362,12 +362,12 @@ class Config(object):
return
else:
if self.gconf is None:
self.gconf = gconf.client_get_default()
self.gconf = GConf.Client.get_default()
value = self.gconf.get('/apps/metacity/general/focus_mode')
value = self.GConf.get('/apps/metacity/general/focus_mode')
if value:
self.system_focus = value.get_string()
self.gconf.notify_add('/apps/metacity/general/focus_mode',
self.GConf.notify_add('/apps/metacity/general/focus_mode',
self.on_gconf_notify)
return(self.system_focus)

View File

@ -3,8 +3,8 @@
# GPL v2 only
"""container.py - classes necessary to contain Terminal widgets"""
import gobject
import gtk
from gi.repository import GObject
from gi.repository import Gtk
from factory import Factory
from config import Config
@ -32,7 +32,7 @@ class Container(object):
def register_signals(self, widget):
"""Register gobject signals in a way that avoids multiple inheritance"""
existing = gobject.signal_list_names(widget)
existing = GObject.signal_list_names(widget)
for signal in self.signals:
if signal['name'] in existing:
dbg('Container:: skipping signal %s for %s, already exists' % (
@ -41,7 +41,7 @@ class Container(object):
dbg('Container:: registering signal for %s on %s' %
(signal['name'], widget))
try:
gobject.signal_new(signal['name'],
GObject.signal_new(signal['name'],
widget,
signal['flags'],
signal['return_type'],
@ -158,39 +158,39 @@ class Container(object):
# skip this dialog if applicable
if self.config['suppress_multiple_term_dialog']:
return gtk.RESPONSE_ACCEPT
return Gtk.ResponseType.ACCEPT
dialog = gtk.Dialog(_('Close?'), window, gtk.DIALOG_MODAL)
dialog = Gtk.Dialog(_('Close?'), window, Gtk.DialogFlags.MODAL)
dialog.set_has_separator(False)
dialog.set_resizable(False)
dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
c_all = dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)
dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
c_all = dialog.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT)
c_all.get_children()[0].get_children()[0].get_children()[1].set_label(
_('Close _Terminals'))
primary = gtk.Label(_('<big><b>Close multiple terminals?</b></big>'))
primary = Gtk.Label(label=_('<big><b>Close multiple terminals?</b></big>'))
primary.set_use_markup(True)
primary.set_alignment(0, 0.5)
secondary = gtk.Label(_('This %s has several terminals open. Closing \
secondary = Gtk.Label(label=_('This %s has several terminals open. Closing \
the %s will also close all terminals within it.') % (reqtype, reqtype))
secondary.set_line_wrap(True)
labels = gtk.VBox()
labels = Gtk.VBox()
labels.pack_start(primary, False, False, 6)
labels.pack_start(secondary, False, False, 6)
image = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING,
gtk.ICON_SIZE_DIALOG)
image = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_WARNING,
Gtk.IconSize.DIALOG)
image.set_alignment(0.5, 0)
box = gtk.HBox()
box = Gtk.HBox()
box.pack_start(image, False, False, 6)
box.pack_start(labels, False, False, 6)
dialog.vbox.pack_start(box, False, False, 12)
checkbox = gtk.CheckButton(_("Do not show this message next time"))
dialog.vbox.pack_end(checkbox)
checkbox = Gtk.CheckButton(_("Do not show this message next time"))
dialog.vbox.pack_end(checkbox, True, True, 0)
dialog.show_all()

View File

@ -18,14 +18,14 @@
# , Boston, MA 02110-1301 USA
""" Editable Label class"""
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
class EditableLabel(gtk.EventBox):
class EditableLabel(Gtk.EventBox):
# pylint: disable-msg=W0212
# pylint: disable-msg=R0904
"""
An eventbox that partialy emulate a gtk.Label
An eventbox that partialy emulate a Gtk.Label
On double-click, the label is editable, entering an empty will revert back to automatic text
"""
_label = None
@ -36,16 +36,16 @@ class EditableLabel(gtk.EventBox):
_entry_handler_id = None
__gsignals__ = {
'edit-done': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'edit-done': (GObject.SignalFlags.RUN_LAST, None, ()),
}
def __init__(self, text = ""):
""" Class initialiser"""
gtk.EventBox.__init__(self)
GObject.GObject.__init__(self)
self.__gobject_init__()
self._entry_handler_id = []
self._label = gtk.Label(text)
self._label = Gtk.Label(label=text)
self._custom = False
self.set_visible_window (False)
self.add (self._label)
@ -74,9 +74,9 @@ class EditableLabel(gtk.EventBox):
"""event handling text edition"""
if event.button != 1:
return False
if event.type == gtk.gdk._2BUTTON_PRESS:
if event.type == Gdk._2BUTTON_PRESS:
self.remove (self._label)
self._entry = gtk.Entry ()
self._entry = Gtk.Entry ()
self._entry.set_text (self._label.get_text ())
self._entry.show ()
self.add (self._entry)
@ -96,7 +96,7 @@ class EditableLabel(gtk.EventBox):
def _entry_to_label (self, widget, event):
# pylint: disable-msg=W0613
"""replace gtk.Entry by the gtk.Label"""
"""replace Gtk.Entry by the Gtk.Label"""
if self._entry and self._entry in self.get_children():
#disconnect signals to avoid segfault :s
for sig in self._entry_handler_id:
@ -113,7 +113,7 @@ class EditableLabel(gtk.EventBox):
def _on_entry_activated (self, widget):
# pylint: disable-msg=W0613
"""get the text entered in gtk.Entry"""
"""get the text entered in Gtk.Entry"""
entry = self._entry.get_text ()
label = self._label.get_text ()
if entry == '':
@ -126,13 +126,13 @@ class EditableLabel(gtk.EventBox):
def _on_entry_keypress (self, widget, event):
# pylint: disable-msg=W0613
"""handle keypressed in gtk.Entry"""
key = gtk.gdk.keyval_name (event.keyval)
"""handle keypressed in Gtk.Entry"""
key = Gdk.keyval_name (event.keyval)
if key == 'Escape':
self._entry_to_label (None, None)
def _on_entry_buttonpress (self, widget, event):
"""handle button events in gtk.Entry."""
"""handle button events in Gtk.Entry."""
# Block right clicks to avoid a deadlock.
# The correct solution here would be for _entry_to_label to trigger a
# deferred execution handler and for that handler to check if focus is
@ -152,4 +152,4 @@ class EditableLabel(gtk.EventBox):
def set_custom(self):
"""Set the customness of the string to True"""
self._custom = True
gobject.type_register(EditableLabel)
GObject.type_register(EditableLabel)

View File

@ -3,7 +3,7 @@
# GPL v2 only
"""ipc.py - DBus server and API calls"""
import gtk
from gi.repository import Gtk
import dbus.service
from dbus.exceptions import DBusException
import dbus.glib
@ -23,7 +23,7 @@ BUS_BASE = 'net.tenshu.Terminator'
BUS_PATH = '/net/tenshu/Terminator'
try:
# Try and include the X11 display name in the dbus bus name
DISPLAY = hex(hash(gtk.gdk.get_display())).replace('-', '_')
DISPLAY = hex(hash(Gdk.get_display())).replace('-', '_')
BUS_NAME = '%s%s' % (BUS_BASE, DISPLAY)
except:
BUS_NAME = BUS_BASE

View File

@ -23,7 +23,7 @@ keyboard shortcuts.
"""
import re
import gtk
from gi.repository import Gtk
from util import err
class KeymapError(Exception):
@ -34,12 +34,12 @@ class Keybindings:
"""Class to handle loading and lookup of Terminator keybindings"""
modifiers = {
'ctrl': gtk.gdk.CONTROL_MASK,
'control': gtk.gdk.CONTROL_MASK,
'primary': gtk.gdk.CONTROL_MASK,
'shift': gtk.gdk.SHIFT_MASK,
'alt': gtk.gdk.MOD1_MASK,
'super': gtk.gdk.SUPER_MASK,
'ctrl': Gdk.ModifierType.CONTROL_MASK,
'control': Gdk.ModifierType.CONTROL_MASK,
'primary': Gdk.ModifierType.CONTROL_MASK,
'shift': Gdk.ModifierType.SHIFT_MASK,
'alt': Gdk.ModifierType.MOD1_MASK,
'super': Gdk.EventMask.SUPER_MASK,
}
empty = {}
@ -48,7 +48,7 @@ class Keybindings:
_lookup = None
def __init__(self):
self.keymap = gtk.gdk.keymap_get_default()
self.keymap = Gdk.keymap_get_default()
self.configure({})
def configure(self, bindings):
@ -71,21 +71,21 @@ class Keybindings:
try:
keyval, mask = self._parsebinding(binding)
# Does much the same, but with poorer error handling.
#keyval, mask = gtk.accelerator_parse(binding)
#keyval, mask = Gtk.accelerator_parse(binding)
except KeymapError as e:
err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e))
else:
if mask & gtk.gdk.SHIFT_MASK:
if keyval == gtk.keysyms.Tab:
keyval = gtk.keysyms.ISO_Left_Tab
mask &= ~gtk.gdk.SHIFT_MASK
if mask & Gdk.ModifierType.SHIFT_MASK:
if keyval == Gdk.KEY_Tab:
keyval = Gdk.KEY_ISO_Left_Tab
mask &= ~Gdk.ModifierType.SHIFT_MASK
else:
keyvals = gtk.gdk.keyval_convert_case(keyval)
keyvals = Gdk.keyval_convert_case(keyval)
if keyvals[0] != keyvals[1]:
keyval = keyvals[1]
mask &= ~gtk.gdk.SHIFT_MASK
mask &= ~Gdk.ModifierType.SHIFT_MASK
else:
keyval = gtk.gdk.keyval_to_lower(keyval)
keyval = Gdk.keyval_to_lower(keyval)
self._lookup.setdefault(mask, {})
self._lookup[mask][keyval] = action
self._masks |= mask
@ -100,7 +100,7 @@ class Keybindings:
key = re.sub(MODIFIER, '', binding)
if key == '':
raise KeymapError('No key found')
keyval = gtk.gdk.keyval_from_name(key)
keyval = Gdk.keyval_from_name(key)
if keyval == 0:
raise KeymapError("Key '%s' is unrecognised" % key)
return (keyval, mask)
@ -117,12 +117,12 @@ class Keybindings:
try:
keyval, _egp, _lvl, consumed = self.keymap.translate_keyboard_state(
event.hardware_keycode,
event.state & ~gtk.gdk.LOCK_MASK,
event.get_state() & ~Gdk.ModifierType.LOCK_MASK,
event.group)
except TypeError:
err ("keybindings.lookup failed to translate keyboard event: %s" %
dir(event))
return None
mask = (event.state & ~consumed) & self._masks
mask = (event.get_state() & ~consumed) & self._masks
return self._lookup.get(mask, self.empty).get(keyval, None)

View File

@ -4,8 +4,8 @@
"""layoutlauncher.py - class for the Layout Launcher window"""
import os
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
from util import dbg, err, spawn_new_terminator
import config
@ -31,7 +31,7 @@ class LayoutLauncher:
self.config = config.Config()
self.config.base.reload()
self.builder = gtk.Builder()
self.builder = Gtk.Builder()
try:
# Figure out where our library is on-disk so we can open our UI
(head, _tail) = os.path.split(config.__file__)
@ -46,12 +46,12 @@ class LayoutLauncher:
self.builder.add_from_string(gladedata)
self.window = self.builder.get_object('layoutlauncherwin')
icon_theme = gtk.IconTheme()
icon_theme = Gtk.IconTheme()
try:
icon = icon_theme.load_icon('terminator-layout', 48, 0)
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px Terminator preferences icon')
icon = self.window.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
icon = self.window.render_icon(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.BUTTON)
self.window.set_icon(icon)
self.builder.connect_signals(self)
@ -105,4 +105,4 @@ if __name__ == '__main__':
import terminal
LAYOUTLAUNCHER = LayoutLauncher()
gtk.main()
Gtk.main()

View File

@ -3,8 +3,8 @@
# GPL v2 only
"""notebook.py - classes for the notebook widget"""
import gobject
import gtk
from gi.repository import GObject
from gi.repository import Gtk
from terminator import Terminator
from config import Config
@ -14,8 +14,8 @@ from editablelabel import EditableLabel
from translation import _
from util import err, dbg, enumerate_descendants, make_uuid
class Notebook(Container, gtk.Notebook):
"""Class implementing a gtk.Notebook container"""
class Notebook(Container, Gtk.Notebook):
"""Class implementing a Gtk.Notebook container"""
window = None
last_active_term = None
pending_on_tab_switch = None
@ -23,15 +23,15 @@ class Notebook(Container, gtk.Notebook):
def __init__(self, window):
"""Class initialiser"""
if isinstance(window.get_child(), gtk.Notebook):
if isinstance(window.get_child(), Gtk.Notebook):
err('There is already a Notebook at the top of this window')
raise(ValueError)
Container.__init__(self)
gtk.Notebook.__init__(self)
GObject.GObject.__init__(self)
self.terminator = Terminator()
self.window = window
gobject.type_register(Notebook)
GObject.type_register(Notebook)
self.register_signals(Notebook)
self.connect('switch-page', self.deferred_on_tab_switch)
self.configure()
@ -66,7 +66,7 @@ class Notebook(Container, gtk.Notebook):
label = self.get_tab_label(self.get_nth_page(tab))
label.update_angle()
style = gtk.RcStyle()
style = Gtk.RcStyle()
style.xthickness = 0
style.ythickness = 0
self.modify_style(style)
@ -132,7 +132,7 @@ class Notebook(Container, gtk.Notebook):
if layout.has_key('active_page'):
# Need to do it later, or layout changes result
gobject.idle_add(self.set_current_page, int(layout['active_page']))
GObject.idle_add(self.set_current_page, int(layout['active_page']))
else:
self.set_current_page(0)
@ -180,11 +180,11 @@ class Notebook(Container, gtk.Notebook):
self.show_all()
while gtk.events_pending():
gtk.main_iteration_do(False)
while Gtk.events_pending():
Gtk.main_iteration_do(False)
self.get_toplevel().set_pos_by_ratio = False
gobject.idle_add(terminal.ensure_visible_and_focussed)
GObject.idle_add(terminal.ensure_visible_and_focussed)
def add(self, widget, metadata=None):
"""Add a widget to the container"""
@ -292,7 +292,7 @@ class Notebook(Container, gtk.Notebook):
self.set_tab_label(term_widget, label)
self.set_tab_label_packing(term_widget, not self.config['scroll_tabbar'],
not self.config['scroll_tabbar'],
gtk.PACK_START)
Gtk.PACK_START)
break
self.set_tab_reorderable(widget, True)
@ -343,7 +343,7 @@ class Notebook(Container, gtk.Notebook):
dbg('Notebook::closetab: child is a Container')
result = self.construct_confirm_close(self.window, _('tab'))
if result == gtk.RESPONSE_ACCEPT:
if result == Gtk.ResponseType.ACCEPT:
containers = None
objects = None
containers, objects = enumerate_descendants(child)
@ -351,8 +351,8 @@ class Notebook(Container, gtk.Notebook):
while len(objects) > 0:
descendant = objects.pop()
descendant.close()
while gtk.events_pending():
gtk.main_iteration()
while Gtk.events_pending():
Gtk.main_iteration()
return
else:
dbg('Notebook::closetab: user cancelled request')
@ -463,7 +463,7 @@ class Notebook(Container, gtk.Notebook):
self.pending_on_tab_switch_args = (notebook, page, page_num, data)
if self.pending_on_tab_switch == True:
return
gobject.idle_add(self.do_deferred_on_tab_switch)
GObject.idle_add(self.do_deferred_on_tab_switch)
self.pending_on_tab_switch = True
def do_deferred_on_tab_switch(self):
@ -477,10 +477,10 @@ class Notebook(Container, gtk.Notebook):
tabs_last_active_term = data['tabs_last_active_term']
if tabs_last_active_term:
term = self.terminator.find_terminal_by_uuid(tabs_last_active_term.urn)
gobject.idle_add(term.ensure_visible_and_focussed)
GObject.idle_add(term.ensure_visible_and_focussed)
return True
class TabLabel(gtk.HBox):
class TabLabel(Gtk.HBox):
"""Class implementing a label widget for Notebook tabs"""
notebook = None
terminator = None
@ -490,13 +490,13 @@ class TabLabel(gtk.HBox):
button = None
__gsignals__ = {
'close-clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_OBJECT,)),
'close-clicked': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_OBJECT,)),
}
def __init__(self, title, notebook):
"""Class initialiser"""
gtk.HBox.__init__(self)
GObject.GObject.__init__(self)
self.__gobject_init__()
self.notebook = notebook
@ -543,15 +543,15 @@ class TabLabel(gtk.HBox):
return
if not self.button:
self.button = gtk.Button()
self.button = Gtk.Button()
if not self.icon:
self.icon = gtk.Image()
self.icon.set_from_stock(gtk.STOCK_CLOSE,
gtk.ICON_SIZE_MENU)
self.icon = Gtk.Image()
self.icon.set_from_stock(Gtk.STOCK_CLOSE,
Gtk.IconSize.MENU)
self.button.set_focus_on_click(False)
self.button.set_relief(gtk.RELIEF_NONE)
style = gtk.RcStyle()
self.button.set_relief(Gtk.ReliefStyle.NONE)
style = Gtk.RcStyle()
style.xthickness = 0
style.ythickness = 0
self.button.modify_style(style)
@ -566,17 +566,17 @@ class TabLabel(gtk.HBox):
def update_angle(self):
"""Update the angle of a label"""
position = self.notebook.get_tab_pos()
if position == gtk.POS_LEFT:
if position == Gtk.PositionType.LEFT:
if hasattr(self, 'set_orientation'):
self.set_orientation(gtk.ORIENTATION_VERTICAL)
self.set_orientation(Gtk.Orientation.VERTICAL)
self.label.set_angle(90)
elif position == gtk.POS_RIGHT:
elif position == Gtk.PositionType.RIGHT:
if hasattr(self, 'set_orientation'):
self.set_orientation(gtk.ORIENTATION_VERTICAL)
self.set_orientation(Gtk.Orientation.VERTICAL)
self.label.set_angle(270)
else:
if hasattr(self, 'set_orientation'):
self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
self.set_orientation(Gtk.Orientation.HORIZONTAL)
self.label.set_angle(0)
def on_close(self, _widget):

View File

@ -4,8 +4,8 @@
"""paned.py - a base Paned container class and the vertical/horizontal
variants"""
import gobject
import gtk
from gi.repository import GObject
from gi.repository import Gtk
from util import dbg, err
from terminator import Terminator
@ -27,9 +27,9 @@ class Paned(Container):
self.maker = Factory()
Container.__init__(self)
self.signals.append({'name': 'resize-term',
'flags': gobject.SIGNAL_RUN_LAST,
'return_type': gobject.TYPE_NONE,
'param_types': (gobject.TYPE_STRING,)})
'flags': GObject.SignalFlags.RUN_LAST,
'return_type': None,
'param_types': (GObject.TYPE_STRING,)})
# pylint: disable-msg=W0613
@ -68,8 +68,8 @@ class Paned(Container):
self.show_all()
sibling.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
while Gtk.events_pending():
Gtk.main_iteration_do(False)
self.get_toplevel().set_pos_by_ratio = False
@ -123,7 +123,7 @@ class Paned(Container):
metadata['had_focus'] == True:
widget.grab_focus()
elif isinstance(widget, gtk.Paned):
elif isinstance(widget, Gtk.Paned):
try:
self.connect_child(widget, 'resize-term', self.resizeterm)
self.connect_child(widget, 'size-allocate', self.new_size)
@ -132,21 +132,21 @@ class Paned(Container):
def on_button_press(self, widget, event):
"""Handle button presses on a Pane"""
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
if event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK:
if event.button == 1 and event.type == Gdk._2BUTTON_PRESS:
if event.get_state() & Gdk.ModifierType.MOD4_MASK == Gdk.ModifierType.MOD4_MASK:
recurse_up=True
else:
recurse_up=False
if event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK:
if event.get_state() & Gdk.ModifierType.SHIFT_MASK == Gdk.ModifierType.SHIFT_MASK:
recurse_down=True
else:
recurse_down=False
# FIXME: These idle events are creating a lot of weird issues
for i in range(3):
while gtk.events_pending():
gtk.main_iteration_do(False)
while Gtk.events_pending():
Gtk.main_iteration_do(False)
self.do_redistribute(recurse_up, recurse_down)
return True
@ -166,10 +166,10 @@ class Paned(Container):
if grandfather != self.get_toplevel():
grandfather.do_redistribute(recurse_up, recurse_down)
gobject.idle_add(highest_ancestor._do_redistribute, recurse_up, recurse_down)
while gtk.events_pending():
gtk.main_iteration_do(False)
gobject.idle_add(highest_ancestor._do_redistribute, recurse_up, recurse_down)
GObject.idle_add(highest_ancestor._do_redistribute, recurse_up, recurse_down)
while Gtk.events_pending():
Gtk.main_iteration_do(False)
GObject.idle_add(highest_ancestor._do_redistribute, recurse_up, recurse_down)
def _do_redistribute(self, recurse_up=False, recurse_down=False):
maker = Factory()
@ -195,7 +195,7 @@ class Paned(Container):
if recurse_down and \
(maker.isinstance(child, 'VPaned') or \
maker.isinstance(child, 'HPaned')):
gobject.idle_add(child.do_redistribute, False, True)
GObject.idle_add(child.do_redistribute, False, True)
#3 Get ancestor x/y => a, and handle size => hs
avail_pixels=self.get_length()
@ -214,11 +214,11 @@ class Paned(Container):
toproc.append(child)
if curr[1].index(child) == 0:
curr[0].set_position((child[2]*single_size)+((child[2]-1)*handle_size))
gobject.idle_add(curr[0].set_position, child[2]*single_size)
GObject.idle_add(curr[0].set_position, child[2]*single_size)
def remove(self, widget):
"""Remove a widget from the container"""
gtk.Paned.remove(self, widget)
Gtk.Paned.remove(self, widget)
self.disconnect_child(widget)
self.children.remove(widget)
return(True)
@ -267,7 +267,7 @@ class Paned(Container):
def resizeterm(self, widget, keyname):
"""Handle a keyboard event requesting a terminal resize"""
if keyname in ['up', 'down'] and isinstance(self, gtk.VPaned):
if keyname in ['up', 'down'] and isinstance(self, Gtk.VPaned):
# This is a key we can handle
position = self.get_position()
@ -280,7 +280,7 @@ class Paned(Container):
self.set_position(position - fontheight)
else:
self.set_position(position + fontheight)
elif keyname in ['left', 'right'] and isinstance(self, gtk.HPaned):
elif keyname in ['left', 'right'] and isinstance(self, Gtk.HPaned):
# This is a key we can handle
position = self.get_position()
@ -396,12 +396,12 @@ class Paned(Container):
self.ratio = float(pos) / self.get_length()
self.set_pos(pos)
class HPaned(Paned, gtk.HPaned):
"""Merge gtk.HPaned into our base Paned Container"""
class HPaned(Paned, Gtk.HPaned):
"""Merge Gtk.HPaned into our base Paned Container"""
def __init__(self):
"""Class initialiser"""
Paned.__init__(self)
gtk.HPaned.__init__(self)
GObject.GObject.__init__(self)
self.register_signals(HPaned)
self.cnxids.new(self, 'button-press-event', self.on_button_press)
@ -409,14 +409,14 @@ class HPaned(Paned, gtk.HPaned):
return(self.allocation.width)
def set_pos(self, pos):
gtk.HPaned.set_position(self, pos)
Gtk.HPaned.set_position(self, pos)
class VPaned(Paned, gtk.VPaned):
"""Merge gtk.VPaned into our base Paned Container"""
class VPaned(Paned, Gtk.VPaned):
"""Merge Gtk.VPaned into our base Paned Container"""
def __init__(self):
"""Class initialiser"""
Paned.__init__(self)
gtk.VPaned.__init__(self)
GObject.GObject.__init__(self)
self.register_signals(VPaned)
self.cnxids.new(self, 'button-press-event', self.on_button_press)
@ -424,8 +424,8 @@ class VPaned(Paned, gtk.VPaned):
return(self.allocation.height)
def set_pos(self, pos):
gtk.VPaned.set_position(self, pos)
Gtk.VPaned.set_position(self, pos)
gobject.type_register(HPaned)
gobject.type_register(VPaned)
GObject.type_register(HPaned)
GObject.type_register(VPaned)
# vim: set expandtab ts=4 sw=4:

View File

@ -4,8 +4,8 @@
"""activitywatch.py - Terminator Plugin to watch a terminal for activity"""
import time
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
import terminatorlib.plugin as plugin
from terminatorlib.translation import _
@ -13,7 +13,7 @@ from terminatorlib.util import err, dbg
from terminatorlib.version import APP_NAME
try:
import pynotify
from gi.repository import Notify
# Every plugin you want Terminator to load *must* be listed in 'AVAILABLE'
# This is inside this try so we only make the plugin available if pynotify
# is present on this computer.
@ -37,15 +37,15 @@ class ActivityWatch(plugin.MenuItem):
if not self.timers:
self.timers = {}
pynotify.init(APP_NAME.capitalize())
Notify.init(APP_NAME.capitalize())
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
if not self.watches.has_key(terminal):
item = gtk.MenuItem(_('Watch for activity'))
item = Gtk.MenuItem(_('Watch for activity'))
item.connect("activate", self.watch, terminal)
else:
item = gtk.MenuItem(_('Stop watching for activity'))
item = Gtk.MenuItem(_('Stop watching for activity'))
item.connect("activate", self.unwatch, terminal)
menuitems.append(item)
@ -66,10 +66,10 @@ class ActivityWatch(plugin.MenuItem):
show_notify = False
# Don't notify if the user is already looking at this terminal.
if terminal.vte.flags() & gtk.HAS_FOCUS:
if terminal.vte.flags() & Gtk.HAS_FOCUS:
return True
note = pynotify.Notification('Terminator', 'Activity in: %s' %
note = Notify.Notification('Terminator', 'Activity in: %s' %
terminal.get_window_title(), 'terminator')
this_time = time.mktime(time.gmtime())
@ -102,15 +102,15 @@ class InactivityWatch(plugin.MenuItem):
if not self.timers:
self.timers = {}
pynotify.init(APP_NAME.capitalize())
Notify.init(APP_NAME.capitalize())
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
if not self.watches.has_key(terminal):
item = gtk.MenuItem(_("Watch for silence"))
item = Gtk.MenuItem(_("Watch for silence"))
item.connect("activate", self.watch, terminal)
else:
item = gtk.MenuItem(_("Stop watching for silence"))
item = Gtk.MenuItem(_("Stop watching for silence"))
item.connect("activate", self.unwatch, terminal)
menuitems.append(item)
dbg('Menu items appended')
@ -120,7 +120,7 @@ class InactivityWatch(plugin.MenuItem):
vte = terminal.get_vte()
self.watches[terminal] = vte.connect('contents-changed',
self.reset_timer, terminal)
timeout_id = gobject.timeout_add(5000, self.check_times, terminal)
timeout_id = GObject.timeout_add(5000, self.check_times, terminal)
self.timers[terminal] = timeout_id
dbg('timer %s added for %s' %(timeout_id, terminal))
@ -129,7 +129,7 @@ class InactivityWatch(plugin.MenuItem):
vte = terminal.get_vte()
vte.disconnect(self.watches[terminal])
del(self.watches[terminal])
gobject.source_remove(self.timers[terminal])
GObject.source_remove(self.timers[terminal])
del(self.timers[terminal])
def reset_timer(self, _vte, terminal):
@ -148,7 +148,7 @@ class InactivityWatch(plugin.MenuItem):
dbg('seconds since last activity: %f (%s)' % (time_now - self.last_activities[terminal], terminal))
if time_now - self.last_activities[terminal] >= 10.0:
del(self.last_activities[terminal])
note = pynotify.Notification('Terminator', 'Silence in: %s' %
note = Notify.Notification('Terminator', 'Silence in: %s' %
terminal.get_window_title(), 'terminator')
note.show()

View File

@ -9,8 +9,8 @@ import os
if __name__ == '__main__':
sys.path.append( os.path.join(os.path.dirname(__file__), "../.."))
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
import terminatorlib.plugin as plugin
from terminatorlib.config import Config
from terminatorlib.translation import _
@ -58,32 +58,32 @@ class CustomCommandsMenu(plugin.MenuItem):
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
item = gtk.MenuItem(_('Custom Commands'))
item = Gtk.MenuItem(_('Custom Commands'))
menuitems.append(item)
submenu = gtk.Menu()
submenu = Gtk.Menu()
item.set_submenu(submenu)
menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
menuitem = Gtk.ImageMenuItem(Gtk.STOCK_PREFERENCES)
menuitem.connect("activate", self.configure)
submenu.append(menuitem)
menuitem = gtk.SeparatorMenuItem()
menuitem = Gtk.SeparatorMenuItem()
submenu.append(menuitem)
theme = gtk.IconTheme()
theme = Gtk.IconTheme()
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
if not command['enabled']:
continue
exe = command['command'].split(' ')[0]
iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
iconinfo = theme.choose_icon([exe], Gtk.IconSize.MENU, Gtk.IconLookupFlags.USE_BUILTIN)
if iconinfo:
image = gtk.Image()
image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
menuitem = gtk.ImageMenuItem(command['name'])
image = Gtk.Image()
image.set_from_icon_name(exe, Gtk.IconSize.MENU)
menuitem = Gtk.ImageMenuItem(command['name'])
menuitem.set_image(image)
else:
menuitem = gtk.MenuItem(command["name"])
menuitem = Gtk.MenuItem(command["name"])
menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
submenu.append(menuitem)
@ -114,91 +114,91 @@ class CustomCommandsMenu(plugin.MenuItem):
def configure(self, widget, data = None):
ui = {}
dbox = gtk.Dialog(
dbox = Gtk.Dialog(
_("Custom Commands Configuration"),
None,
gtk.DIALOG_MODAL,
Gtk.DialogFlags.MODAL,
(
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT
)
)
icon_theme = gtk.IconTheme()
icon_theme = Gtk.IconTheme()
try:
icon = icon_theme.load_icon('terminator-custom-commands', 48, 0)
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px Terminator preferences icon')
icon = dbox.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
icon = dbox.render_icon(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.BUTTON)
dbox.set_icon(icon)
store = gtk.ListStore(bool, str, str)
store = Gtk.ListStore(bool, str, str)
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ]:
store.append([command['enabled'], command['name'], command['command']])
treeview = gtk.TreeView(store)
treeview = Gtk.TreeView(store)
#treeview.connect("cursor-changed", self.on_cursor_changed, ui)
selection = treeview.get_selection()
selection.set_mode(gtk.SELECTION_SINGLE)
selection.set_mode(Gtk.SelectionMode.SINGLE)
selection.connect("changed", self.on_selection_changed, ui)
ui['treeview'] = treeview
renderer = gtk.CellRendererToggle()
renderer = Gtk.CellRendererToggle()
renderer.connect('toggled', self.on_toggled, ui)
column = gtk.TreeViewColumn("Enabled", renderer, active=CC_COL_ENABLED)
column = Gtk.TreeViewColumn("Enabled", renderer, active=CC_COL_ENABLED)
treeview.append_column(column)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("Name", renderer, text=CC_COL_NAME)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn("Name", renderer, text=CC_COL_NAME)
treeview.append_column(column)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("Command", renderer, text=CC_COL_COMMAND)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn("Command", renderer, text=CC_COL_COMMAND)
treeview.append_column(column)
hbox = gtk.HBox()
hbox.pack_start(treeview)
dbox.vbox.pack_start(hbox)
hbox = Gtk.HBox()
hbox.pack_start(treeview, True, True, 0)
dbox.vbox.pack_start(hbox, True, True, 0)
button_box = gtk.VBox()
button_box = Gtk.VBox()
button = gtk.Button(stock=gtk.STOCK_GOTO_TOP)
button = Gtk.Button(stock=Gtk.STOCK_GOTO_TOP)
button_box.pack_start(button, False, True)
button.connect("clicked", self.on_goto_top, ui)
button.set_sensitive(False)
ui['button_top'] = button
button = gtk.Button(stock=gtk.STOCK_GO_UP)
button = Gtk.Button(stock=Gtk.STOCK_GO_UP)
button_box.pack_start(button, False, True)
button.connect("clicked", self.on_go_up, ui)
button.set_sensitive(False)
ui['button_up'] = button
button = gtk.Button(stock=gtk.STOCK_GO_DOWN)
button = Gtk.Button(stock=Gtk.STOCK_GO_DOWN)
button_box.pack_start(button, False, True)
button.connect("clicked", self.on_go_down, ui)
button.set_sensitive(False)
ui['button_down'] = button
button = gtk.Button(stock=gtk.STOCK_GOTO_LAST)
button = Gtk.Button(stock=Gtk.STOCK_GOTO_LAST)
button_box.pack_start(button, False, True)
button.connect("clicked", self.on_goto_last, ui)
button.set_sensitive(False)
ui['button_last'] = button
button = gtk.Button(stock=gtk.STOCK_NEW)
button = Gtk.Button(stock=Gtk.STOCK_NEW)
button_box.pack_start(button, False, True)
button.connect("clicked", self.on_new, ui)
ui['button_new'] = button
button = gtk.Button(stock=gtk.STOCK_EDIT)
button = Gtk.Button(stock=Gtk.STOCK_EDIT)
button_box.pack_start(button, False, True)
button.set_sensitive(False)
button.connect("clicked", self.on_edit, ui)
ui['button_edit'] = button
button = gtk.Button(stock=gtk.STOCK_DELETE)
button = Gtk.Button(stock=Gtk.STOCK_DELETE)
button_box.pack_start(button, False, True)
button.connect("clicked", self.on_delete, ui)
button.set_sensitive(False)
@ -206,10 +206,10 @@ class CustomCommandsMenu(plugin.MenuItem):
hbox.pack_start(button_box)
hbox.pack_start(button_box, True, True, 0)
dbox.show_all()
res = dbox.run()
if res == gtk.RESPONSE_ACCEPT:
if res == Gtk.ResponseType.ACCEPT:
self.update_cmd_list(store)
self._save_config()
dbox.destroy()
@ -255,44 +255,44 @@ class CustomCommandsMenu(plugin.MenuItem):
data['button_delete'].set_sensitive(iter is not None)
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
dialog = gtk.Dialog(
dialog = Gtk.Dialog(
_("New Command"),
None,
gtk.DIALOG_MODAL,
Gtk.DialogFlags.MODAL,
(
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT
)
)
table = gtk.Table(3, 2)
table = Gtk.Table(3, 2)
label = gtk.Label(_("Enabled:"))
label = Gtk.Label(label=_("Enabled:"))
table.attach(label, 0, 1, 0, 1)
enabled = gtk.CheckButton()
enabled = Gtk.CheckButton()
enabled.set_active(enabled_var)
table.attach(enabled, 1, 2, 0, 1)
label = gtk.Label(_("Name:"))
label = Gtk.Label(label=_("Name:"))
table.attach(label, 0, 1, 1, 2)
name = gtk.Entry()
name = Gtk.Entry()
name.set_text(name_var)
table.attach(name, 1, 2, 1, 2)
label = gtk.Label(_("Command:"))
label = Gtk.Label(label=_("Command:"))
table.attach(label, 0, 1, 2, 3)
command = gtk.Entry()
command = Gtk.Entry()
command.set_text(command_var)
table.attach(command, 1, 2, 2, 3)
dialog.vbox.pack_start(table)
dialog.vbox.pack_start(table, True, True, 0)
dialog.show_all()
return (dialog,enabled,name,command)
def _error(self, msg):
err = gtk.MessageDialog(dialog,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
err = Gtk.MessageDialog(dialog,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.CLOSE,
msg
)
err.run()
@ -305,15 +305,15 @@ class CustomCommandsMenu(plugin.MenuItem):
(dialog,enabled,name,command) = self._create_command_dialog()
res = dialog.run()
item = {}
if res == gtk.RESPONSE_ACCEPT:
if res == Gtk.ResponseType.ACCEPT:
item['enabled'] = enabled.get_active()
item['name'] = name.get_text()
item['command'] = command.get_text()
if item['name'] == '' or item['command'] == '':
err = gtk.MessageDialog(dialog,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
err = Gtk.MessageDialog(dialog,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.CLOSE,
_("You need to define a name and command")
)
err.run()
@ -415,15 +415,15 @@ class CustomCommandsMenu(plugin.MenuItem):
)
res = dialog.run()
item = {}
if res == gtk.RESPONSE_ACCEPT:
if res == Gtk.ResponseType.ACCEPT:
item['enabled'] = enabled.get_active()
item['name'] = name.get_text()
item['command'] = command.get_text()
if item['name'] == '' or item['command'] == '':
err = gtk.MessageDialog(dialog,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
err = Gtk.MessageDialog(dialog,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.CLOSE,
_("You need to define a name and command")
)
err.run()
@ -451,5 +451,5 @@ class CustomCommandsMenu(plugin.MenuItem):
if __name__ == '__main__':
c = CustomCommandsMenu()
c.configure(None, None)
gtk.main()
Gtk.main()

View File

@ -8,7 +8,7 @@ terminals """
import os
import sys
import gtk
from gi.repository import Gtk
import terminatorlib.plugin as plugin
from terminatorlib.translation import _
@ -18,9 +18,9 @@ class Logger(plugin.MenuItem):
""" Add custom command to the terminal menu"""
capabilities = ['terminal_menu']
loggers = None
dialog_action = gtk.FILE_CHOOSER_ACTION_SAVE
dialog_buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK)
dialog_action = Gtk.FileChooserAction.SAVE
dialog_buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
def __init__(self):
plugin.MenuItem.__init__(self)
@ -31,10 +31,10 @@ class Logger(plugin.MenuItem):
""" Add save menu item to the menu"""
vte_terminal = terminal.get_vte()
if not self.loggers.has_key(vte_terminal):
item = gtk.MenuItem(_('Start Logger'))
item = Gtk.MenuItem(_('Start Logger'))
item.connect("activate", self.start_logger, terminal)
else:
item = gtk.MenuItem(_('Stop Logger'))
item = Gtk.MenuItem(_('Stop Logger'))
item.connect("activate", self.stop_logger, terminal)
item.set_has_tooltip(True)
item.set_tooltip_text("Saving at '" + self.loggers[vte_terminal]["filepath"] + "'")
@ -63,14 +63,14 @@ class Logger(plugin.MenuItem):
def start_logger(self, _widget, Terminal):
""" Handle menu item callback by saving text to a file"""
savedialog = gtk.FileChooserDialog(title="Save Log File As",
savedialog = Gtk.FileChooserDialog(title="Save Log File As",
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_do_overwrite_confirmation(True)
savedialog.set_local_only(True)
savedialog.show_all()
response = savedialog.run()
if response == gtk.RESPONSE_OK:
if response == Gtk.ResponseType.OK:
try:
logfile = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
@ -88,8 +88,8 @@ class Logger(plugin.MenuItem):
self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
except:
e = sys.exc_info()[1]
error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK, e.strerror)
error = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK, e.strerror)
error.run()
error.destroy()
savedialog.destroy()

View File

@ -5,7 +5,7 @@
terminals"""
import os
import gtk
from gi.repository import Gtk
import terminatorlib.plugin as plugin
from terminatorlib.translation import _
from terminatorlib.util import widget_pixbuf
@ -16,16 +16,16 @@ AVAILABLE = ['TerminalShot']
class TerminalShot(plugin.MenuItem):
"""Add custom commands to the terminal menu"""
capabilities = ['terminal_menu']
dialog_action = gtk.FILE_CHOOSER_ACTION_SAVE
dialog_buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK)
dialog_action = Gtk.FileChooserAction.SAVE
dialog_buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
def __init__(self):
plugin.MenuItem.__init__(self)
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
item = gtk.MenuItem(_('Terminal screenshot'))
item = Gtk.MenuItem(_('Terminal screenshot'))
item.connect("activate", self.terminalshot, terminal)
menuitems.append(item)
@ -34,7 +34,7 @@ class TerminalShot(plugin.MenuItem):
# Grab a pixbuf of the terminal
orig_pixbuf = widget_pixbuf(terminal)
savedialog = gtk.FileChooserDialog(title="Save image",
savedialog = Gtk.FileChooserDialog(title="Save image",
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_do_overwrite_confirmation(True)
@ -42,14 +42,14 @@ class TerminalShot(plugin.MenuItem):
pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
orig_pixbuf.get_height() / 2,
gtk.gdk.INTERP_BILINEAR)
image = gtk.image_new_from_pixbuf(pixbuf)
GdkPixbuf.InterpType.BILINEAR)
image = Gtk.image_new_from_pixbuf(pixbuf)
savedialog.set_preview_widget(image)
savedialog.show_all()
response = savedialog.run()
path = None
if response == gtk.RESPONSE_OK:
if response == Gtk.ResponseType.OK:
path = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
orig_pixbuf.save(path, 'png')

View File

@ -8,8 +8,8 @@ write it to a config file
"""
import os
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
from util import dbg, err
import config
@ -154,7 +154,7 @@ class PrefsEditor:
self.config = config.Config()
self.config.base.reload()
self.term = term
self.builder = gtk.Builder()
self.builder = Gtk.Builder()
self.keybindings = Keybindings()
try:
# Figure out where our library is on-disk so we can open our
@ -170,12 +170,12 @@ class PrefsEditor:
self.builder.add_from_string(gladedata)
self.window = self.builder.get_object('prefswin')
icon_theme = gtk.IconTheme()
icon_theme = Gtk.IconTheme()
try:
icon = icon_theme.load_icon('terminator-preferences', 48, 0)
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px Terminator preferences icon')
icon = self.window.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
icon = self.window.render_icon(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.BUTTON)
self.window.set_icon(icon)
self.layouteditor = LayoutEditor(self.builder)
@ -314,7 +314,7 @@ class PrefsEditor:
## Keybindings tab
widget = guiget('keybindingtreeview')
liststore = widget.get_model()
liststore.set_sort_column_id(0, gtk.SORT_ASCENDING)
liststore.set_sort_column_id(0, Gtk.SortType.ASCENDING)
keybindings = self.config['keybindings']
for keybinding in keybindings:
keyval = 0
@ -410,10 +410,10 @@ class PrefsEditor:
# Cursor colour
widget = guiget('cursor_color')
try:
widget.set_color(gtk.gdk.Color(self.config['cursor_color']))
widget.set_color(Gdk.Color(self.config['cursor_color']))
except ValueError:
self.config['cursor_color'] = "#FFFFFF"
widget.set_color(gtk.gdk.Color(self.config['cursor_color']))
widget.set_color(Gdk.Color(self.config['cursor_color']))
## Command tab
# Login shell
@ -462,14 +462,14 @@ class PrefsEditor:
# NOTE: The scheme is set in the GUI widget after the fore/back colours
# Foreground color
widget = guiget('foreground_colorpicker')
widget.set_color(gtk.gdk.Color(self.config['foreground_color']))
widget.set_color(Gdk.Color(self.config['foreground_color']))
if scheme == 'custom':
widget.set_sensitive(True)
else:
widget.set_sensitive(False)
# Background color
widget = guiget('background_colorpicker')
widget.set_color(gtk.gdk.Color(self.config['background_color']))
widget.set_color(Gdk.Color(self.config['background_color']))
if scheme == 'custom':
widget.set_sensitive(True)
else:
@ -493,7 +493,7 @@ class PrefsEditor:
colourpalette = self.config['palette'].split(':')
for i in xrange(1, 17):
widget = guiget('palette_colorpicker_%d' % i)
widget.set_color(gtk.gdk.Color(colourpalette[i - 1]))
widget.set_color(Gdk.Color(colourpalette[i - 1]))
# Now set the palette selector widget
widget = guiget('palette_combobox')
widget.set_active(self.palettevalues[palette])
@ -502,7 +502,7 @@ class PrefsEditor:
'title_receive_fg_color', 'title_receive_bg_color',
'title_inactive_fg_color', 'title_inactive_bg_color']:
widget = guiget(bit)
widget.set_color(gtk.gdk.Color(self.config[bit]))
widget.set_color(Gdk.Color(self.config[bit]))
# Inactive terminal shading
widget = guiget('inactive_color_offset')
widget.set_value(float(self.config['inactive_color_offset']))
@ -845,7 +845,7 @@ class PrefsEditor:
for num in xrange(1, 17):
# Update the visible elements
picker = guiget('palette_colorpicker_%d' % num)
picker.set_color(gtk.gdk.Color(palettebits[num - 1]))
picker.set_color(Gdk.Color(palettebits[num - 1]))
elif value == 'custom':
palettebits = []
for num in xrange(1, 17):
@ -1334,8 +1334,8 @@ class PrefsEditor:
err('Unknown colourscheme value: %s' % value)
return
fore.set_color(gtk.gdk.Color(forecol))
back.set_color(gtk.gdk.Color(backcol))
fore.set_color(Gdk.Color(forecol))
back.set_color(Gdk.Color(backcol))
self.config['foreground_color'] = forecol
self.config['background_color'] = backcol
@ -1366,7 +1366,7 @@ class PrefsEditor:
liststore.set(celliter, 2, key, 3, mods)
binding = liststore.get_value(liststore.get_iter(path), 0)
accel = gtk.accelerator_name(key, mods)
accel = Gtk.accelerator_name(key, mods)
self.config['keybindings'][binding] = accel
self.config.save()
@ -1554,4 +1554,4 @@ if __name__ == '__main__':
TERM = terminal.Terminal()
PREFEDIT = PrefsEditor(TERM)
gtk.main()
Gtk.main()

View File

@ -3,19 +3,19 @@
# GPL v2 only
"""searchbar.py - classes necessary to provide a terminal search bar"""
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
import re
from translation import _
from config import Config
# pylint: disable-msg=R0904
class Searchbar(gtk.HBox):
class Searchbar(Gtk.HBox):
"""Class implementing the Searchbar widget"""
__gsignals__ = {
'end-search': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'end-search': (GObject.SignalFlags.RUN_LAST, None, ()),
}
entry = None
@ -34,32 +34,32 @@ class Searchbar(gtk.HBox):
def __init__(self):
"""Class initialiser"""
gtk.HBox.__init__(self)
GObject.GObject.__init__(self)
self.__gobject_init__()
self.config = Config()
# Search text
self.entry = gtk.Entry()
self.entry = Gtk.Entry()
self.entry.set_activates_default(True)
self.entry.show()
self.entry.connect('activate', self.do_search)
self.entry.connect('key-press-event', self.search_keypress)
# Label
label = gtk.Label(_('Search:'))
label = Gtk.Label(label=_('Search:'))
label.show()
# Result label
self.reslabel = gtk.Label('')
self.reslabel = Gtk.Label(label='')
self.reslabel.show()
# Close Button
close = gtk.Button()
close.set_relief(gtk.RELIEF_NONE)
close = Gtk.Button()
close.set_relief(Gtk.ReliefStyle.NONE)
close.set_focus_on_click(False)
icon = gtk.Image()
icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
icon = Gtk.Image()
icon.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
close.add(icon)
close.set_name('terminator-search-close-button')
if hasattr(close, 'set_tooltip_text'):
@ -68,19 +68,19 @@ class Searchbar(gtk.HBox):
close.show_all()
# Next Button
self.next = gtk.Button(_('Next'))
self.next = Gtk.Button(_('Next'))
self.next.show()
self.next.set_sensitive(False)
self.next.connect('clicked', self.next_search)
# Previous Button
self.prev = gtk.Button(_('Prev'))
self.prev = Gtk.Button(_('Prev'))
self.prev.show()
self.prev.set_sensitive(False)
self.prev.connect('clicked', self.prev_search)
self.pack_start(label, False)
self.pack_start(self.entry)
self.pack_start(self.entry, True, True, 0)
self.pack_start(self.reslabel, False)
self.pack_start(self.prev, False, False)
self.pack_start(self.next, False, False)
@ -98,7 +98,7 @@ class Searchbar(gtk.HBox):
# pylint: disable-msg=W0613
def search_keypress(self, widget, event):
"""Handle keypress events"""
key = gtk.gdk.keyval_name(event.keyval)
key = Gdk.keyval_name(event.keyval)
if key == 'Escape':
self.end_search()
@ -198,4 +198,4 @@ class Searchbar(gtk.HBox):
"""Return the currently set search term"""
return(self.entry.get_text())
gobject.type_register(Searchbar)
GObject.type_register(Searchbar)

View File

@ -7,11 +7,11 @@ from __future__ import division
import sys
import os
import signal
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import pango
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import Pango
import subprocess
import urllib
@ -36,43 +36,43 @@ except ImportError:
sys.exit(1)
# pylint: disable-msg=R0904
class Terminal(gtk.VBox):
class Terminal(Gtk.VBox):
"""Class implementing the VTE widget and its wrappings"""
__gsignals__ = {
'close-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'title-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'enumerate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_INT,)),
'group-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'group-tab-toggle': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'split-horiz': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'rotate-cw': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'rotate-ccw': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_BOOLEAN, gobject.TYPE_OBJECT)),
'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'focus-out': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'zoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'maximise': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'unzoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'resize-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'navigate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'tab-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_INT,)),
'group-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'group-all-toggle': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'move-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'close-term': (GObject.SignalFlags.RUN_LAST, None, ()),
'title-change': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'enumerate': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_INT,)),
'group-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
'group-tab-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
'ungroup-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
'ungroup-all': (GObject.SignalFlags.RUN_LAST, None, ()),
'split-horiz': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'split-vert': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'rotate-cw': (GObject.SignalFlags.RUN_LAST, None, ()),
'rotate-ccw': (GObject.SignalFlags.RUN_LAST, None, ()),
'tab-new': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_BOOLEAN, GObject.TYPE_OBJECT)),
'tab-top-new': (GObject.SignalFlags.RUN_LAST, None, ()),
'focus-in': (GObject.SignalFlags.RUN_LAST, None, ()),
'focus-out': (GObject.SignalFlags.RUN_LAST, None, ()),
'zoom': (GObject.SignalFlags.RUN_LAST, None, ()),
'maximise': (GObject.SignalFlags.RUN_LAST, None, ()),
'unzoom': (GObject.SignalFlags.RUN_LAST, None, ()),
'resize-term': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'navigate': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'tab-change': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_INT,)),
'group-all': (GObject.SignalFlags.RUN_LAST, None, ()),
'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
'move-tab': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
}
TARGET_TYPE_VTE = 8
@ -113,7 +113,7 @@ class Terminal(gtk.VBox):
def __init__(self):
"""Class initialiser"""
gtk.VBox.__init__(self)
GObject.GObject.__init__(self)
self.__gobject_init__()
self.terminator = Terminator()
@ -131,7 +131,7 @@ class Terminal(gtk.VBox):
self.cwd = get_default_cwd()
self.origcwd = self.terminator.origcwd
self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
self.clipboard = Gtk.clipboard_get(Gdk.SELECTION_CLIPBOARD)
self.pending_on_vte_size_allocate = False
@ -163,8 +163,8 @@ class Terminal(gtk.VBox):
self.show()
self.pack_start(self.titlebar, False)
self.pack_start(self.terminalbox)
self.pack_end(self.searchbar)
self.pack_start(self.terminalbox, True, True, 0)
self.pack_end(self.searchbar, True, True, 0)
self.connect_signals()
@ -217,8 +217,8 @@ class Terminal(gtk.VBox):
def create_terminalbox(self):
"""Create a GtkHBox containing the terminal and a scrollbar"""
terminalbox = gtk.HBox()
self.scrollbar = gtk.VScrollbar(self.vte.get_adjustment())
terminalbox = Gtk.HBox()
self.scrollbar = Gtk.VScrollbar(self.vte.get_adjustment())
self.scrollbar.set_no_show_all(True)
self.scrollbar_position = self.config['scrollbar_position']
@ -322,22 +322,22 @@ class Terminal(gtk.VBox):
self.vte.connect('button-press-event', self.on_buttonpress)
self.vte.connect('popup-menu', self.popup_menu)
srcvtetargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE)]
dsttargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE),
srcvtetargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE)]
dsttargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE),
('text/x-moz-url', 0, 0),
('_NETSCAPE_URL', 0, 0)]
dsttargets = gtk.target_list_add_text_targets(dsttargets)
dsttargets = gtk.target_list_add_uri_targets(dsttargets)
dsttargets = Gtk.target_list_add_text_targets(dsttargets)
dsttargets = Gtk.target_list_add_uri_targets(dsttargets)
dbg('Finalised drag targets: %s' % dsttargets)
for (widget, mask) in [
(self.vte, gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK),
(self.titlebar, gtk.gdk.BUTTON1_MASK)]:
widget.drag_source_set(mask, srcvtetargets, gtk.gdk.ACTION_MOVE)
(self.vte, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.BUTTON3_MASK),
(self.titlebar, Gdk.ModifierType.BUTTON1_MASK)]:
widget.drag_source_set(mask, srcvtetargets, Gdk.DragAction.MOVE)
self.vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,
dsttargets, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
self.vte.drag_dest_set(Gtk.DestDefaults.MOTION |
Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP,
dsttargets, Gdk.DragAction.COPY | Gdk.DragAction.MOVE)
for widget in [self.vte, self.titlebar]:
widget.connect('drag-begin', self.on_drag_begin, self)
@ -363,7 +363,7 @@ class Terminal(gtk.VBox):
self.vte.connect('focus-out-event', self.on_vte_focus_out)
self.vte.connect('size-allocate', self.deferred_on_vte_size_allocate)
self.vte.add_events(gtk.gdk.ENTER_NOTIFY_MASK)
self.vte.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK)
self.vte.connect('enter_notify_event',
self.on_vte_notify_enter)
@ -386,65 +386,65 @@ class Terminal(gtk.VBox):
def populate_group_menu(self):
"""Fill out a group menu"""
menu = gtk.Menu()
menu = Gtk.Menu()
groupitem = None
item = gtk.MenuItem(_('New group...'))
item = Gtk.MenuItem(_('New group...'))
item.connect('activate', self.create_group)
menu.append(item)
if len(self.terminator.groups) > 0:
groupitem = gtk.RadioMenuItem(groupitem, _('None'))
groupitem = Gtk.RadioMenuItem(groupitem, _('None'))
groupitem.set_active(self.group == None)
groupitem.connect('activate', self.set_group, None)
menu.append(groupitem)
for group in self.terminator.groups:
item = gtk.RadioMenuItem(groupitem, group, False)
item = Gtk.RadioMenuItem(groupitem, group, False)
item.set_active(self.group == group)
item.connect('toggled', self.set_group, group)
menu.append(item)
groupitem = item
if self.group != None or len(self.terminator.groups) > 0:
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
if self.group != None:
item = gtk.MenuItem(_('Remove group %s') % self.group)
item = Gtk.MenuItem(_('Remove group %s') % self.group)
item.connect('activate', self.ungroup, self.group)
menu.append(item)
if util.has_ancestor(self, gtk.Notebook):
item = gtk.MenuItem(_('G_roup all in tab'))
if util.has_ancestor(self, Gtk.Notebook):
item = Gtk.MenuItem(_('G_roup all in tab'))
item.connect('activate', lambda x: self.emit('group_tab'))
menu.append(item)
if len(self.terminator.groups) > 0:
item = gtk.MenuItem(_('Ungr_oup all in tab'))
item = Gtk.MenuItem(_('Ungr_oup all in tab'))
item.connect('activate', lambda x: self.emit('ungroup_tab'))
menu.append(item)
if len(self.terminator.groups) > 0:
item = gtk.MenuItem(_('Remove all groups'))
item = Gtk.MenuItem(_('Remove all groups'))
item.connect('activate', lambda x: self.emit('ungroup-all'))
menu.append(item)
if self.group != None:
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
item = gtk.MenuItem(_('Close group %s') % self.group)
item = Gtk.MenuItem(_('Close group %s') % self.group)
item.connect('activate', lambda x:
self.terminator.closegroupedterms(self.group))
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
groupitem = None
for key, value in {_('Broadcast all'):'all',
_('Broadcast group'):'group',
_('Broadcast off'):'off'}.items():
groupitem = gtk.RadioMenuItem(groupitem, key)
groupitem = Gtk.RadioMenuItem(groupitem, key)
dbg('Terminal::populate_group_menu: %s active: %s' %
(key, self.terminator.groupsend ==
self.terminator.groupsend_type[value]))
@ -454,25 +454,25 @@ class Terminal(gtk.VBox):
self.terminator.groupsend_type[value])
menu.append(groupitem)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
item = gtk.CheckMenuItem(_('Split to this group'))
item = Gtk.CheckMenuItem(_('Split to this group'))
item.set_active(self.config['split_to_group'])
item.connect('toggled', lambda x: self.do_splittogroup_toggle())
menu.append(item)
item = gtk.CheckMenuItem(_('Autoclean groups'))
item = Gtk.CheckMenuItem(_('Autoclean groups'))
item.set_active(self.config['autoclean_groups'])
item.connect('toggled', lambda x: self.do_autocleangroups_toggle())
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
item = gtk.MenuItem(_('Insert terminal number'))
item = Gtk.MenuItem(_('Insert terminal number'))
item.connect('activate', lambda x: self.emit('enumerate', False))
menu.append(item)
item = gtk.MenuItem(_('Insert padded terminal number'))
item = Gtk.MenuItem(_('Insert padded terminal number'))
item.connect('activate', lambda x: self.emit('enumerate', True))
menu.append(item)
@ -480,10 +480,10 @@ class Terminal(gtk.VBox):
def position_popup_group_menu(self, menu, widget):
"""Calculate the position of the group popup menu"""
_screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height()
_screen_w = Gdk.Screen.width()
screen_h = Gdk.Screen.height()
if gtk.gtk_version >= (2, 14):
if Gtk.gtk_version >= (2, 14):
widget_win = widget.get_window()
else:
widget_win = widget.window
@ -612,16 +612,16 @@ class Terminal(gtk.VBox):
font = self.config.get_system_font()
else:
font = self.config['font']
self.set_font(pango.FontDescription(font))
self.set_font(Pango.FontDescription(font))
except:
pass
self.vte.set_allow_bold(self.config['allow_bold'])
if self.config['use_theme_colors']:
self.fgcolor_active = self.vte.get_style().text[gtk.STATE_NORMAL]
self.bgcolor = self.vte.get_style().base[gtk.STATE_NORMAL]
self.fgcolor_active = self.vte.get_style().text[Gtk.StateType.NORMAL]
self.bgcolor = self.vte.get_style().base[Gtk.StateType.NORMAL]
else:
self.fgcolor_active = gtk.gdk.color_parse(self.config['foreground_color'])
self.bgcolor = gtk.gdk.color_parse(self.config['background_color'])
self.fgcolor_active = Gdk.color_parse(self.config['foreground_color'])
self.bgcolor = Gdk.color_parse(self.config['background_color'])
factor = self.config['inactive_color_offset']
if factor > 1.0:
@ -643,7 +643,7 @@ class Terminal(gtk.VBox):
self.palette_inactive = []
for color in colors:
if color:
newcolor = gtk.gdk.color_parse(color)
newcolor = Gdk.color_parse(color)
newcolor_inactive = newcolor.copy()
for bit in ['red', 'green', 'blue']:
setattr(newcolor_inactive, bit,
@ -674,7 +674,7 @@ class Terminal(gtk.VBox):
self.vte.set_scroll_background(False)
if background_type in ('image', 'transparent'):
self.vte.set_background_tint_color(gtk.gdk.color_parse(
self.vte.set_background_tint_color(Gdk.color_parse(
self.config['background_color']))
opacity = int(self.config['background_darkness'] * 65536)
saturation = 1.0 - float(self.config['background_darkness'])
@ -769,7 +769,7 @@ class Terminal(gtk.VBox):
# https://bugzilla.gnome.org/show_bug.cgi?id=614910
pass
elif self.config['cursor_color'] != '':
self.vte.set_color_cursor(gtk.gdk.color_parse(
self.vte.set_color_cursor(Gdk.color_parse(
self.config['cursor_color']))
def get_window_title(self):
@ -779,17 +779,17 @@ class Terminal(gtk.VBox):
def on_group_button_press(self, widget, event):
"""Handler for the group button"""
if event.button == 1:
if event.type == gtk.gdk._2BUTTON_PRESS or \
event.type == gtk.gdk._3BUTTON_PRESS:
if event.type == Gdk._2BUTTON_PRESS or \
event.type == Gdk._3BUTTON_PRESS:
# Ignore these, or they make the interaction bad
return True
# Super key applies interaction to all terms in group
include_siblings=event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK
include_siblings=event.get_state() & Gdk.ModifierType.MOD4_MASK == Gdk.ModifierType.MOD4_MASK
if include_siblings:
targets=self.terminator.get_sibling_terms(self)
else:
targets=[self]
if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
if event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:
dbg('on_group_button_press: toggle terminal to focused terminals group')
focused=self.get_toplevel().get_focussed_terminal()
if focused in targets: targets.remove(focused)
@ -801,12 +801,12 @@ class Terminal(gtk.VBox):
[term.set_group(None, new_group) for term in targets]
[term.titlebar.update(focused) for term in targets]
return True
elif event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK:
elif event.get_state() & Gdk.ModifierType.SHIFT_MASK == Gdk.ModifierType.SHIFT_MASK:
dbg('on_group_button_press: rename of terminals group')
self.targets_for_new_group = targets
self.titlebar.create_group()
return True
elif event.type == gtk.gdk.BUTTON_PRESS:
elif event.type == Gdk.EventType.BUTTON_PRESS:
# Single Click gives popup
dbg('on_group_button_press: group menu popup')
self.create_popup_group_menu(widget, event)
@ -834,7 +834,7 @@ class Terminal(gtk.VBox):
# handle the case where user has re-bound copy to ctrl+<key>
# we only copy if there is a selection otherwise let it fall through
# to ^<key>
if (mapping == "copy" and event.state & gtk.gdk.CONTROL_MASK):
if (mapping == "copy" and event.get_state() & Gdk.ModifierType.CONTROL_MASK):
if self.vte.get_has_selection ():
getattr(self, "key_" + mapping)()
return(True)
@ -863,7 +863,7 @@ class Terminal(gtk.VBox):
if event.button == 1:
# Ctrl+leftclick on a URL should open it
if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
if event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:
url = self.check_for_url(event)
if url:
self.open_url(url, prepare=True)
@ -873,7 +873,7 @@ class Terminal(gtk.VBox):
return(True)
elif event.button == 3:
# rightclick should display a context menu if Ctrl is not pressed
if event.state & gtk.gdk.CONTROL_MASK == 0:
if event.get_state() & Gdk.ModifierType.CONTROL_MASK == 0:
self.popup_menu(widget, event)
return(True)
@ -916,23 +916,23 @@ class Terminal(gtk.VBox):
def on_drag_motion(self, widget, drag_context, x, y, _time, _data):
"""*shrug*"""
if not drag_context.targets == ['vte'] and \
(gtk.targets_include_text(drag_context.targets) or \
gtk.targets_include_uri(drag_context.targets)):
(Gtk.targets_include_text(drag_context.targets) or \
Gtk.targets_include_uri(drag_context.targets)):
# copy text from another widget
return
srcwidget = drag_context.get_source_widget()
if(isinstance(srcwidget, gtk.EventBox) and
if(isinstance(srcwidget, Gtk.EventBox) and
srcwidget == self.titlebar) or widget == srcwidget:
# on self
return
alloc = widget.allocation
rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height)
rect = (0, 0, alloc.width, alloc.height)
if self.config['use_theme_colors']:
color = self.vte.get_style().text[gtk.STATE_NORMAL]
color = self.vte.get_style().text[Gtk.StateType.NORMAL]
else:
color = gtk.gdk.color_parse(self.config['foreground_color'])
color = Gdk.color_parse(self.config['foreground_color'])
pos = self.get_location(widget, x, y)
topleft = (0, 0)
@ -987,8 +987,8 @@ class Terminal(gtk.VBox):
"""Something has been dragged into the terminal. Handle it as either a
URL or another terminal."""
dbg('drag data received of type: %s' % selection_data.type)
if gtk.targets_include_text(drag_context.targets) or \
gtk.targets_include_uri(drag_context.targets):
if Gtk.targets_include_text(drag_context.targets) or \
Gtk.targets_include_uri(drag_context.targets):
# copy text to destination
txt = selection_data.data.strip(' ')
if txt[0:7] == 'file://':
@ -1002,7 +1002,7 @@ class Terminal(gtk.VBox):
widgetsrc = data.terminator.terminals[int(selection_data.data)]
srcvte = drag_context.get_source_widget()
#check if computation requireds
if (isinstance(srcvte, gtk.EventBox) and
if (isinstance(srcvte, Gtk.EventBox) and
srcvte == self.titlebar) or srcvte == widget:
return
@ -1061,7 +1061,7 @@ class Terminal(gtk.VBox):
def grab_focus(self):
"""Steal focus for this terminal"""
if not self.vte.flags()&gtk.HAS_FOCUS:
if not self.vte.flags()&Gtk.HAS_FOCUS:
self.vte.grab_focus()
def ensure_visible_and_focussed(self):
@ -1131,7 +1131,7 @@ class Terminal(gtk.VBox):
if self.pending_on_vte_size_allocate == True:
return
self.pending_on_vte_size_allocate = True
gobject.idle_add(self.do_deferred_on_vte_size_allocate, widget, allocation)
GObject.idle_add(self.do_deferred_on_vte_size_allocate, widget, allocation)
def do_deferred_on_vte_size_allocate(self, widget, allocation):
self.pending_on_vte_size_allocate = False
@ -1379,19 +1379,19 @@ class Terminal(gtk.VBox):
except:
dbg('custom url handler did not work, falling back to defaults')
if gtk.gtk_version < (2, 14, 0) or \
if Gtk.gtk_version < (2, 14, 0) or \
not hasattr(gtk, 'show_uri') or \
not hasattr(gtk.gdk, 'CURRENT_TIME'):
not hasattr(Gtk.gdk, 'CURRENT_TIME'):
oldstyle = True
if oldstyle == False:
try:
gtk.show_uri(None, url, gtk.gdk.CURRENT_TIME)
Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
except:
oldstyle = True
if oldstyle == True:
dbg('Old gtk (%s,%s,%s), calling xdg-open' % gtk.gtk_version)
dbg('Old gtk (%s,%s,%s), calling xdg-open' % Gtk.gtk_version)
try:
subprocess.Popen(["xdg-open", url])
except:
@ -1425,10 +1425,10 @@ class Terminal(gtk.VBox):
pangodesc = self.vte.get_font()
fontsize = pangodesc.get_size()
if fontsize > pango.SCALE and not zoom_in:
fontsize -= pango.SCALE
if fontsize > Pango.SCALE and not zoom_in:
fontsize -= Pango.SCALE
elif zoom_in:
fontsize += pango.SCALE
fontsize += Pango.SCALE
pangodesc.set_size(fontsize)
self.set_font(pangodesc)
@ -1441,7 +1441,7 @@ class Terminal(gtk.VBox):
else:
font = self.config['font']
dbg("Terminal::zoom_orig: restoring font to: %s" % font)
self.set_font(pango.FontDescription(font))
self.set_font(Pango.FontDescription(font))
self.custom_font_size = None
def set_font(self, fontdesc):
@ -1479,7 +1479,7 @@ class Terminal(gtk.VBox):
"""Set the urgency hint for our window"""
if self.config['urgent_bell'] == True:
window = self.get_toplevel()
if window.flags() & gtk.TOPLEVEL:
if window.flags() & Gtk.TOPLEVEL:
window.set_urgency_hint(True)
if self.config['icon_bell'] == True:
self.titlebar.icon_bell()
@ -1722,17 +1722,17 @@ class Terminal(gtk.VBox):
def key_edit_window_title(self):
window = self.get_toplevel()
dialog = gtk.Dialog(_('Rename Window'), window,
gtk.DIALOG_MODAL,
( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT ))
dialog.set_default_response(gtk.RESPONSE_ACCEPT)
dialog = Gtk.Dialog(_('Rename Window'), window,
Gtk.DialogFlags.MODAL,
( Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT ))
dialog.set_default_response(Gtk.ResponseType.ACCEPT)
dialog.set_has_separator(False)
dialog.set_resizable(False)
dialog.set_border_width(8)
label = gtk.Label(_('Enter a new title for the Terminator window...'))
name = gtk.Entry()
label = Gtk.Label(label=_('Enter a new title for the Terminator window...'))
name = Gtk.Entry()
name.set_activates_default(True)
if window.title.text != self.vte.get_window_title():
name.set_text(self.get_toplevel().title.text)
@ -1742,7 +1742,7 @@ class Terminal(gtk.VBox):
dialog.show_all()
res = dialog.run()
if res == gtk.RESPONSE_ACCEPT:
if res == Gtk.ResponseType.ACCEPT:
if name.get_text():
window.title.force_title(None)
window.title.force_title(name.get_text())
@ -1774,5 +1774,5 @@ class Terminal(gtk.VBox):
# End key events
gobject.type_register(Terminal)
GObject.type_register(Terminal)
# vim: set expandtab ts=4 sw=4:

View File

@ -4,7 +4,7 @@
"""terminal_popup_menu.py - classes necessary to provide a terminal context
menu"""
import gtk
from gi.repository import Gtk
from version import APP_NAME
from translation import _
@ -31,7 +31,7 @@ class TerminalPopupMenu(object):
"""Display the context menu"""
terminal = self.terminal
menu = gtk.Menu()
menu = Gtk.Menu()
url = None
button = None
time = None
@ -84,35 +84,35 @@ class TerminalPopupMenu(object):
if not namecopy:
namecopy = _('_Copy address')
icon = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,
gtk.ICON_SIZE_MENU)
item = gtk.ImageMenuItem(nameopen)
icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUMP_TO,
Gtk.IconSize.MENU)
item = Gtk.ImageMenuItem(nameopen)
item.set_property('image', icon)
item.connect('activate', lambda x: terminal.open_url(url, True))
menu.append(item)
item = gtk.MenuItem(namecopy)
item = Gtk.MenuItem(namecopy)
item.connect('activate',
lambda x: terminal.clipboard.set_text(terminal.prepare_url(url)))
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
item = gtk.ImageMenuItem(gtk.STOCK_COPY)
item = Gtk.ImageMenuItem(Gtk.STOCK_COPY)
item.connect('activate', lambda x: terminal.vte.copy_clipboard())
item.set_sensitive(terminal.vte.get_has_selection())
menu.append(item)
item = gtk.ImageMenuItem(gtk.STOCK_PASTE)
item = Gtk.ImageMenuItem(Gtk.STOCK_PASTE)
item.connect('activate', lambda x: terminal.paste_clipboard())
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
if not terminal.is_zoomed():
item = gtk.ImageMenuItem(_('Split H_orizontally'))
image = gtk.Image()
image.set_from_icon_name(APP_NAME + '_horiz', gtk.ICON_SIZE_MENU)
item = Gtk.ImageMenuItem(_('Split H_orizontally'))
image = Gtk.Image()
image.set_from_icon_name(APP_NAME + '_horiz', Gtk.IconSize.MENU)
item.set_image(image)
if hasattr(item, 'set_always_show_image'):
item.set_always_show_image(True)
@ -120,9 +120,9 @@ class TerminalPopupMenu(object):
self.terminator.pid_cwd(self.terminal.pid)))
menu.append(item)
item = gtk.ImageMenuItem(_('Split V_ertically'))
image = gtk.Image()
image.set_from_icon_name(APP_NAME + '_vert', gtk.ICON_SIZE_MENU)
item = Gtk.ImageMenuItem(_('Split V_ertically'))
image = Gtk.Image()
image.set_from_icon_name(APP_NAME + '_vert', Gtk.IconSize.MENU)
item.set_image(image)
if hasattr(item, 'set_always_show_image'):
item.set_always_show_image(True)
@ -130,65 +130,65 @@ class TerminalPopupMenu(object):
self.terminator.pid_cwd(self.terminal.pid)))
menu.append(item)
item = gtk.MenuItem(_('Open _Tab'))
item = Gtk.MenuItem(_('Open _Tab'))
item.connect('activate', lambda x: terminal.emit('tab-new', False,
terminal))
menu.append(item)
if self.terminator.debug_address is not None:
item = gtk.MenuItem(_('Open _Debug Tab'))
item = Gtk.MenuItem(_('Open _Debug Tab'))
item.connect('activate', lambda x:
terminal.emit('tab-new', True, terminal))
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
item = gtk.ImageMenuItem(gtk.STOCK_CLOSE)
item = Gtk.ImageMenuItem(Gtk.STOCK_CLOSE)
item.connect('activate', lambda x: terminal.close())
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
if not terminal.is_zoomed():
item = gtk.MenuItem(_('_Zoom terminal'))
item = Gtk.MenuItem(_('_Zoom terminal'))
item.connect('activate', terminal.zoom)
menu.append(item)
item = gtk.MenuItem(_('Ma_ximise terminal'))
item = Gtk.MenuItem(_('Ma_ximise terminal'))
item.connect('activate', terminal.maximise)
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
else:
item = gtk.MenuItem(_('_Restore all terminals'))
item = Gtk.MenuItem(_('_Restore all terminals'))
item.connect('activate', terminal.unzoom)
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
if self.config['show_titlebar'] == False:
item = gtk.MenuItem(_('Grouping'))
item = Gtk.MenuItem(_('Grouping'))
submenu = self.terminal.populate_group_menu()
submenu.show_all()
item.set_submenu(submenu)
menu.append(item)
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
item = gtk.CheckMenuItem(_('Show _scrollbar'))
item = Gtk.CheckMenuItem(_('Show _scrollbar'))
item.set_active(terminal.scrollbar.get_property('visible'))
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
menu.append(item)
if hasattr(gtk, 'Builder'):
item = gtk.MenuItem(_('_Preferences'))
item = Gtk.MenuItem(_('_Preferences'))
item.connect('activate', lambda x: PrefsEditor(self.terminal))
menu.append(item)
profilelist = self.config.list_profiles()
if len(profilelist) > 1:
item = gtk.MenuItem(_('Profiles'))
submenu = gtk.Menu()
item = Gtk.MenuItem(_('Profiles'))
submenu = Gtk.Menu()
item.set_submenu(submenu)
menu.append(item)
@ -197,7 +197,7 @@ class TerminalPopupMenu(object):
group = None
for profile in profilelist:
item = gtk.RadioMenuItem(group, profile.capitalize())
item = Gtk.RadioMenuItem(group, profile.capitalize())
if profile == current:
item.set_active(True)
item.connect('activate', terminal.force_set_profile, profile)
@ -214,7 +214,7 @@ class TerminalPopupMenu(object):
menuplugin.callback(menuitems, menu, terminal)
if len(menuitems) > 0:
menu.append(gtk.MenuItem())
menu.append(Gtk.MenuItem())
for menuitem in menuitems:
menu.append(menuitem)
@ -231,9 +231,9 @@ class TerminalPopupMenu(object):
"""Add the encoding list to the menu"""
terminal = self.terminal
active_encodings = terminal.config['active_encodings']
item = gtk.MenuItem (_("Encodings"))
item = Gtk.MenuItem (_("Encodings"))
menu.append (item)
submenu = gtk.Menu ()
submenu = Gtk.Menu ()
item.set_submenu (submenu)
encodings = TerminatorEncoding ().get_list ()
encodings.sort (lambda x, y: cmp (x[2].lower (), y[2].lower ()))
@ -253,7 +253,7 @@ class TerminalPopupMenu(object):
else:
extratext = ""
radioitem = gtk.RadioMenuItem (group, _(encoding) + extratext)
radioitem = Gtk.RadioMenuItem (group, _(encoding) + extratext)
if encoding == current_encoding:
radioitem.set_active (True)
@ -265,11 +265,11 @@ class TerminalPopupMenu(object):
encoding)
submenu.append (radioitem)
item = gtk.MenuItem (_("Other Encodings"))
item = Gtk.MenuItem (_("Other Encodings"))
submenu.append (item)
#second level
submenu = gtk.Menu ()
submenu = Gtk.Menu ()
item.set_submenu (submenu)
group = None
@ -282,7 +282,7 @@ class TerminalPopupMenu(object):
else:
label = "%s %s" % (encoding[2], encoding[1])
radioitem = gtk.RadioMenuItem (group, label)
radioitem = Gtk.RadioMenuItem (group, label)
if group is None:
group = radioitem

View File

@ -5,7 +5,7 @@
import copy
import os
import gtk
from gi.repository import Gtk
from borg import Borg
from config import Config
@ -131,7 +131,7 @@ class Terminator(Borg):
if len(self.windows) == 0:
# We have no windows left, we should exit
dbg('no windows remain, quitting')
gtk.main_quit()
Gtk.main_quit()
def register_launcher_window(self, window):
"""Register a new launcher window widget"""
@ -152,7 +152,7 @@ class Terminator(Borg):
if len(self.launcher_windows) == 0 and len(self.windows) == 0:
# We have no windows left, we should exit
dbg('no windows remain, quitting')
gtk.main_quit()
Gtk.main_quit()
def register_terminal(self, terminal):
"""Register a new terminal widget"""
@ -348,13 +348,13 @@ class Terminator(Borg):
"""Update configuration for the whole application"""
if self.config['handle_size'] in xrange(0, 6):
gtk.rc_parse_string("""
Gtk.rc_parse_string("""
style "terminator-paned-style" {
GtkPaned::handle_size = %s
}
class "GtkPaned" style "terminator-paned-style"
""" % self.config['handle_size'])
gtk.rc_reset_styles(gtk.settings_get_default())
Gtk.rc_reset_styles(Gtk.Settings.get_default())
# Cause all the terminals to reconfigure
for terminal in self.terminals:
@ -452,7 +452,7 @@ class Terminator(Borg):
def get_focussed_terminal(self):
"""iterate over all the terminals to find which, if any, has focus"""
for terminal in self.terminals:
if terminal.flags()&gtk.HAS_FOCUS:
if terminal.flags()&Gtk.HAS_FOCUS:
return(terminal)
return(None)

View File

@ -3,8 +3,8 @@
# GPL v2 only
"""titlebar.py - classes necessary to provide a terminal title bar"""
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
import random
import itertools
@ -15,7 +15,7 @@ from editablelabel import EditableLabel
# pylint: disable-msg=R0904
# pylint: disable-msg=W0613
class Titlebar(gtk.EventBox):
class Titlebar(Gtk.EventBox):
"""Class implementing the Titlebar widget"""
terminator = None
@ -32,15 +32,15 @@ class Titlebar(gtk.EventBox):
bellicon = None
__gsignals__ = {
'clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'edit-done': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'create-group': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'clicked': (GObject.SignalFlags.RUN_LAST, None, ()),
'edit-done': (GObject.SignalFlags.RUN_LAST, None, ()),
'create-group': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
}
def __init__(self, terminal):
"""Class initialiser"""
gtk.EventBox.__init__(self)
GObject.GObject.__init__(self)
self.__gobject_init__()
self.terminator = Terminator()
@ -49,14 +49,14 @@ class Titlebar(gtk.EventBox):
self.label = EditableLabel()
self.label.connect('edit-done', self.on_edit_done)
self.ebox = gtk.EventBox()
grouphbox = gtk.HBox()
self.grouplabel = gtk.Label()
self.groupicon = gtk.Image()
self.bellicon = gtk.Image()
self.ebox = Gtk.EventBox()
grouphbox = Gtk.HBox()
self.grouplabel = Gtk.Label()
self.groupicon = Gtk.Image()
self.bellicon = Gtk.Image()
self.bellicon.set_no_show_all(True)
self.groupentry = gtk.Entry()
self.groupentry = Gtk.Entry()
self.groupentry.set_no_show_all(True)
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
self.groupentry.connect('activate', self.groupentry_activate)
@ -70,7 +70,7 @@ class Titlebar(gtk.EventBox):
elif self.terminator.groupsend == groupsend_type['off']:
icon_name = 'off'
self.set_from_icon_name('_active_broadcast_%s' % icon_name,
gtk.ICON_SIZE_MENU)
Gtk.IconSize.MENU)
grouphbox.pack_start(self.groupicon, False, True, 2)
grouphbox.pack_start(self.grouplabel, False, True, 2)
@ -79,10 +79,10 @@ class Titlebar(gtk.EventBox):
self.ebox.add(grouphbox)
self.ebox.show_all()
self.bellicon.set_from_icon_name('terminal-bell', gtk.ICON_SIZE_MENU)
hbox = gtk.HBox()
self.bellicon.set_from_icon_name('terminal-bell', Gtk.IconSize.MENU)
hbox = Gtk.HBox()
hbox.pack_start(self.ebox, False, True, 0)
hbox.pack_start(gtk.VSeparator(), False, True, 0)
hbox.pack_start(Gtk.VSeparator(, True, True, 0), False, True, 0)
hbox.pack_start(self.label, True, True)
hbox.pack_end(self.bellicon, False, False, 2)
@ -152,21 +152,21 @@ class Titlebar(gtk.EventBox):
group_fg = self.config['title_transmit_fg_color']
group_bg = self.config['title_transmit_bg_color']
self.label.modify_fg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(title_fg))
self.grouplabel.modify_fg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(group_fg))
self.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(title_bg))
self.label.modify_fg(Gtk.StateType.NORMAL,
Gdk.color_parse(title_fg))
self.grouplabel.modify_fg(Gtk.StateType.NORMAL,
Gdk.color_parse(group_fg))
self.modify_bg(Gtk.StateType.NORMAL,
Gdk.color_parse(title_bg))
if not self.get_desired_visibility():
if default_bg == True:
color = term.get_style().bg[gtk.STATE_NORMAL]
color = term.get_style().bg[Gtk.StateType.NORMAL]
else:
color = gtk.gdk.color_parse(title_bg)
color = Gdk.color_parse(title_bg)
self.update_visibility()
self.ebox.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(group_bg))
self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU)
self.ebox.modify_bg(Gtk.StateType.NORMAL,
Gdk.color_parse(group_bg))
self.set_from_icon_name(icon, Gtk.IconSize.MENU)
def update_visibility(self):
"""Make the titlebar be visible or not"""
@ -189,7 +189,7 @@ class Titlebar(gtk.EventBox):
dbg('configured visibility: %s' % self.config['show_titlebar'])
return(self.config['show_titlebar'])
def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU):
def set_from_icon_name(self, name, size = Gtk.IconSize.MENU):
"""Set an icon for the group label"""
if not name:
self.groupicon.hide()
@ -280,14 +280,14 @@ class Titlebar(gtk.EventBox):
def groupentry_keypress(self, widget, event):
"""Handle keypresses on the entry widget"""
key = gtk.gdk.keyval_name(event.keyval)
key = Gdk.keyval_name(event.keyval)
if key == 'Escape':
self.groupentry_cancel(None, None)
def icon_bell(self):
"""A bell signal requires we display our bell icon"""
self.bellicon.show()
gobject.timeout_add(1000, self.icon_bell_hide)
GObject.timeout_add(1000, self.icon_bell_hide)
def icon_bell_hide(self):
"""Handle a timeout which means we now hide the bell icon"""
@ -306,4 +306,4 @@ class Titlebar(gtk.EventBox):
self.label.set_text(string)
self.label.set_custom()
gobject.type_register(Titlebar)
GObject.type_register(Titlebar)

View File

@ -24,7 +24,7 @@
"""
import sys
import gtk
from gi.repository import Gtk
import os
import pwd
import inspect
@ -78,8 +78,8 @@ def gerr(message = None):
"""Display a graphical error. This should only be used for serious
errors as it will halt execution"""
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message)
dialog.run()
dialog.destroy()
@ -142,12 +142,12 @@ def shell_lookup():
def widget_pixbuf(widget, maxsize=None):
"""Generate a pixbuf of a widget"""
if gtk.gtk_version < (2, 14):
if Gtk.gtk_version < (2, 14):
return(None)
pixmap = widget.get_snapshot()
(width, height) = pixmap.get_size()
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
pixbuf = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, False, 8, width, height)
pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, width,
height)
@ -159,7 +159,7 @@ def widget_pixbuf(widget, maxsize=None):
if not maxsize or (width * factor) > width or (height * factor) > height:
factor = 1
scaledpixbuf = pixbuf.scale_simple(int(width * factor), int(height * factor), gtk.gdk.INTERP_BILINEAR)
scaledpixbuf = pixbuf.scale_simple(int(width * factor), int(height * factor), GdkPixbuf.InterpType.BILINEAR)
return(scaledpixbuf)

View File

@ -6,10 +6,10 @@
import copy
import time
import uuid
import pygtk
pygtk.require('2.0')
import gobject
import gtk
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GObject
from gi.repository import Gtk
from util import dbg, err, make_uuid
import util
@ -26,7 +26,7 @@ except ImportError:
hide_window shortcut will be unavailable')
# pylint: disable-msg=R0904
class Window(Container, gtk.Window):
class Window(Container, Gtk.Window):
"""Class implementing a top-level Terminator window"""
terminator = None
@ -45,11 +45,11 @@ class Window(Container, gtk.Window):
term_zoomed = False
__gproperties__ = {
'term_zoomed': (gobject.TYPE_BOOLEAN,
'term_zoomed': (GObject.TYPE_BOOLEAN,
'terminal zoomed',
'whether the terminal is zoomed',
False,
gobject.PARAM_READWRITE)
GObject.PARAM_READWRITE)
}
def __init__(self):
@ -58,8 +58,8 @@ class Window(Container, gtk.Window):
self.terminator.register_window(self)
Container.__init__(self)
gtk.Window.__init__(self)
gobject.type_register(Window)
GObject.GObject.__init__(self)
GObject.type_register(Window)
self.register_signals(Window)
self.set_property('allow-shrink', True)
@ -168,34 +168,34 @@ class Window(Container, gtk.Window):
def apply_icon(self, requested_icon):
"""Set the window icon"""
icon_theme = gtk.IconTheme()
icon_theme = Gtk.IconTheme()
icon = None
if requested_icon:
try:
self.set_icon_from_file(requested_icon)
icon = self.get_icon()
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px %s icon as file' % (repr(requested_icon)))
if requested_icon and icon is None:
try:
icon = icon_theme.load_icon(requested_icon, 48, 0)
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px %s icon' % (repr(requested_icon)))
if icon is None:
try:
icon = icon_theme.load_icon(self.wmclass_name, 48, 0)
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px %s icon' % (self.wmclass_name))
if icon is None:
try:
icon = icon_theme.load_icon(APP_NAME, 48, 0)
except (NameError, gobject.GError):
except (NameError, GObject.GError):
dbg('Unable to load 48px Terminator icon')
icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
icon = self.render_icon(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.BUTTON)
self.set_icon(icon)
@ -213,9 +213,9 @@ class Window(Container, gtk.Window):
self.set_fullscreen(not self.isfullscreen)
elif mapping == 'close_window':
if not self.on_delete_event(window,
gtk.gdk.Event(gtk.gdk.DELETE)):
Gdk.Event(Gdk.DELETE)):
self.on_destroy_event(window,
gtk.gdk.Event(gtk.gdk.DESTROY))
Gdk.Event(Gdk.DESTROY))
elif mapping == 'new_tab':
self.tab_new(self.get_focussed_terminal())
else:
@ -284,7 +284,7 @@ class Window(Container, gtk.Window):
"""Display a confirmation dialog when the user is closing multiple
terminals in one window"""
return(not (self.construct_confirm_close(window, type) == gtk.RESPONSE_ACCEPT))
return(not (self.construct_confirm_close(window, type) == Gtk.ResponseType.ACCEPT))
def on_destroy_event(self, widget, data=None):
"""Handle window destruction"""
@ -310,7 +310,7 @@ class Window(Container, gtk.Window):
self.show()
self.grab_focus()
try:
t = gtk.gdk.x11_get_server_time(self.window)
t = GdkX11.x11_get_server_time(self.window)
except AttributeError:
t = 0
self.window.focus(t)
@ -322,9 +322,9 @@ class Window(Container, gtk.Window):
def on_window_state_changed(self, window, event):
"""Handle the state of the window changing"""
self.isfullscreen = bool(event.new_window_state &
gtk.gdk.WINDOW_STATE_FULLSCREEN)
Gdk.WindowState.FULLSCREEN)
self.ismaximised = bool(event.new_window_state &
gtk.gdk.WINDOW_STATE_MAXIMIZED)
Gdk.WindowState.MAXIMIZED)
dbg('Window::on_window_state_changed: fullscreen=%s, maximised=%s' \
% (self.isfullscreen, self.ismaximised))
@ -390,7 +390,7 @@ class Window(Container, gtk.Window):
#Present is necessary to grab focus when window is hidden from taskbar.
#It is important to call present() before show(), otherwise the window
#won't be brought to front if an another application has the focus.
#Last note: present() will implicitly call gtk.Window.show()
#Last note: present() will implicitly call Gtk.Window.show()
self.present()
#Window must be shown, then hidden for the hotkeys to be registered
@ -400,9 +400,9 @@ class Window(Container, gtk.Window):
def add(self, widget, metadata=None):
"""Add a widget to the window by way of gtk.Window.add()"""
"""Add a widget to the window by way of Gtk.Window.add()"""
maker = Factory()
gtk.Window.add(self, widget)
Gtk.Window.add(self, widget)
if maker.isinstance(widget, 'Terminal'):
signals = {'close-term': self.closeterm,
'title-change': self.title.set_title,
@ -431,8 +431,8 @@ class Window(Container, gtk.Window):
widget.grab_focus()
def remove(self, widget):
"""Remove our child widget by way of gtk.Window.remove()"""
gtk.Window.remove(self, widget)
"""Remove our child widget by way of Gtk.Window.remove()"""
Gtk.Window.remove(self, widget)
self.disconnect_child(widget)
return(True)
@ -490,8 +490,8 @@ class Window(Container, gtk.Window):
container.show_all()
sibling.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
while Gtk.events_pending():
Gtk.main_iteration_do(False)
self.set_pos_by_ratio = False
@ -557,8 +557,8 @@ class Window(Container, gtk.Window):
self.show_all()
widget.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
while Gtk.events_pending():
Gtk.main_iteration_do(False)
self.set_pos_by_ratio = False
def get_visible_terminals(self):
@ -601,7 +601,7 @@ class Window(Container, gtk.Window):
if self.pending_set_rough_geometry_hint == True:
return
self.pending_set_rough_geometry_hint = True
gobject.idle_add(self.do_deferred_set_rough_geometry_hints)
GObject.idle_add(self.do_deferred_set_rough_geometry_hints)
def do_deferred_set_rough_geometry_hints(self):
self.pending_set_rough_geometry_hint = False