diff options
author | Cristian Garcia <cristian99garcia@gmail.com> | 2013-06-10 23:02:52 (GMT) |
---|---|---|
committer | Cristian Garcia <cristian99garcia@gmail.com> | 2013-06-10 23:02:52 (GMT) |
commit | 57eb3c7864ddbefee8526c846f4f282adbbae6c3 (patch) | |
tree | b669bee0560e2d077df038814031e6db55c89f74 | |
parent | 414489ed120dabdfff88ee0c77e228fdd5f3909d (diff) |
Agregando para que 'le ponga colores' a los archivos que no tienen extension pero siguen siendo de un lenguaje de programacion
-rw-r--r-- | CristianEdit.py | 4 | ||||
-rw-r--r-- | CristianEdit/CristianEdit.py | 6 | ||||
-rw-r--r-- | CristianEdit/objetos.py | 22 | ||||
-rw-r--r-- | CristianEdit/objetos.pyc | bin | 42019 -> 42305 bytes |
4 files changed, 26 insertions, 6 deletions
diff --git a/CristianEdit.py b/CristianEdit.py index dc64d0b..1e7973d 100644 --- a/CristianEdit.py +++ b/CristianEdit.py @@ -126,6 +126,10 @@ class Ventana(Gtk.Window): if if_cerrar: Gtk.main_quit() + else: + if if_cerrar: + Gtk.main_quit() + if __name__ == '__main__': if len(sys.argv) >= 2: lista = list(sys.argv)[1:] diff --git a/CristianEdit/CristianEdit.py b/CristianEdit/CristianEdit.py index 184a121..86be384 100644 --- a/CristianEdit/CristianEdit.py +++ b/CristianEdit/CristianEdit.py @@ -225,8 +225,10 @@ class CristianEdit(Gtk.Plug): pagina = self.notebook.get_current_page() if not direccion: - navegador = Navegador('Abrir archivo de Texto', - self.get_toplevel(), Gtk.FileChooserAction.OPEN, + navegador = Navegador( + 'Abrir archivo de Texto', + self.get_toplevel(), + Gtk.FileChooserAction.OPEN, ['Abrir', Gtk.ResponseType.ACCEPT]) if os.path.exists(self.lugares[pagina]): diff --git a/CristianEdit/objetos.py b/CristianEdit/objetos.py index a2f560b..0ebe37b 100644 --- a/CristianEdit/objetos.py +++ b/CristianEdit/objetos.py @@ -20,6 +20,7 @@ import mimetypes import os +import commands from gi.repository import Pango from gi.repository import Gtk @@ -183,6 +184,23 @@ class Buffer(GtkSource.Buffer): lenguaje = self.lenguaje_manager.guess_language(filename, None) + if not lenguaje: + tipo = commands.getoutput('file %s --mime-type' % filename).split(' ')[1] + + if 'x-' in tipo: + tipo = tipo.replace('x-', '') + + if 'text/' in tipo: + tipo = tipo.replace('text/', '') + + lenguaje = self.lenguaje_manager.get_language(tipo) + + if not lenguaje: + print tipo + self.set_highlight_syntax(False) + + combo.set_active(0) + if lenguaje: self.set_highlight_syntax(True) self.set_language(lenguaje) @@ -196,10 +214,6 @@ class Buffer(GtkSource.Buffer): except: pass - else: - self.set_highlight_syntax(False) - - combo.set_active(0) def get_lenguaje(self): """Devuelve el lenguaje seleccionado""" diff --git a/CristianEdit/objetos.pyc b/CristianEdit/objetos.pyc Binary files differindex ea19bdd..43e208d 100644 --- a/CristianEdit/objetos.pyc +++ b/CristianEdit/objetos.pyc |