diff options
author | Ignacio Rodríguez <ignaciorodriguez@sugarlabs.org> | 2012-12-17 19:05:09 (GMT) |
---|---|---|
committer | Ignacio Rodríguez <ignaciorodriguez@sugarlabs.org> | 2012-12-17 19:05:09 (GMT) |
commit | 3182136963a2c4a5aa8ab94138af3b3cd8a9c835 (patch) | |
tree | 994a4ff17fdfa31253f2e91d97c3cee70ec2faf5 | |
parent | e343232c59a47271352a669adcacb5d1f5698084 (diff) |
Arregladas alertas.
-rw-r--r-- | Compress.py | 6 | ||||
-rw-r--r-- | CompressCanvas.py | 104 |
2 files changed, 66 insertions, 44 deletions
diff --git a/Compress.py b/Compress.py index 24c1ba5..7d555aa 100644 --- a/Compress.py +++ b/Compress.py @@ -39,15 +39,17 @@ from CompressCanvas import * class Compress(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle, True) - canvas = PyApp(self) + canvas = PyApp(self, activity.get_bundle_path()) Actividad = ActivityToolbarButton(self) Parar = StopButton(self) #<-------------Separadores-------------># Separador = gtk.SeparatorToolItem() Separador2 = gtk.SeparatorToolItem() Separador3 = gtk.SeparatorToolItem() + Separador.set_expand(True) Separador.props.draw = False + Separador3.set_expand(True) Separador3.props.draw = False Barra.toolbar.insert(Actividad, 0) @@ -57,7 +59,7 @@ class Compress(activity.Activity): Barra.toolbar.insert(Arriba,4) Barra.toolbar.insert(Separador, 5) Barra.toolbar.insert(newdirectory, 6) - Barra.toolbar.insert(Separador2, 7) + Barra.toolbar.insert(Separador, 7) Barra.toolbar.insert(Abrir, 8) Barra.toolbar.insert(save,9) Barra.toolbar.insert(Separador3, 10) diff --git a/CompressCanvas.py b/CompressCanvas.py index af211fa..7be0e24 100644 --- a/CompressCanvas.py +++ b/CompressCanvas.py @@ -33,28 +33,45 @@ except: from gettext import gettext as _ Archivo = None # CONSTANTES # +entry = gtk.Entry() +alerti = Alert() +hbox = alerti._hbox +hbox.pack_end(entry) +ok_icon = Icon(icon_name='dialog-ok') +cancel_icon = Icon(icon_name='dialog-cancel') +hbox.show_all() +alerti.add_button(gtk.RESPONSE_OK,_('Ok'), ok_icon) +alerti.add_button(gtk.RESPONSE_CANCEL,_('Cancel'), cancel_icon) + + Hboxx = gtk.HBox() + Uri = gtk.Entry() Uri.set_text(os.getcwd()) Uri.props.secondary_icon_stock = 'gtk-apply' Uri.props.secondary_icon_activatable = True + Estado = False + entrada = gtk.Entry() entrada.props.secondary_icon_stock = 'gtk-apply' entrada.props.secondary_icon_activatable = True + botons = gtk.Button(gtk.STOCK_OK) + save = utils.Boton(_('Save file'),'document-save') entrada.set_text(_("For the changes be saved press the '↵' key or the √ icon ")) -entry = gtk.Entry() + ### class Canvas(gtk.TreeView): - def __init__(self, actividad): + def __init__(self, actividad, path): self.modelo = None self.treeview_arbol = None self.barra_de_estado = None gtk.TreeView.__init__(self) self.actividad = actividad + self.path = path try: Home.connect('clicked',self.home) Abrir.connect('clicked',self.open,True) @@ -109,32 +126,37 @@ class Canvas(gtk.TreeView): Uri.show() self.set_model(self.construir_lista()) def new_directory(self,widget): - alerta = Alert() - hbox = alerta._hbox - hbox.pack_end(entry) - alerta.props.title = _('New directory') - alerta.props.msg = _("Write a name for the directory") - ok_icon = Icon(icon_name='dialog-ok') - cancel_icon = Icon(icon_name='dialog-cancel') - hbox.show_all() - alerta.add_button(gtk.RESPONSE_OK,_('Ok'), ok_icon) - alerta.add_button(gtk.RESPONSE_CANCEL,_('Cancel'), cancel_icon) - alerta.connect('response',self.quehacemos) - self.actividad.add_alert(alerta) + alerti.props.title = _('New directory') + alerti.props.msg = _("Write a name for the directory") + alerti.connect('response',self.quehacemos) + self.actividad.add_alert(alerti) def quehacemos(self,widget,respuesta): + self.actividad.remove_alert(widget) if respuesta == gtk.RESPONSE_CANCEL: - entry.set_text("") + entry.set_text('') entry.show() - self.actividad.remove_alert(widget) - if entry.get_text() != "": - self.actividad.remove_alert(widget) + print 'Check' + print entry.get_text() + print respuesta + print 'Fin Check' + if entry.get_text() != '' and respuesta == gtk.RESPONSE_OK: direccion = str(entry.get_text()) - os.mkdir(direccion) - entry.set_text("") + try: + os.mkdir(direccion) + entry.set_text('') + except OSError: + alerta = NotifyAlert(10) + alerta.props.msg = _('Error when trying create the directory') + alerta.connect('response', lambda w, + i: self.actividad.remove_alert(w)) + self.actividad.add_alert(alerta) entry.show() - self.set_model(self.construir_lista()) - if entry.get_text == "" and respuesta == gtk.RESPONSE_OK: - self.actividad.remove_alert(widget) + self.set_model(self.construir_lista()) + self.check(respuesta) + def check(self,respuesta): + print entry.get_text() + + if entry.get_text <= '' and respuesta == gtk.RESPONSE_OK: alerta = NotifyAlert(10) alerta.props.msg = _('Please specify a directory') alerta.connect('response', lambda w, @@ -321,19 +343,23 @@ class Canvas(gtk.TreeView): Menu = gtk.Menu() Archivo = utils.describe_archivo(os.getcwd()+"/"+utils.Archivos) if Boton == 3: + # El siguiente indica la versión de compress # + compressmenuitem = gtk.MenuItem('Compress version:'+str(open(self.path+'/version').read())) + Menu.append(compressmenuitem) + Menu.append(gtk.SeparatorMenuItem()) if utils.Archivo_d == None: if 'zip' in Archivo: Abrir = gtk.MenuItem(_('Open zip')) - Abrir.connect('activate',self.open) + Abrir.connect('activate', self.open) Menu.append(Abrir) + Menu.append(gtk.SeparatorMenuItem()) else: pass else: Close = gtk.MenuItem(_('Close zip: %s'%utils.Archivo_d)) - Close.connect('activate',self.close) + Close.connect('activate', self.close) Menu.append(Close) - Menu.append(gtk.SeparatorMenuItem()) - Copy = gtk.MenuItem(_('Copiar')) + Copy = gtk.MenuItem(_('Copy')) Copy.connect('activate',self.copy) if 'zip' in Archivo: Des = gtk.MenuItem(_('Uncompress')) @@ -357,7 +383,7 @@ class Canvas(gtk.TreeView): Menu.append(Copy) Menu.append(Cut) - Back = gtk.MenuItem(_('Atras')) + Back = gtk.MenuItem(_('Back')) Back.connect('activate',self.back) if os.listdir('/tmp/Compress/') != ['Work']: Paste = gtk.MenuItem(_('Paste')) @@ -384,8 +410,8 @@ class Canvas(gtk.TreeView): os.remove(os.getcwd()+"/"+utils.Archivos) except: shutil.rmtree(os.getcwd()+utils.Archivos) - except: - self.errores('Desconocido') + except OSError: + self.errores('Delete') self.set_model(self.construir_lista()) def cut(self,widget): try: @@ -513,14 +539,15 @@ class Canvas(gtk.TreeView): alerta.connect('response', lambda w, i: self.actividad.remove_alert(w)) self.actividad.add_alert(alerta) - if Evento == 'Desconocido': + if Evento == 'Delete': alerta = NotifyAlert(10) - alerta.props.msg = _('Unknown error') + alerta.props.title = '¡Hey!' + alerta.props.msg = _('You have not got access for this file/directory') alerta.connect('response', lambda w, i: self.actividad.remove_alert(w)) self.actividad.add_alert(alerta) class Canvas_box(gtk.EventBox): - def __init__(self, actividad): + def __init__(self, actividad, path): gtk.EventBox.__init__(self) self.actividad = actividad vbox = gtk.VBox(False, 8) @@ -535,7 +562,7 @@ class Canvas_box(gtk.EventBox): Logo = gtk.Image() Logo.set_from_file('icons/ceibaljam.svg') hbox.pack_start(sw, True, True, 0) - sw.add(Canvas(self.actividad)) + sw.add(Canvas(self.actividad, path)) hx = gtk.HBox() Logo2 = gtk.Image() Logo.set_tooltip_text('http://www.ceibaljam.org') @@ -558,11 +585,4 @@ class Canvas_box(gtk.EventBox): xhbox.pack_start(LogoChico,False,False,0) self.show_all() -if __name__ == "__main__": - a = gtk.Window() - a.add(Canvas_box()) - a.set_title('COMPRESS CANVAS GTK2') - a.show_all() - a.connect('destroy',lambda x: gtk.main_quit()) - a.set_size_request(500,500) - gtk.main() + |