summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2021-04-26 07:46:50 +0200
committerDave Andreoli <dave@gurumeditation.it>2021-04-26 07:46:50 +0200
commitdda3a3564f5b2973231e2928310e65b4a3e54582 (patch)
tree6b33d6a48866274510f5d4ffad9be40f32e96981
parenta618cb4cf36e2e7a6d0828acad53dd9c676901a9 (diff)
Small optimizations
-rw-r--r--espionage/espionage.py48
1 files changed, 30 insertions, 18 deletions
diff --git a/espionage/espionage.py b/espionage/espionage.py
index 4504091..f42b050 100644
--- a/espionage/espionage.py
+++ b/espionage/espionage.py
@@ -280,7 +280,7 @@ def recursive_introspect(bus, named_service, object_path, ret_data=None):
280 if child.tag == 'property': 280 if child.tag == 'property':
281 typ = child.attrib['type'] 281 typ = child.attrib['type']
282 access = child.attrib['access'] 282 access = child.attrib['access']
283 prop = DBusProperty(child.attrib['name'], iface, typ, access) 283 DBusProperty(child.attrib['name'], iface, typ, access)
284 284
285 if child.tag == 'method': 285 if child.tag == 'method':
286 meth = DBusMethod(child.attrib['name'], iface) 286 meth = DBusMethod(child.attrib['name'], iface)
@@ -317,7 +317,8 @@ class NamesListGroupItemClass(GenlistItemClass):
317 def __init__(self): 317 def __init__(self):
318 GenlistItemClass.__init__(self, item_style='group_index') 318 GenlistItemClass.__init__(self, item_style='group_index')
319 319
320 def text_get(self, gl, part, name): 320 @staticmethod
321 def text_get(gl, part, name):
321 return name 322 return name
322 323
323 324
@@ -325,7 +326,8 @@ class NamesListItemClass(GenlistItemClass):
325 def __init__(self): 326 def __init__(self):
326 GenlistItemClass.__init__(self, item_style='default') 327 GenlistItemClass.__init__(self, item_style='default')
327 328
328 def text_get(self, gl, part, name): 329 @staticmethod
330 def text_get(gl, part, name):
329 return name 331 return name
330 332
331 333
@@ -409,7 +411,8 @@ class NamesList(Genlist):
409 else: 411 else:
410 self.win.detail_list.populate(name) 412 self.win.detail_list.populate(name)
411 413
412 def sort_cb(self, it1, it2): 414 @staticmethod
415 def sort_cb(it1, it2):
413 return 1 if it1.data.lower() < it2.data.lower() else -1 416 return 1 if it1.data.lower() < it2.data.lower() else -1
414 417
415 def service_activatable_add(self, name): 418 def service_activatable_add(self, name):
@@ -451,10 +454,12 @@ class ObjectItemClass(GenlistItemClass):
451 def __init__(self): 454 def __init__(self):
452 GenlistItemClass.__init__(self, item_style='group_index') 455 GenlistItemClass.__init__(self, item_style='group_index')
453 456
454 def text_get(self, gl, part, obj): 457 @staticmethod
458 def text_get(gl, part, obj):
455 return obj.name 459 return obj.name
456 460
457 def content_get(self, gl, part, obj): 461 @staticmethod
462 def content_get(gl, part, obj):
458 if part == 'elm.swallow.icon': 463 if part == 'elm.swallow.icon':
459 return Icon(gl, size_hint_min=(22, 22), 464 return Icon(gl, size_hint_min=(22, 22),
460 file=theme_resource_get(obj.icon)) 465 file=theme_resource_get(obj.icon))
@@ -464,7 +469,8 @@ class NodeItemClass(GenlistItemClass):
464 def __init__(self): 469 def __init__(self):
465 GenlistItemClass.__init__(self, item_style='default_style') 470 GenlistItemClass.__init__(self, item_style='default_style')
466 471
467 def text_get(self, gl, part, obj): 472 @staticmethod
473 def text_get(gl, part, obj):
468 if isinstance(obj, DBusInterface): 474 if isinstance(obj, DBusInterface):
469 return '<font %s>%s</>' % (options.stl_iface, obj.name) 475 return '<font %s>%s</>' % (options.stl_iface, obj.name)
470 if isinstance(obj, DBusProperty): 476 if isinstance(obj, DBusProperty):
@@ -488,7 +494,8 @@ class NodeItemClass(GenlistItemClass):
488 params = colored_params(obj.params) 494 params = colored_params(obj.params)
489 return '<font %s>%s</> %s' % (options.stl_name, obj.name, params) 495 return '<font %s>%s</> %s' % (options.stl_name, obj.name, params)
490 496
491 def content_get(self, gl, part, obj): 497 @staticmethod
498 def content_get(gl, part, obj):
492 if part == 'elm.swallow.icon': 499 if part == 'elm.swallow.icon':
493 return Icon(gl, file=theme_resource_get(obj.icon)) 500 return Icon(gl, file=theme_resource_get(obj.icon))
494 501
@@ -521,11 +528,11 @@ class DetailList(Genlist):
521 if not options.show_introspect_stuff and \ 528 if not options.show_introspect_stuff and \
522 iface.name.startswith('org.freedesktop.DBus'): 529 iface.name.startswith('org.freedesktop.DBus'):
523 continue 530 continue
524 iface_item = self.item_append(self.itc, iface, 531 self.item_append(self.itc, iface, parent_item=obj_item,
525 parent_item=obj_item, 532 flags=ELM_GENLIST_ITEM_TREE)
526 flags=ELM_GENLIST_ITEM_TREE)
527 533
528 def sort_cb(self, it1, it2): 534 @staticmethod
535 def sort_cb(it1, it2):
529 pri1 = pri2 = 0 536 pri1 = pri2 = 0
530 if isinstance(it1.data, DBusProperty): 537 if isinstance(it1.data, DBusProperty):
531 pri1 = 3 538 pri1 = 3
@@ -545,7 +552,8 @@ class DetailList(Genlist):
545 return -1 552 return -1
546 return 1 if it1.data.name.lower() < it2.data.name.lower() else -1 553 return 1 if it1.data.name.lower() < it2.data.name.lower() else -1
547 554
548 def expand_request_cb(self, genlist, item): 555 @staticmethod
556 def expand_request_cb(genlist, item):
549 item.expanded = True 557 item.expanded = True
550 558
551 def expanded_cb(self, genlist, item): 559 def expanded_cb(self, genlist, item):
@@ -553,10 +561,12 @@ class DetailList(Genlist):
553 for obj in iface.properties + iface.methods + iface.signals: 561 for obj in iface.properties + iface.methods + iface.signals:
554 self.item_sorted_insert(self.itc, obj, self.sort_cb, parent_item=item) 562 self.item_sorted_insert(self.itc, obj, self.sort_cb, parent_item=item)
555 563
556 def contract_request_cb(self, genlist, item): 564 @staticmethod
565 def contract_request_cb(genlist, item):
557 item.expanded = False 566 item.expanded = False
558 567
559 def contracted_cb(self, genlist, item): 568 @staticmethod
569 def contracted_cb(genlist, item):
560 item.subitems_clear() 570 item.subitems_clear()
561 571
562 def double_click_cb(self, genlist, item): 572 def double_click_cb(self, genlist, item):
@@ -726,12 +736,14 @@ class SignalItemClass(GenlistItemClass):
726 def __init__(self): 736 def __init__(self):
727 GenlistItemClass.__init__(self, item_style='default_style') 737 GenlistItemClass.__init__(self, item_style='default_style')
728 738
729 def text_get(self, gl, part, data): 739 @staticmethod
740 def text_get(gl, part, data):
730 return '<font %s>%s</> <font %s>iface: %s</> <font %s>path: %s</> <font %s>sender: %s</>' % \ 741 return '<font %s>%s</> <font %s>iface: %s</> <font %s>path: %s</> <font %s>sender: %s</>' % \
731 (options.stl_name, data['signal'], options.stl_ptype, data['iface'], 742 (options.stl_name, data['signal'], options.stl_ptype, data['iface'],
732 options.stl_pname, data['path'], options.stl_value, data['sender']) 743 options.stl_pname, data['path'], options.stl_value, data['sender'])
733 744
734 def content_get(self, gl, part, data): 745 @staticmethod
746 def content_get(gl, part, data):
735 if part == 'elm.swallow.icon': 747 if part == 'elm.swallow.icon':
736 return Icon(gl, file=theme_resource_get('signal.png')) 748 return Icon(gl, file=theme_resource_get('signal.png'))
737 749
@@ -926,7 +938,7 @@ class EspionageWin(StandardWindow):
926 938
927def main(): 939def main():
928 elm.init() 940 elm.init()
929 win = EspionageWin() 941 EspionageWin()
930 elm.run() 942 elm.run()
931 elm.shutdown() 943 elm.shutdown()
932 return 0 944 return 0