Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/CristianEdit/Globales.py
blob: edef445f3f7af6f718da54878a1ba96a13cfdc1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#   Globales.py por:
#   Cristian García <cristian99garcia@gmail.com>

import os
import commands

from gi.repository import Gtk
from gi.repository import GtkSource

BIENVENIDA = '''\n\nTerminal creada en python,
por Cristian García <cristian99garcia@gmail.com>'''

lenguaje_manager = GtkSource.LanguageManager()
lenguajes = lenguaje_manager.get_language_ids()

lenguajes.insert(0, 'Texto Plano')

estilo_manager = GtkSource.StyleSchemeManager()
estilos = estilo_manager.get_scheme_ids()


def get_clasico():
    """Devuelve la posisión de classic en el combo"""

    cuenta = 0
    clasico = 0

    for estilo in estilos:
        if estilo == 'classic':
            clasico = cuenta

        cuenta += 1

    return clasico

datos = os.path.expanduser('~/.cristianedit')
if not os.path.exists(datos):
    os.mkdir(datos)

configuracion = os.path.join(datos, 'configuracion.cfg')

if not os.path.exists(configuracion):

    f = open(configuracion, 'w')
    f.write('''[datos]
enumeracion = True
fuente = Monospace
margen = 80
is_margen =
ajuste = True
ajuste_palabras =
tabulador = 8
insertar_espacios =
sangria =
recientes =
tema = classic''')

    f.close()


def guardar_dato(cadena, dato, archivo):

    if dato:
        archivo.set('datos', cadena, dato)

    else:
        archivo.set('datos', cadena, '')

def get_mime_type(direccion):

    tipo = commands.getoutput('file %s --mime-type' % direccion).split(' ')
    if 'x-empty' in tipo or 'text' in tipo:
        return True

    return None