Changes made by pygi-convert.sh
This commit is contained in:
parent
0091b59150
commit
7ca6dd96c6
10
terminator
10
terminator
|
@ -27,12 +27,12 @@ except OSError:
|
||||||
|
|
||||||
# Check we have simple basics like Gtk+ and a valid $DISPLAY
|
# Check we have simple basics like Gtk+ and a valid $DISPLAY
|
||||||
try:
|
try:
|
||||||
import pygtk
|
import gi
|
||||||
pygtk.require ("2.0")
|
pyGtk.require ("2.0")
|
||||||
# pylint: disable-msg=W0611
|
# pylint: disable-msg=W0611
|
||||||
import gtk, pango, gobject
|
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. ' \
|
print('You need to run terminator in an X environment. ' \
|
||||||
'Make sure $DISPLAY is properly set')
|
'Make sure $DISPLAY is properly set')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -115,12 +115,12 @@ if __name__ == '__main__':
|
||||||
# pylint: disable-msg=W0611
|
# pylint: disable-msg=W0611
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
gtk.gdk.threads_init()
|
Gdk.threads_init()
|
||||||
(DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals())
|
(DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals())
|
||||||
TERMINATOR.debug_address = DEBUGSVR.server_address
|
TERMINATOR.debug_address = DEBUGSVR.server_address
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gtk.main()
|
Gtk.main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ from borg import Borg
|
||||||
from util import dbg, err, DEBUG, get_config_dir, dict_diff
|
from util import dbg, err, DEBUG, get_config_dir, dict_diff
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gconf
|
from gi.repository import GConf
|
||||||
except ImportError:
|
except ImportError:
|
||||||
dbg('Unable to import gconf, GNOME defaults unavailable')
|
dbg('Unable to import gconf, GNOME defaults unavailable')
|
||||||
|
|
||||||
|
@ -344,12 +344,12 @@ class Config(object):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if self.gconf is None:
|
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')
|
'/desktop/gnome/interface/monospace_font_name')
|
||||||
self.system_font = value.get_string()
|
self.system_font = value.get_string()
|
||||||
self.gconf.notify_add(
|
self.GConf.notify_add(
|
||||||
'/desktop/gnome/interface/monospace_font_name',
|
'/desktop/gnome/interface/monospace_font_name',
|
||||||
self.on_gconf_notify)
|
self.on_gconf_notify)
|
||||||
return(self.system_font)
|
return(self.system_font)
|
||||||
|
@ -362,12 +362,12 @@ class Config(object):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if self.gconf is None:
|
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:
|
if value:
|
||||||
self.system_focus = value.get_string()
|
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)
|
self.on_gconf_notify)
|
||||||
return(self.system_focus)
|
return(self.system_focus)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
# GPL v2 only
|
# GPL v2 only
|
||||||
"""container.py - classes necessary to contain Terminal widgets"""
|
"""container.py - classes necessary to contain Terminal widgets"""
|
||||||
|
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from factory import Factory
|
from factory import Factory
|
||||||
from config import Config
|
from config import Config
|
||||||
|
@ -32,7 +32,7 @@ class Container(object):
|
||||||
|
|
||||||
def register_signals(self, widget):
|
def register_signals(self, widget):
|
||||||
"""Register gobject signals in a way that avoids multiple inheritance"""
|
"""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:
|
for signal in self.signals:
|
||||||
if signal['name'] in existing:
|
if signal['name'] in existing:
|
||||||
dbg('Container:: skipping signal %s for %s, already exists' % (
|
dbg('Container:: skipping signal %s for %s, already exists' % (
|
||||||
|
@ -41,7 +41,7 @@ class Container(object):
|
||||||
dbg('Container:: registering signal for %s on %s' %
|
dbg('Container:: registering signal for %s on %s' %
|
||||||
(signal['name'], widget))
|
(signal['name'], widget))
|
||||||
try:
|
try:
|
||||||
gobject.signal_new(signal['name'],
|
GObject.signal_new(signal['name'],
|
||||||
widget,
|
widget,
|
||||||
signal['flags'],
|
signal['flags'],
|
||||||
signal['return_type'],
|
signal['return_type'],
|
||||||
|
@ -158,39 +158,39 @@ class Container(object):
|
||||||
|
|
||||||
# skip this dialog if applicable
|
# skip this dialog if applicable
|
||||||
if self.config['suppress_multiple_term_dialog']:
|
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_has_separator(False)
|
||||||
dialog.set_resizable(False)
|
dialog.set_resizable(False)
|
||||||
|
|
||||||
dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
|
dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
|
||||||
c_all = dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)
|
c_all = dialog.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT)
|
||||||
c_all.get_children()[0].get_children()[0].get_children()[1].set_label(
|
c_all.get_children()[0].get_children()[0].get_children()[1].set_label(
|
||||||
_('Close _Terminals'))
|
_('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_use_markup(True)
|
||||||
primary.set_alignment(0, 0.5)
|
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))
|
the %s will also close all terminals within it.') % (reqtype, reqtype))
|
||||||
secondary.set_line_wrap(True)
|
secondary.set_line_wrap(True)
|
||||||
|
|
||||||
labels = gtk.VBox()
|
labels = Gtk.VBox()
|
||||||
labels.pack_start(primary, False, False, 6)
|
labels.pack_start(primary, False, False, 6)
|
||||||
labels.pack_start(secondary, False, False, 6)
|
labels.pack_start(secondary, False, False, 6)
|
||||||
|
|
||||||
image = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING,
|
image = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_WARNING,
|
||||||
gtk.ICON_SIZE_DIALOG)
|
Gtk.IconSize.DIALOG)
|
||||||
image.set_alignment(0.5, 0)
|
image.set_alignment(0.5, 0)
|
||||||
|
|
||||||
box = gtk.HBox()
|
box = Gtk.HBox()
|
||||||
box.pack_start(image, False, False, 6)
|
box.pack_start(image, False, False, 6)
|
||||||
box.pack_start(labels, False, False, 6)
|
box.pack_start(labels, False, False, 6)
|
||||||
dialog.vbox.pack_start(box, False, False, 12)
|
dialog.vbox.pack_start(box, False, False, 12)
|
||||||
|
|
||||||
checkbox = gtk.CheckButton(_("Do not show this message next time"))
|
checkbox = Gtk.CheckButton(_("Do not show this message next time"))
|
||||||
dialog.vbox.pack_end(checkbox)
|
dialog.vbox.pack_end(checkbox, True, True, 0)
|
||||||
|
|
||||||
dialog.show_all()
|
dialog.show_all()
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
# , Boston, MA 02110-1301 USA
|
# , Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
""" Editable Label class"""
|
""" Editable Label class"""
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
|
|
||||||
class EditableLabel(gtk.EventBox):
|
class EditableLabel(Gtk.EventBox):
|
||||||
# pylint: disable-msg=W0212
|
# pylint: disable-msg=W0212
|
||||||
# pylint: disable-msg=R0904
|
# 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
|
On double-click, the label is editable, entering an empty will revert back to automatic text
|
||||||
"""
|
"""
|
||||||
_label = None
|
_label = None
|
||||||
|
@ -36,16 +36,16 @@ class EditableLabel(gtk.EventBox):
|
||||||
_entry_handler_id = None
|
_entry_handler_id = None
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'edit-done': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'edit-done': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, text = ""):
|
def __init__(self, text = ""):
|
||||||
""" Class initialiser"""
|
""" Class initialiser"""
|
||||||
gtk.EventBox.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.__gobject_init__()
|
self.__gobject_init__()
|
||||||
|
|
||||||
self._entry_handler_id = []
|
self._entry_handler_id = []
|
||||||
self._label = gtk.Label(text)
|
self._label = Gtk.Label(label=text)
|
||||||
self._custom = False
|
self._custom = False
|
||||||
self.set_visible_window (False)
|
self.set_visible_window (False)
|
||||||
self.add (self._label)
|
self.add (self._label)
|
||||||
|
@ -74,9 +74,9 @@ class EditableLabel(gtk.EventBox):
|
||||||
"""event handling text edition"""
|
"""event handling text edition"""
|
||||||
if event.button != 1:
|
if event.button != 1:
|
||||||
return False
|
return False
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS:
|
if event.type == Gdk._2BUTTON_PRESS:
|
||||||
self.remove (self._label)
|
self.remove (self._label)
|
||||||
self._entry = gtk.Entry ()
|
self._entry = Gtk.Entry ()
|
||||||
self._entry.set_text (self._label.get_text ())
|
self._entry.set_text (self._label.get_text ())
|
||||||
self._entry.show ()
|
self._entry.show ()
|
||||||
self.add (self._entry)
|
self.add (self._entry)
|
||||||
|
@ -96,7 +96,7 @@ class EditableLabel(gtk.EventBox):
|
||||||
|
|
||||||
def _entry_to_label (self, widget, event):
|
def _entry_to_label (self, widget, event):
|
||||||
# pylint: disable-msg=W0613
|
# 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():
|
if self._entry and self._entry in self.get_children():
|
||||||
#disconnect signals to avoid segfault :s
|
#disconnect signals to avoid segfault :s
|
||||||
for sig in self._entry_handler_id:
|
for sig in self._entry_handler_id:
|
||||||
|
@ -113,7 +113,7 @@ class EditableLabel(gtk.EventBox):
|
||||||
|
|
||||||
def _on_entry_activated (self, widget):
|
def _on_entry_activated (self, widget):
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
"""get the text entered in gtk.Entry"""
|
"""get the text entered in Gtk.Entry"""
|
||||||
entry = self._entry.get_text ()
|
entry = self._entry.get_text ()
|
||||||
label = self._label.get_text ()
|
label = self._label.get_text ()
|
||||||
if entry == '':
|
if entry == '':
|
||||||
|
@ -126,13 +126,13 @@ class EditableLabel(gtk.EventBox):
|
||||||
|
|
||||||
def _on_entry_keypress (self, widget, event):
|
def _on_entry_keypress (self, widget, event):
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
"""handle keypressed in gtk.Entry"""
|
"""handle keypressed in Gtk.Entry"""
|
||||||
key = gtk.gdk.keyval_name (event.keyval)
|
key = Gdk.keyval_name (event.keyval)
|
||||||
if key == 'Escape':
|
if key == 'Escape':
|
||||||
self._entry_to_label (None, None)
|
self._entry_to_label (None, None)
|
||||||
|
|
||||||
def _on_entry_buttonpress (self, widget, event):
|
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.
|
# Block right clicks to avoid a deadlock.
|
||||||
# The correct solution here would be for _entry_to_label to trigger a
|
# 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
|
# deferred execution handler and for that handler to check if focus is
|
||||||
|
@ -152,4 +152,4 @@ class EditableLabel(gtk.EventBox):
|
||||||
def set_custom(self):
|
def set_custom(self):
|
||||||
"""Set the customness of the string to True"""
|
"""Set the customness of the string to True"""
|
||||||
self._custom = True
|
self._custom = True
|
||||||
gobject.type_register(EditableLabel)
|
GObject.type_register(EditableLabel)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# GPL v2 only
|
# GPL v2 only
|
||||||
"""ipc.py - DBus server and API calls"""
|
"""ipc.py - DBus server and API calls"""
|
||||||
|
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import dbus.service
|
import dbus.service
|
||||||
from dbus.exceptions import DBusException
|
from dbus.exceptions import DBusException
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
|
@ -23,7 +23,7 @@ BUS_BASE = 'net.tenshu.Terminator'
|
||||||
BUS_PATH = '/net/tenshu/Terminator'
|
BUS_PATH = '/net/tenshu/Terminator'
|
||||||
try:
|
try:
|
||||||
# Try and include the X11 display name in the dbus bus name
|
# 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)
|
BUS_NAME = '%s%s' % (BUS_BASE, DISPLAY)
|
||||||
except:
|
except:
|
||||||
BUS_NAME = BUS_BASE
|
BUS_NAME = BUS_BASE
|
||||||
|
|
|
@ -23,7 +23,7 @@ keyboard shortcuts.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
from util import err
|
from util import err
|
||||||
|
|
||||||
class KeymapError(Exception):
|
class KeymapError(Exception):
|
||||||
|
@ -34,12 +34,12 @@ class Keybindings:
|
||||||
"""Class to handle loading and lookup of Terminator keybindings"""
|
"""Class to handle loading and lookup of Terminator keybindings"""
|
||||||
|
|
||||||
modifiers = {
|
modifiers = {
|
||||||
'ctrl': gtk.gdk.CONTROL_MASK,
|
'ctrl': Gdk.ModifierType.CONTROL_MASK,
|
||||||
'control': gtk.gdk.CONTROL_MASK,
|
'control': Gdk.ModifierType.CONTROL_MASK,
|
||||||
'primary': gtk.gdk.CONTROL_MASK,
|
'primary': Gdk.ModifierType.CONTROL_MASK,
|
||||||
'shift': gtk.gdk.SHIFT_MASK,
|
'shift': Gdk.ModifierType.SHIFT_MASK,
|
||||||
'alt': gtk.gdk.MOD1_MASK,
|
'alt': Gdk.ModifierType.MOD1_MASK,
|
||||||
'super': gtk.gdk.SUPER_MASK,
|
'super': Gdk.EventMask.SUPER_MASK,
|
||||||
}
|
}
|
||||||
|
|
||||||
empty = {}
|
empty = {}
|
||||||
|
@ -48,7 +48,7 @@ class Keybindings:
|
||||||
_lookup = None
|
_lookup = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.keymap = gtk.gdk.keymap_get_default()
|
self.keymap = Gdk.keymap_get_default()
|
||||||
self.configure({})
|
self.configure({})
|
||||||
|
|
||||||
def configure(self, bindings):
|
def configure(self, bindings):
|
||||||
|
@ -71,21 +71,21 @@ class Keybindings:
|
||||||
try:
|
try:
|
||||||
keyval, mask = self._parsebinding(binding)
|
keyval, mask = self._parsebinding(binding)
|
||||||
# Does much the same, but with poorer error handling.
|
# 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:
|
except KeymapError as e:
|
||||||
err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e))
|
err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e))
|
||||||
else:
|
else:
|
||||||
if mask & gtk.gdk.SHIFT_MASK:
|
if mask & Gdk.ModifierType.SHIFT_MASK:
|
||||||
if keyval == gtk.keysyms.Tab:
|
if keyval == Gdk.KEY_Tab:
|
||||||
keyval = gtk.keysyms.ISO_Left_Tab
|
keyval = Gdk.KEY_ISO_Left_Tab
|
||||||
mask &= ~gtk.gdk.SHIFT_MASK
|
mask &= ~Gdk.ModifierType.SHIFT_MASK
|
||||||
else:
|
else:
|
||||||
keyvals = gtk.gdk.keyval_convert_case(keyval)
|
keyvals = Gdk.keyval_convert_case(keyval)
|
||||||
if keyvals[0] != keyvals[1]:
|
if keyvals[0] != keyvals[1]:
|
||||||
keyval = keyvals[1]
|
keyval = keyvals[1]
|
||||||
mask &= ~gtk.gdk.SHIFT_MASK
|
mask &= ~Gdk.ModifierType.SHIFT_MASK
|
||||||
else:
|
else:
|
||||||
keyval = gtk.gdk.keyval_to_lower(keyval)
|
keyval = Gdk.keyval_to_lower(keyval)
|
||||||
self._lookup.setdefault(mask, {})
|
self._lookup.setdefault(mask, {})
|
||||||
self._lookup[mask][keyval] = action
|
self._lookup[mask][keyval] = action
|
||||||
self._masks |= mask
|
self._masks |= mask
|
||||||
|
@ -100,7 +100,7 @@ class Keybindings:
|
||||||
key = re.sub(MODIFIER, '', binding)
|
key = re.sub(MODIFIER, '', binding)
|
||||||
if key == '':
|
if key == '':
|
||||||
raise KeymapError('No key found')
|
raise KeymapError('No key found')
|
||||||
keyval = gtk.gdk.keyval_from_name(key)
|
keyval = Gdk.keyval_from_name(key)
|
||||||
if keyval == 0:
|
if keyval == 0:
|
||||||
raise KeymapError("Key '%s' is unrecognised" % key)
|
raise KeymapError("Key '%s' is unrecognised" % key)
|
||||||
return (keyval, mask)
|
return (keyval, mask)
|
||||||
|
@ -117,12 +117,12 @@ class Keybindings:
|
||||||
try:
|
try:
|
||||||
keyval, _egp, _lvl, consumed = self.keymap.translate_keyboard_state(
|
keyval, _egp, _lvl, consumed = self.keymap.translate_keyboard_state(
|
||||||
event.hardware_keycode,
|
event.hardware_keycode,
|
||||||
event.state & ~gtk.gdk.LOCK_MASK,
|
event.get_state() & ~Gdk.ModifierType.LOCK_MASK,
|
||||||
event.group)
|
event.group)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
err ("keybindings.lookup failed to translate keyboard event: %s" %
|
err ("keybindings.lookup failed to translate keyboard event: %s" %
|
||||||
dir(event))
|
dir(event))
|
||||||
return None
|
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)
|
return self._lookup.get(mask, self.empty).get(keyval, None)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"""layoutlauncher.py - class for the Layout Launcher window"""
|
"""layoutlauncher.py - class for the Layout Launcher window"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
|
|
||||||
from util import dbg, err, spawn_new_terminator
|
from util import dbg, err, spawn_new_terminator
|
||||||
import config
|
import config
|
||||||
|
@ -31,7 +31,7 @@ class LayoutLauncher:
|
||||||
|
|
||||||
self.config = config.Config()
|
self.config = config.Config()
|
||||||
self.config.base.reload()
|
self.config.base.reload()
|
||||||
self.builder = gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
try:
|
try:
|
||||||
# Figure out where our library is on-disk so we can open our UI
|
# Figure out where our library is on-disk so we can open our UI
|
||||||
(head, _tail) = os.path.split(config.__file__)
|
(head, _tail) = os.path.split(config.__file__)
|
||||||
|
@ -46,12 +46,12 @@ class LayoutLauncher:
|
||||||
self.builder.add_from_string(gladedata)
|
self.builder.add_from_string(gladedata)
|
||||||
self.window = self.builder.get_object('layoutlauncherwin')
|
self.window = self.builder.get_object('layoutlauncherwin')
|
||||||
|
|
||||||
icon_theme = gtk.IconTheme()
|
icon_theme = Gtk.IconTheme()
|
||||||
try:
|
try:
|
||||||
icon = icon_theme.load_icon('terminator-layout', 48, 0)
|
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')
|
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.window.set_icon(icon)
|
||||||
|
|
||||||
self.builder.connect_signals(self)
|
self.builder.connect_signals(self)
|
||||||
|
@ -105,4 +105,4 @@ if __name__ == '__main__':
|
||||||
import terminal
|
import terminal
|
||||||
LAYOUTLAUNCHER = LayoutLauncher()
|
LAYOUTLAUNCHER = LayoutLauncher()
|
||||||
|
|
||||||
gtk.main()
|
Gtk.main()
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
# GPL v2 only
|
# GPL v2 only
|
||||||
"""notebook.py - classes for the notebook widget"""
|
"""notebook.py - classes for the notebook widget"""
|
||||||
|
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from terminator import Terminator
|
from terminator import Terminator
|
||||||
from config import Config
|
from config import Config
|
||||||
|
@ -14,8 +14,8 @@ from editablelabel import EditableLabel
|
||||||
from translation import _
|
from translation import _
|
||||||
from util import err, dbg, enumerate_descendants, make_uuid
|
from util import err, dbg, enumerate_descendants, make_uuid
|
||||||
|
|
||||||
class Notebook(Container, gtk.Notebook):
|
class Notebook(Container, Gtk.Notebook):
|
||||||
"""Class implementing a gtk.Notebook container"""
|
"""Class implementing a Gtk.Notebook container"""
|
||||||
window = None
|
window = None
|
||||||
last_active_term = None
|
last_active_term = None
|
||||||
pending_on_tab_switch = None
|
pending_on_tab_switch = None
|
||||||
|
@ -23,15 +23,15 @@ class Notebook(Container, gtk.Notebook):
|
||||||
|
|
||||||
def __init__(self, window):
|
def __init__(self, window):
|
||||||
"""Class initialiser"""
|
"""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')
|
err('There is already a Notebook at the top of this window')
|
||||||
raise(ValueError)
|
raise(ValueError)
|
||||||
|
|
||||||
Container.__init__(self)
|
Container.__init__(self)
|
||||||
gtk.Notebook.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
self.window = window
|
self.window = window
|
||||||
gobject.type_register(Notebook)
|
GObject.type_register(Notebook)
|
||||||
self.register_signals(Notebook)
|
self.register_signals(Notebook)
|
||||||
self.connect('switch-page', self.deferred_on_tab_switch)
|
self.connect('switch-page', self.deferred_on_tab_switch)
|
||||||
self.configure()
|
self.configure()
|
||||||
|
@ -66,7 +66,7 @@ class Notebook(Container, gtk.Notebook):
|
||||||
label = self.get_tab_label(self.get_nth_page(tab))
|
label = self.get_tab_label(self.get_nth_page(tab))
|
||||||
label.update_angle()
|
label.update_angle()
|
||||||
|
|
||||||
style = gtk.RcStyle()
|
style = Gtk.RcStyle()
|
||||||
style.xthickness = 0
|
style.xthickness = 0
|
||||||
style.ythickness = 0
|
style.ythickness = 0
|
||||||
self.modify_style(style)
|
self.modify_style(style)
|
||||||
|
@ -132,7 +132,7 @@ class Notebook(Container, gtk.Notebook):
|
||||||
|
|
||||||
if layout.has_key('active_page'):
|
if layout.has_key('active_page'):
|
||||||
# Need to do it later, or layout changes result
|
# 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:
|
else:
|
||||||
self.set_current_page(0)
|
self.set_current_page(0)
|
||||||
|
|
||||||
|
@ -180,11 +180,11 @@ class Notebook(Container, gtk.Notebook):
|
||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
while gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration_do(False)
|
Gtk.main_iteration_do(False)
|
||||||
self.get_toplevel().set_pos_by_ratio = 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):
|
def add(self, widget, metadata=None):
|
||||||
"""Add a widget to the container"""
|
"""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(term_widget, label)
|
||||||
self.set_tab_label_packing(term_widget, not self.config['scroll_tabbar'],
|
self.set_tab_label_packing(term_widget, not self.config['scroll_tabbar'],
|
||||||
not self.config['scroll_tabbar'],
|
not self.config['scroll_tabbar'],
|
||||||
gtk.PACK_START)
|
Gtk.PACK_START)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.set_tab_reorderable(widget, True)
|
self.set_tab_reorderable(widget, True)
|
||||||
|
@ -343,7 +343,7 @@ class Notebook(Container, gtk.Notebook):
|
||||||
dbg('Notebook::closetab: child is a Container')
|
dbg('Notebook::closetab: child is a Container')
|
||||||
result = self.construct_confirm_close(self.window, _('tab'))
|
result = self.construct_confirm_close(self.window, _('tab'))
|
||||||
|
|
||||||
if result == gtk.RESPONSE_ACCEPT:
|
if result == Gtk.ResponseType.ACCEPT:
|
||||||
containers = None
|
containers = None
|
||||||
objects = None
|
objects = None
|
||||||
containers, objects = enumerate_descendants(child)
|
containers, objects = enumerate_descendants(child)
|
||||||
|
@ -351,8 +351,8 @@ class Notebook(Container, gtk.Notebook):
|
||||||
while len(objects) > 0:
|
while len(objects) > 0:
|
||||||
descendant = objects.pop()
|
descendant = objects.pop()
|
||||||
descendant.close()
|
descendant.close()
|
||||||
while gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
dbg('Notebook::closetab: user cancelled request')
|
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)
|
self.pending_on_tab_switch_args = (notebook, page, page_num, data)
|
||||||
if self.pending_on_tab_switch == True:
|
if self.pending_on_tab_switch == True:
|
||||||
return
|
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
|
self.pending_on_tab_switch = True
|
||||||
|
|
||||||
def do_deferred_on_tab_switch(self):
|
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']
|
tabs_last_active_term = data['tabs_last_active_term']
|
||||||
if tabs_last_active_term:
|
if tabs_last_active_term:
|
||||||
term = self.terminator.find_terminal_by_uuid(tabs_last_active_term.urn)
|
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
|
return True
|
||||||
|
|
||||||
class TabLabel(gtk.HBox):
|
class TabLabel(Gtk.HBox):
|
||||||
"""Class implementing a label widget for Notebook tabs"""
|
"""Class implementing a label widget for Notebook tabs"""
|
||||||
notebook = None
|
notebook = None
|
||||||
terminator = None
|
terminator = None
|
||||||
|
@ -490,13 +490,13 @@ class TabLabel(gtk.HBox):
|
||||||
button = None
|
button = None
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'close-clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'close-clicked': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_OBJECT,)),
|
(GObject.TYPE_OBJECT,)),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, title, notebook):
|
def __init__(self, title, notebook):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
gtk.HBox.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.__gobject_init__()
|
self.__gobject_init__()
|
||||||
|
|
||||||
self.notebook = notebook
|
self.notebook = notebook
|
||||||
|
@ -543,15 +543,15 @@ class TabLabel(gtk.HBox):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.button:
|
if not self.button:
|
||||||
self.button = gtk.Button()
|
self.button = Gtk.Button()
|
||||||
if not self.icon:
|
if not self.icon:
|
||||||
self.icon = gtk.Image()
|
self.icon = Gtk.Image()
|
||||||
self.icon.set_from_stock(gtk.STOCK_CLOSE,
|
self.icon.set_from_stock(Gtk.STOCK_CLOSE,
|
||||||
gtk.ICON_SIZE_MENU)
|
Gtk.IconSize.MENU)
|
||||||
|
|
||||||
self.button.set_focus_on_click(False)
|
self.button.set_focus_on_click(False)
|
||||||
self.button.set_relief(gtk.RELIEF_NONE)
|
self.button.set_relief(Gtk.ReliefStyle.NONE)
|
||||||
style = gtk.RcStyle()
|
style = Gtk.RcStyle()
|
||||||
style.xthickness = 0
|
style.xthickness = 0
|
||||||
style.ythickness = 0
|
style.ythickness = 0
|
||||||
self.button.modify_style(style)
|
self.button.modify_style(style)
|
||||||
|
@ -566,17 +566,17 @@ class TabLabel(gtk.HBox):
|
||||||
def update_angle(self):
|
def update_angle(self):
|
||||||
"""Update the angle of a label"""
|
"""Update the angle of a label"""
|
||||||
position = self.notebook.get_tab_pos()
|
position = self.notebook.get_tab_pos()
|
||||||
if position == gtk.POS_LEFT:
|
if position == Gtk.PositionType.LEFT:
|
||||||
if hasattr(self, 'set_orientation'):
|
if hasattr(self, 'set_orientation'):
|
||||||
self.set_orientation(gtk.ORIENTATION_VERTICAL)
|
self.set_orientation(Gtk.Orientation.VERTICAL)
|
||||||
self.label.set_angle(90)
|
self.label.set_angle(90)
|
||||||
elif position == gtk.POS_RIGHT:
|
elif position == Gtk.PositionType.RIGHT:
|
||||||
if hasattr(self, 'set_orientation'):
|
if hasattr(self, 'set_orientation'):
|
||||||
self.set_orientation(gtk.ORIENTATION_VERTICAL)
|
self.set_orientation(Gtk.Orientation.VERTICAL)
|
||||||
self.label.set_angle(270)
|
self.label.set_angle(270)
|
||||||
else:
|
else:
|
||||||
if hasattr(self, 'set_orientation'):
|
if hasattr(self, 'set_orientation'):
|
||||||
self.set_orientation(gtk.ORIENTATION_HORIZONTAL)
|
self.set_orientation(Gtk.Orientation.HORIZONTAL)
|
||||||
self.label.set_angle(0)
|
self.label.set_angle(0)
|
||||||
|
|
||||||
def on_close(self, _widget):
|
def on_close(self, _widget):
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"""paned.py - a base Paned container class and the vertical/horizontal
|
"""paned.py - a base Paned container class and the vertical/horizontal
|
||||||
variants"""
|
variants"""
|
||||||
|
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from util import dbg, err
|
from util import dbg, err
|
||||||
from terminator import Terminator
|
from terminator import Terminator
|
||||||
|
@ -27,9 +27,9 @@ class Paned(Container):
|
||||||
self.maker = Factory()
|
self.maker = Factory()
|
||||||
Container.__init__(self)
|
Container.__init__(self)
|
||||||
self.signals.append({'name': 'resize-term',
|
self.signals.append({'name': 'resize-term',
|
||||||
'flags': gobject.SIGNAL_RUN_LAST,
|
'flags': GObject.SignalFlags.RUN_LAST,
|
||||||
'return_type': gobject.TYPE_NONE,
|
'return_type': None,
|
||||||
'param_types': (gobject.TYPE_STRING,)})
|
'param_types': (GObject.TYPE_STRING,)})
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
|
@ -68,8 +68,8 @@ class Paned(Container):
|
||||||
self.show_all()
|
self.show_all()
|
||||||
sibling.grab_focus()
|
sibling.grab_focus()
|
||||||
|
|
||||||
while gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration_do(False)
|
Gtk.main_iteration_do(False)
|
||||||
self.get_toplevel().set_pos_by_ratio = False
|
self.get_toplevel().set_pos_by_ratio = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class Paned(Container):
|
||||||
metadata['had_focus'] == True:
|
metadata['had_focus'] == True:
|
||||||
widget.grab_focus()
|
widget.grab_focus()
|
||||||
|
|
||||||
elif isinstance(widget, gtk.Paned):
|
elif isinstance(widget, Gtk.Paned):
|
||||||
try:
|
try:
|
||||||
self.connect_child(widget, 'resize-term', self.resizeterm)
|
self.connect_child(widget, 'resize-term', self.resizeterm)
|
||||||
self.connect_child(widget, 'size-allocate', self.new_size)
|
self.connect_child(widget, 'size-allocate', self.new_size)
|
||||||
|
@ -132,21 +132,21 @@ class Paned(Container):
|
||||||
|
|
||||||
def on_button_press(self, widget, event):
|
def on_button_press(self, widget, event):
|
||||||
"""Handle button presses on a Pane"""
|
"""Handle button presses on a Pane"""
|
||||||
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
if event.button == 1 and event.type == Gdk._2BUTTON_PRESS:
|
||||||
if event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK:
|
if event.get_state() & Gdk.ModifierType.MOD4_MASK == Gdk.ModifierType.MOD4_MASK:
|
||||||
recurse_up=True
|
recurse_up=True
|
||||||
else:
|
else:
|
||||||
recurse_up=False
|
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
|
recurse_down=True
|
||||||
else:
|
else:
|
||||||
recurse_down=False
|
recurse_down=False
|
||||||
|
|
||||||
# FIXME: These idle events are creating a lot of weird issues
|
# FIXME: These idle events are creating a lot of weird issues
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
while gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration_do(False)
|
Gtk.main_iteration_do(False)
|
||||||
self.do_redistribute(recurse_up, recurse_down)
|
self.do_redistribute(recurse_up, recurse_down)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -166,10 +166,10 @@ class Paned(Container):
|
||||||
if grandfather != self.get_toplevel():
|
if grandfather != self.get_toplevel():
|
||||||
grandfather.do_redistribute(recurse_up, recurse_down)
|
grandfather.do_redistribute(recurse_up, recurse_down)
|
||||||
|
|
||||||
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():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration_do(False)
|
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)
|
||||||
|
|
||||||
def _do_redistribute(self, recurse_up=False, recurse_down=False):
|
def _do_redistribute(self, recurse_up=False, recurse_down=False):
|
||||||
maker = Factory()
|
maker = Factory()
|
||||||
|
@ -195,7 +195,7 @@ class Paned(Container):
|
||||||
if recurse_down and \
|
if recurse_down and \
|
||||||
(maker.isinstance(child, 'VPaned') or \
|
(maker.isinstance(child, 'VPaned') or \
|
||||||
maker.isinstance(child, 'HPaned')):
|
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
|
#3 Get ancestor x/y => a, and handle size => hs
|
||||||
avail_pixels=self.get_length()
|
avail_pixels=self.get_length()
|
||||||
|
@ -214,11 +214,11 @@ class Paned(Container):
|
||||||
toproc.append(child)
|
toproc.append(child)
|
||||||
if curr[1].index(child) == 0:
|
if curr[1].index(child) == 0:
|
||||||
curr[0].set_position((child[2]*single_size)+((child[2]-1)*handle_size))
|
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):
|
def remove(self, widget):
|
||||||
"""Remove a widget from the container"""
|
"""Remove a widget from the container"""
|
||||||
gtk.Paned.remove(self, widget)
|
Gtk.Paned.remove(self, widget)
|
||||||
self.disconnect_child(widget)
|
self.disconnect_child(widget)
|
||||||
self.children.remove(widget)
|
self.children.remove(widget)
|
||||||
return(True)
|
return(True)
|
||||||
|
@ -267,7 +267,7 @@ class Paned(Container):
|
||||||
|
|
||||||
def resizeterm(self, widget, keyname):
|
def resizeterm(self, widget, keyname):
|
||||||
"""Handle a keyboard event requesting a terminal resize"""
|
"""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
|
# This is a key we can handle
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class Paned(Container):
|
||||||
self.set_position(position - fontheight)
|
self.set_position(position - fontheight)
|
||||||
else:
|
else:
|
||||||
self.set_position(position + fontheight)
|
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
|
# This is a key we can handle
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
|
|
||||||
|
@ -396,12 +396,12 @@ class Paned(Container):
|
||||||
self.ratio = float(pos) / self.get_length()
|
self.ratio = float(pos) / self.get_length()
|
||||||
self.set_pos(pos)
|
self.set_pos(pos)
|
||||||
|
|
||||||
class HPaned(Paned, gtk.HPaned):
|
class HPaned(Paned, Gtk.HPaned):
|
||||||
"""Merge gtk.HPaned into our base Paned Container"""
|
"""Merge Gtk.HPaned into our base Paned Container"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
Paned.__init__(self)
|
Paned.__init__(self)
|
||||||
gtk.HPaned.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.register_signals(HPaned)
|
self.register_signals(HPaned)
|
||||||
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
||||||
|
|
||||||
|
@ -409,14 +409,14 @@ class HPaned(Paned, gtk.HPaned):
|
||||||
return(self.allocation.width)
|
return(self.allocation.width)
|
||||||
|
|
||||||
def set_pos(self, pos):
|
def set_pos(self, pos):
|
||||||
gtk.HPaned.set_position(self, pos)
|
Gtk.HPaned.set_position(self, pos)
|
||||||
|
|
||||||
class VPaned(Paned, gtk.VPaned):
|
class VPaned(Paned, Gtk.VPaned):
|
||||||
"""Merge gtk.VPaned into our base Paned Container"""
|
"""Merge Gtk.VPaned into our base Paned Container"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
Paned.__init__(self)
|
Paned.__init__(self)
|
||||||
gtk.VPaned.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.register_signals(VPaned)
|
self.register_signals(VPaned)
|
||||||
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
self.cnxids.new(self, 'button-press-event', self.on_button_press)
|
||||||
|
|
||||||
|
@ -424,8 +424,8 @@ class VPaned(Paned, gtk.VPaned):
|
||||||
return(self.allocation.height)
|
return(self.allocation.height)
|
||||||
|
|
||||||
def set_pos(self, pos):
|
def set_pos(self, pos):
|
||||||
gtk.VPaned.set_position(self, pos)
|
Gtk.VPaned.set_position(self, pos)
|
||||||
|
|
||||||
gobject.type_register(HPaned)
|
GObject.type_register(HPaned)
|
||||||
gobject.type_register(VPaned)
|
GObject.type_register(VPaned)
|
||||||
# vim: set expandtab ts=4 sw=4:
|
# vim: set expandtab ts=4 sw=4:
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"""activitywatch.py - Terminator Plugin to watch a terminal for activity"""
|
"""activitywatch.py - Terminator Plugin to watch a terminal for activity"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
|
|
||||||
import terminatorlib.plugin as plugin
|
import terminatorlib.plugin as plugin
|
||||||
from terminatorlib.translation import _
|
from terminatorlib.translation import _
|
||||||
|
@ -13,7 +13,7 @@ from terminatorlib.util import err, dbg
|
||||||
from terminatorlib.version import APP_NAME
|
from terminatorlib.version import APP_NAME
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pynotify
|
from gi.repository import Notify
|
||||||
# Every plugin you want Terminator to load *must* be listed in 'AVAILABLE'
|
# 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
|
# This is inside this try so we only make the plugin available if pynotify
|
||||||
# is present on this computer.
|
# is present on this computer.
|
||||||
|
@ -37,15 +37,15 @@ class ActivityWatch(plugin.MenuItem):
|
||||||
if not self.timers:
|
if not self.timers:
|
||||||
self.timers = {}
|
self.timers = {}
|
||||||
|
|
||||||
pynotify.init(APP_NAME.capitalize())
|
Notify.init(APP_NAME.capitalize())
|
||||||
|
|
||||||
def callback(self, menuitems, menu, terminal):
|
def callback(self, menuitems, menu, terminal):
|
||||||
"""Add our menu items to the menu"""
|
"""Add our menu items to the menu"""
|
||||||
if not self.watches.has_key(terminal):
|
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)
|
item.connect("activate", self.watch, terminal)
|
||||||
else:
|
else:
|
||||||
item = gtk.MenuItem(_('Stop watching for activity'))
|
item = Gtk.MenuItem(_('Stop watching for activity'))
|
||||||
item.connect("activate", self.unwatch, terminal)
|
item.connect("activate", self.unwatch, terminal)
|
||||||
menuitems.append(item)
|
menuitems.append(item)
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@ class ActivityWatch(plugin.MenuItem):
|
||||||
show_notify = False
|
show_notify = False
|
||||||
|
|
||||||
# Don't notify if the user is already looking at this terminal.
|
# 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
|
return True
|
||||||
|
|
||||||
note = pynotify.Notification('Terminator', 'Activity in: %s' %
|
note = Notify.Notification('Terminator', 'Activity in: %s' %
|
||||||
terminal.get_window_title(), 'terminator')
|
terminal.get_window_title(), 'terminator')
|
||||||
|
|
||||||
this_time = time.mktime(time.gmtime())
|
this_time = time.mktime(time.gmtime())
|
||||||
|
@ -102,15 +102,15 @@ class InactivityWatch(plugin.MenuItem):
|
||||||
if not self.timers:
|
if not self.timers:
|
||||||
self.timers = {}
|
self.timers = {}
|
||||||
|
|
||||||
pynotify.init(APP_NAME.capitalize())
|
Notify.init(APP_NAME.capitalize())
|
||||||
|
|
||||||
def callback(self, menuitems, menu, terminal):
|
def callback(self, menuitems, menu, terminal):
|
||||||
"""Add our menu items to the menu"""
|
"""Add our menu items to the menu"""
|
||||||
if not self.watches.has_key(terminal):
|
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)
|
item.connect("activate", self.watch, terminal)
|
||||||
else:
|
else:
|
||||||
item = gtk.MenuItem(_("Stop watching for silence"))
|
item = Gtk.MenuItem(_("Stop watching for silence"))
|
||||||
item.connect("activate", self.unwatch, terminal)
|
item.connect("activate", self.unwatch, terminal)
|
||||||
menuitems.append(item)
|
menuitems.append(item)
|
||||||
dbg('Menu items appended')
|
dbg('Menu items appended')
|
||||||
|
@ -120,7 +120,7 @@ class InactivityWatch(plugin.MenuItem):
|
||||||
vte = terminal.get_vte()
|
vte = terminal.get_vte()
|
||||||
self.watches[terminal] = vte.connect('contents-changed',
|
self.watches[terminal] = vte.connect('contents-changed',
|
||||||
self.reset_timer, terminal)
|
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
|
self.timers[terminal] = timeout_id
|
||||||
dbg('timer %s added for %s' %(timeout_id, terminal))
|
dbg('timer %s added for %s' %(timeout_id, terminal))
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class InactivityWatch(plugin.MenuItem):
|
||||||
vte = terminal.get_vte()
|
vte = terminal.get_vte()
|
||||||
vte.disconnect(self.watches[terminal])
|
vte.disconnect(self.watches[terminal])
|
||||||
del(self.watches[terminal])
|
del(self.watches[terminal])
|
||||||
gobject.source_remove(self.timers[terminal])
|
GObject.source_remove(self.timers[terminal])
|
||||||
del(self.timers[terminal])
|
del(self.timers[terminal])
|
||||||
|
|
||||||
def reset_timer(self, _vte, 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))
|
dbg('seconds since last activity: %f (%s)' % (time_now - self.last_activities[terminal], terminal))
|
||||||
if time_now - self.last_activities[terminal] >= 10.0:
|
if time_now - self.last_activities[terminal] >= 10.0:
|
||||||
del(self.last_activities[terminal])
|
del(self.last_activities[terminal])
|
||||||
note = pynotify.Notification('Terminator', 'Silence in: %s' %
|
note = Notify.Notification('Terminator', 'Silence in: %s' %
|
||||||
terminal.get_window_title(), 'terminator')
|
terminal.get_window_title(), 'terminator')
|
||||||
note.show()
|
note.show()
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import os
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.path.append( os.path.join(os.path.dirname(__file__), "../.."))
|
sys.path.append( os.path.join(os.path.dirname(__file__), "../.."))
|
||||||
|
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import terminatorlib.plugin as plugin
|
import terminatorlib.plugin as plugin
|
||||||
from terminatorlib.config import Config
|
from terminatorlib.config import Config
|
||||||
from terminatorlib.translation import _
|
from terminatorlib.translation import _
|
||||||
|
@ -58,32 +58,32 @@ class CustomCommandsMenu(plugin.MenuItem):
|
||||||
|
|
||||||
def callback(self, menuitems, menu, terminal):
|
def callback(self, menuitems, menu, terminal):
|
||||||
"""Add our menu items to the menu"""
|
"""Add our menu items to the menu"""
|
||||||
item = gtk.MenuItem(_('Custom Commands'))
|
item = Gtk.MenuItem(_('Custom Commands'))
|
||||||
menuitems.append(item)
|
menuitems.append(item)
|
||||||
|
|
||||||
submenu = gtk.Menu()
|
submenu = Gtk.Menu()
|
||||||
item.set_submenu(submenu)
|
item.set_submenu(submenu)
|
||||||
|
|
||||||
menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
|
menuitem = Gtk.ImageMenuItem(Gtk.STOCK_PREFERENCES)
|
||||||
menuitem.connect("activate", self.configure)
|
menuitem.connect("activate", self.configure)
|
||||||
submenu.append(menuitem)
|
submenu.append(menuitem)
|
||||||
|
|
||||||
menuitem = gtk.SeparatorMenuItem()
|
menuitem = Gtk.SeparatorMenuItem()
|
||||||
submenu.append(menuitem)
|
submenu.append(menuitem)
|
||||||
|
|
||||||
theme = gtk.IconTheme()
|
theme = Gtk.IconTheme()
|
||||||
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
|
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
|
||||||
if not command['enabled']:
|
if not command['enabled']:
|
||||||
continue
|
continue
|
||||||
exe = command['command'].split(' ')[0]
|
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:
|
if iconinfo:
|
||||||
image = gtk.Image()
|
image = Gtk.Image()
|
||||||
image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
|
image.set_from_icon_name(exe, Gtk.IconSize.MENU)
|
||||||
menuitem = gtk.ImageMenuItem(command['name'])
|
menuitem = Gtk.ImageMenuItem(command['name'])
|
||||||
menuitem.set_image(image)
|
menuitem.set_image(image)
|
||||||
else:
|
else:
|
||||||
menuitem = gtk.MenuItem(command["name"])
|
menuitem = Gtk.MenuItem(command["name"])
|
||||||
menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
|
menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
|
||||||
submenu.append(menuitem)
|
submenu.append(menuitem)
|
||||||
|
|
||||||
|
@ -114,91 +114,91 @@ class CustomCommandsMenu(plugin.MenuItem):
|
||||||
|
|
||||||
def configure(self, widget, data = None):
|
def configure(self, widget, data = None):
|
||||||
ui = {}
|
ui = {}
|
||||||
dbox = gtk.Dialog(
|
dbox = Gtk.Dialog(
|
||||||
_("Custom Commands Configuration"),
|
_("Custom Commands Configuration"),
|
||||||
None,
|
None,
|
||||||
gtk.DIALOG_MODAL,
|
Gtk.DialogFlags.MODAL,
|
||||||
(
|
(
|
||||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
|
||||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
|
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
icon_theme = gtk.IconTheme()
|
icon_theme = Gtk.IconTheme()
|
||||||
try:
|
try:
|
||||||
icon = icon_theme.load_icon('terminator-custom-commands', 48, 0)
|
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')
|
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)
|
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()) ]:
|
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ]:
|
||||||
store.append([command['enabled'], command['name'], command['command']])
|
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)
|
#treeview.connect("cursor-changed", self.on_cursor_changed, ui)
|
||||||
selection = treeview.get_selection()
|
selection = treeview.get_selection()
|
||||||
selection.set_mode(gtk.SELECTION_SINGLE)
|
selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||||
selection.connect("changed", self.on_selection_changed, ui)
|
selection.connect("changed", self.on_selection_changed, ui)
|
||||||
ui['treeview'] = treeview
|
ui['treeview'] = treeview
|
||||||
|
|
||||||
renderer = gtk.CellRendererToggle()
|
renderer = Gtk.CellRendererToggle()
|
||||||
renderer.connect('toggled', self.on_toggled, ui)
|
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)
|
treeview.append_column(column)
|
||||||
|
|
||||||
renderer = gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
column = gtk.TreeViewColumn("Name", renderer, text=CC_COL_NAME)
|
column = Gtk.TreeViewColumn("Name", renderer, text=CC_COL_NAME)
|
||||||
treeview.append_column(column)
|
treeview.append_column(column)
|
||||||
|
|
||||||
renderer = gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
column = gtk.TreeViewColumn("Command", renderer, text=CC_COL_COMMAND)
|
column = Gtk.TreeViewColumn("Command", renderer, text=CC_COL_COMMAND)
|
||||||
treeview.append_column(column)
|
treeview.append_column(column)
|
||||||
|
|
||||||
hbox = gtk.HBox()
|
hbox = Gtk.HBox()
|
||||||
hbox.pack_start(treeview)
|
hbox.pack_start(treeview, True, True, 0)
|
||||||
dbox.vbox.pack_start(hbox)
|
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_box.pack_start(button, False, True)
|
||||||
button.connect("clicked", self.on_goto_top, ui)
|
button.connect("clicked", self.on_goto_top, ui)
|
||||||
button.set_sensitive(False)
|
button.set_sensitive(False)
|
||||||
ui['button_top'] = button
|
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_box.pack_start(button, False, True)
|
||||||
button.connect("clicked", self.on_go_up, ui)
|
button.connect("clicked", self.on_go_up, ui)
|
||||||
button.set_sensitive(False)
|
button.set_sensitive(False)
|
||||||
ui['button_up'] = button
|
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_box.pack_start(button, False, True)
|
||||||
button.connect("clicked", self.on_go_down, ui)
|
button.connect("clicked", self.on_go_down, ui)
|
||||||
button.set_sensitive(False)
|
button.set_sensitive(False)
|
||||||
ui['button_down'] = button
|
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_box.pack_start(button, False, True)
|
||||||
button.connect("clicked", self.on_goto_last, ui)
|
button.connect("clicked", self.on_goto_last, ui)
|
||||||
button.set_sensitive(False)
|
button.set_sensitive(False)
|
||||||
ui['button_last'] = button
|
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_box.pack_start(button, False, True)
|
||||||
button.connect("clicked", self.on_new, ui)
|
button.connect("clicked", self.on_new, ui)
|
||||||
ui['button_new'] = button
|
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_box.pack_start(button, False, True)
|
||||||
button.set_sensitive(False)
|
button.set_sensitive(False)
|
||||||
button.connect("clicked", self.on_edit, ui)
|
button.connect("clicked", self.on_edit, ui)
|
||||||
ui['button_edit'] = button
|
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_box.pack_start(button, False, True)
|
||||||
button.connect("clicked", self.on_delete, ui)
|
button.connect("clicked", self.on_delete, ui)
|
||||||
button.set_sensitive(False)
|
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()
|
dbox.show_all()
|
||||||
res = dbox.run()
|
res = dbox.run()
|
||||||
if res == gtk.RESPONSE_ACCEPT:
|
if res == Gtk.ResponseType.ACCEPT:
|
||||||
self.update_cmd_list(store)
|
self.update_cmd_list(store)
|
||||||
self._save_config()
|
self._save_config()
|
||||||
dbox.destroy()
|
dbox.destroy()
|
||||||
|
@ -255,44 +255,44 @@ class CustomCommandsMenu(plugin.MenuItem):
|
||||||
data['button_delete'].set_sensitive(iter is not None)
|
data['button_delete'].set_sensitive(iter is not None)
|
||||||
|
|
||||||
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
|
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
|
||||||
dialog = gtk.Dialog(
|
dialog = Gtk.Dialog(
|
||||||
_("New Command"),
|
_("New Command"),
|
||||||
None,
|
None,
|
||||||
gtk.DIALOG_MODAL,
|
Gtk.DialogFlags.MODAL,
|
||||||
(
|
(
|
||||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
|
||||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
|
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)
|
table.attach(label, 0, 1, 0, 1)
|
||||||
enabled = gtk.CheckButton()
|
enabled = Gtk.CheckButton()
|
||||||
enabled.set_active(enabled_var)
|
enabled.set_active(enabled_var)
|
||||||
table.attach(enabled, 1, 2, 0, 1)
|
table.attach(enabled, 1, 2, 0, 1)
|
||||||
|
|
||||||
label = gtk.Label(_("Name:"))
|
label = Gtk.Label(label=_("Name:"))
|
||||||
table.attach(label, 0, 1, 1, 2)
|
table.attach(label, 0, 1, 1, 2)
|
||||||
name = gtk.Entry()
|
name = Gtk.Entry()
|
||||||
name.set_text(name_var)
|
name.set_text(name_var)
|
||||||
table.attach(name, 1, 2, 1, 2)
|
table.attach(name, 1, 2, 1, 2)
|
||||||
|
|
||||||
label = gtk.Label(_("Command:"))
|
label = Gtk.Label(label=_("Command:"))
|
||||||
table.attach(label, 0, 1, 2, 3)
|
table.attach(label, 0, 1, 2, 3)
|
||||||
command = gtk.Entry()
|
command = Gtk.Entry()
|
||||||
command.set_text(command_var)
|
command.set_text(command_var)
|
||||||
table.attach(command, 1, 2, 2, 3)
|
table.attach(command, 1, 2, 2, 3)
|
||||||
|
|
||||||
dialog.vbox.pack_start(table)
|
dialog.vbox.pack_start(table, True, True, 0)
|
||||||
dialog.show_all()
|
dialog.show_all()
|
||||||
return (dialog,enabled,name,command)
|
return (dialog,enabled,name,command)
|
||||||
|
|
||||||
def _error(self, msg):
|
def _error(self, msg):
|
||||||
err = gtk.MessageDialog(dialog,
|
err = Gtk.MessageDialog(dialog,
|
||||||
gtk.DIALOG_MODAL,
|
Gtk.DialogFlags.MODAL,
|
||||||
gtk.MESSAGE_ERROR,
|
Gtk.MessageType.ERROR,
|
||||||
gtk.BUTTONS_CLOSE,
|
Gtk.ButtonsType.CLOSE,
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
err.run()
|
err.run()
|
||||||
|
@ -305,15 +305,15 @@ class CustomCommandsMenu(plugin.MenuItem):
|
||||||
(dialog,enabled,name,command) = self._create_command_dialog()
|
(dialog,enabled,name,command) = self._create_command_dialog()
|
||||||
res = dialog.run()
|
res = dialog.run()
|
||||||
item = {}
|
item = {}
|
||||||
if res == gtk.RESPONSE_ACCEPT:
|
if res == Gtk.ResponseType.ACCEPT:
|
||||||
item['enabled'] = enabled.get_active()
|
item['enabled'] = enabled.get_active()
|
||||||
item['name'] = name.get_text()
|
item['name'] = name.get_text()
|
||||||
item['command'] = command.get_text()
|
item['command'] = command.get_text()
|
||||||
if item['name'] == '' or item['command'] == '':
|
if item['name'] == '' or item['command'] == '':
|
||||||
err = gtk.MessageDialog(dialog,
|
err = Gtk.MessageDialog(dialog,
|
||||||
gtk.DIALOG_MODAL,
|
Gtk.DialogFlags.MODAL,
|
||||||
gtk.MESSAGE_ERROR,
|
Gtk.MessageType.ERROR,
|
||||||
gtk.BUTTONS_CLOSE,
|
Gtk.ButtonsType.CLOSE,
|
||||||
_("You need to define a name and command")
|
_("You need to define a name and command")
|
||||||
)
|
)
|
||||||
err.run()
|
err.run()
|
||||||
|
@ -415,15 +415,15 @@ class CustomCommandsMenu(plugin.MenuItem):
|
||||||
)
|
)
|
||||||
res = dialog.run()
|
res = dialog.run()
|
||||||
item = {}
|
item = {}
|
||||||
if res == gtk.RESPONSE_ACCEPT:
|
if res == Gtk.ResponseType.ACCEPT:
|
||||||
item['enabled'] = enabled.get_active()
|
item['enabled'] = enabled.get_active()
|
||||||
item['name'] = name.get_text()
|
item['name'] = name.get_text()
|
||||||
item['command'] = command.get_text()
|
item['command'] = command.get_text()
|
||||||
if item['name'] == '' or item['command'] == '':
|
if item['name'] == '' or item['command'] == '':
|
||||||
err = gtk.MessageDialog(dialog,
|
err = Gtk.MessageDialog(dialog,
|
||||||
gtk.DIALOG_MODAL,
|
Gtk.DialogFlags.MODAL,
|
||||||
gtk.MESSAGE_ERROR,
|
Gtk.MessageType.ERROR,
|
||||||
gtk.BUTTONS_CLOSE,
|
Gtk.ButtonsType.CLOSE,
|
||||||
_("You need to define a name and command")
|
_("You need to define a name and command")
|
||||||
)
|
)
|
||||||
err.run()
|
err.run()
|
||||||
|
@ -451,5 +451,5 @@ class CustomCommandsMenu(plugin.MenuItem):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
c = CustomCommandsMenu()
|
c = CustomCommandsMenu()
|
||||||
c.configure(None, None)
|
c.configure(None, None)
|
||||||
gtk.main()
|
Gtk.main()
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ terminals """
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import terminatorlib.plugin as plugin
|
import terminatorlib.plugin as plugin
|
||||||
from terminatorlib.translation import _
|
from terminatorlib.translation import _
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ class Logger(plugin.MenuItem):
|
||||||
""" Add custom command to the terminal menu"""
|
""" Add custom command to the terminal menu"""
|
||||||
capabilities = ['terminal_menu']
|
capabilities = ['terminal_menu']
|
||||||
loggers = None
|
loggers = None
|
||||||
dialog_action = gtk.FILE_CHOOSER_ACTION_SAVE
|
dialog_action = Gtk.FileChooserAction.SAVE
|
||||||
dialog_buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
dialog_buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
plugin.MenuItem.__init__(self)
|
plugin.MenuItem.__init__(self)
|
||||||
|
@ -31,10 +31,10 @@ class Logger(plugin.MenuItem):
|
||||||
""" Add save menu item to the menu"""
|
""" Add save menu item to the menu"""
|
||||||
vte_terminal = terminal.get_vte()
|
vte_terminal = terminal.get_vte()
|
||||||
if not self.loggers.has_key(vte_terminal):
|
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)
|
item.connect("activate", self.start_logger, terminal)
|
||||||
else:
|
else:
|
||||||
item = gtk.MenuItem(_('Stop Logger'))
|
item = Gtk.MenuItem(_('Stop Logger'))
|
||||||
item.connect("activate", self.stop_logger, terminal)
|
item.connect("activate", self.stop_logger, terminal)
|
||||||
item.set_has_tooltip(True)
|
item.set_has_tooltip(True)
|
||||||
item.set_tooltip_text("Saving at '" + self.loggers[vte_terminal]["filepath"] + "'")
|
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):
|
def start_logger(self, _widget, Terminal):
|
||||||
""" Handle menu item callback by saving text to a file"""
|
""" 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,
|
action=self.dialog_action,
|
||||||
buttons=self.dialog_buttons)
|
buttons=self.dialog_buttons)
|
||||||
savedialog.set_do_overwrite_confirmation(True)
|
savedialog.set_do_overwrite_confirmation(True)
|
||||||
savedialog.set_local_only(True)
|
savedialog.set_local_only(True)
|
||||||
savedialog.show_all()
|
savedialog.show_all()
|
||||||
response = savedialog.run()
|
response = savedialog.run()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == Gtk.ResponseType.OK:
|
||||||
try:
|
try:
|
||||||
logfile = os.path.join(savedialog.get_current_folder(),
|
logfile = os.path.join(savedialog.get_current_folder(),
|
||||||
savedialog.get_filename())
|
savedialog.get_filename())
|
||||||
|
@ -88,8 +88,8 @@ class Logger(plugin.MenuItem):
|
||||||
self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
|
self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
|
||||||
except:
|
except:
|
||||||
e = sys.exc_info()[1]
|
e = sys.exc_info()[1]
|
||||||
error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
error = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
|
||||||
gtk.BUTTONS_OK, e.strerror)
|
Gtk.ButtonsType.OK, e.strerror)
|
||||||
error.run()
|
error.run()
|
||||||
error.destroy()
|
error.destroy()
|
||||||
savedialog.destroy()
|
savedialog.destroy()
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
terminals"""
|
terminals"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import terminatorlib.plugin as plugin
|
import terminatorlib.plugin as plugin
|
||||||
from terminatorlib.translation import _
|
from terminatorlib.translation import _
|
||||||
from terminatorlib.util import widget_pixbuf
|
from terminatorlib.util import widget_pixbuf
|
||||||
|
@ -16,16 +16,16 @@ AVAILABLE = ['TerminalShot']
|
||||||
class TerminalShot(plugin.MenuItem):
|
class TerminalShot(plugin.MenuItem):
|
||||||
"""Add custom commands to the terminal menu"""
|
"""Add custom commands to the terminal menu"""
|
||||||
capabilities = ['terminal_menu']
|
capabilities = ['terminal_menu']
|
||||||
dialog_action = gtk.FILE_CHOOSER_ACTION_SAVE
|
dialog_action = Gtk.FileChooserAction.SAVE
|
||||||
dialog_buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
dialog_buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
plugin.MenuItem.__init__(self)
|
plugin.MenuItem.__init__(self)
|
||||||
|
|
||||||
def callback(self, menuitems, menu, terminal):
|
def callback(self, menuitems, menu, terminal):
|
||||||
"""Add our menu items to the menu"""
|
"""Add our menu items to the menu"""
|
||||||
item = gtk.MenuItem(_('Terminal screenshot'))
|
item = Gtk.MenuItem(_('Terminal screenshot'))
|
||||||
item.connect("activate", self.terminalshot, terminal)
|
item.connect("activate", self.terminalshot, terminal)
|
||||||
menuitems.append(item)
|
menuitems.append(item)
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class TerminalShot(plugin.MenuItem):
|
||||||
# Grab a pixbuf of the terminal
|
# Grab a pixbuf of the terminal
|
||||||
orig_pixbuf = widget_pixbuf(terminal)
|
orig_pixbuf = widget_pixbuf(terminal)
|
||||||
|
|
||||||
savedialog = gtk.FileChooserDialog(title="Save image",
|
savedialog = Gtk.FileChooserDialog(title="Save image",
|
||||||
action=self.dialog_action,
|
action=self.dialog_action,
|
||||||
buttons=self.dialog_buttons)
|
buttons=self.dialog_buttons)
|
||||||
savedialog.set_do_overwrite_confirmation(True)
|
savedialog.set_do_overwrite_confirmation(True)
|
||||||
|
@ -42,14 +42,14 @@ class TerminalShot(plugin.MenuItem):
|
||||||
|
|
||||||
pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
|
pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
|
||||||
orig_pixbuf.get_height() / 2,
|
orig_pixbuf.get_height() / 2,
|
||||||
gtk.gdk.INTERP_BILINEAR)
|
GdkPixbuf.InterpType.BILINEAR)
|
||||||
image = gtk.image_new_from_pixbuf(pixbuf)
|
image = Gtk.image_new_from_pixbuf(pixbuf)
|
||||||
savedialog.set_preview_widget(image)
|
savedialog.set_preview_widget(image)
|
||||||
|
|
||||||
savedialog.show_all()
|
savedialog.show_all()
|
||||||
response = savedialog.run()
|
response = savedialog.run()
|
||||||
path = None
|
path = None
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == Gtk.ResponseType.OK:
|
||||||
path = os.path.join(savedialog.get_current_folder(),
|
path = os.path.join(savedialog.get_current_folder(),
|
||||||
savedialog.get_filename())
|
savedialog.get_filename())
|
||||||
orig_pixbuf.save(path, 'png')
|
orig_pixbuf.save(path, 'png')
|
||||||
|
|
|
@ -8,8 +8,8 @@ write it to a config file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
|
|
||||||
from util import dbg, err
|
from util import dbg, err
|
||||||
import config
|
import config
|
||||||
|
@ -154,7 +154,7 @@ class PrefsEditor:
|
||||||
self.config = config.Config()
|
self.config = config.Config()
|
||||||
self.config.base.reload()
|
self.config.base.reload()
|
||||||
self.term = term
|
self.term = term
|
||||||
self.builder = gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.keybindings = Keybindings()
|
self.keybindings = Keybindings()
|
||||||
try:
|
try:
|
||||||
# Figure out where our library is on-disk so we can open our
|
# 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.builder.add_from_string(gladedata)
|
||||||
self.window = self.builder.get_object('prefswin')
|
self.window = self.builder.get_object('prefswin')
|
||||||
|
|
||||||
icon_theme = gtk.IconTheme()
|
icon_theme = Gtk.IconTheme()
|
||||||
try:
|
try:
|
||||||
icon = icon_theme.load_icon('terminator-preferences', 48, 0)
|
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')
|
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.window.set_icon(icon)
|
||||||
|
|
||||||
self.layouteditor = LayoutEditor(self.builder)
|
self.layouteditor = LayoutEditor(self.builder)
|
||||||
|
@ -314,7 +314,7 @@ class PrefsEditor:
|
||||||
## Keybindings tab
|
## Keybindings tab
|
||||||
widget = guiget('keybindingtreeview')
|
widget = guiget('keybindingtreeview')
|
||||||
liststore = widget.get_model()
|
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']
|
keybindings = self.config['keybindings']
|
||||||
for keybinding in keybindings:
|
for keybinding in keybindings:
|
||||||
keyval = 0
|
keyval = 0
|
||||||
|
@ -410,10 +410,10 @@ class PrefsEditor:
|
||||||
# Cursor colour
|
# Cursor colour
|
||||||
widget = guiget('cursor_color')
|
widget = guiget('cursor_color')
|
||||||
try:
|
try:
|
||||||
widget.set_color(gtk.gdk.Color(self.config['cursor_color']))
|
widget.set_color(Gdk.Color(self.config['cursor_color']))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.config['cursor_color'] = "#FFFFFF"
|
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
|
## Command tab
|
||||||
# Login shell
|
# Login shell
|
||||||
|
@ -462,14 +462,14 @@ class PrefsEditor:
|
||||||
# NOTE: The scheme is set in the GUI widget after the fore/back colours
|
# NOTE: The scheme is set in the GUI widget after the fore/back colours
|
||||||
# Foreground color
|
# Foreground color
|
||||||
widget = guiget('foreground_colorpicker')
|
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':
|
if scheme == 'custom':
|
||||||
widget.set_sensitive(True)
|
widget.set_sensitive(True)
|
||||||
else:
|
else:
|
||||||
widget.set_sensitive(False)
|
widget.set_sensitive(False)
|
||||||
# Background color
|
# Background color
|
||||||
widget = guiget('background_colorpicker')
|
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':
|
if scheme == 'custom':
|
||||||
widget.set_sensitive(True)
|
widget.set_sensitive(True)
|
||||||
else:
|
else:
|
||||||
|
@ -493,7 +493,7 @@ class PrefsEditor:
|
||||||
colourpalette = self.config['palette'].split(':')
|
colourpalette = self.config['palette'].split(':')
|
||||||
for i in xrange(1, 17):
|
for i in xrange(1, 17):
|
||||||
widget = guiget('palette_colorpicker_%d' % i)
|
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
|
# Now set the palette selector widget
|
||||||
widget = guiget('palette_combobox')
|
widget = guiget('palette_combobox')
|
||||||
widget.set_active(self.palettevalues[palette])
|
widget.set_active(self.palettevalues[palette])
|
||||||
|
@ -502,7 +502,7 @@ class PrefsEditor:
|
||||||
'title_receive_fg_color', 'title_receive_bg_color',
|
'title_receive_fg_color', 'title_receive_bg_color',
|
||||||
'title_inactive_fg_color', 'title_inactive_bg_color']:
|
'title_inactive_fg_color', 'title_inactive_bg_color']:
|
||||||
widget = guiget(bit)
|
widget = guiget(bit)
|
||||||
widget.set_color(gtk.gdk.Color(self.config[bit]))
|
widget.set_color(Gdk.Color(self.config[bit]))
|
||||||
# Inactive terminal shading
|
# Inactive terminal shading
|
||||||
widget = guiget('inactive_color_offset')
|
widget = guiget('inactive_color_offset')
|
||||||
widget.set_value(float(self.config['inactive_color_offset']))
|
widget.set_value(float(self.config['inactive_color_offset']))
|
||||||
|
@ -845,7 +845,7 @@ class PrefsEditor:
|
||||||
for num in xrange(1, 17):
|
for num in xrange(1, 17):
|
||||||
# Update the visible elements
|
# Update the visible elements
|
||||||
picker = guiget('palette_colorpicker_%d' % num)
|
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':
|
elif value == 'custom':
|
||||||
palettebits = []
|
palettebits = []
|
||||||
for num in xrange(1, 17):
|
for num in xrange(1, 17):
|
||||||
|
@ -1334,8 +1334,8 @@ class PrefsEditor:
|
||||||
err('Unknown colourscheme value: %s' % value)
|
err('Unknown colourscheme value: %s' % value)
|
||||||
return
|
return
|
||||||
|
|
||||||
fore.set_color(gtk.gdk.Color(forecol))
|
fore.set_color(Gdk.Color(forecol))
|
||||||
back.set_color(gtk.gdk.Color(backcol))
|
back.set_color(Gdk.Color(backcol))
|
||||||
|
|
||||||
self.config['foreground_color'] = forecol
|
self.config['foreground_color'] = forecol
|
||||||
self.config['background_color'] = backcol
|
self.config['background_color'] = backcol
|
||||||
|
@ -1366,7 +1366,7 @@ class PrefsEditor:
|
||||||
liststore.set(celliter, 2, key, 3, mods)
|
liststore.set(celliter, 2, key, 3, mods)
|
||||||
|
|
||||||
binding = liststore.get_value(liststore.get_iter(path), 0)
|
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['keybindings'][binding] = accel
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
||||||
|
@ -1554,4 +1554,4 @@ if __name__ == '__main__':
|
||||||
TERM = terminal.Terminal()
|
TERM = terminal.Terminal()
|
||||||
PREFEDIT = PrefsEditor(TERM)
|
PREFEDIT = PrefsEditor(TERM)
|
||||||
|
|
||||||
gtk.main()
|
Gtk.main()
|
||||||
|
|
|
@ -3,19 +3,19 @@
|
||||||
# GPL v2 only
|
# GPL v2 only
|
||||||
"""searchbar.py - classes necessary to provide a terminal search bar"""
|
"""searchbar.py - classes necessary to provide a terminal search bar"""
|
||||||
|
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from translation import _
|
from translation import _
|
||||||
from config import Config
|
from config import Config
|
||||||
|
|
||||||
# pylint: disable-msg=R0904
|
# pylint: disable-msg=R0904
|
||||||
class Searchbar(gtk.HBox):
|
class Searchbar(Gtk.HBox):
|
||||||
"""Class implementing the Searchbar widget"""
|
"""Class implementing the Searchbar widget"""
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'end-search': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'end-search': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = None
|
entry = None
|
||||||
|
@ -34,32 +34,32 @@ class Searchbar(gtk.HBox):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
gtk.HBox.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.__gobject_init__()
|
self.__gobject_init__()
|
||||||
|
|
||||||
self.config = Config()
|
self.config = Config()
|
||||||
|
|
||||||
# Search text
|
# Search text
|
||||||
self.entry = gtk.Entry()
|
self.entry = Gtk.Entry()
|
||||||
self.entry.set_activates_default(True)
|
self.entry.set_activates_default(True)
|
||||||
self.entry.show()
|
self.entry.show()
|
||||||
self.entry.connect('activate', self.do_search)
|
self.entry.connect('activate', self.do_search)
|
||||||
self.entry.connect('key-press-event', self.search_keypress)
|
self.entry.connect('key-press-event', self.search_keypress)
|
||||||
|
|
||||||
# Label
|
# Label
|
||||||
label = gtk.Label(_('Search:'))
|
label = Gtk.Label(label=_('Search:'))
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
# Result label
|
# Result label
|
||||||
self.reslabel = gtk.Label('')
|
self.reslabel = Gtk.Label(label='')
|
||||||
self.reslabel.show()
|
self.reslabel.show()
|
||||||
|
|
||||||
# Close Button
|
# Close Button
|
||||||
close = gtk.Button()
|
close = Gtk.Button()
|
||||||
close.set_relief(gtk.RELIEF_NONE)
|
close.set_relief(Gtk.ReliefStyle.NONE)
|
||||||
close.set_focus_on_click(False)
|
close.set_focus_on_click(False)
|
||||||
icon = gtk.Image()
|
icon = Gtk.Image()
|
||||||
icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
|
icon.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
|
||||||
close.add(icon)
|
close.add(icon)
|
||||||
close.set_name('terminator-search-close-button')
|
close.set_name('terminator-search-close-button')
|
||||||
if hasattr(close, 'set_tooltip_text'):
|
if hasattr(close, 'set_tooltip_text'):
|
||||||
|
@ -68,19 +68,19 @@ class Searchbar(gtk.HBox):
|
||||||
close.show_all()
|
close.show_all()
|
||||||
|
|
||||||
# Next Button
|
# Next Button
|
||||||
self.next = gtk.Button(_('Next'))
|
self.next = Gtk.Button(_('Next'))
|
||||||
self.next.show()
|
self.next.show()
|
||||||
self.next.set_sensitive(False)
|
self.next.set_sensitive(False)
|
||||||
self.next.connect('clicked', self.next_search)
|
self.next.connect('clicked', self.next_search)
|
||||||
|
|
||||||
# Previous Button
|
# Previous Button
|
||||||
self.prev = gtk.Button(_('Prev'))
|
self.prev = Gtk.Button(_('Prev'))
|
||||||
self.prev.show()
|
self.prev.show()
|
||||||
self.prev.set_sensitive(False)
|
self.prev.set_sensitive(False)
|
||||||
self.prev.connect('clicked', self.prev_search)
|
self.prev.connect('clicked', self.prev_search)
|
||||||
|
|
||||||
self.pack_start(label, False)
|
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.reslabel, False)
|
||||||
self.pack_start(self.prev, False, False)
|
self.pack_start(self.prev, False, False)
|
||||||
self.pack_start(self.next, False, False)
|
self.pack_start(self.next, False, False)
|
||||||
|
@ -98,7 +98,7 @@ class Searchbar(gtk.HBox):
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
def search_keypress(self, widget, event):
|
def search_keypress(self, widget, event):
|
||||||
"""Handle keypress events"""
|
"""Handle keypress events"""
|
||||||
key = gtk.gdk.keyval_name(event.keyval)
|
key = Gdk.keyval_name(event.keyval)
|
||||||
if key == 'Escape':
|
if key == 'Escape':
|
||||||
self.end_search()
|
self.end_search()
|
||||||
|
|
||||||
|
@ -198,4 +198,4 @@ class Searchbar(gtk.HBox):
|
||||||
"""Return the currently set search term"""
|
"""Return the currently set search term"""
|
||||||
return(self.entry.get_text())
|
return(self.entry.get_text())
|
||||||
|
|
||||||
gobject.type_register(Searchbar)
|
GObject.type_register(Searchbar)
|
||||||
|
|
|
@ -7,11 +7,11 @@ from __future__ import division
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import pygtk
|
import gi
|
||||||
pygtk.require('2.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import pango
|
from gi.repository import Pango
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
@ -36,43 +36,43 @@ except ImportError:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# pylint: disable-msg=R0904
|
# pylint: disable-msg=R0904
|
||||||
class Terminal(gtk.VBox):
|
class Terminal(Gtk.VBox):
|
||||||
"""Class implementing the VTE widget and its wrappings"""
|
"""Class implementing the VTE widget and its wrappings"""
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'close-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'close-term': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'title-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'title-change': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
'enumerate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'enumerate': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_INT,)),
|
(GObject.TYPE_INT,)),
|
||||||
'group-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'group-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'group-tab-toggle': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'group-tab-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'ungroup-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'ungroup-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'ungroup-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'ungroup-all': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'split-horiz': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'split-horiz': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'split-vert': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
'rotate-cw': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'rotate-cw': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'rotate-ccw': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'rotate-ccw': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'tab-new': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_BOOLEAN, gobject.TYPE_OBJECT)),
|
(GObject.TYPE_BOOLEAN, GObject.TYPE_OBJECT)),
|
||||||
'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'tab-top-new': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'focus-in': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'focus-out': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'focus-out': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'zoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'zoom': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'maximise': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'maximise': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'unzoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'unzoom': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'resize-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'resize-term': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
'navigate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'navigate': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
'tab-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'tab-change': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_INT,)),
|
(GObject.TYPE_INT,)),
|
||||||
'group-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'group-all': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'group-all-toggle': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'move-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'move-tab': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
}
|
}
|
||||||
|
|
||||||
TARGET_TYPE_VTE = 8
|
TARGET_TYPE_VTE = 8
|
||||||
|
@ -113,7 +113,7 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
gtk.VBox.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.__gobject_init__()
|
self.__gobject_init__()
|
||||||
|
|
||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
|
@ -131,7 +131,7 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
self.cwd = get_default_cwd()
|
self.cwd = get_default_cwd()
|
||||||
self.origcwd = self.terminator.origcwd
|
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
|
self.pending_on_vte_size_allocate = False
|
||||||
|
|
||||||
|
@ -163,8 +163,8 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
self.pack_start(self.titlebar, False)
|
self.pack_start(self.titlebar, False)
|
||||||
self.pack_start(self.terminalbox)
|
self.pack_start(self.terminalbox, True, True, 0)
|
||||||
self.pack_end(self.searchbar)
|
self.pack_end(self.searchbar, True, True, 0)
|
||||||
|
|
||||||
self.connect_signals()
|
self.connect_signals()
|
||||||
|
|
||||||
|
@ -217,8 +217,8 @@ class Terminal(gtk.VBox):
|
||||||
def create_terminalbox(self):
|
def create_terminalbox(self):
|
||||||
"""Create a GtkHBox containing the terminal and a scrollbar"""
|
"""Create a GtkHBox containing the terminal and a scrollbar"""
|
||||||
|
|
||||||
terminalbox = gtk.HBox()
|
terminalbox = Gtk.HBox()
|
||||||
self.scrollbar = gtk.VScrollbar(self.vte.get_adjustment())
|
self.scrollbar = Gtk.VScrollbar(self.vte.get_adjustment())
|
||||||
self.scrollbar.set_no_show_all(True)
|
self.scrollbar.set_no_show_all(True)
|
||||||
self.scrollbar_position = self.config['scrollbar_position']
|
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('button-press-event', self.on_buttonpress)
|
||||||
self.vte.connect('popup-menu', self.popup_menu)
|
self.vte.connect('popup-menu', self.popup_menu)
|
||||||
|
|
||||||
srcvtetargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE)]
|
srcvtetargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE)]
|
||||||
dsttargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE),
|
dsttargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE),
|
||||||
('text/x-moz-url', 0, 0),
|
('text/x-moz-url', 0, 0),
|
||||||
('_NETSCAPE_URL', 0, 0)]
|
('_NETSCAPE_URL', 0, 0)]
|
||||||
dsttargets = gtk.target_list_add_text_targets(dsttargets)
|
dsttargets = Gtk.target_list_add_text_targets(dsttargets)
|
||||||
dsttargets = gtk.target_list_add_uri_targets(dsttargets)
|
dsttargets = Gtk.target_list_add_uri_targets(dsttargets)
|
||||||
dbg('Finalised drag targets: %s' % dsttargets)
|
dbg('Finalised drag targets: %s' % dsttargets)
|
||||||
|
|
||||||
for (widget, mask) in [
|
for (widget, mask) in [
|
||||||
(self.vte, gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK),
|
(self.vte, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.BUTTON3_MASK),
|
||||||
(self.titlebar, gtk.gdk.BUTTON1_MASK)]:
|
(self.titlebar, Gdk.ModifierType.BUTTON1_MASK)]:
|
||||||
widget.drag_source_set(mask, srcvtetargets, gtk.gdk.ACTION_MOVE)
|
widget.drag_source_set(mask, srcvtetargets, Gdk.DragAction.MOVE)
|
||||||
|
|
||||||
self.vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
|
self.vte.drag_dest_set(Gtk.DestDefaults.MOTION |
|
||||||
gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,
|
Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP,
|
||||||
dsttargets, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
|
dsttargets, Gdk.DragAction.COPY | Gdk.DragAction.MOVE)
|
||||||
|
|
||||||
for widget in [self.vte, self.titlebar]:
|
for widget in [self.vte, self.titlebar]:
|
||||||
widget.connect('drag-begin', self.on_drag_begin, self)
|
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('focus-out-event', self.on_vte_focus_out)
|
||||||
self.vte.connect('size-allocate', self.deferred_on_vte_size_allocate)
|
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.vte.connect('enter_notify_event',
|
||||||
self.on_vte_notify_enter)
|
self.on_vte_notify_enter)
|
||||||
|
|
||||||
|
@ -386,65 +386,65 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def populate_group_menu(self):
|
def populate_group_menu(self):
|
||||||
"""Fill out a group menu"""
|
"""Fill out a group menu"""
|
||||||
menu = gtk.Menu()
|
menu = Gtk.Menu()
|
||||||
groupitem = None
|
groupitem = None
|
||||||
|
|
||||||
item = gtk.MenuItem(_('New group...'))
|
item = Gtk.MenuItem(_('New group...'))
|
||||||
item.connect('activate', self.create_group)
|
item.connect('activate', self.create_group)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if len(self.terminator.groups) > 0:
|
if len(self.terminator.groups) > 0:
|
||||||
groupitem = gtk.RadioMenuItem(groupitem, _('None'))
|
groupitem = Gtk.RadioMenuItem(groupitem, _('None'))
|
||||||
groupitem.set_active(self.group == None)
|
groupitem.set_active(self.group == None)
|
||||||
groupitem.connect('activate', self.set_group, None)
|
groupitem.connect('activate', self.set_group, None)
|
||||||
menu.append(groupitem)
|
menu.append(groupitem)
|
||||||
|
|
||||||
for group in self.terminator.groups:
|
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.set_active(self.group == group)
|
||||||
item.connect('toggled', self.set_group, group)
|
item.connect('toggled', self.set_group, group)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
groupitem = item
|
groupitem = item
|
||||||
|
|
||||||
if self.group != None or len(self.terminator.groups) > 0:
|
if self.group != None or len(self.terminator.groups) > 0:
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
|
|
||||||
if self.group != None:
|
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)
|
item.connect('activate', self.ungroup, self.group)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if util.has_ancestor(self, gtk.Notebook):
|
if util.has_ancestor(self, Gtk.Notebook):
|
||||||
item = gtk.MenuItem(_('G_roup all in tab'))
|
item = Gtk.MenuItem(_('G_roup all in tab'))
|
||||||
item.connect('activate', lambda x: self.emit('group_tab'))
|
item.connect('activate', lambda x: self.emit('group_tab'))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if len(self.terminator.groups) > 0:
|
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'))
|
item.connect('activate', lambda x: self.emit('ungroup_tab'))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if len(self.terminator.groups) > 0:
|
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'))
|
item.connect('activate', lambda x: self.emit('ungroup-all'))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if self.group != None:
|
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:
|
item.connect('activate', lambda x:
|
||||||
self.terminator.closegroupedterms(self.group))
|
self.terminator.closegroupedterms(self.group))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
|
|
||||||
groupitem = None
|
groupitem = None
|
||||||
|
|
||||||
for key, value in {_('Broadcast all'):'all',
|
for key, value in {_('Broadcast all'):'all',
|
||||||
_('Broadcast group'):'group',
|
_('Broadcast group'):'group',
|
||||||
_('Broadcast off'):'off'}.items():
|
_('Broadcast off'):'off'}.items():
|
||||||
groupitem = gtk.RadioMenuItem(groupitem, key)
|
groupitem = Gtk.RadioMenuItem(groupitem, key)
|
||||||
dbg('Terminal::populate_group_menu: %s active: %s' %
|
dbg('Terminal::populate_group_menu: %s active: %s' %
|
||||||
(key, self.terminator.groupsend ==
|
(key, self.terminator.groupsend ==
|
||||||
self.terminator.groupsend_type[value]))
|
self.terminator.groupsend_type[value]))
|
||||||
|
@ -454,25 +454,25 @@ class Terminal(gtk.VBox):
|
||||||
self.terminator.groupsend_type[value])
|
self.terminator.groupsend_type[value])
|
||||||
menu.append(groupitem)
|
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.set_active(self.config['split_to_group'])
|
||||||
item.connect('toggled', lambda x: self.do_splittogroup_toggle())
|
item.connect('toggled', lambda x: self.do_splittogroup_toggle())
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
item = gtk.CheckMenuItem(_('Autoclean groups'))
|
item = Gtk.CheckMenuItem(_('Autoclean groups'))
|
||||||
item.set_active(self.config['autoclean_groups'])
|
item.set_active(self.config['autoclean_groups'])
|
||||||
item.connect('toggled', lambda x: self.do_autocleangroups_toggle())
|
item.connect('toggled', lambda x: self.do_autocleangroups_toggle())
|
||||||
menu.append(item)
|
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))
|
item.connect('activate', lambda x: self.emit('enumerate', False))
|
||||||
menu.append(item)
|
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))
|
item.connect('activate', lambda x: self.emit('enumerate', True))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
|
@ -480,10 +480,10 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def position_popup_group_menu(self, menu, widget):
|
def position_popup_group_menu(self, menu, widget):
|
||||||
"""Calculate the position of the group popup menu"""
|
"""Calculate the position of the group popup menu"""
|
||||||
_screen_w = gtk.gdk.screen_width()
|
_screen_w = Gdk.Screen.width()
|
||||||
screen_h = gtk.gdk.screen_height()
|
screen_h = Gdk.Screen.height()
|
||||||
|
|
||||||
if gtk.gtk_version >= (2, 14):
|
if Gtk.gtk_version >= (2, 14):
|
||||||
widget_win = widget.get_window()
|
widget_win = widget.get_window()
|
||||||
else:
|
else:
|
||||||
widget_win = widget.window
|
widget_win = widget.window
|
||||||
|
@ -612,16 +612,16 @@ class Terminal(gtk.VBox):
|
||||||
font = self.config.get_system_font()
|
font = self.config.get_system_font()
|
||||||
else:
|
else:
|
||||||
font = self.config['font']
|
font = self.config['font']
|
||||||
self.set_font(pango.FontDescription(font))
|
self.set_font(Pango.FontDescription(font))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.vte.set_allow_bold(self.config['allow_bold'])
|
self.vte.set_allow_bold(self.config['allow_bold'])
|
||||||
if self.config['use_theme_colors']:
|
if self.config['use_theme_colors']:
|
||||||
self.fgcolor_active = self.vte.get_style().text[gtk.STATE_NORMAL]
|
self.fgcolor_active = self.vte.get_style().text[Gtk.StateType.NORMAL]
|
||||||
self.bgcolor = self.vte.get_style().base[gtk.STATE_NORMAL]
|
self.bgcolor = self.vte.get_style().base[Gtk.StateType.NORMAL]
|
||||||
else:
|
else:
|
||||||
self.fgcolor_active = gtk.gdk.color_parse(self.config['foreground_color'])
|
self.fgcolor_active = Gdk.color_parse(self.config['foreground_color'])
|
||||||
self.bgcolor = gtk.gdk.color_parse(self.config['background_color'])
|
self.bgcolor = Gdk.color_parse(self.config['background_color'])
|
||||||
|
|
||||||
factor = self.config['inactive_color_offset']
|
factor = self.config['inactive_color_offset']
|
||||||
if factor > 1.0:
|
if factor > 1.0:
|
||||||
|
@ -643,7 +643,7 @@ class Terminal(gtk.VBox):
|
||||||
self.palette_inactive = []
|
self.palette_inactive = []
|
||||||
for color in colors:
|
for color in colors:
|
||||||
if color:
|
if color:
|
||||||
newcolor = gtk.gdk.color_parse(color)
|
newcolor = Gdk.color_parse(color)
|
||||||
newcolor_inactive = newcolor.copy()
|
newcolor_inactive = newcolor.copy()
|
||||||
for bit in ['red', 'green', 'blue']:
|
for bit in ['red', 'green', 'blue']:
|
||||||
setattr(newcolor_inactive, bit,
|
setattr(newcolor_inactive, bit,
|
||||||
|
@ -674,7 +674,7 @@ class Terminal(gtk.VBox):
|
||||||
self.vte.set_scroll_background(False)
|
self.vte.set_scroll_background(False)
|
||||||
|
|
||||||
if background_type in ('image', 'transparent'):
|
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']))
|
self.config['background_color']))
|
||||||
opacity = int(self.config['background_darkness'] * 65536)
|
opacity = int(self.config['background_darkness'] * 65536)
|
||||||
saturation = 1.0 - float(self.config['background_darkness'])
|
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
|
# https://bugzilla.gnome.org/show_bug.cgi?id=614910
|
||||||
pass
|
pass
|
||||||
elif self.config['cursor_color'] != '':
|
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']))
|
self.config['cursor_color']))
|
||||||
|
|
||||||
def get_window_title(self):
|
def get_window_title(self):
|
||||||
|
@ -779,17 +779,17 @@ class Terminal(gtk.VBox):
|
||||||
def on_group_button_press(self, widget, event):
|
def on_group_button_press(self, widget, event):
|
||||||
"""Handler for the group button"""
|
"""Handler for the group button"""
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS or \
|
if event.type == Gdk._2BUTTON_PRESS or \
|
||||||
event.type == gtk.gdk._3BUTTON_PRESS:
|
event.type == Gdk._3BUTTON_PRESS:
|
||||||
# Ignore these, or they make the interaction bad
|
# Ignore these, or they make the interaction bad
|
||||||
return True
|
return True
|
||||||
# Super key applies interaction to all terms in group
|
# 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:
|
if include_siblings:
|
||||||
targets=self.terminator.get_sibling_terms(self)
|
targets=self.terminator.get_sibling_terms(self)
|
||||||
else:
|
else:
|
||||||
targets=[self]
|
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')
|
dbg('on_group_button_press: toggle terminal to focused terminals group')
|
||||||
focused=self.get_toplevel().get_focussed_terminal()
|
focused=self.get_toplevel().get_focussed_terminal()
|
||||||
if focused in targets: targets.remove(focused)
|
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.set_group(None, new_group) for term in targets]
|
||||||
[term.titlebar.update(focused) for term in targets]
|
[term.titlebar.update(focused) for term in targets]
|
||||||
return True
|
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')
|
dbg('on_group_button_press: rename of terminals group')
|
||||||
self.targets_for_new_group = targets
|
self.targets_for_new_group = targets
|
||||||
self.titlebar.create_group()
|
self.titlebar.create_group()
|
||||||
return True
|
return True
|
||||||
elif event.type == gtk.gdk.BUTTON_PRESS:
|
elif event.type == Gdk.EventType.BUTTON_PRESS:
|
||||||
# Single Click gives popup
|
# Single Click gives popup
|
||||||
dbg('on_group_button_press: group menu popup')
|
dbg('on_group_button_press: group menu popup')
|
||||||
self.create_popup_group_menu(widget, event)
|
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>
|
# 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
|
# we only copy if there is a selection otherwise let it fall through
|
||||||
# to ^<key>
|
# 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 ():
|
if self.vte.get_has_selection ():
|
||||||
getattr(self, "key_" + mapping)()
|
getattr(self, "key_" + mapping)()
|
||||||
return(True)
|
return(True)
|
||||||
|
@ -863,7 +863,7 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
# Ctrl+leftclick on a URL should open it
|
# 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)
|
url = self.check_for_url(event)
|
||||||
if url:
|
if url:
|
||||||
self.open_url(url, prepare=True)
|
self.open_url(url, prepare=True)
|
||||||
|
@ -873,7 +873,7 @@ class Terminal(gtk.VBox):
|
||||||
return(True)
|
return(True)
|
||||||
elif event.button == 3:
|
elif event.button == 3:
|
||||||
# rightclick should display a context menu if Ctrl is not pressed
|
# 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)
|
self.popup_menu(widget, event)
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
|
@ -916,23 +916,23 @@ class Terminal(gtk.VBox):
|
||||||
def on_drag_motion(self, widget, drag_context, x, y, _time, _data):
|
def on_drag_motion(self, widget, drag_context, x, y, _time, _data):
|
||||||
"""*shrug*"""
|
"""*shrug*"""
|
||||||
if not drag_context.targets == ['vte'] and \
|
if not drag_context.targets == ['vte'] and \
|
||||||
(gtk.targets_include_text(drag_context.targets) or \
|
(Gtk.targets_include_text(drag_context.targets) or \
|
||||||
gtk.targets_include_uri(drag_context.targets)):
|
Gtk.targets_include_uri(drag_context.targets)):
|
||||||
# copy text from another widget
|
# copy text from another widget
|
||||||
return
|
return
|
||||||
srcwidget = drag_context.get_source_widget()
|
srcwidget = drag_context.get_source_widget()
|
||||||
if(isinstance(srcwidget, gtk.EventBox) and
|
if(isinstance(srcwidget, Gtk.EventBox) and
|
||||||
srcwidget == self.titlebar) or widget == srcwidget:
|
srcwidget == self.titlebar) or widget == srcwidget:
|
||||||
# on self
|
# on self
|
||||||
return
|
return
|
||||||
|
|
||||||
alloc = widget.allocation
|
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']:
|
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:
|
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)
|
pos = self.get_location(widget, x, y)
|
||||||
topleft = (0, 0)
|
topleft = (0, 0)
|
||||||
|
@ -987,8 +987,8 @@ class Terminal(gtk.VBox):
|
||||||
"""Something has been dragged into the terminal. Handle it as either a
|
"""Something has been dragged into the terminal. Handle it as either a
|
||||||
URL or another terminal."""
|
URL or another terminal."""
|
||||||
dbg('drag data received of type: %s' % selection_data.type)
|
dbg('drag data received of type: %s' % selection_data.type)
|
||||||
if gtk.targets_include_text(drag_context.targets) or \
|
if Gtk.targets_include_text(drag_context.targets) or \
|
||||||
gtk.targets_include_uri(drag_context.targets):
|
Gtk.targets_include_uri(drag_context.targets):
|
||||||
# copy text to destination
|
# copy text to destination
|
||||||
txt = selection_data.data.strip(' ')
|
txt = selection_data.data.strip(' ')
|
||||||
if txt[0:7] == 'file://':
|
if txt[0:7] == 'file://':
|
||||||
|
@ -1002,7 +1002,7 @@ class Terminal(gtk.VBox):
|
||||||
widgetsrc = data.terminator.terminals[int(selection_data.data)]
|
widgetsrc = data.terminator.terminals[int(selection_data.data)]
|
||||||
srcvte = drag_context.get_source_widget()
|
srcvte = drag_context.get_source_widget()
|
||||||
#check if computation requireds
|
#check if computation requireds
|
||||||
if (isinstance(srcvte, gtk.EventBox) and
|
if (isinstance(srcvte, Gtk.EventBox) and
|
||||||
srcvte == self.titlebar) or srcvte == widget:
|
srcvte == self.titlebar) or srcvte == widget:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1061,7 +1061,7 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def grab_focus(self):
|
def grab_focus(self):
|
||||||
"""Steal focus for this terminal"""
|
"""Steal focus for this terminal"""
|
||||||
if not self.vte.flags()>k.HAS_FOCUS:
|
if not self.vte.flags()&Gtk.HAS_FOCUS:
|
||||||
self.vte.grab_focus()
|
self.vte.grab_focus()
|
||||||
|
|
||||||
def ensure_visible_and_focussed(self):
|
def ensure_visible_and_focussed(self):
|
||||||
|
@ -1131,7 +1131,7 @@ class Terminal(gtk.VBox):
|
||||||
if self.pending_on_vte_size_allocate == True:
|
if self.pending_on_vte_size_allocate == True:
|
||||||
return
|
return
|
||||||
self.pending_on_vte_size_allocate = True
|
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):
|
def do_deferred_on_vte_size_allocate(self, widget, allocation):
|
||||||
self.pending_on_vte_size_allocate = False
|
self.pending_on_vte_size_allocate = False
|
||||||
|
@ -1379,19 +1379,19 @@ class Terminal(gtk.VBox):
|
||||||
except:
|
except:
|
||||||
dbg('custom url handler did not work, falling back to defaults')
|
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, 'show_uri') or \
|
||||||
not hasattr(gtk.gdk, 'CURRENT_TIME'):
|
not hasattr(Gtk.gdk, 'CURRENT_TIME'):
|
||||||
oldstyle = True
|
oldstyle = True
|
||||||
|
|
||||||
if oldstyle == False:
|
if oldstyle == False:
|
||||||
try:
|
try:
|
||||||
gtk.show_uri(None, url, gtk.gdk.CURRENT_TIME)
|
Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
|
||||||
except:
|
except:
|
||||||
oldstyle = True
|
oldstyle = True
|
||||||
|
|
||||||
if 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:
|
try:
|
||||||
subprocess.Popen(["xdg-open", url])
|
subprocess.Popen(["xdg-open", url])
|
||||||
except:
|
except:
|
||||||
|
@ -1425,10 +1425,10 @@ class Terminal(gtk.VBox):
|
||||||
pangodesc = self.vte.get_font()
|
pangodesc = self.vte.get_font()
|
||||||
fontsize = pangodesc.get_size()
|
fontsize = pangodesc.get_size()
|
||||||
|
|
||||||
if fontsize > pango.SCALE and not zoom_in:
|
if fontsize > Pango.SCALE and not zoom_in:
|
||||||
fontsize -= pango.SCALE
|
fontsize -= Pango.SCALE
|
||||||
elif zoom_in:
|
elif zoom_in:
|
||||||
fontsize += pango.SCALE
|
fontsize += Pango.SCALE
|
||||||
|
|
||||||
pangodesc.set_size(fontsize)
|
pangodesc.set_size(fontsize)
|
||||||
self.set_font(pangodesc)
|
self.set_font(pangodesc)
|
||||||
|
@ -1441,7 +1441,7 @@ class Terminal(gtk.VBox):
|
||||||
else:
|
else:
|
||||||
font = self.config['font']
|
font = self.config['font']
|
||||||
dbg("Terminal::zoom_orig: restoring font to: %s" % 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
|
self.custom_font_size = None
|
||||||
|
|
||||||
def set_font(self, fontdesc):
|
def set_font(self, fontdesc):
|
||||||
|
@ -1479,7 +1479,7 @@ class Terminal(gtk.VBox):
|
||||||
"""Set the urgency hint for our window"""
|
"""Set the urgency hint for our window"""
|
||||||
if self.config['urgent_bell'] == True:
|
if self.config['urgent_bell'] == True:
|
||||||
window = self.get_toplevel()
|
window = self.get_toplevel()
|
||||||
if window.flags() & gtk.TOPLEVEL:
|
if window.flags() & Gtk.TOPLEVEL:
|
||||||
window.set_urgency_hint(True)
|
window.set_urgency_hint(True)
|
||||||
if self.config['icon_bell'] == True:
|
if self.config['icon_bell'] == True:
|
||||||
self.titlebar.icon_bell()
|
self.titlebar.icon_bell()
|
||||||
|
@ -1722,17 +1722,17 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
def key_edit_window_title(self):
|
def key_edit_window_title(self):
|
||||||
window = self.get_toplevel()
|
window = self.get_toplevel()
|
||||||
dialog = gtk.Dialog(_('Rename Window'), window,
|
dialog = Gtk.Dialog(_('Rename Window'), window,
|
||||||
gtk.DIALOG_MODAL,
|
Gtk.DialogFlags.MODAL,
|
||||||
( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
( Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
|
||||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT ))
|
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT ))
|
||||||
dialog.set_default_response(gtk.RESPONSE_ACCEPT)
|
dialog.set_default_response(Gtk.ResponseType.ACCEPT)
|
||||||
dialog.set_has_separator(False)
|
dialog.set_has_separator(False)
|
||||||
dialog.set_resizable(False)
|
dialog.set_resizable(False)
|
||||||
dialog.set_border_width(8)
|
dialog.set_border_width(8)
|
||||||
|
|
||||||
label = gtk.Label(_('Enter a new title for the Terminator window...'))
|
label = Gtk.Label(label=_('Enter a new title for the Terminator window...'))
|
||||||
name = gtk.Entry()
|
name = Gtk.Entry()
|
||||||
name.set_activates_default(True)
|
name.set_activates_default(True)
|
||||||
if window.title.text != self.vte.get_window_title():
|
if window.title.text != self.vte.get_window_title():
|
||||||
name.set_text(self.get_toplevel().title.text)
|
name.set_text(self.get_toplevel().title.text)
|
||||||
|
@ -1742,7 +1742,7 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
dialog.show_all()
|
dialog.show_all()
|
||||||
res = dialog.run()
|
res = dialog.run()
|
||||||
if res == gtk.RESPONSE_ACCEPT:
|
if res == Gtk.ResponseType.ACCEPT:
|
||||||
if name.get_text():
|
if name.get_text():
|
||||||
window.title.force_title(None)
|
window.title.force_title(None)
|
||||||
window.title.force_title(name.get_text())
|
window.title.force_title(name.get_text())
|
||||||
|
@ -1774,5 +1774,5 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
# End key events
|
# End key events
|
||||||
|
|
||||||
gobject.type_register(Terminal)
|
GObject.type_register(Terminal)
|
||||||
# vim: set expandtab ts=4 sw=4:
|
# vim: set expandtab ts=4 sw=4:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"""terminal_popup_menu.py - classes necessary to provide a terminal context
|
"""terminal_popup_menu.py - classes necessary to provide a terminal context
|
||||||
menu"""
|
menu"""
|
||||||
|
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from version import APP_NAME
|
from version import APP_NAME
|
||||||
from translation import _
|
from translation import _
|
||||||
|
@ -31,7 +31,7 @@ class TerminalPopupMenu(object):
|
||||||
"""Display the context menu"""
|
"""Display the context menu"""
|
||||||
terminal = self.terminal
|
terminal = self.terminal
|
||||||
|
|
||||||
menu = gtk.Menu()
|
menu = Gtk.Menu()
|
||||||
url = None
|
url = None
|
||||||
button = None
|
button = None
|
||||||
time = None
|
time = None
|
||||||
|
@ -84,35 +84,35 @@ class TerminalPopupMenu(object):
|
||||||
if not namecopy:
|
if not namecopy:
|
||||||
namecopy = _('_Copy address')
|
namecopy = _('_Copy address')
|
||||||
|
|
||||||
icon = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,
|
icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUMP_TO,
|
||||||
gtk.ICON_SIZE_MENU)
|
Gtk.IconSize.MENU)
|
||||||
item = gtk.ImageMenuItem(nameopen)
|
item = Gtk.ImageMenuItem(nameopen)
|
||||||
item.set_property('image', icon)
|
item.set_property('image', icon)
|
||||||
item.connect('activate', lambda x: terminal.open_url(url, True))
|
item.connect('activate', lambda x: terminal.open_url(url, True))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
item = gtk.MenuItem(namecopy)
|
item = Gtk.MenuItem(namecopy)
|
||||||
item.connect('activate',
|
item.connect('activate',
|
||||||
lambda x: terminal.clipboard.set_text(terminal.prepare_url(url)))
|
lambda x: terminal.clipboard.set_text(terminal.prepare_url(url)))
|
||||||
menu.append(item)
|
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.connect('activate', lambda x: terminal.vte.copy_clipboard())
|
||||||
item.set_sensitive(terminal.vte.get_has_selection())
|
item.set_sensitive(terminal.vte.get_has_selection())
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
item = gtk.ImageMenuItem(gtk.STOCK_PASTE)
|
item = Gtk.ImageMenuItem(Gtk.STOCK_PASTE)
|
||||||
item.connect('activate', lambda x: terminal.paste_clipboard())
|
item.connect('activate', lambda x: terminal.paste_clipboard())
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
|
|
||||||
if not terminal.is_zoomed():
|
if not terminal.is_zoomed():
|
||||||
item = gtk.ImageMenuItem(_('Split H_orizontally'))
|
item = Gtk.ImageMenuItem(_('Split H_orizontally'))
|
||||||
image = gtk.Image()
|
image = Gtk.Image()
|
||||||
image.set_from_icon_name(APP_NAME + '_horiz', gtk.ICON_SIZE_MENU)
|
image.set_from_icon_name(APP_NAME + '_horiz', Gtk.IconSize.MENU)
|
||||||
item.set_image(image)
|
item.set_image(image)
|
||||||
if hasattr(item, 'set_always_show_image'):
|
if hasattr(item, 'set_always_show_image'):
|
||||||
item.set_always_show_image(True)
|
item.set_always_show_image(True)
|
||||||
|
@ -120,9 +120,9 @@ class TerminalPopupMenu(object):
|
||||||
self.terminator.pid_cwd(self.terminal.pid)))
|
self.terminator.pid_cwd(self.terminal.pid)))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
item = gtk.ImageMenuItem(_('Split V_ertically'))
|
item = Gtk.ImageMenuItem(_('Split V_ertically'))
|
||||||
image = gtk.Image()
|
image = Gtk.Image()
|
||||||
image.set_from_icon_name(APP_NAME + '_vert', gtk.ICON_SIZE_MENU)
|
image.set_from_icon_name(APP_NAME + '_vert', Gtk.IconSize.MENU)
|
||||||
item.set_image(image)
|
item.set_image(image)
|
||||||
if hasattr(item, 'set_always_show_image'):
|
if hasattr(item, 'set_always_show_image'):
|
||||||
item.set_always_show_image(True)
|
item.set_always_show_image(True)
|
||||||
|
@ -130,65 +130,65 @@ class TerminalPopupMenu(object):
|
||||||
self.terminator.pid_cwd(self.terminal.pid)))
|
self.terminator.pid_cwd(self.terminal.pid)))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
item = gtk.MenuItem(_('Open _Tab'))
|
item = Gtk.MenuItem(_('Open _Tab'))
|
||||||
item.connect('activate', lambda x: terminal.emit('tab-new', False,
|
item.connect('activate', lambda x: terminal.emit('tab-new', False,
|
||||||
terminal))
|
terminal))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if self.terminator.debug_address is not None:
|
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:
|
item.connect('activate', lambda x:
|
||||||
terminal.emit('tab-new', True, terminal))
|
terminal.emit('tab-new', True, terminal))
|
||||||
menu.append(item)
|
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())
|
item.connect('activate', lambda x: terminal.close())
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
|
|
||||||
if not terminal.is_zoomed():
|
if not terminal.is_zoomed():
|
||||||
item = gtk.MenuItem(_('_Zoom terminal'))
|
item = Gtk.MenuItem(_('_Zoom terminal'))
|
||||||
item.connect('activate', terminal.zoom)
|
item.connect('activate', terminal.zoom)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
item = gtk.MenuItem(_('Ma_ximise terminal'))
|
item = Gtk.MenuItem(_('Ma_ximise terminal'))
|
||||||
item.connect('activate', terminal.maximise)
|
item.connect('activate', terminal.maximise)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
else:
|
else:
|
||||||
item = gtk.MenuItem(_('_Restore all terminals'))
|
item = Gtk.MenuItem(_('_Restore all terminals'))
|
||||||
item.connect('activate', terminal.unzoom)
|
item.connect('activate', terminal.unzoom)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
|
|
||||||
if self.config['show_titlebar'] == False:
|
if self.config['show_titlebar'] == False:
|
||||||
item = gtk.MenuItem(_('Grouping'))
|
item = Gtk.MenuItem(_('Grouping'))
|
||||||
submenu = self.terminal.populate_group_menu()
|
submenu = self.terminal.populate_group_menu()
|
||||||
submenu.show_all()
|
submenu.show_all()
|
||||||
item.set_submenu(submenu)
|
item.set_submenu(submenu)
|
||||||
menu.append(item)
|
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.set_active(terminal.scrollbar.get_property('visible'))
|
||||||
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
|
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
if hasattr(gtk, 'Builder'):
|
if hasattr(gtk, 'Builder'):
|
||||||
item = gtk.MenuItem(_('_Preferences'))
|
item = Gtk.MenuItem(_('_Preferences'))
|
||||||
item.connect('activate', lambda x: PrefsEditor(self.terminal))
|
item.connect('activate', lambda x: PrefsEditor(self.terminal))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
profilelist = self.config.list_profiles()
|
profilelist = self.config.list_profiles()
|
||||||
|
|
||||||
if len(profilelist) > 1:
|
if len(profilelist) > 1:
|
||||||
item = gtk.MenuItem(_('Profiles'))
|
item = Gtk.MenuItem(_('Profiles'))
|
||||||
submenu = gtk.Menu()
|
submenu = Gtk.Menu()
|
||||||
item.set_submenu(submenu)
|
item.set_submenu(submenu)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ class TerminalPopupMenu(object):
|
||||||
group = None
|
group = None
|
||||||
|
|
||||||
for profile in profilelist:
|
for profile in profilelist:
|
||||||
item = gtk.RadioMenuItem(group, profile.capitalize())
|
item = Gtk.RadioMenuItem(group, profile.capitalize())
|
||||||
if profile == current:
|
if profile == current:
|
||||||
item.set_active(True)
|
item.set_active(True)
|
||||||
item.connect('activate', terminal.force_set_profile, profile)
|
item.connect('activate', terminal.force_set_profile, profile)
|
||||||
|
@ -214,7 +214,7 @@ class TerminalPopupMenu(object):
|
||||||
menuplugin.callback(menuitems, menu, terminal)
|
menuplugin.callback(menuitems, menu, terminal)
|
||||||
|
|
||||||
if len(menuitems) > 0:
|
if len(menuitems) > 0:
|
||||||
menu.append(gtk.MenuItem())
|
menu.append(Gtk.MenuItem())
|
||||||
|
|
||||||
for menuitem in menuitems:
|
for menuitem in menuitems:
|
||||||
menu.append(menuitem)
|
menu.append(menuitem)
|
||||||
|
@ -231,9 +231,9 @@ class TerminalPopupMenu(object):
|
||||||
"""Add the encoding list to the menu"""
|
"""Add the encoding list to the menu"""
|
||||||
terminal = self.terminal
|
terminal = self.terminal
|
||||||
active_encodings = terminal.config['active_encodings']
|
active_encodings = terminal.config['active_encodings']
|
||||||
item = gtk.MenuItem (_("Encodings"))
|
item = Gtk.MenuItem (_("Encodings"))
|
||||||
menu.append (item)
|
menu.append (item)
|
||||||
submenu = gtk.Menu ()
|
submenu = Gtk.Menu ()
|
||||||
item.set_submenu (submenu)
|
item.set_submenu (submenu)
|
||||||
encodings = TerminatorEncoding ().get_list ()
|
encodings = TerminatorEncoding ().get_list ()
|
||||||
encodings.sort (lambda x, y: cmp (x[2].lower (), y[2].lower ()))
|
encodings.sort (lambda x, y: cmp (x[2].lower (), y[2].lower ()))
|
||||||
|
@ -253,7 +253,7 @@ class TerminalPopupMenu(object):
|
||||||
else:
|
else:
|
||||||
extratext = ""
|
extratext = ""
|
||||||
|
|
||||||
radioitem = gtk.RadioMenuItem (group, _(encoding) + extratext)
|
radioitem = Gtk.RadioMenuItem (group, _(encoding) + extratext)
|
||||||
|
|
||||||
if encoding == current_encoding:
|
if encoding == current_encoding:
|
||||||
radioitem.set_active (True)
|
radioitem.set_active (True)
|
||||||
|
@ -265,11 +265,11 @@ class TerminalPopupMenu(object):
|
||||||
encoding)
|
encoding)
|
||||||
submenu.append (radioitem)
|
submenu.append (radioitem)
|
||||||
|
|
||||||
item = gtk.MenuItem (_("Other Encodings"))
|
item = Gtk.MenuItem (_("Other Encodings"))
|
||||||
submenu.append (item)
|
submenu.append (item)
|
||||||
#second level
|
#second level
|
||||||
|
|
||||||
submenu = gtk.Menu ()
|
submenu = Gtk.Menu ()
|
||||||
item.set_submenu (submenu)
|
item.set_submenu (submenu)
|
||||||
group = None
|
group = None
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ class TerminalPopupMenu(object):
|
||||||
else:
|
else:
|
||||||
label = "%s %s" % (encoding[2], encoding[1])
|
label = "%s %s" % (encoding[2], encoding[1])
|
||||||
|
|
||||||
radioitem = gtk.RadioMenuItem (group, label)
|
radioitem = Gtk.RadioMenuItem (group, label)
|
||||||
if group is None:
|
if group is None:
|
||||||
group = radioitem
|
group = radioitem
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from borg import Borg
|
from borg import Borg
|
||||||
from config import Config
|
from config import Config
|
||||||
|
@ -131,7 +131,7 @@ class Terminator(Borg):
|
||||||
if len(self.windows) == 0:
|
if len(self.windows) == 0:
|
||||||
# We have no windows left, we should exit
|
# We have no windows left, we should exit
|
||||||
dbg('no windows remain, quitting')
|
dbg('no windows remain, quitting')
|
||||||
gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
def register_launcher_window(self, window):
|
def register_launcher_window(self, window):
|
||||||
"""Register a new launcher window widget"""
|
"""Register a new launcher window widget"""
|
||||||
|
@ -152,7 +152,7 @@ class Terminator(Borg):
|
||||||
if len(self.launcher_windows) == 0 and len(self.windows) == 0:
|
if len(self.launcher_windows) == 0 and len(self.windows) == 0:
|
||||||
# We have no windows left, we should exit
|
# We have no windows left, we should exit
|
||||||
dbg('no windows remain, quitting')
|
dbg('no windows remain, quitting')
|
||||||
gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
def register_terminal(self, terminal):
|
def register_terminal(self, terminal):
|
||||||
"""Register a new terminal widget"""
|
"""Register a new terminal widget"""
|
||||||
|
@ -348,13 +348,13 @@ class Terminator(Borg):
|
||||||
"""Update configuration for the whole application"""
|
"""Update configuration for the whole application"""
|
||||||
|
|
||||||
if self.config['handle_size'] in xrange(0, 6):
|
if self.config['handle_size'] in xrange(0, 6):
|
||||||
gtk.rc_parse_string("""
|
Gtk.rc_parse_string("""
|
||||||
style "terminator-paned-style" {
|
style "terminator-paned-style" {
|
||||||
GtkPaned::handle_size = %s
|
GtkPaned::handle_size = %s
|
||||||
}
|
}
|
||||||
class "GtkPaned" style "terminator-paned-style"
|
class "GtkPaned" style "terminator-paned-style"
|
||||||
""" % self.config['handle_size'])
|
""" % 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
|
# Cause all the terminals to reconfigure
|
||||||
for terminal in self.terminals:
|
for terminal in self.terminals:
|
||||||
|
@ -452,7 +452,7 @@ class Terminator(Borg):
|
||||||
def get_focussed_terminal(self):
|
def get_focussed_terminal(self):
|
||||||
"""iterate over all the terminals to find which, if any, has focus"""
|
"""iterate over all the terminals to find which, if any, has focus"""
|
||||||
for terminal in self.terminals:
|
for terminal in self.terminals:
|
||||||
if terminal.flags()>k.HAS_FOCUS:
|
if terminal.flags()&Gtk.HAS_FOCUS:
|
||||||
return(terminal)
|
return(terminal)
|
||||||
return(None)
|
return(None)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
# GPL v2 only
|
# GPL v2 only
|
||||||
"""titlebar.py - classes necessary to provide a terminal title bar"""
|
"""titlebar.py - classes necessary to provide a terminal title bar"""
|
||||||
|
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import random
|
import random
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from editablelabel import EditableLabel
|
||||||
|
|
||||||
# pylint: disable-msg=R0904
|
# pylint: disable-msg=R0904
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
class Titlebar(gtk.EventBox):
|
class Titlebar(Gtk.EventBox):
|
||||||
"""Class implementing the Titlebar widget"""
|
"""Class implementing the Titlebar widget"""
|
||||||
|
|
||||||
terminator = None
|
terminator = None
|
||||||
|
@ -32,15 +32,15 @@ class Titlebar(gtk.EventBox):
|
||||||
bellicon = None
|
bellicon = None
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'clicked': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'edit-done': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'edit-done': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||||
'create-group': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
'create-group': (GObject.SignalFlags.RUN_LAST, None,
|
||||||
(gobject.TYPE_STRING,)),
|
(GObject.TYPE_STRING,)),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, terminal):
|
def __init__(self, terminal):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
gtk.EventBox.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.__gobject_init__()
|
self.__gobject_init__()
|
||||||
|
|
||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
|
@ -49,14 +49,14 @@ class Titlebar(gtk.EventBox):
|
||||||
|
|
||||||
self.label = EditableLabel()
|
self.label = EditableLabel()
|
||||||
self.label.connect('edit-done', self.on_edit_done)
|
self.label.connect('edit-done', self.on_edit_done)
|
||||||
self.ebox = gtk.EventBox()
|
self.ebox = Gtk.EventBox()
|
||||||
grouphbox = gtk.HBox()
|
grouphbox = Gtk.HBox()
|
||||||
self.grouplabel = gtk.Label()
|
self.grouplabel = Gtk.Label()
|
||||||
self.groupicon = gtk.Image()
|
self.groupicon = Gtk.Image()
|
||||||
self.bellicon = gtk.Image()
|
self.bellicon = Gtk.Image()
|
||||||
self.bellicon.set_no_show_all(True)
|
self.bellicon.set_no_show_all(True)
|
||||||
|
|
||||||
self.groupentry = gtk.Entry()
|
self.groupentry = Gtk.Entry()
|
||||||
self.groupentry.set_no_show_all(True)
|
self.groupentry.set_no_show_all(True)
|
||||||
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
|
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
|
||||||
self.groupentry.connect('activate', self.groupentry_activate)
|
self.groupentry.connect('activate', self.groupentry_activate)
|
||||||
|
@ -70,7 +70,7 @@ class Titlebar(gtk.EventBox):
|
||||||
elif self.terminator.groupsend == groupsend_type['off']:
|
elif self.terminator.groupsend == groupsend_type['off']:
|
||||||
icon_name = 'off'
|
icon_name = 'off'
|
||||||
self.set_from_icon_name('_active_broadcast_%s' % icon_name,
|
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.groupicon, False, True, 2)
|
||||||
grouphbox.pack_start(self.grouplabel, 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.add(grouphbox)
|
||||||
self.ebox.show_all()
|
self.ebox.show_all()
|
||||||
|
|
||||||
self.bellicon.set_from_icon_name('terminal-bell', gtk.ICON_SIZE_MENU)
|
self.bellicon.set_from_icon_name('terminal-bell', Gtk.IconSize.MENU)
|
||||||
hbox = gtk.HBox()
|
hbox = Gtk.HBox()
|
||||||
hbox.pack_start(self.ebox, False, True, 0)
|
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_start(self.label, True, True)
|
||||||
hbox.pack_end(self.bellicon, False, False, 2)
|
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_fg = self.config['title_transmit_fg_color']
|
||||||
group_bg = self.config['title_transmit_bg_color']
|
group_bg = self.config['title_transmit_bg_color']
|
||||||
|
|
||||||
self.label.modify_fg(gtk.STATE_NORMAL,
|
self.label.modify_fg(Gtk.StateType.NORMAL,
|
||||||
gtk.gdk.color_parse(title_fg))
|
Gdk.color_parse(title_fg))
|
||||||
self.grouplabel.modify_fg(gtk.STATE_NORMAL,
|
self.grouplabel.modify_fg(Gtk.StateType.NORMAL,
|
||||||
gtk.gdk.color_parse(group_fg))
|
Gdk.color_parse(group_fg))
|
||||||
self.modify_bg(gtk.STATE_NORMAL,
|
self.modify_bg(Gtk.StateType.NORMAL,
|
||||||
gtk.gdk.color_parse(title_bg))
|
Gdk.color_parse(title_bg))
|
||||||
if not self.get_desired_visibility():
|
if not self.get_desired_visibility():
|
||||||
if default_bg == True:
|
if default_bg == True:
|
||||||
color = term.get_style().bg[gtk.STATE_NORMAL]
|
color = term.get_style().bg[Gtk.StateType.NORMAL]
|
||||||
else:
|
else:
|
||||||
color = gtk.gdk.color_parse(title_bg)
|
color = Gdk.color_parse(title_bg)
|
||||||
self.update_visibility()
|
self.update_visibility()
|
||||||
self.ebox.modify_bg(gtk.STATE_NORMAL,
|
self.ebox.modify_bg(Gtk.StateType.NORMAL,
|
||||||
gtk.gdk.color_parse(group_bg))
|
Gdk.color_parse(group_bg))
|
||||||
self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU)
|
self.set_from_icon_name(icon, Gtk.IconSize.MENU)
|
||||||
|
|
||||||
def update_visibility(self):
|
def update_visibility(self):
|
||||||
"""Make the titlebar be visible or not"""
|
"""Make the titlebar be visible or not"""
|
||||||
|
@ -189,7 +189,7 @@ class Titlebar(gtk.EventBox):
|
||||||
dbg('configured visibility: %s' % self.config['show_titlebar'])
|
dbg('configured visibility: %s' % self.config['show_titlebar'])
|
||||||
return(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"""
|
"""Set an icon for the group label"""
|
||||||
if not name:
|
if not name:
|
||||||
self.groupicon.hide()
|
self.groupicon.hide()
|
||||||
|
@ -280,14 +280,14 @@ class Titlebar(gtk.EventBox):
|
||||||
|
|
||||||
def groupentry_keypress(self, widget, event):
|
def groupentry_keypress(self, widget, event):
|
||||||
"""Handle keypresses on the entry widget"""
|
"""Handle keypresses on the entry widget"""
|
||||||
key = gtk.gdk.keyval_name(event.keyval)
|
key = Gdk.keyval_name(event.keyval)
|
||||||
if key == 'Escape':
|
if key == 'Escape':
|
||||||
self.groupentry_cancel(None, None)
|
self.groupentry_cancel(None, None)
|
||||||
|
|
||||||
def icon_bell(self):
|
def icon_bell(self):
|
||||||
"""A bell signal requires we display our bell icon"""
|
"""A bell signal requires we display our bell icon"""
|
||||||
self.bellicon.show()
|
self.bellicon.show()
|
||||||
gobject.timeout_add(1000, self.icon_bell_hide)
|
GObject.timeout_add(1000, self.icon_bell_hide)
|
||||||
|
|
||||||
def icon_bell_hide(self):
|
def icon_bell_hide(self):
|
||||||
"""Handle a timeout which means we now hide the bell icon"""
|
"""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_text(string)
|
||||||
self.label.set_custom()
|
self.label.set_custom()
|
||||||
|
|
||||||
gobject.type_register(Titlebar)
|
GObject.type_register(Titlebar)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -78,8 +78,8 @@ def gerr(message = None):
|
||||||
"""Display a graphical error. This should only be used for serious
|
"""Display a graphical error. This should only be used for serious
|
||||||
errors as it will halt execution"""
|
errors as it will halt execution"""
|
||||||
|
|
||||||
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
|
dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL,
|
||||||
gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
|
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message)
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
|
@ -142,12 +142,12 @@ def shell_lookup():
|
||||||
|
|
||||||
def widget_pixbuf(widget, maxsize=None):
|
def widget_pixbuf(widget, maxsize=None):
|
||||||
"""Generate a pixbuf of a widget"""
|
"""Generate a pixbuf of a widget"""
|
||||||
if gtk.gtk_version < (2, 14):
|
if Gtk.gtk_version < (2, 14):
|
||||||
return(None)
|
return(None)
|
||||||
|
|
||||||
pixmap = widget.get_snapshot()
|
pixmap = widget.get_snapshot()
|
||||||
(width, height) = pixmap.get_size()
|
(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,
|
pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, width,
|
||||||
height)
|
height)
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ def widget_pixbuf(widget, maxsize=None):
|
||||||
if not maxsize or (width * factor) > width or (height * factor) > height:
|
if not maxsize or (width * factor) > width or (height * factor) > height:
|
||||||
factor = 1
|
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)
|
return(scaledpixbuf)
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
import copy
|
import copy
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
import pygtk
|
import gi
|
||||||
pygtk.require('2.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
import gobject
|
from gi.repository import GObject
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from util import dbg, err, make_uuid
|
from util import dbg, err, make_uuid
|
||||||
import util
|
import util
|
||||||
|
@ -26,7 +26,7 @@ except ImportError:
|
||||||
hide_window shortcut will be unavailable')
|
hide_window shortcut will be unavailable')
|
||||||
|
|
||||||
# pylint: disable-msg=R0904
|
# pylint: disable-msg=R0904
|
||||||
class Window(Container, gtk.Window):
|
class Window(Container, Gtk.Window):
|
||||||
"""Class implementing a top-level Terminator window"""
|
"""Class implementing a top-level Terminator window"""
|
||||||
|
|
||||||
terminator = None
|
terminator = None
|
||||||
|
@ -45,11 +45,11 @@ class Window(Container, gtk.Window):
|
||||||
|
|
||||||
term_zoomed = False
|
term_zoomed = False
|
||||||
__gproperties__ = {
|
__gproperties__ = {
|
||||||
'term_zoomed': (gobject.TYPE_BOOLEAN,
|
'term_zoomed': (GObject.TYPE_BOOLEAN,
|
||||||
'terminal zoomed',
|
'terminal zoomed',
|
||||||
'whether the terminal is zoomed',
|
'whether the terminal is zoomed',
|
||||||
False,
|
False,
|
||||||
gobject.PARAM_READWRITE)
|
GObject.PARAM_READWRITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -58,8 +58,8 @@ class Window(Container, gtk.Window):
|
||||||
self.terminator.register_window(self)
|
self.terminator.register_window(self)
|
||||||
|
|
||||||
Container.__init__(self)
|
Container.__init__(self)
|
||||||
gtk.Window.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
gobject.type_register(Window)
|
GObject.type_register(Window)
|
||||||
self.register_signals(Window)
|
self.register_signals(Window)
|
||||||
|
|
||||||
self.set_property('allow-shrink', True)
|
self.set_property('allow-shrink', True)
|
||||||
|
@ -168,34 +168,34 @@ class Window(Container, gtk.Window):
|
||||||
|
|
||||||
def apply_icon(self, requested_icon):
|
def apply_icon(self, requested_icon):
|
||||||
"""Set the window icon"""
|
"""Set the window icon"""
|
||||||
icon_theme = gtk.IconTheme()
|
icon_theme = Gtk.IconTheme()
|
||||||
icon = None
|
icon = None
|
||||||
|
|
||||||
if requested_icon:
|
if requested_icon:
|
||||||
try:
|
try:
|
||||||
self.set_icon_from_file(requested_icon)
|
self.set_icon_from_file(requested_icon)
|
||||||
icon = self.get_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)))
|
dbg('Unable to load 48px %s icon as file' % (repr(requested_icon)))
|
||||||
|
|
||||||
if requested_icon and icon is None:
|
if requested_icon and icon is None:
|
||||||
try:
|
try:
|
||||||
icon = icon_theme.load_icon(requested_icon, 48, 0)
|
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)))
|
dbg('Unable to load 48px %s icon' % (repr(requested_icon)))
|
||||||
|
|
||||||
if icon is None:
|
if icon is None:
|
||||||
try:
|
try:
|
||||||
icon = icon_theme.load_icon(self.wmclass_name, 48, 0)
|
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))
|
dbg('Unable to load 48px %s icon' % (self.wmclass_name))
|
||||||
|
|
||||||
if icon is None:
|
if icon is None:
|
||||||
try:
|
try:
|
||||||
icon = icon_theme.load_icon(APP_NAME, 48, 0)
|
icon = icon_theme.load_icon(APP_NAME, 48, 0)
|
||||||
except (NameError, gobject.GError):
|
except (NameError, GObject.GError):
|
||||||
dbg('Unable to load 48px Terminator icon')
|
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)
|
self.set_icon(icon)
|
||||||
|
|
||||||
|
@ -213,9 +213,9 @@ class Window(Container, gtk.Window):
|
||||||
self.set_fullscreen(not self.isfullscreen)
|
self.set_fullscreen(not self.isfullscreen)
|
||||||
elif mapping == 'close_window':
|
elif mapping == 'close_window':
|
||||||
if not self.on_delete_event(window,
|
if not self.on_delete_event(window,
|
||||||
gtk.gdk.Event(gtk.gdk.DELETE)):
|
Gdk.Event(Gdk.DELETE)):
|
||||||
self.on_destroy_event(window,
|
self.on_destroy_event(window,
|
||||||
gtk.gdk.Event(gtk.gdk.DESTROY))
|
Gdk.Event(Gdk.DESTROY))
|
||||||
elif mapping == 'new_tab':
|
elif mapping == 'new_tab':
|
||||||
self.tab_new(self.get_focussed_terminal())
|
self.tab_new(self.get_focussed_terminal())
|
||||||
else:
|
else:
|
||||||
|
@ -284,7 +284,7 @@ class Window(Container, gtk.Window):
|
||||||
"""Display a confirmation dialog when the user is closing multiple
|
"""Display a confirmation dialog when the user is closing multiple
|
||||||
terminals in one window"""
|
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):
|
def on_destroy_event(self, widget, data=None):
|
||||||
"""Handle window destruction"""
|
"""Handle window destruction"""
|
||||||
|
@ -310,7 +310,7 @@ class Window(Container, gtk.Window):
|
||||||
self.show()
|
self.show()
|
||||||
self.grab_focus()
|
self.grab_focus()
|
||||||
try:
|
try:
|
||||||
t = gtk.gdk.x11_get_server_time(self.window)
|
t = GdkX11.x11_get_server_time(self.window)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
t = 0
|
t = 0
|
||||||
self.window.focus(t)
|
self.window.focus(t)
|
||||||
|
@ -322,9 +322,9 @@ class Window(Container, gtk.Window):
|
||||||
def on_window_state_changed(self, window, event):
|
def on_window_state_changed(self, window, event):
|
||||||
"""Handle the state of the window changing"""
|
"""Handle the state of the window changing"""
|
||||||
self.isfullscreen = bool(event.new_window_state &
|
self.isfullscreen = bool(event.new_window_state &
|
||||||
gtk.gdk.WINDOW_STATE_FULLSCREEN)
|
Gdk.WindowState.FULLSCREEN)
|
||||||
self.ismaximised = bool(event.new_window_state &
|
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' \
|
dbg('Window::on_window_state_changed: fullscreen=%s, maximised=%s' \
|
||||||
% (self.isfullscreen, self.ismaximised))
|
% (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.
|
#Present is necessary to grab focus when window is hidden from taskbar.
|
||||||
#It is important to call present() before show(), otherwise the window
|
#It is important to call present() before show(), otherwise the window
|
||||||
#won't be brought to front if an another application has the focus.
|
#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()
|
self.present()
|
||||||
|
|
||||||
#Window must be shown, then hidden for the hotkeys to be registered
|
#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):
|
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()
|
maker = Factory()
|
||||||
gtk.Window.add(self, widget)
|
Gtk.Window.add(self, widget)
|
||||||
if maker.isinstance(widget, 'Terminal'):
|
if maker.isinstance(widget, 'Terminal'):
|
||||||
signals = {'close-term': self.closeterm,
|
signals = {'close-term': self.closeterm,
|
||||||
'title-change': self.title.set_title,
|
'title-change': self.title.set_title,
|
||||||
|
@ -431,8 +431,8 @@ class Window(Container, gtk.Window):
|
||||||
widget.grab_focus()
|
widget.grab_focus()
|
||||||
|
|
||||||
def remove(self, widget):
|
def remove(self, widget):
|
||||||
"""Remove our child widget by way of gtk.Window.remove()"""
|
"""Remove our child widget by way of Gtk.Window.remove()"""
|
||||||
gtk.Window.remove(self, widget)
|
Gtk.Window.remove(self, widget)
|
||||||
self.disconnect_child(widget)
|
self.disconnect_child(widget)
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
|
@ -490,8 +490,8 @@ class Window(Container, gtk.Window):
|
||||||
container.show_all()
|
container.show_all()
|
||||||
sibling.grab_focus()
|
sibling.grab_focus()
|
||||||
|
|
||||||
while gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration_do(False)
|
Gtk.main_iteration_do(False)
|
||||||
self.set_pos_by_ratio = False
|
self.set_pos_by_ratio = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -557,8 +557,8 @@ class Window(Container, gtk.Window):
|
||||||
self.show_all()
|
self.show_all()
|
||||||
widget.grab_focus()
|
widget.grab_focus()
|
||||||
|
|
||||||
while gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
gtk.main_iteration_do(False)
|
Gtk.main_iteration_do(False)
|
||||||
self.set_pos_by_ratio = False
|
self.set_pos_by_ratio = False
|
||||||
|
|
||||||
def get_visible_terminals(self):
|
def get_visible_terminals(self):
|
||||||
|
@ -601,7 +601,7 @@ class Window(Container, gtk.Window):
|
||||||
if self.pending_set_rough_geometry_hint == True:
|
if self.pending_set_rough_geometry_hint == True:
|
||||||
return
|
return
|
||||||
self.pending_set_rough_geometry_hint = True
|
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):
|
def do_deferred_set_rough_geometry_hints(self):
|
||||||
self.pending_set_rough_geometry_hint = False
|
self.pending_set_rough_geometry_hint = False
|
||||||
|
|
Loading…
Reference in New Issue