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-09 22:08:10 (GMT)
committer Cristian Garcia <cristian99garcia@gmail.com>2013-06-09 22:08:10 (GMT)
commit4920c82d5cc5b336a5eb248852a4e33cb8d423cd (patch)
tree923b9adc549de5eae5a2b534297779671a59a87c
parent6bc5e159266b20b2f8715ceccebbafd3d9c197bd (diff)
Arreglando metodos y estetica ;)
-rw-r--r--CristianEdit.py48
-rw-r--r--CristianEdit/Creditos.pycbin37510 -> 37550 bytes
-rw-r--r--CristianEdit/CristianEdit.css37
-rw-r--r--CristianEdit/CristianEdit.py40
-rw-r--r--CristianEdit/Globales.py3
-rw-r--r--CristianEdit/__init__.pycbin140 -> 150 bytes
-rw-r--r--CristianEdit/objetos.py135
-rw-r--r--CristianEdit/objetos.pycbin47931 -> 42841 bytes
8 files changed, 147 insertions, 116 deletions
diff --git a/CristianEdit.py b/CristianEdit.py
index 227a358..7b1786a 100644
--- a/CristianEdit.py
+++ b/CristianEdit.py
@@ -27,7 +27,7 @@ from gi.repository import Gdk
import CristianEdit
from CristianEdit.CristianEdit import CristianEdit
-from CristianEdit import objetos
+from CristianEdit.objetos import DialogoCerrar
screen = Gdk.Screen.get_default()
@@ -58,6 +58,7 @@ class Ventana(Gtk.Window):
self.set_position(Gtk.WindowPosition.CENTER)
self.socket = Gtk.Socket()
+
self.add(self.socket)
self.cristianedit = CristianEdit()
self.socket.add_id(self.cristianedit.get_id())
@@ -66,17 +67,24 @@ class Ventana(Gtk.Window):
self.realize()
self.cristianedit.setup_init(direcciones)
- self.connect('destroy', self.salir)
+ self.connect('delete-event', self.salir)
self.connect('key-press-event', self.cristianedit.tecla)
+ self.cristianedit.connect('cerrar', self.salir)
- def salir(self, widget):
+ def salir(self, *args):
"""Consultar al plug CristianEdit sí se puede salir,
en ese caso le pasa Gtk.main_quit(), de lo
contrario consulta al usuario sí guardar o no
antes de cerrar"""
"""
- buffers, direcciones, views = self.cristianedit.get_if_exit()
+ 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')
+
+ self.cristianedit.guardar_configuracion()
for buffer in buffers:
if buffer.get_modified():
@@ -84,14 +92,36 @@ class Ventana(Gtk.Window):
numero = buffers.index(buffer)
view = views[numero]
direccion = direcciones[numero]
- dialogo = objetos.dialogo_cerrar(direccion, buffer,
- self.cristianedit, 'cerrar')
+
+ dialog = DialogoCerrar(
+ direccion,
+ numero,
+ notebook,
+ direcciones,
+ labels,
+ self)
- numero = 0
- """
+ dialog.add_label('El archivo:\n%s\ntiene cambios sin guardar.')
+ dialog.add_label('¿Desea guardar antes de cerrar?')
- self.cristianedit.guardar_configuracion()
+ respuesta = dialog.run()
+ dialog.show_all()
+ dialog.destroy()
+
+ if accion == Gtk.ResponseType.YES:
+ dialog.guardar(lugares[numero])
+ return True
+
+ elif accion == Gtk.ResponseType.CANCEL:
+ return False
+
+ else:
+ if buffers.index(buffer) == -1:
+ print buffer
+
+ """
Gtk.main_quit()
+ return False
if __name__ == '__main__':
if len(sys.argv) >= 2:
diff --git a/CristianEdit/Creditos.pyc b/CristianEdit/Creditos.pyc
index 28b5008..13de23c 100644
--- a/CristianEdit/Creditos.pyc
+++ b/CristianEdit/Creditos.pyc
Binary files differ
diff --git a/CristianEdit/CristianEdit.css b/CristianEdit/CristianEdit.css
index c7faa49..6cd4417 100644
--- a/CristianEdit/CristianEdit.css
+++ b/CristianEdit/CristianEdit.css
@@ -1,33 +1,22 @@
-/* Configuracion de tema de colores para CristianEdit */
+Menu, Notebook, Toolbar, Navegador, BarraInferior, ComboEstilos, ComboLenguajes, DialogoCerrar, DialogoEstado, SelectordeFuente, Configuraciones, DialogoAdvertencia, Teclado, GtkMenu, GtkMenuItem {
+ transition-property: color, background-color, border-color, background-image, padding, border-width;
+ transition-duration: 0.5s;
-/* GtkSeparatorToolItem {
- background-color: green;
- color: green;
+ font: Ubuntu Light 10px;
}
-GtkComboBoxText {
- background-color: black;
- color: green;
+.button {
+ background-color: #000;
+ border-style: solid;
+ border-color: #333;
}
-GtkMenu, GtkMenuItem {
- background-color: black;
- color: green;
+.button *:hover {
+ color: white;
}
-GtkWindow {
- background-color: black;
+.button:hover:active,
+.button:active {
+ background-color: #993401;
}
-GtkScrolledWindow {
- -GtkRange-slider-width: 10;
- -GtkRange-trough-border: 0;
- -GtkRange-stepper-size: 0;
- -GtkScrollbar-min-slider-length: 45;
- -GtkScrollbar-has-forward-stepper: 0;
- -GtkScrollbar-has-backward-stepper: 0;
- -GtkScrollbar-has-secondary-forward-stepper: 0;
- -GtkScrollbar-has-secondary-backward-stepper: 0;
-}
-
-*/
diff --git a/CristianEdit/CristianEdit.py b/CristianEdit/CristianEdit.py
index 4cf71c2..8b881dd 100644
--- a/CristianEdit/CristianEdit.py
+++ b/CristianEdit/CristianEdit.py
@@ -22,7 +22,6 @@ import os
import ConfigParser
import time
import datetime
-import Run
import thread
import Globales as G
@@ -50,6 +49,10 @@ from gi.repository import Gdk
class CristianEdit(Gtk.Plug):
"""Clase principal."""
+ __gsignals__ = {
+ 'cerrar': (GObject.SIGNAL_RUN_FIRST, None, [])
+ }
+
def __init__(self):
Gtk.Plug.__init__(self)
@@ -76,11 +79,8 @@ class CristianEdit(Gtk.Plug):
tecla = Gdk.keyval_name(event.keyval)
- if tecla == 'F5':
- self.ejecutar(None)
-
if tecla == 'Escape':
- self.get_parent().get_parent().salir(None)
+ self.emit('cerrar')
def embed_event(self, widget):
@@ -134,7 +134,10 @@ class CristianEdit(Gtk.Plug):
"""Muestra un teclado en pantalla."""
if mostrar:
- self.teclado = Teclado(self)
+ ventana = self.get_toplevel()
+ buffer = self.get_buffer()
+
+ self.teclado = Teclado(ventana, buffer)
self.teclado.show_all()
else:
@@ -446,20 +449,6 @@ class CristianEdit(Gtk.Plug):
for x in range(0, len(self.etiquetas)):
self.notebook.next_page()
- def ejecutar(self, widget):
- """Ejecuta el archivo actual"""
-
- pass
- """
- buffer = self.get_buffer()
- lugar = self.get_direccion()
- inicio, fin = buffer.get_bounds()
-
- thread.start_new_thread(Run.ejecutar, (lugar,))
- time.sleep(0.1)
- buffer.select_range(inicio, fin)
- """
-
def deshacer(self, widget):
"""Deshacer cambios"""
@@ -488,7 +477,8 @@ class CristianEdit(Gtk.Plug):
"""Selecciona la fuente de texto"""
fuente = self.configuraciones['fuente']
- selector = SelectordeFuente(fuente)
+ ventana = self.get_toplevel()
+ selector = SelectordeFuente(fuente, self.get_toplevel())
selector.connect('font-changed', self.set_fuente)
@@ -508,9 +498,6 @@ class CristianEdit(Gtk.Plug):
ventana = self.get_toplevel()
dialog = Configuraciones(ventana, self.configuraciones)
- dialog.set_transient_for(self)
- dialog.set_modal(True)
-
dialog.connect('configuration-changed', self.configuration_changed)
dialog.show_all()
@@ -581,9 +568,10 @@ class CristianEdit(Gtk.Plug):
self.guardar_configuracion()
- def get_if_exit(self):
+ def get_objeto(self, lista):
+ """Devuelve el objeto solicitado"""
- return self.buffers, self.lugares, self.views
+ return eval(lista)
def buscar_changed(self, widget, texto):
"""Busca texto en el buffer actual por
diff --git a/CristianEdit/Globales.py b/CristianEdit/Globales.py
index edef445..81d1999 100644
--- a/CristianEdit/Globales.py
+++ b/CristianEdit/Globales.py
@@ -10,9 +10,6 @@ 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()
diff --git a/CristianEdit/__init__.pyc b/CristianEdit/__init__.pyc
index 35d5e72..76b2e99 100644
--- a/CristianEdit/__init__.pyc
+++ b/CristianEdit/__init__.pyc
Binary files differ
diff --git a/CristianEdit/objetos.py b/CristianEdit/objetos.py
index d2f4b22..517db4b 100644
--- a/CristianEdit/objetos.py
+++ b/CristianEdit/objetos.py
@@ -33,28 +33,6 @@ from Creditos import Creditos
import Globales as G
-def dialogo_cerrar(direccion, buffer, cristianedit, accion):
- """Diálogo que cierra el programa o guarda según el usuario"""
-
- dialog = Gtk.MessageDialog(type=Gtk.MessageType(1))
- dialog.add_buttons(Gtk.STOCK_NO, 0, Gtk.STOCK_YES, 1)
-
- archivo = direccion.split('/')[-1]
- dialog.set_markup('<b>%s</b>' % \
- 'El archivo %s tiene cambios sin guardar' % archivo)
-
- dialog.format_secondary_text('¿Guardar antes de salir?')
-
- respuesta = dialog.run()
- dialog.destroy()
-
- if respuesta == 1:
- cristianedit.guardar(None, direccion=direccion)
-
- if accion == 'cerrar':
- Gtk.main_quit()
-
-
def dialogo_reemplazar(direccion, buffer, cristianedit):
"""Preguntar si reemplazar o no, cuando la dirección ya existe"""
@@ -83,6 +61,8 @@ def dialogo_reemplazar(direccion, buffer, cristianedit):
class Menu(Gtk.MenuBar):
"""Barra de Menú"""
+ __gtype_name__ = 'Menu'
+
def __init__(self, padre):
Gtk.MenuBar.__init__(self)
@@ -361,6 +341,8 @@ class View(GtkSource.View):
self.seleccionar_texto(texto, start, enter)
+ self.emit('cambio-de-busqueda', '#000000')
+
else:
buffer.select_range(posicion, posicion)
@@ -400,6 +382,8 @@ class View(GtkSource.View):
class Notebook(Gtk.Notebook):
"""Cuaderno de Fichas"""
+ __gtype_name__ = 'Notebook'
+
__gsignals__ = {
'boton-cerrar-clicked': (GObject.SIGNAL_RUN_FIRST,
None, (object,)),
@@ -500,6 +484,8 @@ class Notebook(Gtk.Notebook):
class Barra(Gtk.Toolbar):
"""Barra de herramientas."""
+ __gtype_name__ = 'Toolbar'
+
__gsignals__ = {
'abrir': (GObject.SIGNAL_RUN_FIRST,
None, []),
@@ -593,6 +579,8 @@ class Barra(Gtk.Toolbar):
class Navegador(Gtk.FileChooserDialog):
"""Navegador de archivos"""
+ __gtype_name__ = 'Navegador'
+
def __init__(self, titulo, padre, accion, botones):
Gtk.FileChooserDialog.__init__(self, title=titulo,
@@ -630,6 +618,8 @@ class BarraInferior(Gtk.HBox):
"""Un GtkHBox() que contiene los
Widgets de la parte inferior de la ventana"""
+ __gtype_name__ = 'BarraInferior'
+
def __init__(self):
Gtk.HBox.__init__(self)
@@ -658,6 +648,8 @@ class ComboEstilos(Gtk.ComboBoxText):
"""Un GtkComboBoxText para mostrar y utilizar
los temas instalados en el sistema"""
+ __gtype_name__ = 'ComboEstilos'
+
def __init__(self, estilo_principal=0):
Gtk.ComboBoxText.__init__(self)
@@ -672,6 +664,8 @@ class ComboLenguajes(Gtk.ComboBoxText):
"""Un GtkComboBoxText para mostrar los
lenguajes de programación instalados en el sistema"""
+ __gtype_name__ = 'ComboLenguajes'
+
def __init__(self):
Gtk.ComboBoxText.__init__(self)
@@ -712,14 +706,24 @@ class DialogoCerrar(Gtk.Dialog):
"""El díalogo que le pregunta al usuario sí en
realidad quiere borrar la página del GtkNotebook()"""
- def __init__(self, direccion, pagina, notebook, lugares, etiquetas, padre):
+ __gtype_name__ = 'DialogoCerrar'
+
+ def __init__(
+ self,
+ direccion,
+ pagina,
+ notebook,
+ lugares,
+ 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])
+ buttons=[
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ 'No guardar', Gtk.ResponseType.NO,
+ Gtk.STOCK_SAVE, Gtk.ResponseType.YES])
self.direccion = direccion
self.pagina = pagina
@@ -728,10 +732,6 @@ class DialogoCerrar(Gtk.Dialog):
self.etiquetas = etiquetas
self.padre = padre
- label = Gtk.Label('Está a punto de cerrar un archivo con cambios sin guardar.')
- label.modify_font(Pango.FontDescription('bold'))
- self.vbox.pack_start(label, False, False, 0)
-
def cerrar(self, widget):
"""Cierra el widget clase destrullendolo"""
@@ -748,17 +748,32 @@ class DialogoCerrar(Gtk.Dialog):
def guardar(self, widget):
"""Guarda el archivo antes de cerrar la pestaña"""
- if not self.direccion == 'Sin dirección':
- self.padre.guardar(None, direccion=self.direccion)
+ try:
+ if not self.direccion == 'Sin dirección':
+ self.padre.guardar(None, direccion=self.direccion)
- else:
- self.padre.guardar_como(None)
+ else:
+ self.padre.guardar_como(None)
+
+ except:
+ if not self.direccion == 'Sin dirección':
+ self.padre.cristianedit.guardar(None, direccion=self.direccion)
+ else:
+ self.padre.cristianedit.guardar_como(None)
+
self.borrar(None)
+ def add_label(self, string):
+ """Crea un label con el texto y se le agrega"""
+
+ self.vbox.add(Gtk.Label(string))
+
class DialogoEstado(Gtk.Dialog):
+ __gtype_name__ = 'DialogoEstado'
+
def __init__(self, padre, notebook):
Gtk.Dialog.__init__(self)
@@ -852,16 +867,23 @@ class DialogoEstado(Gtk.Dialog):
class SelectordeFuente(Gtk.FontSelectionDialog):
+ __gtype_name__ = 'SelectordeFuente'
+
__gsignals__ = {
'font-changed': (GObject.SIGNAL_RUN_FIRST,
None, (str,))
}
- def __init__(self, fuente):
+ def __init__(self, fuente, padre):
Gtk.FontSelectionDialog.__init__(self, title='Fuente de texto...')
self.fuente = fuente
+ self.padre = padre
+
+ self.set_font_name(self.fuente)
+ self.set_transient_for(self.padre)
+ self.set_modal(True)
close_button = Gtk.Button(None, Gtk.STOCK_CLOSE)
ok_button = Gtk.Button(None, Gtk.STOCK_OK)
@@ -869,8 +891,6 @@ class SelectordeFuente(Gtk.FontSelectionDialog):
for x in list(self.action_area):
x.destroy()
- self.set_font_name(self.fuente)
-
self.action_area.add(close_button)
self.action_area.add(ok_button)
@@ -892,6 +912,8 @@ class SelectordeFuente(Gtk.FontSelectionDialog):
class Configuraciones(Gtk.Dialog):
+ __gtype_name__ = 'Configuraciones'
+
__gsignals__ = {
'configuration-changed': (GObject.SIGNAL_RUN_FIRST,
None, (GObject.TYPE_PYOBJECT,))
@@ -905,6 +927,8 @@ class Configuraciones(Gtk.Dialog):
self.configuraciones = configuraciones
self.set_resizable(False)
+ self.set_transient_for(padre)
+ self.set_modal(True)
notebook = Gtk.Notebook()
vbox1 = Gtk.VBox()
@@ -1061,6 +1085,8 @@ class Configuraciones(Gtk.Dialog):
class DialogoAdvertencia(Gtk.Dialog):
+ __gtype_name__ = 'DialogoAdvertencia'
+
def __init__(self, padre, direccion, cristianedit):
Gtk.Dialog.__init__(self, 'Hay cambios sin guardar',
@@ -1092,15 +1118,20 @@ class DialogoAdvertencia(Gtk.Dialog):
class Teclado(Gtk.Dialog):
- def __init__(self, padre):
+ __gtype_name__ = 'Teclado'
+
+ def __init__(self, padre, buffer):
Gtk.Dialog.__init__(self)
self.estado = 'minusculas'
self.padre = padre
+ self.buffer = buffer
self.set_title('Teclado de CristianEdit 2')
self.set_resizable(False)
+ self.set_transient_for(self.padre)
+ self.set_modal(True)
vbox = Gtk.VBox()
self.vbox.hbox = Gtk.HBox()
@@ -1169,7 +1200,7 @@ class Teclado(Gtk.Dialog):
self.destroy()
def recargar(self):
- """Borra y crea los botones nuevamente"""
+ """Destruye los botones y los crea nuevamente"""
for x in self.vbox.hbox0:
x.destroy()
@@ -1244,27 +1275,23 @@ class Teclado(Gtk.Dialog):
def clic(self, widget, especial=None):
"""Escribe el texto"""
- buffer = self.padre.get_buffer()
-
if not especial:
texto = widget.get_label()
else:
texto = especial
- buffer.insert_at_cursor(texto)
+ self.buffer.insert_at_cursor(texto)
def borrar(self, widget):
"""Borrar el carácter actual"""
- buffer = self.padre.get_buffer()
-
- if buffer.get_selection_bounds():
- start, end = buffer.get_bounds()
- inicio, fin = buffer.get_selection_bounds()
+ if self.buffer.get_selection_bounds():
+ start, end = self.buffer.get_bounds()
+ inicio, fin = self.buffer.get_selection_bounds()
- texto_start = list(buffer.get_text(start, inicio, 0))
- texto_end = list(buffer.get_text(fin, end, 0))
+ texto_start = list(self.buffer.get_text(start, inicio, 0))
+ texto_end = list(self.buffer.get_text(fin, end, 0))
string1 = ''
string2 = ''
@@ -1276,12 +1303,12 @@ class Teclado(Gtk.Dialog):
string1 = string1 + x2
else:
- start, fin = buffer.get_bounds()
- actual = buffer.get_iter_at_mark(buffer.get_insert())
+ start, fin = self.buffer.get_bounds()
+ actual = self.buffer.get_iter_at_mark(self.buffer.get_insert())
numero = actual.get_offset()
- texto_start = list(buffer.get_text(start, actual, 0))[:numero - 1]
- texto_end = list(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))#[numero:]
string1 = ''
string2 = ''
@@ -1291,4 +1318,4 @@ class Teclado(Gtk.Dialog):
for x2 in texto_end:
string2 = string2 + x2
- buffer.set_text(string1 + string2)
+ self.buffer.set_text(string1 + string2)
diff --git a/CristianEdit/objetos.pyc b/CristianEdit/objetos.pyc
index 381b769..46433cc 100644
--- a/CristianEdit/objetos.pyc
+++ b/CristianEdit/objetos.pyc
Binary files differ