# -*- coding: utf-8 -*- import os import urllib from gi.repository import Nautilus,GObject def get_translation(text): translations={} translations["Exec in terminal"]={} translations["Exec in terminal"]["es"]="Ejecuta en terminal" translations["Exec in terminal"]["qcv"]="Executa en terminal" lng=os.getenv("LANG") if text in translations: if "qcv" in lng or "ca_ES" in lng: return translations[text]["qcv"] if "es_" in lng or "es." in lng: return translations[text]["es"] return text #def get_translation _=get_translation class OpenTerminalExtension(GObject.GObject, Nautilus.MenuProvider): def __init__(self): pass# self.client = gconf.client_get_default() def _open_terminal(self, file): filename = urllib.unquote(file.get_uri()[7:]) os.system('gnome-terminal -e "%s" &' % filename) def menu_activate_cb(self, menu, file): self._open_terminal(file) def menu_background_activate_cb(self, menu, file): self._open_terminal(file) def get_file_items(self, window, files): if len(files) != 1: return file = files[0] path_dir="" line=str(file.get_parent_uri()) if line.startswith("file://"): path_dir=line[7:] path_to_file=path_dir+"/"+str(file.get_name()) aux_file=open(path_to_file) if os.access(path_to_file, os.X_OK): ext = os.path.splitext(path_to_file)[-1].lower() if ext in [".sh",".pl",".py",".lua",".ksh",".rb"]: etiq = _("Exec in terminal") item = Nautilus.MenuItem(name='NautilusPython::deletefolder_file_item', label= etiq, tip='%s %s' % (etiq,file.get_name()), icon='gtk-execute') item.connect('activate', self.menu_activate_cb, file) return item,