本文整理汇总了Python中terminator.Terminator类的典型用法代码示例。如果您正苦于以下问题:Python Terminator类的具体用法?Python Terminator怎么用?Python Terminator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Terminator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_replicator
def setup_replicator(self):
'''
Target:
- clone a database in PostgreSQL.
'''
connecter = self.get_connecter()
self.logger.debug(Messenger.BEGINNING_EXE_REPLICATOR)
replicator = self.get_replicator(connecter)
pg_superuser = connecter.is_pg_superuser()
if not pg_superuser:
connecter.cursor.execute(Queries.GET_PG_DB_SOME_DATA,
(replicator.original_dbname, ))
db = connecter.cursor.fetchone()
if db['owner'] != connecter.user:
self.logger.stop_exe(Messenger.ACTION_DB_NO_SUPERUSER)
# Terminate every connection to the database which is going to be
# replicated, if necessary
if self.args.terminate:
terminator = Terminator(connecter,
target_dbs=[replicator.original_dbname],
logger=self.logger)
terminator.terminate_backend_dbs([replicator.original_dbname])
# Clone the database
replicator.replicate_pg_db()
# Close connection to PostgreSQL
connecter.pg_disconnect()
开发者ID:alejandrosantana,项目名称:py_pg_tools,代码行数:30,代码来源:orchestrator.py
示例2: toggle_tab_visibility
def toggle_tab_visibility(self, widget):
"""tab visibility"""
status = self.config['tab_position']
old_tab_position = self.config['old_tab_position']
if status == 'hidden':
if old_tab_position:
#if there's no oldstatus, hidden is default option
self.config['tab_position'] = old_tab_position
self.config.save()
else:
self.config['old_tab_position'] = status
self.config['tab_position'] = 'hidden'
self.config.save()
terminator = Terminator()
terminator.reconfigure()
开发者ID:swegener,项目名称:terminator,代码行数:16,代码来源:terminal_popup_menu.py
示例3: __init__
def __init__(self, user, database):
# The database connection parameters are specified in the CONFIG.py file.
# Contains the reference to the database object.
self.db = None
# The database cursor.
self.cursor = None
# The current connection timeout limit.
self.timeout = CONNECTION_TIMEOUT
# The savepoints.
self.savepoints = []
# The user to connect with. If no user is specified, picks the first user
# in the dictionary.
self.user = user if user is not None else LOGIN.keys()[0]
# The name of the database to connect to. If none is specified, use
# <user>_db as the default database.
self.database = database if database is not None else "%s_db" % self.user
# Separate database connection used to terminate queries. If the terminator
# cannot start, the grading cannot occur.
try:
self.terminator = Terminator(self.user, self.database)
except mysql.connector.errors.Error:
err("Could not start up terminator connection! Any unruly queries " +
"must be manually killed!")
开发者ID:anjoola,项目名称:cs12x-automate,代码行数:29,代码来源:dbtools.py
示例4: __init__
def __init__(self):
"""Class initialiser"""
self.terminator = Terminator()
self.terminator.register_window(self)
Container.__init__(self)
gtk.Window.__init__(self)
gobject.type_register(Window)
self.register_signals(Window)
self.set_property("allow-shrink", True)
self.apply_icon()
self.register_callbacks()
self.apply_config()
self.title = WindowTitle(self)
self.title.update()
options = self.config.options_get()
if options:
if options.forcedtitle is not None:
self.title.force_title(options.forcedtitle)
if options.role is not None:
self.set_role(options.role)
if options.geometry is not None:
if not self.parse_geometry(options.geometry):
err("Window::__init__: Unable to parse geometry: %s" % options.geometry)
self.pending_set_rough_geometry_hint = False
开发者ID:AmosZ,项目名称:terminal,代码行数:32,代码来源:window.py
示例5: __init__
def __init__(self, window):
"""Class initialiser"""
if isinstance(window.get_child(), gtk.Notebook):
err('There is already a Notebook at the top of this window')
raise(ValueError)
Container.__init__(self)
gtk.Notebook.__init__(self)
self.terminator = Terminator()
self.window = window
gobject.type_register(Notebook)
self.register_signals(Notebook)
self.connect('switch-page', self.deferred_on_tab_switch)
self.configure()
child = window.get_child()
window.remove(child)
window.add(self)
window_last_active_term = window.last_active_term
self.newtab(widget=child)
if window_last_active_term:
self.set_last_active_term(window_last_active_term)
window.last_active_term = None
self.show_all()
开发者ID:dannywillems,项目名称:terminator,代码行数:25,代码来源:notebook.py
示例6: __init__
class LayoutLauncher:
"""Class implementing the various parts of the preferences editor"""
terminator = None
config = None
registry = None
plugins = None
keybindings = None
window = None
builder = None
layouttreeview = None
layouttreestore = None
def __init__ (self):
self.terminator = Terminator()
self.terminator.register_launcher_window(self)
self.config = config.Config()
self.config.base.reload()
self.builder = gtk.Builder()
try:
# Figure out where our library is on-disk so we can open our UI
(head, _tail) = os.path.split(config.__file__)
librarypath = os.path.join(head, 'layoutlauncher.glade')
gladefile = open(librarypath, 'r')
gladedata = gladefile.read()
except Exception, ex:
print "Failed to find layoutlauncher.glade"
print ex
return
self.builder.add_from_string(gladedata)
self.window = self.builder.get_object('layoutlauncherwin')
icon_theme = gtk.IconTheme()
try:
icon = icon_theme.load_icon('terminator-layout', 48, 0)
except (NameError, gobject.GError):
dbg('Unable to load 48px Terminator preferences icon')
icon = self.window.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
self.window.set_icon(icon)
self.builder.connect_signals(self)
self.window.connect('destroy', self.on_destroy_event)
self.window.show_all()
self.layouttreeview = self.builder.get_object('layoutlist')
self.layouttreestore = self.builder.get_object('layoutstore')
self.update_layouts()
开发者ID:Reventl0v,项目名称:Terminator,代码行数:47,代码来源:layoutlauncher.py
示例7: on_stone_received
def on_stone_received(self, stone):
pid_file = tempfile.mktemp()
stone = pickle.loads(stone)
logging.getLogger(__name__).info("received %s task from broker" % stone.name)
child_pid = os.fork()
time.sleep(0.1)
if not child_pid:
#child
logging.getLogger(__name__).debug("started child %s" % os.getpid())
s = Sisyphus(stone, pid_file, ttl=SISYPHUS_JOIN_TTL, logger=logging.getLogger(__name__))
s.run()
time.sleep(0.1)
else:
#master
t = Terminator(child_pid, pid_file, ttl=SISYPHUS_WORKER_TTL)
t.start()
time.sleep(0.1)
开发者ID:mkorenkov,项目名称:sisyphus,代码行数:17,代码来源:master.py
示例8: __init__
def __init__(self, terminal):
"""Class initialiser"""
GObject.GObject.__init__(self)
self.terminator = Terminator()
self.terminal = terminal
self.config = self.terminal.config
self.label = EditableLabel()
self.label.connect('edit-done', self.on_edit_done)
self.ebox = Gtk.EventBox()
grouphbox = Gtk.HBox()
self.grouplabel = Gtk.Label(ellipsize='end')
self.groupicon = Gtk.Image()
self.bellicon = Gtk.Image()
self.bellicon.set_no_show_all(True)
self.groupentry = Gtk.Entry()
self.groupentry.set_no_show_all(True)
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
self.groupentry.connect('activate', self.groupentry_activate)
self.groupentry.connect('key-press-event', self.groupentry_keypress)
groupsend_type = self.terminator.groupsend_type
if self.terminator.groupsend == groupsend_type['all']:
icon_name = 'all'
elif self.terminator.groupsend == groupsend_type['group']:
icon_name = 'group'
elif self.terminator.groupsend == groupsend_type['off']:
icon_name = 'off'
self.set_from_icon_name('_active_broadcast_%s' % icon_name,
Gtk.IconSize.MENU)
grouphbox.pack_start(self.groupicon, False, True, 2)
grouphbox.pack_start(self.grouplabel, False, True, 2)
grouphbox.pack_start(self.groupentry, False, True, 2)
self.ebox.add(grouphbox)
self.ebox.show_all()
self.bellicon.set_from_icon_name('terminal-bell', Gtk.IconSize.MENU)
viewport = Gtk.Viewport(hscroll_policy='natural')
viewport.add(self.label)
hbox = Gtk.HBox()
hbox.pack_start(self.ebox, False, True, 0)
hbox.pack_start(Gtk.VSeparator(), False, True, 0)
hbox.pack_start(viewport, True, True, 0)
hbox.pack_end(self.bellicon, False, False, 2)
self.add(hbox)
hbox.show_all()
self.set_no_show_all(True)
self.show()
self.connect('button-press-event', self.on_clicked)
开发者ID:guoxiao,项目名称:terminator-gtk3,代码行数:57,代码来源:titlebar.py
示例9: __init__
def __init__(self, terminal):
"""Class initialiser"""
gtk.EventBox.__init__(self)
self.__gobject_init__()
self.terminator = Terminator()
self.terminal = terminal
self.config = self.terminal.config
self.label = EditableLabel()
self.label.connect('edit-done', self.on_edit_done)
self.ebox = gtk.EventBox()
grouphbox = gtk.HBox()
self.grouplabel = gtk.Label()
self.groupicon = gtk.Image()
self.bellicon = gtk.Image()
self.bellicon.set_no_show_all(True)
self.groupentry = gtk.Entry()
self.groupentry.set_no_show_all(True)
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
self.groupentry.connect('activate', self.groupentry_activate)
self.groupentry.connect('key-press-event', self.groupentry_keypress)
groupsend_type = self.terminator.groupsend_type
if self.terminator.groupsend == groupsend_type['all']:
icon_name = 'all'
elif self.terminator.groupsend == groupsend_type['group']:
icon_name = 'group'
elif self.terminator.groupsend == groupsend_type['off']:
icon_name = 'off'
self.set_from_icon_name('_active_broadcast_%s' % icon_name,
gtk.ICON_SIZE_MENU)
grouphbox.pack_start(self.groupicon, False, True, 2)
grouphbox.pack_start(self.grouplabel, False, True, 2)
grouphbox.pack_start(self.groupentry, False, True, 2)
self.ebox.add(grouphbox)
self.ebox.show_all()
self.bellicon.set_from_icon_name('terminal-bell', gtk.ICON_SIZE_MENU)
hbox = gtk.HBox()
hbox.pack_start(self.ebox, False, True, 0)
hbox.pack_start(gtk.VSeparator(), False, True, 0)
hbox.pack_start(self.label, True, True)
hbox.pack_end(self.bellicon, False, False, 2)
self.add(hbox)
hbox.show_all()
self.set_no_show_all(True)
self.show()
self.connect('button-press-event', self.on_clicked)
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:54,代码来源:titlebar.py
示例10: setup_dropper
def setup_dropper(self):
'''
Target:
- delete specified databases in PostgreSQL.
'''
connecter = self.get_connecter()
self.logger.debug(Messenger.BEGINNING_EXE_DROPPER)
dropper = self.get_dropper(connecter)
# Terminate every connection to the target databases if necessary
if self.args.terminate:
terminator = Terminator(connecter, target_dbs=dropper.dbnames,
logger=self.logger)
terminator.terminate_backend_dbs(dropper.dbnames)
# Delete the databases
dropper.drop_pg_dbs(dropper.dbnames)
# Close connection to PostgreSQL
connecter.pg_disconnect()
开发者ID:alejandrosantana,项目名称:py_pg_tools,代码行数:20,代码来源:orchestrator.py
示例11: setup_vacuumer
def setup_vacuumer(self):
'''
Target:
- executes the vacuumer taking into account the value of its
variables.
'''
connecter = self.get_connecter()
self.logger.debug(Messenger.BEGINNING_EXE_VACUUMER)
vacuumer = self.get_vacuumer(connecter)
# Check if the role of user connected to PostgreSQL is superuser
pg_superuser = connecter.is_pg_superuser()
if not pg_superuser:
# Users who are not superusers will only be able to vacuum the
# databases they own
vacuumer.db_owner = connecter.user
self.logger.warning(Messenger.ACTION_DB_NO_SUPERUSER)
# Get PostgreSQL databases' names, connection permissions and owners
dbs_all = connecter.get_pg_dbs_data(vacuumer.ex_templates,
vacuumer.db_owner)
# Show and log their names
Orchestrator.show_dbs(dbs_all, self.logger)
# Get the target databases in a list
vacuum_list = DbSelector.get_filtered_dbs(
dbs_all, vacuumer.in_dbs, vacuumer.ex_dbs, vacuumer.in_regex,
vacuumer.ex_regex, vacuumer.in_priority, self.logger)
# Terminate every connection to these target databases if necessary
if self.args.terminate:
terminator = Terminator(connecter, target_dbs=vacuum_list,
logger=self.logger)
terminator.terminate_backend_dbs(vacuum_list)
# Vacuum the target databases
vacuumer.vacuum_dbs(vacuum_list)
# Close connection to PostgreSQL
connecter.pg_disconnect()
开发者ID:alejandrosantana,项目名称:py_pg_tools,代码行数:41,代码来源:orchestrator.py
示例12: setup_alterer
def setup_alterer(self):
'''
Target:
- change the owner of the specified databases in PostgreSQL.
'''
connecter = self.get_connecter()
self.logger.debug(Messenger.BEGINNING_EXE_ALTERER)
alterer = self.get_alterer(connecter)
# Check if the role of user connected to PostgreSQL is superuser
pg_superuser = connecter.is_pg_superuser()
if not pg_superuser:
# Users who are not superusers will only be able to backup the
# databases they own
owner = connecter.user
self.logger.highlight('warning', Messenger.ACTION_DB_NO_SUPERUSER,
'yellow', effect='bold')
else:
owner = ''
# Get PostgreSQL databases' names, connection permissions and owners
dbs_all = connecter.get_pg_dbs_data(ex_templates=False, db_owner=owner)
# Show and log their names
Orchestrator.show_dbs(dbs_all, self.logger)
# Get the target databases in a list
alt_list = DbSelector.get_filtered_dbs(
dbs_all=dbs_all, in_dbs=alterer.in_dbs, logger=self.logger)
# Terminate every connection to the target databases if necessary
if self.args.terminate:
terminator = Terminator(connecter, target_dbs=alt_list,
logger=self.logger)
terminator.terminate_backend_dbs(alt_list)
# Delete the databases
alterer.alter_dbs_owner(alt_list)
# Close connection to PostgreSQL
connecter.pg_disconnect()
开发者ID:alejandrosantana,项目名称:py_pg_tools,代码行数:40,代码来源:orchestrator.py
示例13: __init__
class LayoutLauncher:
"""Class implementing the various parts of the preferences editor"""
terminator = None
config = None
registry = None
plugins = None
keybindings = None
window = None
builder = None
layouttreeview = None
layouttreestore = None
def __init__ (self):
self.terminator = Terminator()
self.terminator.register_launcher_window(self)
self.config = config.Config()
self.config.base.reload()
self.builder = gtk.Builder()
try:
# Figure out where our library is on-disk so we can open our UI
(head, _tail) = os.path.split(config.__file__)
librarypath = os.path.join(head, 'layoutlauncher.glade')
gladefile = open(librarypath, 'r')
gladedata = gladefile.read()
except Exception, ex:
print "Failed to find layoutlauncher.glade"
print ex
return
self.builder.add_from_string(gladedata)
self.window = self.builder.get_object('layoutlauncherwin')
self.builder.connect_signals(self)
self.window.connect('destroy', self.on_destroy_event)
self.window.show_all()
self.layouttreeview = self.builder.get_object('layoutlist')
self.layouttreestore = self.builder.get_object('layoutstore')
self.update_layouts()
开发者ID:janisozaur,项目名称:terminator,代码行数:38,代码来源:layoutlauncher.py
示例14: prepare_attributes
def prepare_attributes(self):
"""Ensure we are populated"""
if not self.bus_name:
dbg('Checking for bus name availability: %s' % BUS_NAME)
bus = dbus.SessionBus()
proxy = bus.get_object('org.freedesktop.DBus',
'/org/freedesktop/DBus')
flags = 1 | 4 # allow replacement | do not queue
if not proxy.RequestName(BUS_NAME, dbus.UInt32(flags)) in (1, 4):
dbg('bus name unavailable: %s' % BUS_NAME)
raise dbus.exceptions.DBusException(
"Couldn't get DBus name %s: Name exists" % BUS_NAME)
self.bus_name = dbus.service.BusName(BUS_NAME,
bus=dbus.SessionBus())
if not self.bus_path:
self.bus_path = BUS_PATH
if not self.terminator:
self.terminator = Terminator()
开发者ID:AmosZ,项目名称:terminal,代码行数:18,代码来源:ipc.py
示例15: __init__
def __init__(self):
"""Class initialiser"""
self.terminator = Terminator()
self.terminator.register_window(self)
Container.__init__(self)
GObject.GObject.__init__(self)
GObject.type_register(Window)
self.register_signals(Window)
self.get_style_context().add_class("terminator-terminal-window")
# self.set_property('allow-shrink', True) # FIXME FOR GTK3, or do we need this actually?
icon_to_apply=''
self.register_callbacks()
self.apply_config()
self.title = WindowTitle(self)
self.title.update()
self.preventHide = False
options = self.config.options_get()
if options:
if options.forcedtitle:
self.title.force_title(options.forcedtitle)
if options.role:
self.set_role(options.role)
if options.forcedicon is not None:
icon_to_apply = options.forcedicon
if options.geometry:
if not self.parse_geometry(options.geometry):
err('Window::__init__: Unable to parse geometry: %s' %
options.geometry)
self.apply_icon(icon_to_apply)
self.pending_set_rough_geometry_hint = False
开发者ID:albfan,项目名称:terminator,代码行数:41,代码来源:window.py
示例16: DBusService
class DBusService(Borg, dbus.service.Object):
"""DBus Server class. This is implemented as a Borg"""
bus_name = None
bus_path = None
terminator = None
def __init__(self):
"""Class initialiser"""
Borg.__init__(self, self.__class__.__name__)
self.prepare_attributes()
try:
dbus.service.Object.__init__(self, self.bus_name, BUS_PATH)
except:
None
def prepare_attributes(self):
"""Ensure we are populated"""
if not self.bus_name:
dbg('Checking for bus name availability: %s' % BUS_NAME)
bus = dbus.SessionBus()
proxy = bus.get_object('org.freedesktop.DBus',
'/org/freedesktop/DBus')
flags = 1 | 4 # allow replacement | do not queue
if not proxy.RequestName(BUS_NAME, dbus.UInt32(flags)) in (1, 4):
dbg('bus name unavailable: %s' % BUS_NAME)
raise dbus.exceptions.DBusException(
"Couldn't get DBus name %s: Name exists" % BUS_NAME)
self.bus_name = dbus.service.BusName(BUS_NAME,
bus=dbus.SessionBus())
if not self.bus_path:
self.bus_path = BUS_PATH
if not self.terminator:
self.terminator = Terminator()
@dbus.service.method(BUS_NAME, in_signature='a{ss}')
def new_window_cmdline(self, options=dbus.Dictionary()):
"""Create a new Window"""
dbg('dbus method called: new_window with parameters %s'%(options))
oldopts = self.terminator.config.options_get()
oldopts.__dict__ = options
self.terminator.config.options_set(oldopts)
self.terminator.create_layout(oldopts.layout)
self.terminator.layout_done()
@dbus.service.method(BUS_NAME, in_signature='a{ss}')
def new_tab_cmdline(self, options=dbus.Dictionary()):
"""Create a new tab"""
dbg('dbus method called: new_tab with parameters %s'%(options))
oldopts = self.terminator.config.options_get()
oldopts.__dict__ = options
self.terminator.config.options_set(oldopts)
window = self.terminator.get_windows()[0]
window.tab_new()
@dbus.service.method(BUS_NAME)
def new_window(self):
"""Create a new Window"""
terminals_before = set(self.get_terminals())
self.terminator.new_window()
terminals_after = set(self.get_terminals())
new_terminal_set = list(terminals_after - terminals_before)
if len(new_terminal_set) != 1:
return "ERROR: Cannot determine the UUID of the added terminal"
else:
return new_terminal_set[0]
@dbus.service.method(BUS_NAME)
def new_tab(self, uuid=None):
"""Create a new tab"""
return self.new_terminal(uuid, 'tab')
@dbus.service.method(BUS_NAME)
def hsplit(self, uuid=None):
"""Split a terminal horizontally, by UUID"""
return self.new_terminal(uuid, 'hsplit')
@dbus.service.method(BUS_NAME)
def vsplit(self, uuid=None):
"""Split a terminal vertically, by UUID"""
return self.new_terminal(uuid, 'vsplit')
def new_terminal(self, uuid, type):
"""Split a terminal horizontally or vertically, by UUID"""
dbg('dbus method called: %s' % type)
if not uuid:
return "ERROR: No UUID specified"
terminal = self.terminator.find_terminal_by_uuid(uuid)
terminals_before = set(self.get_terminals())
if not terminal:
return "ERROR: Terminal with supplied UUID not found"
elif type == 'tab':
terminal.key_new_tab()
elif type == 'hsplit':
terminal.key_split_horiz()
elif type == 'vsplit':
terminal.key_split_vert()
else:
return "ERROR: Unknown type \"%s\" specified" % (type)
terminals_after = set(self.get_terminals())
# Detect the new terminal UUID
#.........这里部分代码省略.........
开发者ID:albfan,项目名称:terminator,代码行数:101,代码来源:ipc.py
示例17: Notebook
class Notebook(Container, gtk.Notebook):
"""Class implementing a gtk.Notebook container"""
window = None
last_active_term = None
pending_on_tab_switch = None
pending_on_tab_switch_args = None
def __init__(self, window):
"""Class initialiser"""
if isinstance(window.get_child(), gtk.Notebook):
err('There is already a Notebook at the top of this window')
raise(ValueError)
Container.__init__(self)
gtk.Notebook.__init__(self)
self.terminator = Terminator()
self.window = window
gobject.type_register(Notebook)
self.register_signals(Notebook)
self.connect('switch-page', self.deferred_on_tab_switch)
self.configure()
child = window.get_child()
window.remove(child)
window.add(self)
window_last_active_term = window.last_active_term
self.newtab(widget=child)
if window_last_active_term:
self.set_last_active_term(window_last_active_term)
window.last_active_term = None
self.show_all()
def configure(self):
"""Apply widget-wide settings"""
# FIXME: The old reordered handler updated Terminator.terminals with
# the new order of terminals. We probably need to preserve this for
# navigation to next/prev terminals.
#self.connect('page-reordered', self.on_page_reordered)
self.set_property('homogeneous', self.config['homogeneous_tabbar'])
self.set_scrollable(self.config['scroll_tabbar'])
if self.config['tab_position'] == 'hidden' or self.config['hide_tabbar']:
self.set_show_tabs(False)
else:
self.set_show_tabs(True)
pos = getattr(gtk, 'POS_%s' % self.config['tab_position'].upper())
self.set_tab_pos(pos)
for tab in xrange(0, self.get_n_pages()):
label = self.get_tab_label(self.get_nth_page(tab))
label.update_angle()
style = gtk.RcStyle()
style.xthickness = 0
style.ythickness = 0
self.modify_style(style)
self.last_active_term = {}
def create_layout(self, layout):
"""Apply layout configuration"""
def child_compare(a, b):
order_a = children[a]['order']
order_b = children[b]['order']
if (order_a == order_b):
return 0
if (order_a < order_b):
return -1
if (order_a > order_b):
return 1
if not layout.has_key('children'):
err('layout specifies no children: %s' % layout)
return
children = layout['children']
if len(children) <= 1:
#Notebooks should have two or more children
err('incorrect number of children for Notebook: %s' % layout)
return
num = 0
keys = children.keys()
keys.sort(child_compare)
for child_key in keys:
child = children[child_key]
dbg('Making a child of type: %s' % child['type'])
if child['type'] == 'Terminal':
pass
elif child['type'] == 'VPaned':
page = self.get_nth_page(num)
self.split_axis(page, True)
elif child['type'] == 'HPaned':
page = self.get_nth_page(num)
self.split_axis(page, False)
num = num + 1
num = 0
#.........这里部分代码省略.........
开发者ID:dannywillems,项目名称:terminator,代码行数:101,代码来源:notebook.py
示例18: Window
class Window(Container, gtk.Window):
"""Class implementing a top-level Terminator window"""
terminator = None
title = None
isfullscreen = None
ismaximised = None
hidebound = None
hidefunc = None
losefocus_time = 0
position = None
ignore_startup_show = None
set_pos_by_ratio = None
zoom_data = None
term_zoomed = False
__gproperties__ = {
'term_zoomed': (gobject.TYPE_BOOLEAN,
'terminal zoomed',
'whether the terminal is zoomed',
False,
gobject.PARAM_READWRITE)
}
def __init__(self):
"""Class initialiser"""
self.terminator = Terminator()
self.terminator.register_window(self)
Container.__init__(self)
gtk.Window.__init__(self)
gobject.type_register(Window)
self.register_signals(Window)
self.set_property('allow-shrink', True)
icon_to_apply=''
self.register_callbacks()
self.apply_config()
self.title = WindowTitle(self)
self.title.update()
options = self.config.options_get()
if options:
if options.forcedtitle:
self.title.force_title(options.forcedtitle)
if options.role:
self.set_role(options.role)
if options.classname is not None:
self.set_wmclass(options.classname, self.wmclass_class)
if options.forcedicon is not None:
icon_to_apply = options.forcedicon
if options.geometry:
if not self.parse_geometry(options.geometry):
err('Window::__init__: Unable to parse geometry: %s' %
options.geometry)
self.apply_icon(icon_to_apply)
self.pending_set_rough_geometry_hint = False
def do_get_property(self, prop):
"""Handle gobject getting a property"""
if prop.name in ['term_zoomed', 'term-zoomed']:
return(self.term_zoomed)
else:
raise AttributeError('unknown property %s' % prop.name)
def do_set_property(self, prop, value):
"""Handle gobject setting a property"""
if prop.name in ['term_zoomed', 'term-zoomed']:
self.term_zoomed = value
else:
raise AttributeError('unknown property %s' % prop.name)
def register_callbacks(self):
"""Connect the GTK+ signals we care about"""
self.connect('key-press-event', self.on_key_press)
self.connect('button-press-event', self.on_button_press)
self.connect('delete_event', self.on_delete_event)
self.connect('destroy', self.on_destroy_event)
self.connect('window-state-event', self.on_window_state_changed)
self.connect('focus-out-event', self.on_focus_out)
self.connect('focus-in-event', self.on_focus_in)
# Attempt to grab a global hotkey for hiding the window.
# If we fail, we'll never hide the window, iconifying instead.
if self.config['keybindings']['hide_window'] != None:
try:
self.hidebound = keybinder.bind(
self.config['keybindings']['hide_window'],
self.on_hide_window)
except (KeyError, NameError):
pass
#.........这里部分代码省略.........
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:101,代码来源:window.py
示例19: __init__
def __init__(self, terminal):
"""Class initialiser"""
self.terminal = terminal
self.terminator = Terminator()
self.config = Config()
开发者ID:safiyat,项目名称:terminator,代码行数:5,代码来源:terminal_popup_menu.py
示例20: TerminalPopupMenu
class TerminalPopupMenu(object):
"""Class implementing the Terminal context menu"""
terminal = None
terminator = None
config = None
def __init__(self, terminal):
"""Class initialiser"""
self.terminal = terminal
self.terminator = Terminator()
self.config = Config()
def show(self, widget, event=None):
"""Display the context menu"""
terminal = self.terminal
menu = gtk.Menu()
url = None
button = None
time = None
self.config.set_profile(terminal.get_profile())
if event:
url = terminal.check_for_url(event)
button = event.button
time = event.time
else:
time = 0
button = 3
if url:
dbg("URL matches id: %d" % url[1])
if not url[1] in terminal.matches.values():
err("Unknown URL match id: %d" % url[1])
dbg("Available matches: %s" % terminal.matches)
nameopen = None
namecopy = None
if url[1] == terminal.matches['email']:
nameopen = _('_Send email to...')
namecopy = _('_Copy email address')
elif url[1] == terminal.matches['voip']:
nameopen = _('Ca_ll VoIP address')
namecopy = _('_Copy VoIP address')
elif url[1] in terminal.matches.values():
# This is a plugin match
for pluginname in terminal.matches:
if terminal.matches[pluginname] == url[1]:
break
dbg("Found match ID (%d) in terminal.matches plugin %s" %
(url[1], pluginname))
registry = plugin.PluginRegistry()
registry.load_plugins()
plugins = registry.get_plugins_by_capability('url_handler')
for urlplugin in plugins:
if urlplugin.handler_name == pluginname:
dbg("Identified matching plugin: %s" %
urlplugin.handler_name)
nameopen = _(urlplugin.nameopen)
namecopy = _(urlplugin.namecopy)
break
if not nameopen:
nameopen = _('_Open link')
if not namecopy:
namecopy = _('_Copy address')
icon = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,
gtk.ICON_SIZE_MENU)
item = gtk.ImageMenuItem(nameopen)
item.set_property('image', icon)
item.connect('activate', lambda x: terminal.open_url(url, True))
menu.append(item)
item = gtk.MenuItem(namecopy)
item.connect('activate',
lambda x: terminal.clipboard.set_text(terminal.prepare_url(url)))
menu.append(item)
menu.append(gtk.MenuItem())
item = gtk.ImageMenuItem(gtk.STOCK_COPY)
item.connect('activate', lambda x: terminal.vte.copy_clipboard())
item.set_sensitive(terminal.vte.get_has_selection())
menu.append(item)
item = gtk.ImageMenuItem(gtk.STOCK_PASTE)
item.connect('activate', lambda x: terminal.paste_clipboard())
menu.append(item)
menu.append(gtk.MenuItem())
if not terminal.is_zoomed():
item = gtk.ImageMenuItem(_('Split H_orizontally'))
image = gtk.Image()
image.set_from_icon_name(APP_NAME + '_horiz', gtk.ICON_SIZE_MENU)
item.set_image(image)
if hasattr(item, 'set_always_show_image'):
#.........这里部分代码省略.........
开发者ID:safiyat,项目名称:terminator,代码行数:101,代码来源:terminal_popup_menu.py
注:本文中的terminator.Terminator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论