@@ -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.
@@ -255,8 +257,79 @@ def __init__(self):
255257 }
256258 builder .connect_signals (handlers )
257259
260+ builder .get_object ("toolbutton1" ).connect ("clicked" , objlst .show )
261+
258262 self .ventana .show_all ()
259263
264+ class ObjLst ():
265+ def __init__ (self ):
266+ self .view = builder .get_object ("objetos_treeview" )
267+ self .tree = Gtk .TreeStore (str ,str )
268+ renderer = Gtk .CellRendererText ()
269+ column = Gtk .TreeViewColumn ("Objetos" , renderer , text = 0 )
270+ self .view .append_column (column )
271+ column .set_sort_column_id (0 )
272+
273+ renderer = Gtk .CellRendererText ()
274+ column = Gtk .TreeViewColumn ("Valor" , renderer , text = 1 )
275+ column .set_sort_column_id (1 )
276+ self .view .append_column (column )
277+ self .view .set_model (self .tree )
278+ self .view .show_all ()
279+
280+ self .revealer = builder .get_object ("Revealer1" )
281+ print ("Revealer:" ,self .revealer .get_reveal_child ())
282+ self .panpos = 100
283+
284+ def append (self , obj , otherdata = []):
285+ #SI OBJ YA ESTÄ, QUE AÑADA ATRIBUTOS A LA LISTA.
286+ it1 = self .tree .append (None , row = [obj .name , obj .objectype ])
287+ 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 )])
289+ for i in otherdata :
290+ self .tree .append (it1 , row = i )
291+
292+ obj .trdic = {"MAC" :it2 , "Connections" :itc }
293+
294+ return it1
295+
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+
316+ def show (self , * args ):
317+ rev = self .revealer .get_reveal_child ()
318+ if rev :
319+ self .panpos = builder .get_object ("paned1" ).get_position ()
320+
321+ builder .get_object ("paned1" ).set_position (- 1 )
322+ self .revealer .set_reveal_child (not self .revealer .get_reveal_child ())
323+
324+ if not rev :
325+ pass
326+
327+ def set_value (self ,* args ):
328+ self .tree .set_value (* args )
329+
330+ def delete (self , obj ):
331+ self .tree .remove (obj .trlst )
332+
260333 def showcfgwindow (self , * args ):
261334 global configWindow
262335 try :
@@ -378,6 +451,7 @@ def load(*args):
378451 def new (* args ):
379452 global allobjects
380453 global cables
454+ save .last = 0
381455 while len (allobjects ) > 0 :
382456 allobjects [0 ].delete (pr = 0 )
383457 while len (cables ) > 0 :
@@ -609,6 +683,7 @@ def __str__(self):
609683#De la que heredaran las demas funciones
610684cnt_objects = 1
611685cnt_rows = 2
686+ objlst = MainClase .ObjLst ()
612687
613688import uuid
614689
@@ -671,13 +746,8 @@ def __init__(self, x, y, objtype, *args, name="Default", maxconnections=4, ip=No
671746
672747 #Ahora vamos con lo de aparecer en la lista de la izquierda,
673748 #aunque en realidad es un grid
674- lista = builder .get_object ("grid2" )
675- lista .insert_row (cnt_rows )
676- self .label = Gtk .Label .new (self .name )
677- lista .attach (self .label , 0 , cnt_rows , 1 , 1 )
678- cnt_rows += 1
679- #lprint(cnt_rows)
680- self .label .show ()
749+ lista = objlst
750+ self .trlst = lista .append (self )
681751 self .image .set_tooltip_text (self .name + " (" + str (len (self .connections )) + "/" + str (self .max_connections ) + ")\n " + self .ipstr )
682752
683753 self .window_changethings = w_changethings (self )
@@ -851,7 +921,9 @@ def update(self):
851921 print ("\033 [95m>>Updating\033 [00m" , self )
852922 print (self .builder .get_object ("grid_rclick-disconnect" ))
853923 self .image .set_tooltip_text (self .name + " (" + str (len (self .connections )) + "/" + str (self .max_connections ) + ")" )
854- self .label .set_text (self .name )
924+ objlst .set_value (self .trlst , 0 , self .name )
925+
926+ objlst .update (self ,"MAC" , str (self .macdir ))
855927 for child in self .builder .get_object ("grid_rclick-disconnect" ).get_submenu ().get_children ():
856928 if child .props .label .upper () != "TODOS" :
857929 if child .link .uuid not in [x .uuid for x in self .connections ]:
@@ -861,15 +933,17 @@ def update(self):
861933 else :
862934 print ("Object" , child .link .__repr__ (), "in self.connections" , self .connections )
863935 pass
936+
937+ objlst .upcon (self )
938+
864939 print ("\033 [95m<<\033 [00m" )
865940
866941 def connect (self , objeto , cable ):
867- #Permutado objeto y self para ver que tal va
868942 tmp = Gtk .MenuItem .new_with_label (objeto .name )
869943 self .builder .get_object ("grid_rclick-disconnect" ).get_submenu ().append (tmp )
870944 tmp .show ()
871945 tmp .connect ("activate" , self .disconnect )
872- #link es un objeto vinculado al widget
946+ #link es un objeto vinculado al widget, luego es útil.
873947 tmp .link = objeto
874948 tmp2 = Gtk .MenuItem .new_with_label (objeto .name )
875949 self .builder .get_object ("grid_rclick-sendpkg" ).get_submenu ().append (tmp2 )
@@ -892,9 +966,11 @@ def connect(self, objeto, cable):
892966
893967 self .connections .append (objeto )
894968 self .cables .append (cable )
969+ #objlst.tree.append(self.trdic["Connections"], row=[objeto.name, objeto.objectype])
895970
896971 objeto .connections .append (self )
897972 objeto .cables .append (cable )
973+ #objlst.tree.append(objeto.trdic["Connections"], row=[self.name, self.objectype])
898974
899975 self .update ()
900976 objeto .update ()
@@ -925,8 +1001,11 @@ def disconnect(self, widget, *args, de=None):
9251001 self .disconnect (widget , de = self .connections [0 ])
9261002
9271003 else :
928- print (self .connections )
929- 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+
9301009 de .connections .remove (self )
9311010 self .connections .remove (de )
9321011
@@ -960,7 +1039,7 @@ def delete(self, *widget, conf=1, pr=1):
9601039 yonR = 1
9611040 if yonR == 1 :
9621041 self .disconnect (0 , de = "All" )
963- self . label . destroy ( )
1042+ objlst . delete ( self )
9641043 self .image .destroy ()
9651044 global allobjects
9661045 allobjects .remove (self )
@@ -1062,7 +1141,7 @@ def append(self, lst):
10621141 print (lst )
10631142 row = self .store .append (lst )
10641143 print (self .view .get_property ("visible" ))
1065- if self .view .get_property ("visible" ) == True and self . ticking == False :
1144+ if self .view .get_property ("visible" ) == True :
10661145 self .ticking = True
10671146 GObject .timeout_add (1001 , self .tick )
10681147
@@ -1083,8 +1162,8 @@ def remove(self, lst):
10831162 if row == lst :
10841163 self .store .remove (row .iter )
10851164 self .link .table
1165+ break
10861166 pass
1087- #Get children, if children.get_label() == MAC, delete it.
10881167
10891168 def __init__ (self , x , y , * args , name = "Default" , maxconnections = 5 ):
10901169 self .objectype = "Switch"
@@ -1263,8 +1342,8 @@ def __init__(self, x, y, *args, name="Default", maxconnections=1, ip=None):
12631342 self .x = x
12641343 self .y = y
12651344 self .max_connections = maxconnections
1266- #self.IP = self.ip()
12671345 self .IP = None
1346+ self .update ()
12681347
12691348 class ip ():
12701349 def __init__ (self , * args , ipstr = "None" ):
@@ -1323,7 +1402,6 @@ def parser(self, ip2p, mode):
13231402 def update (self ):
13241403 ObjetoBase .update (self )
13251404 self .image .set_tooltip_text (self .name + " (" + str (len (self .connections )) + "/" + str (self .max_connections ) + ")\n " + str (self .IP ))
1326- self .label .set_text (self .name )
13271405 submenu1 = self .builder .get_object ("grid_rclick-sendpkg" ).get_submenu ()
13281406 print ("Compcon: " , [x .name for x in self .compcon ()])
13291407
@@ -1345,6 +1423,9 @@ def update(self):
13451423
13461424 print ("self.connections" , self .connections )
13471425
1426+ if self .IP != None :
1427+ objlst .update (self ,"IP" , str (self .IP ))
1428+
13481429 #Ahora es cuando viene la parte de haber estudiado.
13491430 #SÓLO ENVÍA PINGS, (ICMP)
13501431 sub_N = 0
0 commit comments