@@ -220,6 +220,8 @@ def __init__(self):
220220 self .ventana .set_default_size (WRES , HRES )
221221 self .ventana .set_keep_above (bool (config .getboolean ("GRAPHICS" , "window-set-keep-above" )))
222222
223+ builder .get_object ("Revealer1" ).set_reveal_child (bool (config .getboolean ("GRAPHICS" , "revealer-show-default" )))
224+
223225 i = int (config .get ('GRAPHICS' , 'toolbutton-size' ))
224226
225227 #Probablemente estas dos variables se puedan coger del builder de alguna manera, pero no se cómo.
@@ -283,11 +285,34 @@ def append(self, obj, otherdata=[]):
283285 #SI OBJ YA ESTÄ, QUE AÑADA ATRIBUTOS A LA LISTA.
284286 it1 = self .tree .append (None , row = [obj .name , obj .objectype ])
285287 it2 = self .tree .append (it1 , row = ["MAC" , str (obj .macdir )])
288+ itc = self .tree .append (it1 , row = ["Conexiones" , "{}/{}" .format (len (obj .connections ), obj .max_connections )])
286289 for i in otherdata :
287290 self .tree .append (it1 , row = i )
288291
292+ obj .trdic = {"MAC" :it2 , "Connections" :itc }
293+
289294 return it1
290295
296+ def update (self , obj , thing , val ):
297+ if thing in obj .trdic .keys ():
298+ self .tree .set_value (obj .trdic [thing ], 1 , val )
299+ else :
300+ it = self .tree .append (obj .trlst , row = [thing , val ])
301+ obj .trdic [thing ] = it
302+
303+ def upcon (self , obj ):
304+ if not hasattr (obj , "trcondic" ):
305+ obj .trcondic = {}
306+ #objlst.tree.append(self.trdic["Connections"], row=[self.name, self.objectype])
307+ self .tree .set_value (obj .trdic ["Connections" ], 1 , "{}/{}" .format (len (obj .connections ), obj .max_connections ))
308+ for i in obj .connections :
309+ print (i .__repr__ (), obj .trcondic )
310+ if i in obj .trcondic .keys ():
311+ self .tree .set_value (obj .trcondic [i ], 0 , i .name )
312+ else :
313+ r = self .tree .append (obj .trdic ["Connections" ], row = [i .name , "" ])
314+ obj .trcondic [i ] = r
315+
291316 def show (self , * args ):
292317 rev = self .revealer .get_reveal_child ()
293318 if rev :
@@ -302,6 +327,9 @@ def show(self, *args):
302327 def set_value (self ,* args ):
303328 self .tree .set_value (* args )
304329
330+ def delete (self , obj ):
331+ self .tree .remove (obj .trlst )
332+
305333 def showcfgwindow (self , * args ):
306334 global configWindow
307335 try :
@@ -895,9 +923,7 @@ def update(self):
895923 self .image .set_tooltip_text (self .name + " (" + str (len (self .connections )) + "/" + str (self .max_connections ) + ")" )
896924 objlst .set_value (self .trlst , 0 , self .name )
897925
898- ### HACER UN DICCIONARIO CON LO DE SELF.TRLST
899-
900- objlst .set_value ()
926+ objlst .update (self ,"MAC" , str (self .macdir ))
901927 for child in self .builder .get_object ("grid_rclick-disconnect" ).get_submenu ().get_children ():
902928 if child .props .label .upper () != "TODOS" :
903929 if child .link .uuid not in [x .uuid for x in self .connections ]:
@@ -907,15 +933,17 @@ def update(self):
907933 else :
908934 print ("Object" , child .link .__repr__ (), "in self.connections" , self .connections )
909935 pass
936+
937+ objlst .upcon (self )
938+
910939 print ("\033 [95m<<\033 [00m" )
911940
912941 def connect (self , objeto , cable ):
913- #Permutado objeto y self para ver que tal va
914942 tmp = Gtk .MenuItem .new_with_label (objeto .name )
915943 self .builder .get_object ("grid_rclick-disconnect" ).get_submenu ().append (tmp )
916944 tmp .show ()
917945 tmp .connect ("activate" , self .disconnect )
918- #link es un objeto vinculado al widget
946+ #link es un objeto vinculado al widget, luego es útil.
919947 tmp .link = objeto
920948 tmp2 = Gtk .MenuItem .new_with_label (objeto .name )
921949 self .builder .get_object ("grid_rclick-sendpkg" ).get_submenu ().append (tmp2 )
@@ -938,9 +966,11 @@ def connect(self, objeto, cable):
938966
939967 self .connections .append (objeto )
940968 self .cables .append (cable )
969+ #objlst.tree.append(self.trdic["Connections"], row=[objeto.name, objeto.objectype])
941970
942971 objeto .connections .append (self )
943972 objeto .cables .append (cable )
973+ #objlst.tree.append(objeto.trdic["Connections"], row=[self.name, self.objectype])
944974
945975 self .update ()
946976 objeto .update ()
@@ -971,8 +1001,11 @@ def disconnect(self, widget, *args, de=None):
9711001 self .disconnect (widget , de = self .connections [0 ])
9721002
9731003 else :
974- print (self .connections )
975- print (de .__repr__ ())
1004+ objlst .tree .remove (self .trcondic [de ])
1005+ del self .trcondic [de ]
1006+ objlst .tree .remove (de .trcondic [self ])
1007+ del de .trcondic [self ]
1008+
9761009 de .connections .remove (self )
9771010 self .connections .remove (de )
9781011
@@ -1006,7 +1039,7 @@ def delete(self, *widget, conf=1, pr=1):
10061039 yonR = 1
10071040 if yonR == 1 :
10081041 self .disconnect (0 , de = "All" )
1009- self . label . destroy ( )
1042+ objlst . delete ( self )
10101043 self .image .destroy ()
10111044 global allobjects
10121045 allobjects .remove (self )
@@ -1390,6 +1423,9 @@ def update(self):
13901423
13911424 print ("self.connections" , self .connections )
13921425
1426+ if self .IP != None :
1427+ objlst .update (self ,"IP" , str (self .IP ))
1428+
13931429 #Ahora es cuando viene la parte de haber estudiado.
13941430 #SÓLO ENVÍA PINGS, (ICMP)
13951431 sub_N = 0
0 commit comments