# -*- coding: utf-8 -*- import os import urllib from urllib import unquote from gi.repository import Nautilus, GObject def get_translation(text): translations={} translations["Create launcher"]={} translations["Create launcher"]["es"]="Crea lanzador" translations["Create launcher"]["qcv"]="Crea llançador" 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 ColumnExtension(GObject.GObject, Nautilus.MenuProvider): def __init__(self): pass def menu_activate_carpeta(self, menu, file): fichero = file.get_uri() if fichero == "x-nautilus-desktop:///": os.system("gnome-desktop-item-edit $(xdg-user-dir DESKTOP) --create-new") else: directorio = urllib.unquote(fichero[7:]) os.system('gnome-desktop-item-edit "%s" --create-new &' % directorio) def get_background_items(self, window, file): etiq = _("Create launcher") menuitem = Nautilus.MenuItem(name='ExampleMenuProvider::CreateLauncher', label=etiq, tip='', icon='') menuitem.connect('activate', self.menu_activate_carpeta,file) return menuitem,