Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Garcia <cristian99garcia@gmail.com>2013-06-10 23:43:27 (GMT)
committer Cristian Garcia <cristian99garcia@gmail.com>2013-06-10 23:43:27 (GMT)
commite5b6765e42d1cc02f81867f46f0bb6d480c46488 (patch)
treefda1ff64bf662aa56f01d8613546594ea60d9e61
parent57eb3c7864ddbefee8526c846f4f282adbbae6c3 (diff)
Arreglando prolijidad
-rw-r--r--CristianEdit.py16
-rw-r--r--CristianEdit/Creditos.py2
-rw-r--r--CristianEdit/CristianEdit.py46
-rw-r--r--CristianEdit/Globales.py3
-rw-r--r--CristianEdit/objetos.py72
5 files changed, 67 insertions, 72 deletions
diff --git a/CristianEdit.py b/CristianEdit.py
index 1e7973d..f2b34c8 100644
--- a/CristianEdit.py
+++ b/CristianEdit.py
@@ -21,11 +21,9 @@
import sys
import os
-import gi
from gi.repository import Gtk
from gi.repository import Gdk
-import CristianEdit
from CristianEdit.CristianEdit import CristianEdit
from CristianEdit.objetos import DialogoCerrar
@@ -34,7 +32,7 @@ screen = Gdk.Screen.get_default()
css_provider = Gtk.CssProvider()
style = os.path.join(os.path.dirname(__file__), 'CristianEdit/CristianEdit.css')
-
+
css_provider.load_from_path(style)
context = Gtk.StyleContext()
@@ -76,10 +74,9 @@ class Ventana(Gtk.Window):
en ese caso le pasa Gtk.main_quit(), de lo
contrario consulta al usuario sí guardar o no
antes de cerrar"""
-
+
notebook = self.cristianedit.get_objeto('self.notebook')
buffers = self.cristianedit.get_objeto('self.buffers')
- views = self.cristianedit.get_objeto('self.views')
direcciones = self.cristianedit.get_objeto('self.lugares')
labels = self.cristianedit.get_objeto('self.etiquetas')
@@ -95,9 +92,8 @@ class Ventana(Gtk.Window):
if buffer.get_modified():
numero = buffers.index(buffer)
- view = views[numero]
direccion = direcciones[numero]
-
+
dialog = DialogoCerrar(
direccion,
numero,
@@ -106,15 +102,15 @@ class Ventana(Gtk.Window):
labels,
self)
- dialog.add_label('El archivo:\n%s\ntiene cambios sin guardar.' % direccion)
+ dialog.add_label(
+ 'El archivo:\n%s\ntiene cambios sin guardar.' % direccion)
dialog.add_label('¿Desea guardar antes de cerrar?')
respuesta = dialog.run()
dialog.destroy()
- print respuesta, if_cerrar
if respuesta == Gtk.ResponseType.YES:
- dialog.guardar(lugares[numero])
+ dialog.guardar(direcciones[numero])
if if_cerrar:
Gtk.main_quit()
diff --git a/CristianEdit/Creditos.py b/CristianEdit/Creditos.py
index 288e086..14dbc68 100644
--- a/CristianEdit/Creditos.py
+++ b/CristianEdit/Creditos.py
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import os
-
from gi.repository import Gtk
from gi.repository import Pango
diff --git a/CristianEdit/CristianEdit.py b/CristianEdit/CristianEdit.py
index 86be384..a3fe571 100644
--- a/CristianEdit/CristianEdit.py
+++ b/CristianEdit/CristianEdit.py
@@ -22,11 +22,9 @@ import os
import ConfigParser
import time
import datetime
-import thread
import Globales as G
-import objetos
from objetos import Menu
from objetos import Buffer
from objetos import View
@@ -142,10 +140,6 @@ class CristianEdit(Gtk.Plug):
self.notebook.set_current_page(numero)
lugar = self.get_direccion()
- label = self.etiquetas[numero]
- view = self.views[numero]
- buffer = self.buffers[numero]
- barra = self.barras_de_abajo[numero]
if buffer.get_modified():
dialog = DialogoCerrar(lugar,
@@ -258,7 +252,8 @@ class CristianEdit(Gtk.Plug):
escritura = self.get_escritura(lugar)
self.agregar_a_recientes(lugar)
- self.menu.actualizar_recientes(self.configuraciones['recientes'])
+ self.menu.actualizar_recientes(
+ self.configuraciones['recientes'])
buffer.set_text(texto)
buffer.set_modified(False)
@@ -299,7 +294,8 @@ class CristianEdit(Gtk.Plug):
escritura = self.get_escritura(direccion)
self.agregar_a_recientes(direccion)
- self.menu.actualizar_recientes(self.configuraciones['recientes'])
+ self.menu.actualizar_recientes(
+ self.configuraciones['recientes'])
buffer.set_text(texto)
buffer.set_modified(False)
@@ -560,10 +556,10 @@ class CristianEdit(Gtk.Plug):
def configuration_changed(self, widget, dict):
"""Configura todos los views que se encunetren abiertos."""
-
+
self.configuraciones = dict
self.guardar_configuracion()
-
+
for view in self.views:
view.configurar(self.configuraciones)
@@ -665,9 +661,11 @@ class CristianEdit(Gtk.Plug):
cfg.set('datos', 'margen', self.configuraciones['margen'])
cfg.set('datos', 'is_margen', self.configuraciones['is_margen'])
cfg.set('datos', 'ajuste', self.configuraciones['ajuste'])
- cfg.set('datos', 'ajuste_palabras', self.configuraciones['ajuste_palabras'])
+ cfg.set('datos', 'ajuste_palabras',
+ self.configuraciones['ajuste_palabras'])
cfg.set('datos', 'tabulador', self.configuraciones['tabulador'])
- cfg.set('datos', 'insertar_espacios', self.configuraciones['insertar_espacios'])
+ cfg.set('datos', 'insertar_espacios',
+ self.configuraciones['insertar_espacios'])
cfg.set('datos', 'sangria', self.configuraciones['sangria'])
cfg.set('datos', 'tema', self.configuraciones['tema'])
cfg.set('datos', 'recientes', str(self.configuraciones['recientes']))
@@ -684,16 +682,24 @@ class CristianEdit(Gtk.Plug):
try:
try:
- self.configuraciones['enumeracion'] = eval(cfg.get('datos', 'enumeracion'))
+ self.configuraciones['enumeracion'] = eval(
+ cfg.get('datos', 'enumeracion'))
self.configuraciones['fuente'] = str(cfg.get('datos', 'fuente'))
self.configuraciones['margen'] = int(cfg.get('datos', 'margen'))
- self.configuraciones['is_margen'] = eval(cfg.get('datos', 'is_margen'))
- self.configuraciones['ajuste'] = eval(cfg.get('datos', 'ajuste'))
- self.configuraciones['ajuste_palabras'] = eval(cfg.get('datos', 'ajuste_palabras'))
- self.configuraciones['tabulador'] = int(eval(cfg.get('datos', 'tabulador')))
- self.configuraciones['insertar_espacios'] = eval(cfg.get('datos', 'insertar_espacios'))
- self.configuraciones['sangria'] = eval(cfg.get('datos', 'sangria'))
- self.configuraciones['recientes'] = eval(cfg.get('datos', 'recientes'))
+ self.configuraciones['is_margen'] = eval(
+ cfg.get('datos', 'is_margen'))
+ self.configuraciones['ajuste'] = eval(
+ cfg.get('datos', 'ajuste'))
+ self.configuraciones['ajuste_palabras'] = eval(
+ cfg.get('datos', 'ajuste_palabras'))
+ self.configuraciones['tabulador'] = int(eval(
+ cfg.get('datos', 'tabulador')))
+ self.configuraciones['insertar_espacios'] = eval(
+ cfg.get('datos', 'insertar_espacios'))
+ self.configuraciones['sangria'] = eval(cfg.get(
+ 'datos', 'sangria'))
+ self.configuraciones['recientes'] = eval(
+ cfg.get('datos', 'recientes'))
self.configuraciones['tema'] = str(cfg.get('datos', 'tema'))
except:
diff --git a/CristianEdit/Globales.py b/CristianEdit/Globales.py
index c54e5d1..7bdbba9 100644
--- a/CristianEdit/Globales.py
+++ b/CristianEdit/Globales.py
@@ -7,7 +7,6 @@
import os
import commands
-from gi.repository import Gtk
from gi.repository import GtkSource
lenguaje_manager = GtkSource.LanguageManager()
@@ -66,6 +65,7 @@ def guardar_dato(cadena, dato, archivo):
else:
archivo.set('datos', cadena, '')
+
def get_mime_type(direccion):
tipo = commands.getoutput('file %s --mime-type' % direccion).split(' ')[1]
@@ -74,4 +74,3 @@ def get_mime_type(direccion):
return True
return None
-
diff --git a/CristianEdit/objetos.py b/CristianEdit/objetos.py
index 0ebe37b..ce0d707 100644
--- a/CristianEdit/objetos.py
+++ b/CristianEdit/objetos.py
@@ -27,10 +27,8 @@ from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import GtkSource
from gi.repository import Gdk
-from gi.repository import Vte
-from gi.repository import GLib
-import Globales as G
+from . import Globales as G
class Menu(Gtk.MenuBar):
@@ -49,7 +47,6 @@ class Menu(Gtk.MenuBar):
Gtk.MenuBar.__init__(self)
- items = []
self.padre = padre
self.grupo = Gtk.AccelGroup()
self.recientes = []
@@ -185,7 +182,8 @@ 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]
+ tipo = commands.getoutput(
+ 'file %s --mime-type' % filename).split(' ')[1]
if 'x-' in tipo:
tipo = tipo.replace('x-', '')
@@ -196,34 +194,28 @@ class Buffer(GtkSource.Buffer):
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)
-
+
try:
nombre = lenguaje.get_name()
numero = self.lenguajes.index(nombre.lower())
-
+
combo.set_active(numero + 1)
-
+
except:
pass
-
def get_lenguaje(self):
"""Devuelve el lenguaje seleccionado"""
return self.lenguaje
- def algo(self, widget):
-
- lineas = self.get_line_count()
-
class View(GtkSource.View):
"""Visor de Texto"""
@@ -237,7 +229,7 @@ class View(GtkSource.View):
self.set_buffer(buffer)
self.set_size_request(400, 500)
-
+
self.lenguaje_manager = G.lenguaje_manager
self.lenguajes = G.lenguajes
self.estilo_manager = G.estilo_manager
@@ -258,7 +250,7 @@ class View(GtkSource.View):
def configurar(self, configuraciones):
"""Establecer configuración
según los argumentos."""
-
+
buffer = self.get_buffer()
enumeracion = configuraciones['enumeracion']
@@ -275,8 +267,8 @@ class View(GtkSource.View):
self.set_property('show-line-numbers', enumeracion)
self.set_property('right-margin-position', margen)
self.set_property('show-right-margin', is_margen)
-
- if ajuste != None and ajuste != False:
+
+ if ajuste:
self.set_wrap_mode(Gtk.WrapMode.CHAR)
else:
@@ -432,7 +424,7 @@ class Notebook(Gtk.Notebook):
def borrar_pagina(self, numero=None):
"""Borra la página actual"""
- if numero == None:
+ if not numero:
self.remove_page(self.get_current_page())
else:
@@ -489,7 +481,7 @@ class Barra(Gtk.Toolbar):
self.toolbutton(Gtk.STOCK_PREFERENCES, 'Preferencias')
self.separador()
-
+
item = Gtk.ToolItem()
self.add(item)
@@ -525,9 +517,9 @@ class Barra(Gtk.Toolbar):
self.emit('accion', accion)
def emit_buscar(self, widget, accion, *args):
- """Emite la señal que corresponde al argumento
+ """Emite la señal que corresponde al argumento
'senial', con el texto como parámetro."""
-
+
texto = widget.get_text()
self.emit('buscar', accion, texto)
@@ -667,7 +659,7 @@ class DialogoReemplazar(Gtk.MessageDialog):
self,
parent=padre,
type=Gtk.MessageType.QUESTION)
-
+
self.set_transient_for(padre)
self.set_modal(True)
self.set_markup('<b>%s</b>' % 'La dirección especificada ya existe...')
@@ -681,7 +673,7 @@ class DialogoReemplazar(Gtk.MessageDialog):
respuesta = self.run()
self.destroy()
-
+
if respuesta == Gtk.ResponseType.ACCEPT:
escritura = open(direccion, 'w')
@@ -706,13 +698,15 @@ class DialogoCerrar(Gtk.Dialog):
etiquetas,
padre):
- Gtk.Dialog.__init__(self, title='Hay cambios sin guardar',
- parent=padre.get_toplevel(),
- flags=Gtk.DialogFlags.MODAL,
- buttons=[
- Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- 'No guardar', Gtk.ResponseType.NO,
- Gtk.STOCK_SAVE, Gtk.ResponseType.YES])
+ Gtk.Dialog.__init__(
+ self,
+ title='Hay cambios sin guardar',
+ parent=padre.get_toplevel(),
+ flags=Gtk.DialogFlags.MODAL,
+ buttons=[
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ 'No guardar', Gtk.ResponseType.NO,
+ Gtk.STOCK_SAVE, Gtk.ResponseType.YES])
self.direccion = direccion
self.pagina = pagina
@@ -750,7 +744,7 @@ class DialogoCerrar(Gtk.Dialog):
else:
self.padre.cristianedit.guardar_como(None)
-
+
self.borrar(None)
def add_label(self, string):
@@ -939,7 +933,8 @@ class Configuraciones(Gtk.Dialog):
boton_sangria = Gtk.CheckButton('Sangría automatica')
ajuste1 = Gtk.Adjustment(self.configuraciones['margen'], 1, 1000, 1, 10)
- ajuste2 = Gtk.Adjustment(self.configuraciones['tabulador'], 1, 30, 1, 10)
+ ajuste2 = Gtk.Adjustment(
+ self.configuraciones['tabulador'], 1, 30, 1, 10)
spin1 = Gtk.SpinButton()
spin2 = Gtk.SpinButton()
@@ -952,7 +947,7 @@ class Configuraciones(Gtk.Dialog):
for x in l:
x.modify_font(Pango.FontDescription('bold'))
-
+
boton_margen.set_active(self.configuraciones['is_margen'])
boton_enumeracion.set_active(self.configuraciones['enumeracion'])
spin1.set_adjustment(ajuste1)
@@ -1005,7 +1000,7 @@ class Configuraciones(Gtk.Dialog):
def estilo_changed(self, widget):
"""Establece en tema de colores"""
-
+
self.configuraciones['tema'] = G.estilos[widget.get_active()]
self.emit('configuration-changed', self.configuraciones)
@@ -1299,8 +1294,9 @@ class Teclado(Gtk.Dialog):
actual = self.buffer.get_iter_at_mark(self.buffer.get_insert())
numero = actual.get_offset()
- texto_start = list(self.buffer.get_text(start, actual, 0))[:numero - 1]
- texto_end = list(self.buffer.get_text(actual, fin, 0))#[numero:]
+ texto_start = list(
+ self.buffer.get_text(start, actual, 0))[:numero - 1]
+ texto_end = list(self.buffer.get_text(actual, fin, 0))
string1 = ''
string2 = ''