From ffda62d11b5b56fac89309d63f56c0038dc2e361 Mon Sep 17 00:00:00 2001 From: Cristian García Date: Thu, 10 Oct 2013 16:29:49 +0000 Subject: Mejorando el codigo para poder avanzar en funcionalidades --- diff --git a/Archivos.pyc b/Archivos.pyc index 2e0be95..3d7ca23 100644 --- a/Archivos.pyc +++ b/Archivos.pyc Binary files differ diff --git a/Widgets.py b/Widgets.py index a5da937..5376ec3 100644 --- a/Widgets.py +++ b/Widgets.py @@ -11,22 +11,15 @@ from gi.repository import GdkPixbuf from gi.repository import Gio from gi.repository import Pango -COPIAR = None - class AreadeMontajes(Gtk.TreeView): - """Parte de la entana en la que se muestran - los montajes actualmente introducidos""" - __gsinglas__ = {'change-directory': (GObject.SIGNAL_RUN_FIRST, - GObject.TYPE_NONE, (GObject.TYPE_STRING,))} + __gsinglas__ = {'change-directory': (GObject.SIGNAL_RUN_FIRST, None, [str])} - def __init__(self, padre): - """Inicia la clase""" + def __init__(self): Gtk.TreeView.__init__(self) - self.padre = padre self.montajes = [] self.volume_monitor = Gio.VolumeMonitor.get() self.numero = 0 @@ -136,7 +129,7 @@ class AreadeMontajes(Gtk.TreeView): def copiar(self, widget, direccion): - COPIAR = direccion + pass def propiedades(self, widget, direccion): @@ -145,24 +138,23 @@ class AreadeMontajes(Gtk.TreeView): class Area(Gtk.IconView): - """Area de navegación""" __gsignals__ = { - 'cambio-de-direccion': (GObject.SIGNAL_RUN_FIRST, - GObject.TYPE_NONE, (GObject.TYPE_STRING,)), - 'cambio-de-mensaje': (GObject.SIGNAL_RUN_FIRST, - GObject.TYPE_NONE, (GObject.TYPE_STRING,)), - 'copiar': (GObject.SIGNAL_RUN_FIRST, - GObject.TYPE_NONE, (GObject.TYPE_STRING,)), - 'propiedades': (GObject.SIGNAL_RUN_FIRST, - GObject.TYPE_NONE, (GObject.TYPE_STRING,))} - - def __init__(self, padre): - """Inicia la clase""" + 'cambio-de-direccion': (GObject.SIGNAL_RUN_FIRST, None, [str]), + 'cambio-de-mensaje': (GObject.SIGNAL_RUN_FIRST, None, [str]), + 'copiar': (GObject.SIGNAL_RUN_FIRST, None, [str]), + 'propiedades': (GObject.SIGNAL_RUN_FIRST, None, [str]), + 'solicitar-direccion': (GObject.SIGNAL_RUN_FIRST, None, []) + } + + def __init__(self): Gtk.IconView.__init__(self) - self.padre = padre + self.lista_carpetas = [] + self.lista_archivos = [] + self.direccion = '' + self.modelo = Gtk.ListStore(str, GdkPixbuf.Pixbuf) self.set_selection_mode(Gtk.SelectionMode(1)) @@ -170,9 +162,6 @@ class Area(Gtk.IconView): self.set_text_column(0) self.set_pixbuf_column(1) - self.lista_carpetas = [] - self.lista_archivos = [] - self.connect('button-press-event', self.click) self.connect('selection-changed', self.changed) @@ -182,7 +171,7 @@ class Area(Gtk.IconView): if self.get_selected_items(): - direccion = self.padre.direccion + direccion = self.get_direccion() path = self.get_selected_items()[0] iter = self.modelo.get_iter(path) direccion = os.path.join(direccion, self.modelo.get_value(iter, 0)) @@ -205,17 +194,12 @@ class Area(Gtk.IconView): def agregar(self, nombre, direccion): """Agrega el icono de una carpeta o un archivo""" - if not list(direccion)[-1] == '/': - direccion += '/' - - dir = direccion + nombre - - if ' ' in dir: - dir.replace(' ', '\ ') + direccion = os.path.join(direccion, nombre) - pixbuf = Archivos.get_pixbuf(dir) + if ' ' in direccion: + direccion.replace(' ', '\ ') - self.modelo.append([nombre, pixbuf]) + self.modelo.append([nombre, Archivos.get_pixbuf(direccion)]) def borrar_area(self): """Borra todos los objetos en el modelo""" @@ -231,15 +215,13 @@ class Area(Gtk.IconView): posy = event.y tiempo = event.time + self.solicitar_direccion() + try: path = widget.get_path_at_pos(int(posx), int(posy)) - direccion = self.padre.direccion - if list(direccion)[-1] != '/': - direccion += '/' - iter = self.modelo.get_iter(path) - direccion += self.modelo.get_value(iter, 0) + direccion = os.path.join(self.direccion, self.modelo.get_value(iter, 0)) if boton == 3: self.crear_menu_emergente(boton, tiempo, path) @@ -258,12 +240,7 @@ class Area(Gtk.IconView): iter = self.modelo.get_iter(path) nombre = self.modelo.get_value(iter, 0) - direccion = self.padre.direccion - - if direccion[-1] != '/': - direccion += '/' - - direccion += nombre + direccion = os.path.join(self.get_direccion(), nombre) item = Gtk.MenuItem('') menu = Gtk.Menu() @@ -293,6 +270,14 @@ class Area(Gtk.IconView): menu.show_all() menu.popup(None, None, None, None, boton, tiempo) + def get_direccion(self): + + return self.direccion + + def set_direccion(self, direccion): + + self.direccion = direccion + def abrir(self, widget, direccion): """Abre la dirección del montaje seleccionado""" @@ -309,9 +294,12 @@ class Area(Gtk.IconView): self.emit('propiedades', direccion) + def solicitar_direccion(self): + + self.emit('solicitar-direccion') + class Toolbar(Gtk.Toolbar): - """Barra de herramientas.""" __gsignals__ = { 'accion': (GObject.SIGNAL_RUN_FIRST, None, (str,)) @@ -357,7 +345,6 @@ class Toolbar(Gtk.Toolbar): class Entrada(Gtk.Entry): - """Entrada de navegación""" def __init__(self): """Inicia la clase""" @@ -397,8 +384,6 @@ class Entrada(Gtk.Entry): class BarradeEstado(Gtk.Statusbar): - """Un GtkStatusbar para mostrar la - información del elemento seleccionado""" def __init__(self): @@ -422,7 +407,6 @@ class BarradeEstado(Gtk.Statusbar): class DialogoError(Gtk.Dialog): - """Un diálogo que muestra errores.""" def __init__(self, error, direccion, padre): diff --git a/Widgets.pyc b/Widgets.pyc index 9a62d2c..4de25a8 100644 --- a/Widgets.pyc +++ b/Widgets.pyc Binary files differ diff --git a/window.py b/window.py index badf62c..44acc97 100644 --- a/window.py +++ b/window.py @@ -58,7 +58,7 @@ class CExplorer(Gtk.Window): self.vbox = Gtk.VBox() self.toolbar = Toolbar() self.entrada = Entrada() - self.area = Area(self) + self.area = Area() self.area_montajes = AreadeMontajes(self) self.b_estado = BarradeEstado() @@ -90,6 +90,7 @@ class CExplorer(Gtk.Window): self.entrada.connect('activate', self.nueva_direccion) self.area.connect('cambio-de-direccion', self.abrir_desde_widget) self.area.connect('cambio-de-mensaje', self.cambio_de_mensaje) + self.area.connect('solicitar-direccion', self.setear_direccion) self.abrir(self.direccion) @@ -177,6 +178,8 @@ class CExplorer(Gtk.Window): except: self.abrir(os.path.expanduser('~')) + self.setear_direccion(self.area) + def tecla_presionada(self, widget, event): tecla = event.keyval @@ -212,6 +215,10 @@ class CExplorer(Gtk.Window): if lectura and escritura: self.crear_directorio() + def setear_direccion(self, widget): + + widget.set_direccion(self.direccion) + def abrir_desde_widget(self, widget, direccion): """Llama a la función 'abrir'.""" -- cgit v0.9.1