summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2013-12-20 20:28:51 +0100
committerdavemds <dave@gurumeditation.it>2013-12-20 20:30:25 +0100
commit04c9800df0c2250199967d1b6ff781525088a668 (patch)
treea17a39aaf36ac33abc33d24fdfc75199815d6ef3
parent49faa4d42352f2d58673a6ff6ff8a7c719be7936 (diff)
Espionage: add icons to th right genlist
Icons are just placeholder, I surly need better icons
-rw-r--r--espionage/espionage.py54
-rw-r--r--espionage/themes/default/interface.pngbin0 -> 4103 bytes
-rw-r--r--espionage/themes/default/method.pngbin0 -> 4340 bytes
-rw-r--r--espionage/themes/default/object.pngbin0 -> 2974 bytes
-rw-r--r--espionage/themes/default/property.pngbin0 -> 2236 bytes
-rw-r--r--espionage/themes/default/signal.pngbin0 -> 4526 bytes
-rwxr-xr-xsetup.py3
7 files changed, 46 insertions, 11 deletions
diff --git a/espionage/espionage.py b/espionage/espionage.py
index 0f663d9..4afc3fb 100644
--- a/espionage/espionage.py
+++ b/espionage/espionage.py
@@ -18,6 +18,7 @@
18# You should have received a copy of the GNU Lesser General Public License 18# You should have received a copy of the GNU Lesser General Public License
19# along with Espionage. If not, see <http://www.gnu.org/licenses/>. 19# along with Espionage. If not, see <http://www.gnu.org/licenses/>.
20 20
21import os
21import sys 22import sys
22import dbus 23import dbus
23import json 24import json
@@ -33,6 +34,7 @@ from efl.elementary.entry import Entry, \
33 Entry_markup_to_utf8 as markup_to_utf8, \ 34 Entry_markup_to_utf8 as markup_to_utf8, \
34 Entry_utf8_to_markup as utf8_to_markup 35 Entry_utf8_to_markup as utf8_to_markup
35from efl.elementary.flipselector import FlipSelector 36from efl.elementary.flipselector import FlipSelector
37from efl.elementary.icon import Icon
36from efl.elementary.label import Label 38from efl.elementary.label import Label
37from efl.elementary.panes import Panes 39from efl.elementary.panes import Panes
38from efl.elementary.progressbar import Progressbar 40from efl.elementary.progressbar import Progressbar
@@ -53,6 +55,7 @@ class Options(object):
53 self.show_private_stuff = False 55 self.show_private_stuff = False
54 self.pretty_output = True 56 self.pretty_output = True
55 self.scroll_on_signal = True 57 self.scroll_on_signal = True
58 self.theme_name = 'default'
56 59
57 self.stl_name = "font_weight=Bold color=#FFF font_size=11" 60 self.stl_name = "font_weight=Bold color=#FFF font_size=11"
58 self.stl_value = "color=#FF99FF" 61 self.stl_value = "color=#FF99FF"
@@ -63,6 +66,11 @@ class Options(object):
63 self.stl_pname = "color=#AAFFAA" 66 self.stl_pname = "color=#AAFFAA"
64 67
65 68
69script_path = os.path.dirname(__file__)
70
71def theme_resource_get(fname):
72 return os.path.join(script_path, 'themes', options.theme_name, fname)
73
66def prettify_if_needed(data): 74def prettify_if_needed(data):
67 if options.pretty_output: 75 if options.pretty_output:
68 return utf8_to_markup(json.dumps(data, indent=2)) 76 return utf8_to_markup(json.dumps(data, indent=2))
@@ -78,6 +86,7 @@ def colored_params(plist, omit_braces=False):
78 return '<font %s>(</>%s<font %s>)</>' % \ 86 return '<font %s>(</>%s<font %s>)</>' % \
79 (options.stl_brackets, p, options.stl_brackets) 87 (options.stl_brackets, p, options.stl_brackets)
80 88
89
81### connect to session and system buses, and set session as the current one 90### connect to session and system buses, and set session as the current one
82session_bus = dbus.SessionBus(mainloop=DBusEcoreMainLoop()) 91session_bus = dbus.SessionBus(mainloop=DBusEcoreMainLoop())
83system_bus = dbus.SystemBus(mainloop=DBusEcoreMainLoop()) 92system_bus = dbus.SystemBus(mainloop=DBusEcoreMainLoop())
@@ -111,6 +120,9 @@ class DBusObject(DBusNode):
111 def interfaces(self): 120 def interfaces(self):
112 return self._interfaces 121 return self._interfaces
113 122
123 @property
124 def icon(self):
125 return 'object.png'
114 126
115class DBusInterface(DBusNode): 127class DBusInterface(DBusNode):
116 """object to represent a DBus Interface""" 128 """object to represent a DBus Interface"""
@@ -134,6 +146,9 @@ class DBusInterface(DBusNode):
134 def signals(self): 146 def signals(self):
135 return self._signals 147 return self._signals
136 148
149 @property
150 def icon(self):
151 return 'interface.png'
137 152
138class DBusProperty(DBusNode): 153class DBusProperty(DBusNode):
139 """object to represent a DBus Property""" 154 """object to represent a DBus Property"""
@@ -165,6 +180,9 @@ class DBusProperty(DBusNode):
165 def access(self): 180 def access(self):
166 return self._access 181 return self._access
167 182
183 @property
184 def icon(self):
185 return 'property.png'
168 186
169class DBusMethod(DBusNode): 187class DBusMethod(DBusNode):
170 """object to represent a DBus Method""" 188 """object to represent a DBus Method"""
@@ -190,6 +208,9 @@ class DBusMethod(DBusNode):
190 def returns_str(self): 208 def returns_str(self):
191 return ', '.join([(ty+' '+name).strip() for name, ty in self._returns]) 209 return ', '.join([(ty+' '+name).strip() for name, ty in self._returns])
192 210
211 @property
212 def icon(self):
213 return 'method.png'
193 214
194class DBusSignal(DBusNode): 215class DBusSignal(DBusNode):
195 """object to represent a DBus Signal""" 216 """object to represent a DBus Signal"""
@@ -206,6 +227,9 @@ class DBusSignal(DBusNode):
206 def params_str(self): 227 def params_str(self):
207 return ', '.join([(ty+' '+name).strip() for name, ty in self._params]) 228 return ', '.join([(ty+' '+name).strip() for name, ty in self._params])
208 229
230 @property
231 def icon(self):
232 return 'signal.png'
209 233
210### Introspect a named service and return a list of DBusObjects 234### Introspect a named service and return a list of DBusObjects
211def recursive_introspect(bus, named_service, object_path, ret_data=None): 235def recursive_introspect(bus, named_service, object_path, ret_data=None):
@@ -407,39 +431,44 @@ class ObjectItemClass(GenlistItemClass):
407 def __init__(self): 431 def __init__(self):
408 GenlistItemClass.__init__(self, item_style="group_index") 432 GenlistItemClass.__init__(self, item_style="group_index")
409 def text_get(self, gl, part, obj): 433 def text_get(self, gl, part, obj):
410 return '[OBJ] ' + obj.name 434 return obj.name
435 def content_get(self, gl, part, obj):
436 if part == 'elm.swallow.icon':
437 return Icon(gl, file=theme_resource_get(obj.icon))
411 438
412class NodeItemClass(GenlistItemClass): 439class NodeItemClass(GenlistItemClass):
413 440
414
415 def __init__(self): 441 def __init__(self):
416 GenlistItemClass.__init__(self, item_style="default_style") 442 GenlistItemClass.__init__(self, item_style="default_style")
417 443
418 def text_get(self, gl, part, obj): 444 def text_get(self, gl, part, obj):
419 if isinstance(obj, DBusInterface): 445 if isinstance(obj, DBusInterface):
420 return '<font %s>[IFACE] %s</>' % (options.stl_iface, obj.name) 446 return '<font %s>%s</>' % (options.stl_iface, obj.name)
421 if isinstance(obj, DBusProperty): 447 if isinstance(obj, DBusProperty):
422 if obj.value is not None: 448 if obj.value is not None:
423 return '<font %s>[PROP] %s</> <font %s>%s</> %s <font %s>→</> <font %s>%s</>' % \ 449 return '<font %s>%s</> <font %s>%s</> %s <font %s>→</> <font %s>%s</>' % \
424 (options.stl_name, obj.name, options.stl_ptype, obj.type, 450 (options.stl_name, obj.name, options.stl_ptype, obj.type,
425 obj.access, options.stl_arrow, options.stl_value, str(obj.value)) 451 obj.access, options.stl_arrow, options.stl_value, str(obj.value))
426
427 else: 452 else:
428 return '<font %s>[PROP] %s</> <font %s>%s</> %s <font %s>→</>' % \ 453 return '<font %s>%s</> <font %s>%s</> %s <font %s>→</>' % \
429 (options.stl_name, obj.name, options.stl_ptype, obj.type, 454 (options.stl_name, obj.name, options.stl_ptype, obj.type,
430 obj.access, options.stl_arrow) 455 obj.access, options.stl_arrow)
431 if isinstance(obj, DBusMethod): 456 if isinstance(obj, DBusMethod):
432 params = colored_params(obj.params) 457 params = colored_params(obj.params)
433 if obj.returns: 458 if obj.returns:
434 rets = colored_params(obj.returns) 459 rets = colored_params(obj.returns)
435 return '<font %s>[METH] %s</> %s <font %s>→</> %s' % \ 460 return '<font %s>%s</> %s <font %s>→</> %s' % \
436 (options.stl_name, obj.name, params, options.stl_arrow, rets) 461 (options.stl_name, obj.name, params, options.stl_arrow, rets)
437 else: 462 else:
438 return '<font %s>[METH] %s</> %s' % (options.stl_name, obj.name, params) 463 return '<font %s>%s</> %s' % (options.stl_name, obj.name, params)
439 if isinstance(obj, DBusSignal): 464 if isinstance(obj, DBusSignal):
440 params = colored_params(obj.params) 465 params = colored_params(obj.params)
441 return '<font %s>[SIGN] %s</> %s' % (options.stl_name, obj.name, params) 466 return '<font %s>%s</> %s' % (options.stl_name, obj.name, params)
442 467
468 def content_get(self, gl, part, obj):
469 if part == 'elm.swallow.icon':
470 return Icon(gl, file=theme_resource_get(obj.icon))
471
443class DetailList(Genlist): 472class DetailList(Genlist):
444 def __init__(self, parent): 473 def __init__(self, parent):
445 Genlist.__init__(self, parent) 474 Genlist.__init__(self, parent)
@@ -552,7 +581,7 @@ class MethodRunner(StandardWindow):
552 self._param_entry = en 581 self._param_entry = en
553 vbox.pack_end(en) 582 vbox.pack_end(en)
554 en.show() 583 en.show()
555 584
556 # returns label + entry 585 # returns label + entry
557 label = Entry(self, editable=False) 586 label = Entry(self, editable=False)
558 label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 587 label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
@@ -661,7 +690,10 @@ class SignalItemClass(GenlistItemClass):
661 return '<font %s>%s</> <font %s>iface: %s</> <font %s>path: %s</> <font %s>sender: %s</>' % \ 690 return '<font %s>%s</> <font %s>iface: %s</> <font %s>path: %s</> <font %s>sender: %s</>' % \
662 (options.stl_name, data['signal'], options.stl_ptype, data['iface'], 691 (options.stl_name, data['signal'], options.stl_ptype, data['iface'],
663 options.stl_pname, data['path'], options.stl_value, data['sender']) 692 options.stl_pname, data['path'], options.stl_value, data['sender'])
664 693 def content_get(self, gl, part, data):
694 if part == 'elm.swallow.icon':
695 return Icon(gl, file=theme_resource_get('signal.png'))
696
665class SignalReceiver(Frame): 697class SignalReceiver(Frame):
666 def __init__(self, parent): 698 def __init__(self, parent):
667 Frame.__init__(self, parent, text="Signals") 699 Frame.__init__(self, parent, text="Signals")
diff --git a/espionage/themes/default/interface.png b/espionage/themes/default/interface.png
new file mode 100644
index 0000000..073f43b
--- /dev/null
+++ b/espionage/themes/default/interface.png
Binary files differ
diff --git a/espionage/themes/default/method.png b/espionage/themes/default/method.png
new file mode 100644
index 0000000..226bb9a
--- /dev/null
+++ b/espionage/themes/default/method.png
Binary files differ
diff --git a/espionage/themes/default/object.png b/espionage/themes/default/object.png
new file mode 100644
index 0000000..083c23b
--- /dev/null
+++ b/espionage/themes/default/object.png
Binary files differ
diff --git a/espionage/themes/default/property.png b/espionage/themes/default/property.png
new file mode 100644
index 0000000..4f900ce
--- /dev/null
+++ b/espionage/themes/default/property.png
Binary files differ
diff --git a/espionage/themes/default/signal.png b/espionage/themes/default/signal.png
new file mode 100644
index 0000000..7522bfe
--- /dev/null
+++ b/espionage/themes/default/signal.png
Binary files differ
diff --git a/setup.py b/setup.py
index 0e8e0cd..89ff188 100755
--- a/setup.py
+++ b/setup.py
@@ -14,6 +14,9 @@ setup(
14 packages = ['espionage'], 14 packages = ['espionage'],
15 requires = ['efl', 'dbus', 'json', 'xml.etree'], 15 requires = ['efl', 'dbus', 'json', 'xml.etree'],
16 provides = ['espionage'], 16 provides = ['espionage'],
17 package_data = {
18 'espionage': ['themes/*/*'],
19 },
17 data_files = [ 20 data_files = [
18 ('bin', ['bin/espionage']), 21 ('bin', ['bin/espionage']),
19 ('share/applications', ['data/espionage.desktop']), 22 ('share/applications', ['data/espionage.desktop']),