def __init__(self, widget, boton, pos, tiempo, path, modelo): gtk.Menu.__init__(self) self.modelo = modelo self.parent_objet = widget lectura, escritura, ejecucion = (False, False, False) unidad, directorio, archivo, enlace = (False, False, False, False) iter_ = self.modelo.get_iter(path) direccion = self.modelo.get_value(iter_, 2) if describe_acceso_uri(direccion): lectura, escritura, ejecucion = describe_acceso_uri(direccion) unidad, directorio, archivo, enlace = describe_uri(direccion) abrir_pestania = gtk.MenuItem("Abrir en Pestaña Nueva") self.append(abrir_pestania) abrir_pestania.connect_object("activate", self.__emit_accion, path, "Abrir") notebook = self.parent_objet.get_parent( ).get_parent().notebookdirectorios if escritura and (directorio or unidad) and \ (notebook.copiando or notebook.cortando): pegar = gtk.MenuItem("Pegar") self.append(pegar) pegar.connect_object("activate", self.__emit_accion, path, "Pegar") self.show_all() self.attach_to_widget(widget, self.__null)
def __init__(self, widget, boton, pos, tiempo, path, modelo): gtk.Menu.__init__(self) self.modelo = modelo self.parent_objet = widget lectura, escritura, ejecucion = (False, False, False) unidad, directorio, archivo, enlace = (False, False, False, False) iter_ = self.modelo.get_iter(path) direccion = self.modelo.get_value(iter_, 2) if describe_acceso_uri(direccion): lectura, escritura, ejecucion = describe_acceso_uri(direccion) unidad, directorio, archivo, enlace = describe_uri(direccion) abrir_pestania = gtk.MenuItem("Abrir en Pestaña Nueva") self.append(abrir_pestania) abrir_pestania.connect_object("activate", self.__emit_accion, path, "Abrir") notebook = self.parent_objet.get_parent().get_parent( ).notebookdirectorios if escritura and (directorio or unidad) and \ (notebook.copiando or notebook.cortando): pegar = gtk.MenuItem("Pegar") self.append(pegar) pegar.connect_object("activate", self.__emit_accion, path, "Pegar") self.show_all() self.attach_to_widget(widget, self.__null)
def __init__(self, widget, boton, pos, tiempo, path, modelo): gtk.Menu.__init__(self) self.modelo = modelo self.parent_objet = widget lectura, escritura, ejecucion = (False, False, False) unidad, directorio, archivo, enlace = (False, False, False, False) iter_ = self.modelo.get_iter(path) direccion = self.modelo.get_value(iter_, 2) if describe_acceso_uri(direccion): lectura, escritura, ejecucion = describe_acceso_uri(direccion) unidad, directorio, archivo, enlace = describe_uri(direccion) else: return if lectura: item = gtk.MenuItem("Copiar") self.append(item) item.connect_object("activate", self.__emit_accion, path, "Copiar") if escritura and not unidad: borrar = gtk.MenuItem("Borrar") self.append(borrar) borrar.connect_object("activate", self.__emit_accion, path, "Borrar") notebook = self.parent_objet.get_parent().get_parent() if escritura and (directorio or unidad) and \ (notebook.copiando or notebook.cortando): pegar = gtk.MenuItem("Pegar") self.append(pegar) pegar.connect_object("activate", self.__emit_accion, path, "Pegar") if escritura and (directorio or archivo): cortar = gtk.MenuItem("Cortar") self.append(cortar) cortar.connect_object("activate", self.__emit_accion, path, "Cortar") if escritura and (directorio or unidad): abrir_pestania = gtk.MenuItem("Abrir en Pestaña Nueva") self.append(abrir_pestania) abrir_pestania.connect_object("activate", self.__emit_accion, path, "new-tab") nuevodirectorio = gtk.MenuItem("Crear Directorio") self.append(nuevodirectorio) nuevodirectorio.connect_object("activate", self.__emit_accion, path, "Crear Directorio") self.show_all() self.attach_to_widget(widget, self.__null)
def __Llenar_ListStore(self): self.get_toplevel().set_sensitive(False) icono = os.path.join(ICONOS, "def.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Raiz', ROOT]) icono = os.path.join(ICONOS, "stock-home.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, commands.getoutput('whoami'), HOME]) if describe_uri(ACTIVITIES): icono = os.path.join(ICONOS, "stock-home.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Actividades', ACTIVITIES]) if describe_uri(JAMEDIA): icono = os.path.join(ICONOS, "JAMedia.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'JAMediaDatos', JAMEDIA]) if describe_uri(DIARIO): icono = os.path.join(ICONOS, "diario.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Diario', DIARIO]) if describe_uri(LOGS): icono = os.path.join(ICONOS, "diario.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Logs', LOGS]) icono = os.path.join(ICONOS, "drive-removable-media-usb.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) unidades = self.demonio_unidades.get_unidades() for unidad in unidades.keys(): dic = unidades.get(unidad, False) if dic: mount_path = dic.get('mount_path', "") self.get_model().append([ pixbuf, mount_path.split("/")[-1], mount_path]) self.get_toplevel().set_sensitive(True)
def __Llenar_ListStore(self): self.get_toplevel().set_sensitive(False) icono = os.path.join(ICONOS, "def.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Raiz', ROOT]) icono = os.path.join(ICONOS, "stock-home.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, commands.getoutput('whoami'), HOME]) if describe_uri(ACTIVITIES): icono = os.path.join(ICONOS, "stock-home.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Actividades', ACTIVITIES]) if describe_uri(JAMEDIA): icono = os.path.join(ICONOS, "JAMedia.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'JAMediaDatos', JAMEDIA]) if describe_uri(DIARIO): icono = os.path.join(ICONOS, "diario.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Diario', DIARIO]) if describe_uri(LOGS): icono = os.path.join(ICONOS, "diario.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) self.get_model().append([pixbuf, 'Logs', LOGS]) icono = os.path.join(ICONOS, "drive-removable-media-usb.svg") pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, 30, -1) unidades = self.demonio_unidades.get_unidades() for unidad in unidades.keys(): dic = unidades.get(unidad, False) if dic: mount_path = dic.get('mount_path', "") self.get_model().append( [pixbuf, mount_path.split("/")[-1], mount_path]) self.get_toplevel().set_sensitive(True)
def __get_info(self, widget, path): """ Recibe el path seleccionado en la estructura de directorios, obtiene información sobre el mismo y la pasa a infowidget para ser mostrada. """ if not path: return if not os.path.exists(path): return self.toolbar_try.label.set_text(path) # FIXME: Falla si se movió y no se actualiza unidad, directorio, archivo, enlace = describe_uri(path) lectura, escritura, ejecucion = describe_acceso_uri(path) texto = "" typeinfo = "" if enlace: texto = "Enlace.\n" else: if directorio: texto = "Directorio.\n" elif archivo: texto = "Archivo.\n" texto += "Tipo:\n" for dato in describe_archivo(path).split(";"): texto += "\t%s\n" % (dato.strip()) typeinfo += dato texto += "Tamaño:\n" texto += "\t%s bytes\n" % (get_tamanio(path)) texto += "Permisos: \n" texto += "\tLactura: %s\n" % (lectura) texto += "\tEscritura: %s\n" % (escritura) texto += "\tEjecución: %s\n" % (ejecucion) self.navegador.infowidget.set_info(texto, typeinfo)
def __ejecutar_agregar_elemento(self, elementos): """ Agrega los items a la lista, uno a uno, actualizando. """ if not elementos: self.permitir_select = True self.seleccionar_primero() self.get_toplevel().set_sensitive(True) return False texto, path = elementos[0] from JAMFileSystem import describe_uri from JAMFileSystem import describe_archivo descripcion = describe_uri(path) icono = None if descripcion: if descripcion[2]: # Es un Archivo tipo = describe_archivo(path) if 'video' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "video.png") elif 'audio' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "sonido.png") elif 'image' in tipo and not 'iso' in tipo: icono = os.path.join(path) # exige rendimiento #icono = os.path.join(JAMediaWidgetsBASE, # "Iconos", "imagen.png") elif 'pdf' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "pdf.png") elif 'zip' in tipo or 'rar' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "zip.png") else: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "archivo.png") else: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "archivo.png") try: pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icono, get_pixels(0.8), -1) self.modelo.append([pixbuf, texto, path]) except: pass elementos.remove(elementos[0]) gobject.idle_add(self.__ejecutar_agregar_elemento, elementos) return False
def __ejecutar_agregar_elemento(self, elementos): """ Agrega los items a la lista, uno a uno, actualizando. """ if not elementos: self.permitir_select = True self.seleccionar_primero() self.get_toplevel().set_sensitive(True) return False texto, path = elementos[0] from JAMFileSystem import describe_uri from JAMFileSystem import describe_archivo descripcion = describe_uri(path) icono = None if descripcion: if descripcion[2]: # Es un Archivo tipo = describe_archivo(path) if 'video' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "video.svg") elif 'audio' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "sonido.svg") elif 'image' in tipo and not 'iso' in tipo: icono = os.path.join(path) # exige rendimiento #icono = os.path.join(JAMediaWidgetsBASE, # "Iconos", "imagen.png") elif 'pdf' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "pdf.svg") elif 'zip' in tipo or 'rar' in tipo: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "edit-select-all.svg") else: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "edit-select-all.svg") else: icono = os.path.join(JAMediaWidgetsBASE, "Iconos", "edit-select-all.svg") try: pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( icono, get_pixels(0.8), -1) self.modelo.append([pixbuf, texto, path]) except: pass elementos.remove(elementos[0]) GLib.idle_add(self.__ejecutar_agregar_elemento, elementos) return False