Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/CompressCanvas.py
blob: 7be0e24826c7f145e9fd34cbb187c22b802ce54a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Ignacio Rodríguez <nachoel01@gmail.com>
# Rafael Cordano <rafael.cordano@gmail.com>
# Ezequiel Pereira <eze2307@gmail.com>
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
try:
	from Compress import *
	import utils
	import gtk,os,shutil,gobject,pygtk
	from sugar.graphics.alert import NotifyAlert,Alert
	from sugar.graphics.objectchooser import ObjectChooser
	from sugar.graphics.icon import Icon
	from sugar.datastore import datastore
	shutil.rmtree('/tmp/Compress')
	os.mkdir('/tmp/Compress')
	os.mkdir('/tmp/Compress/Work')
except:
	pass
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 "))

###
class Canvas(gtk.TreeView):
	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)		
			Arriba.connect('clicked',self.back)
			save.connect('clicked',self.copiar_al_diario)
#			open_from_journal.connect('clicked',self.open_diario)
			Add.connect('clicked',self.anadir)
			newdirectory.connect('clicked',self.new_directory)
		except:
			pass
	        Uri.connect('activate',self.change)
	        Uri.connect("icon-press", self.change)
		self.set_property("rules-hint", True)
		entrada.connect('icon-press',self.update,entrada)
		entrada.connect('activate',self.update_e,entrada)
		
		self.Copiado = None
		self.modelo = self.construir_lista()
		self.construir_columnas()
		self.seleccion = self.get_selection() # treeview.get_selection()
		self.seleccion.set_mode(gtk.SELECTION_SINGLE)
		self.seleccion.set_select_function(self.archivo_clickeado, self.modelo, True)
		self.connect("row-activated", self.doble_click)
		self.connect('button-release-event', self.menu_click)  
		self.connect('key-release-event', self.atras_button)   
		self.set_model(self.modelo)
		self.presentado = False
		self.show_all()
		self.icon_name = None
		if Estado:
			Hboxx.show()
		else:
			Hboxx.hide()
	def update(self,widget,a,b,entrada): # Icono
		botons.connect('clicked',self.descomprimir_final,entrada.get_text())
	def update_e(self,widget,entrada): # Enter en la entrada
		botons.connect('clicked',self.descomprimir_final,entrada.get_text())
	def compress_file(self,widget,archivo): # Comprime un archivo
			utils.compress(utils.Archivos,os.getcwd()+"/"+utils.Archivos+".zip")
			self.set_model(self.construir_lista())
	def open(self,widget,clickeado=False): # Abrir
		if not clickeado:
			try:
				utils.decompress(utils.Archivos,Hboxx,'/tmp/Compress/Work','Abrir')
				utils.Archivo_d = Uri.get_text()+"/"+utils.Archivos
				os.chdir('/tmp/Compress/Work')
			except:
				utils.Abrir(Hboxx,entrada)
		if clickeado:
				utils.Abrir(Hboxx,entrada)
		Uri.set_text(os.getcwd())
		Uri.show()
		self.set_model(self.construir_lista())	
	def new_directory(self,widget):
		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.show()
		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())
			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())
		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,
                                       i: self.actividad.remove_alert(w))
			self.actividad.add_alert(alerta)
	def archivo_clickeado(self, seleccion, modelo, archivo, seleccionado, a): # Cuando se selecciona
		iter= modelo.get_iter(archivo)
		directorio =  modelo.get_value(iter,0)
		utils.Archivos = directorio
		estado = utils.describe_archivo(os.getcwd()+"/"+utils.Archivos)
	
		if 'image' in estado:
			self.icon_name = 'imagen'
			save.set_tooltip(_('Save image: '+utils.Archivos+' to journal'))
		if 'text' in estado:
			self.icon_name = 'texto'
			save.set_tooltip(_('Save text: '+utils.Archivos+' to journal'))
		if 'audio' in estado:
			self.icon_name = 'audio'
			save.set_tooltip(_('Save audio: '+utils.Archivos+' to journal'))

		if 'video' in estado:
			self.icon_name = 'video'
			save.set_tooltip(_('Guardar: '+utils.Archivos+' al diario'))
		if not 'directory' in estado and not 'no read permission' in estado:
			try:
				save.set_icon_name(self.icon_name)
				save.show()
			except:
				save.set_icon(self.icon_name)
				save.show()
		else:
			save.hide()
		return True
	def anadir(self,widget):
		Selector = gtk.FileChooserDialog(_("Seleccione un archivo"),None,gtk.FILE_CHOOSER_ACTION_OPEN,(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
		Selector.set_default_response(gtk.RESPONSE_CANCEL)
		if utils.Archivo_d != None:
			Echo = Selector.run()
			if Echo == gtk.RESPONSE_OK:
				File = Selector.get_filename()
				print 'ARCHIVO'
				print File
				utils.compress(File,utils.Archivo_d)
				print 'AÑADIDO'
				utils.decompress(utils.Archivo_d,Hboxx)
				print 'DESCOMPRIMIDO'
				Selector.destroy()
			elif Echo == gtk.RESPONSE_CANCEL:
				Selector.destroy()
		if utils.Archivo_d == None:
				self.errores('Copiar_a_nada')
		os.chdir('/tmp/Compress/Work')
		self.set_model(self.construir_lista())
		Uri.set_text(os.getcwd())
		Uri.show()
	def open_diario(self,widget): # Abrir un zip desde el diario.
			chooser = ObjectChooser()      
			resultado = chooser.run()
   			if resultado == gtk.RESPONSE_ACCEPT:
				Archivo_s = chooser.get_selected_object()
				Archivo = Archivo_s.get_file_path()
				try:
					print Archivo
					utils.Archivo_d = Archivo
					utils.decompress(Archivo,Hboxx,'/tmp/Compress/Work','Abrir',True)
		
				except IOError:
					alerta = NotifyAlert(10)
					alerta.props.msg = _('Error when trying cut: %s')%utils.Archivos
					alerta.connect('response', lambda w,
                                		       i,z,e: self.actividad.remove_alert(w), self.set_model(self.construir_lista()),Uri.set_text(os.getcwd()))
					self.actividad.add_alert(alerta)
					
	def construir_lista(self):
		store = gtk.ListStore(str)
		dirList=os.listdir(os.getcwd())
		dircontents = []
		for item in dirList: 
			if item[0] != '.':
				if os.path.isdir(item):
					dircontents.append(['/'+item])
				else:
					dircontents.append([item])
					
		dircontents.sort() 
		for act in dircontents:
			store.append([act[0]])
		return store
	def descomprimir_en(self,widget=None):
		if not self.presentado:
			label = gtk.Label(_('Directory:'))
			#entrada.set_text('/tmp/Compress/Work')
			boton = gtk.Button(gtk.STOCK_OPEN)
			botona = gtk.Button(gtk.STOCK_CANCEL)
			botona.set_use_stock(True)
			botona.connect('clicked',lambda x:Hboxx.hide())
			boton.set_use_stock(True)
			boton.connect('clicked',utils.Abrir_Directorio,entrada,utils.Archivos,Estado,Hboxx)
			Hboxx.pack_start(label,False,False,0)
			Hboxx.pack_start(entrada,True,True,0)
			Hboxx.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse('#FF0000'))
			Hboxx.pack_start(boton,False,False,0)
			botons.set_use_stock(True)
			Hboxx.pack_start(botons,False,False,0)
			Hboxx.pack_start(botona,False,False,0)
			
			Hboxx.show_all()
			self.presentado = True
		else:
			Hboxx.show_all()
	def descomprimir_final(self,widget,dire):
		utils.decompress(utils.Archivos,Hboxx,dire,'Descomprimir')
		Hboxx.hide()
		os.chdir(dire)
		Uri.set_text(os.getcwd())
		Uri.show()
		self.set_model(self.construir_lista())
	def descomprimir(self,widget):
		self.descomprimir_en()
		Estado = True
	def construir_columnas(self):
		columna= gtk.TreeViewColumn(_('Files in the directory'))
		celda_de_texto = gtk.CellRendererText() # para el texto
		columna.pack_start(celda_de_texto, True)
		self.append_column (columna)
		columna.set_attributes(celda_de_texto, text=0)
	def doble_click(self, widget, row, col): # Clickeado
		model = widget.get_model()
		target = model[row][0]
		Archivo = utils.describe_archivo(os.getcwd()+"/"+utils.Archivos)
		if target[0] != "/":
				utils.Archivos = target
				ventana = gtk.Window()
				ventana.set_title(target)																									
				ventana.connect('destroy',lambda x: ventana.destroy)
				if 'image' in Archivo:
					try:
						pix = gtk.gdk.pixbuf_new_from_file(target)
						image = gtk.Image()
						image.set_from_pixbuf(pix)
						ventana.add(image)
						image.show()
						ventana.show()
					except IOError:
						self.ops(_('image'))
				if not 'binary' in Archivo:
					try:
						ventana.set_size_request(gtk.gdk.screen_width()/2,gtk.gdk.screen_height()/2)
						texta = gtk.ScrolledWindow()
						texs = gtk.TextBuffer()
						text = gtk.TextView(texs)
						texta.add(text)
						text.set_editable(False)
						texs.set_text(open(target).read())
						ventana.add(texta)
						ventana.show_all()
					except IOError:
						self.ops(_('file'))
		else:
			try:
				os.chdir(os.getcwd()+target)
				self.set_model(self.construir_lista())
			except:
				self.ops(_('directory'))
			Uri.set_text(os.getcwd())
			Uri.show()
	def create_columns(self, treeView):
		rendererText = gtk.CellRendererText()
		img = celda_de_imagen = gtk.CellRendererPixbuf()
		column = gtk.TreeViewColumn(_('Files in the directory'))
		column.set_sort_column_id(0)
		column.pack_start(rendererText,False)    
		column.set_attributes(rendererText, text=0)
		self.append_column(column)     
	def close(self,widget):
		shutil.rmtree('/tmp/Compress/Work')
		os.mkdir('/tmp/Compress/Work')
		utils.Archivo_d = None
		self.set_model(self.construir_lista())
	def menu_click(self,widget,event):
		Boton = event.button
		Tiempo = event.time
		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)
					Menu.append(Abrir)
					Menu.append(gtk.SeparatorMenuItem())
				else:
					pass
			else:
				Close = gtk.MenuItem(_('Close zip:  %s'%utils.Archivo_d))
				Close.connect('activate', self.close)
				Menu.append(Close)
			Copy = gtk.MenuItem(_('Copy'))
			Copy.connect('activate',self.copy)
			if 'zip' in Archivo:
				Des = gtk.MenuItem(_('Uncompress'))
				Des.connect('activate',self.descomprimir)
			Cut = gtk.MenuItem(_('Cut'))
			Cut.connect('activate',self.cut)
			Delete = gtk.MenuItem(_('Delete'))
			Delete.connect('activate',self.sure)
			CompressFile= gtk.MenuItem(_('Compress this file'))
			CompressFile.connect('activate',self.compress_file,utils.Archivos)
			Menu.append(CompressFile)
			try:
				Menu.append(Des)
			except:
				pass
			Menu.append(gtk.SeparatorMenuItem())
			if utils.Archivo_d != None:
				Copyw = gtk.MenuItem(_('Copy to zip'))
				Copyw.connect('activate',self.copy,True)
				Menu.append(Copyw)
			Menu.append(Copy)
			
			Menu.append(Cut)
			Back = gtk.MenuItem(_('Back'))
			Back.connect('activate',self.back)
			if os.listdir('/tmp/Compress/') != ['Work']:
				Paste = gtk.MenuItem(_('Paste'))
				Paste.connect('activate',self.paste)
				Menu.append(Paste)
			Menu.append(gtk.SeparatorMenuItem())
			Menu.append(Delete)
			Menu.append(Back)
			Menu.show_all()
			Menu.popup(None, None, None, Boton, Tiempo)
	def atras_button(self,widget,event):
		Boton = event.keyval
		if Boton == 65288:
			self.back()
		if Boton == 65535: # Solo existe en la 1.5 y en las magallanes
			self.sure()
	def delete(self,widget=None,estado=None):
		if estado == gtk.RESPONSE_CANCEL:
			self.actividad.remove_alert(widget)
		else:
			self.actividad.remove_alert(widget)
			try:
				try:
					os.remove(os.getcwd()+"/"+utils.Archivos)
				except:
					shutil.rmtree(os.getcwd()+utils.Archivos)
			except OSError:
				self.errores('Delete')
			self.set_model(self.construir_lista())
	def cut(self,widget):
		try:
			self.Copiado = utils.Archivos
#			os.system('mv '+ os.getcwd()+"/"+utils.Archivos+" "+'/tmp/Compress/'+utils.Archivos)
			shutil.move(os.getcwd()+"/"+utils.Archivos,'/tmp/Compress/'+utils.Archivos)
			self.set_model(self.construir_lista())
		except:
			self.errores('Cortar')
	def paste(self,widget):
		try:
			
			#os.system('mv /tmp/Compress/'+self.Copiado+" " + os.getcwd()+"/")
			shutil.move('/tmp/Compress/'+self.Copiado,os.getcwd()+"/")			
			self.set_model(self.construir_lista())
		except:
			List = os.listdir('/tmp/Compress')
			if List == ['Work']:
				self.errores("Pegar_None")
			else:
				self.errores('Pegar')
	def back(self,widget=None):
		os.chdir(os.getcwd()+"/..")
		self.set_model(self.construir_lista())
		Uri.set_text(os.getcwd())
		Uri.show()
	def change(self,widget,a=None,b=None):
		try:
			os.chdir(widget.get_text())
			self.set_model(self.construir_lista())
		except:
			self.ops(_('directory'))
	def copy(self,widget,W=False):
		try:
			self.Copiado = utils.Archivos
			if not W:
				try:
					shutil.copy(os.getcwd()+"/"+utils.Archivos,'/tmp/Compress/')
				except:
					shutil.copytree(os.getcwd()+"/"+utils.Archivos,'/tmp/Compress/'+utils.Archivos)
				
			if W:
				try:
					utils.compress("./"+utils.Archivos,utils.Archivo_d)
					utils.decompress(utils.Archivo_d,Hboxx)
					
				except:
					self.errores('Copiar_a_nada')
			
		except:
			self.errores('Copiar')
	def sure(self,widget=None):
		alerta = Alert()
		alerta.props.title = _('Sure?')
		alerta.props.msg = _("Are you sure you want to delete this file: %s ?" %utils.Archivos)
		ok_icon = Icon(icon_name='dialog-ok')
		cancel_icon = Icon(icon_name='dialog-cancel')
		alerta.add_button(gtk.RESPONSE_OK,_('Ok'), ok_icon)
		alerta.add_button(gtk.RESPONSE_CANCEL,_('Cancel'), cancel_icon)
		alerta.connect('response',self.delete)
		self.actividad.add_alert(alerta)
	def ops(self,donde):
		alerta = NotifyAlert(10)
		alerta.props.msg = _('Error accessing to '+donde+' razón:\n%s' %self.razon(str(Uri.get_text()),donde))
		Ant = os.getcwd()
		alerta.connect('response', lambda w,
                               i,z,x,d: self.actividad.remove_alert(w),os.chdir(Ant),Uri.set_text(os.getcwd()),Uri.show())
		self.actividad.add_alert(alerta)

###
	def razon(self,directorio,razon):
		if not os.path.exists(directorio):
			return _("The "+razon+" no exist")
		else:
			try:
				open(directorio)
			except:
				return _("You have not got access for this "+razon )
		try:
			open(directorio+"/")
		except:
			return _(directorio+" It is not a directory")
	def home(self,widget=None):
		os.chdir('/tmp/Compress/Work')
		Uri.set_text(os.getcwd())
		Uri.show()
		self.set_model(self.construir_lista())
	def copiar_al_diario(self,widget):
		descripcion = utils.describe_archivo(utils.Archivos)
		mime = utils.describe_mime(utils.Archivos)
		if not 'directory' in descripcion:
			acopiar = datastore.create()
			acopiar.metadata['title'] = utils.Archivos
			acopiar.metadata['mime_type'] = mime
			acopiar.set_file_path(os.getcwd()+"/"+utils.Archivos)
			datastore.write(acopiar)
			acopiar.destroy()
	def errores(self,Evento=None):
		if Evento == "Copiar":
			info = gtk.MessageDialog(type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK,message_format=_("Error when trying copy: %s "%utils.Archivos))
			a = info.run()
			if a == gtk.RESPONSE_OK:
				info.destroy()
		if Evento == "Cortar":
			alerta = NotifyAlert(10)
			alerta.props.msg = _('Error when trying cut: %s')%utils.Archivos
			alerta.connect('response', lambda w,
                                       i: self.actividad.remove_alert(w))
			self.actividad.add_alert(alerta)		
		if Evento == "Pegar_None":
			alerta = NotifyAlert(10)
			alerta.props.msg = _('Error: It is not nothing in the clipboard')
			alerta.connect('response', lambda w,
                                       i: self.actividad.remove_alert(w))
			self.actividad.add_alert(alerta)	
		if Evento == "Pegar":
			alerta = NotifyAlert(10)
			alerta.props.msg = _('Error when trying paste a file')
			alerta.connect('response', lambda w,
                                       i: self.actividad.remove_alert(w))
			self.actividad.add_alert(alerta)	
		if Evento == 'Copiar_a_nada':
			alerta = NotifyAlert(10)
			alerta.props.msg = _('Ups! Seems not yet opened any file')
			alerta.connect('response', lambda w,
                                       i: self.actividad.remove_alert(w))
			self.actividad.add_alert(alerta)		
		if Evento == 'Delete':
			alerta = NotifyAlert(10)
			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, path):
		gtk.EventBox.__init__(self)
		self.actividad = actividad
		vbox = gtk.VBox(False, 8)
		xhbox = gtk.HBox()
		sw = gtk.ScrolledWindow()
		sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
		sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		xhbox.pack_start(Uri,True,True,0)
		hbox = gtk.HBox()
		vbox.pack_start(xhbox,False,False)
		vbox.pack_start(hbox)
		Logo = gtk.Image()
		Logo.set_from_file('icons/ceibaljam.svg')
		hbox.pack_start(sw, True, True, 0)
		sw.add(Canvas(self.actividad, path))
		hx = gtk.HBox()
		Logo2 = gtk.Image()
		Logo.set_tooltip_text('http://www.ceibaljam.org')
		Logo2.set_from_file('icons/sugarlabs.svg')
		Logo2.set_tooltip_text('http://www.wiki.sugarlabs.org')

		self.add(vbox)
		vbox.pack_start(Hboxx,False,False,0)
		if gtk.gdk.screen_width() >= 1200:
			vbox.pack_start(hx,False,False,0)
			hx.pack_start(Logo2,True,True,0)		
			hx.pack_start(Logo,True,True,100)
		else:
			Uri.set_size_request(int(gtk.gdk.screen_width()-157.797),int(45.466))
			Uri.show()
			LogoChico = gtk.Image()
			LogoChico.set_from_file('icons/ceibaljam_chico.svg')
			
			LogoChico.show()
			xhbox.pack_start(LogoChico,False,False,0)
		self.show_all()