本文整理汇总了Python中terminatorlib.translation._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
def configure(self, widget, data = None):
ui = {}
dbox = Gtk.Dialog( _("Terminator themes"), None, Gtk.DialogFlags.MODAL)
headers = { "Accept": "application/vnd.github.v3.raw" }
response = requests.get(self.base_url, headers=headers)
if response.status_code != 200:
gerr(_("Failed to get list of available themes"))
return
self.themes_from_repo = response.json()["themes"]
self.profiles = self.terminal.config.list_profiles()
main_container = Gtk.HBox(spacing=7)
main_container.pack_start(self._create_themes_list(ui), True, True, 0)
main_container.pack_start(self._create_settings_grid(ui), True, True, 0)
dbox.vbox.pack_start(main_container, True, True, 0)
self.dbox = dbox
dbox.show_all()
res = dbox.run()
if res == Gtk.ResponseType.ACCEPT:
self.terminal.config.save()
del(self.dbox)
dbox.destroy()
return
示例2: _create_command_dialog
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
dialog = Gtk.Dialog(
_("New Command"),
None,
Gtk.DialogFlags.MODAL,
(
Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT
)
)
table = Gtk.Table(3, 2)
label = Gtk.Label(label=_("Enabled:"))
table.attach(label, 0, 1, 0, 1)
enabled = Gtk.CheckButton()
enabled.set_active(enabled_var)
table.attach(enabled, 1, 2, 0, 1)
label = Gtk.Label(label=_("Name:"))
table.attach(label, 0, 1, 1, 2)
name = Gtk.Entry()
name.set_text(name_var)
table.attach(name, 1, 2, 1, 2)
label = Gtk.Label(label=_("Command:"))
table.attach(label, 0, 1, 2, 3)
command = Gtk.Entry()
command.set_text(command_var)
table.attach(command, 1, 2, 2, 3)
dialog.vbox.pack_start(table, True, True, 0)
dialog.show_all()
return (dialog,enabled,name,command)
示例3: _create_command_dialog
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
dialog = gtk.Dialog(
_("New Command"),
None,
gtk.DIALOG_MODAL,
(
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
)
)
table = gtk.Table(3, 2)
label = gtk.Label(_("Enabled:"))
table.attach(label, 0, 1, 0, 1)
enabled = gtk.CheckButton()
enabled.set_active(enabled_var)
table.attach(enabled, 1, 2, 0, 1)
label = gtk.Label(_("Name:"))
table.attach(label, 0, 1, 1, 2)
name = gtk.Entry()
name.set_text(name_var)
table.attach(name, 1, 2, 1, 2)
label = gtk.Label(_("Command:"))
table.attach(label, 0, 1, 2, 3)
command = gtk.Entry()
command.set_text(command_var)
table.attach(command, 1, 2, 2, 3)
dialog.vbox.pack_start(table)
dialog.show_all()
return (dialog,enabled,name,command)
示例4: callback
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
item = gtk.MenuItem(_('_Custom Commands'))
menuitems.append(item)
submenu = gtk.Menu()
item.set_submenu(submenu)
menuitem = gtk.ImageMenuItem(_('_Preferences'))
menuitem.connect("activate", self.configure)
submenu.append(menuitem)
menuitem = gtk.SeparatorMenuItem()
submenu.append(menuitem)
theme = gtk.icon_theme_get_default()
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
if not command['enabled']:
continue
exe = command['command'].split(' ')[0]
iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
if iconinfo:
image = gtk.Image()
image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
menuitem = gtk.ImageMenuItem(command['name'])
menuitem.set_image(image)
else:
menuitem = gtk.MenuItem(command["name"])
terminals = terminal.terminator.get_target_terms(terminal)
menuitem.connect("activate", self._execute, {'terminals' : terminals, 'command' : command['command'] })
submenu.append(menuitem)
示例5: on_new
def on_new(self, button, data):
(dialog,enabled,name,command) = self._create_command_dialog()
res = dialog.run()
item = {}
if res == Gtk.ResponseType.ACCEPT:
item['enabled'] = enabled.get_active()
item['name'] = name.get_text()
item['command'] = command.get_text()
if item['name'] == '' or item['command'] == '':
err = Gtk.MessageDialog(dialog,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.CLOSE,
_("You need to define a name and command")
)
err.run()
err.destroy()
else:
# we have a new command
store = data['treeview'].get_model()
iter = store.get_iter_first()
name_exist = False
while iter != None:
if store.get_value(iter,CC_COL_NAME) == item['name']:
name_exist = True
break
iter = store.iter_next(iter)
if not name_exist:
store.append((item['enabled'], item['name'], item['command']))
else:
self._err(_("Name *%s* already exist") % item['name'])
dialog.destroy()
示例6: callback
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
if not self.watches.has_key(terminal):
item = gtk.MenuItem(_('Watch for activity'))
item.connect("activate", self.watch, terminal)
else:
item = gtk.MenuItem(_('Stop watching for activity'))
item.connect("activate", self.unwatch, terminal)
menuitems.append(item)
示例7: callback
def callback(self, menuitems, menu, terminal):
""" Add save menu item to the menu"""
vte_terminal = terminal.get_vte()
if not self.loggers.has_key(vte_terminal):
item = gtk.MenuItem(_('Start Logger'))
item.connect("activate", self.start_logger, terminal)
else:
item = gtk.MenuItem(_('Stop Logger'))
item.connect("activate", self.stop_logger, terminal)
item.set_has_tooltip(True)
item.set_tooltip_text("Saving at '" + self.loggers[vte_terminal]["filepath"] + "'")
menuitems.append(item)
示例8: check_times
def check_times(self, terminal):
"""Check if this terminal has gone silent"""
time_now = time.mktime(time.gmtime())
if not self.last_activities.has_key(terminal):
dbg('Terminal %s has no last activity' % terminal)
return True
dbg('seconds since last activity: %f (%s)' % (time_now - self.last_activities[terminal], terminal))
if time_now - self.last_activities[terminal] >= inactive_period:
del(self.last_activities[terminal])
note = Notify.Notification.new(_('Terminator'), _('Silence in: %s') %
terminal.get_window_title(), 'terminator')
note.show()
return True
示例9: callback
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
item = gtk.MenuItem(_('Custom Commands'))
menuitems.append(item)
submenu = gtk.Menu()
item.set_submenu(submenu)
menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
menuitem.connect("activate", self.configure)
submenu.append(menuitem)
menuitem = gtk.SeparatorMenuItem()
submenu.append(menuitem)
theme = gtk.IconTheme()
for command in self.cmd_list:
if not command['enabled']:
continue
exe = command['command'].split(' ')[0]
iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
if iconinfo:
image = gtk.Image()
image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
menuitem = gtk.ImageMenuItem(command['name'])
menuitem.set_image(image)
else:
menuitem = gtk.MenuItem(command["name"])
menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
submenu.append(menuitem)
示例10: start_logger
def start_logger(self, _widget, Terminal):
""" Handle menu item callback by saving text to a file"""
savedialog = gtk.FileChooserDialog(title=_("Save Log File As"),
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_do_overwrite_confirmation(True)
savedialog.set_local_only(True)
savedialog.show_all()
response = savedialog.run()
if response == gtk.RESPONSE_OK:
try:
logfile = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
fd = open(logfile, 'w+')
# Save log file path,
# associated file descriptor, signal handler id
# and last saved col,row positions respectively.
vte_terminal = Terminal.get_vte()
(col, row) = vte_terminal.get_cursor_position()
self.loggers[vte_terminal] = {"filepath":logfile,
"handler_id":0, "fd":fd,
"col":col, "row":row}
# Add contents-changed callback
self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
except:
e = sys.exc_info()[1]
error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK, e.strerror)
error.run()
error.destroy()
savedialog.destroy()
示例11: terminalshot
def terminalshot(self, _widget, terminal):
"""Handle the taking, prompting and saving of a terminalshot"""
# Grab a pixbuf of the terminal
orig_pixbuf = widget_pixbuf(terminal)
savedialog = gtk.FileChooserDialog(title=_("Save image"),
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_do_overwrite_confirmation(True)
savedialog.set_local_only(True)
pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
orig_pixbuf.get_height() / 2,
gtk.gdk.INTERP_BILINEAR)
image = gtk.image_new_from_pixbuf(pixbuf)
savedialog.set_preview_widget(image)
savedialog.show_all()
response = savedialog.run()
path = None
if response == gtk.RESPONSE_OK:
path = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
orig_pixbuf.save(path, 'png')
savedialog.destroy()
示例12: _create_main_action_button
def _create_main_action_button(self, ui, label, action):
btn = Gtk.Button(_(label.capitalize()))
btn.connect("clicked", action, ui)
btn.set_sensitive(False)
ui['button_' + label] = btn
return btn
示例13: callback
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
item = Gtk.MenuItem(_('Custom Commands'))
menuitems.append(item)
submenu = Gtk.Menu()
item.set_submenu(submenu)
menuitem = Gtk.ImageMenuItem(Gtk.STOCK_PREFERENCES)
menuitem.connect("activate", self.configure)
submenu.append(menuitem)
menuitem = Gtk.SeparatorMenuItem()
submenu.append(menuitem)
theme = Gtk.IconTheme()
for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
if not command['enabled']:
continue
exe = command['command'].split(' ')[0]
iconinfo = theme.choose_icon([exe], Gtk.IconSize.MENU, Gtk.IconLookupFlags.USE_BUILTIN)
if iconinfo:
image = Gtk.Image()
image.set_from_icon_name(exe, Gtk.IconSize.MENU)
menuitem = Gtk.ImageMenuItem(command['name'])
menuitem.set_image(image)
else:
menuitem = Gtk.MenuItem(command["name"])
terminals = terminal.terminator.get_target_terms(terminal)
menuitem.connect("activate", self._execute, {'terminals' : terminals, 'command' : command['command'] })
submenu.append(menuitem)
示例14: terminalshot
def terminalshot(self, _widget, terminal):
"""Handle the taking, prompting and saving of a terminalshot"""
# Grab a pixbuf of the terminal
orig_pixbuf = widget_pixbuf(terminal)
savedialog = Gtk.FileChooserDialog(title=_("Save image"),
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_transient_for(_widget.get_toplevel())
savedialog.set_do_overwrite_confirmation(True)
savedialog.set_local_only(True)
pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
orig_pixbuf.get_height() / 2,
GdkPixbuf.InterpType.BILINEAR)
image = Gtk.Image.new_from_pixbuf(pixbuf)
savedialog.set_preview_widget(image)
savedialog.show_all()
response = savedialog.run()
path = None
if response == Gtk.ResponseType.OK:
path = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
orig_pixbuf.savev(path, 'png', [], [])
savedialog.destroy()
示例15: on_install
def on_install(self, button, data):
treeview = data['treeview']
selection = treeview.get_selection()
(store, iter) = selection.get_selected()
target = store[iter][0]
widget = self.terminal.get_vte()
treeview.set_enable_tree_lines(False)
if not iter:
return
headers = { "Accept": "application/vnd.github.v3.raw" }
response = requests.get(self.base_url+ '/' + target + '.config', headers=headers)
if response.status_code != 200:
gerr(_("Failed to download selected theme"))
return
# Creates a new profile and overwrites the default colors for the new theme
self.terminal.config.add_profile(target)
target_data = self.make_dictionary(response.content)
for k, v in target_data.items():
if k != 'background_image':
self.config_base.set_item(k, v[1:-1], target)
self.terminal.force_set_profile(widget, target)
self.terminal.config.save()
# "Remove" button available again
self.liststore.set_value(iter, 1, False)
self.on_selection_changed(selection, data)
treeview.set_enable_tree_lines(True)