Espionage: add icons to th right genlist
Icons are just placeholder, I surly need better icons
This commit is contained in:
parent
49faa4d423
commit
04c9800df0
|
@ -18,6 +18,7 @@
|
|||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Espionage. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import dbus
|
||||
import json
|
||||
|
@ -33,6 +34,7 @@ from efl.elementary.entry import Entry, \
|
|||
Entry_markup_to_utf8 as markup_to_utf8, \
|
||||
Entry_utf8_to_markup as utf8_to_markup
|
||||
from efl.elementary.flipselector import FlipSelector
|
||||
from efl.elementary.icon import Icon
|
||||
from efl.elementary.label import Label
|
||||
from efl.elementary.panes import Panes
|
||||
from efl.elementary.progressbar import Progressbar
|
||||
|
@ -53,6 +55,7 @@ class Options(object):
|
|||
self.show_private_stuff = False
|
||||
self.pretty_output = True
|
||||
self.scroll_on_signal = True
|
||||
self.theme_name = 'default'
|
||||
|
||||
self.stl_name = "font_weight=Bold color=#FFF font_size=11"
|
||||
self.stl_value = "color=#FF99FF"
|
||||
|
@ -63,6 +66,11 @@ class Options(object):
|
|||
self.stl_pname = "color=#AAFFAA"
|
||||
|
||||
|
||||
script_path = os.path.dirname(__file__)
|
||||
|
||||
def theme_resource_get(fname):
|
||||
return os.path.join(script_path, 'themes', options.theme_name, fname)
|
||||
|
||||
def prettify_if_needed(data):
|
||||
if options.pretty_output:
|
||||
return utf8_to_markup(json.dumps(data, indent=2))
|
||||
|
@ -78,6 +86,7 @@ def colored_params(plist, omit_braces=False):
|
|||
return '<font %s>(</>%s<font %s>)</>' % \
|
||||
(options.stl_brackets, p, options.stl_brackets)
|
||||
|
||||
|
||||
### connect to session and system buses, and set session as the current one
|
||||
session_bus = dbus.SessionBus(mainloop=DBusEcoreMainLoop())
|
||||
system_bus = dbus.SystemBus(mainloop=DBusEcoreMainLoop())
|
||||
|
@ -111,6 +120,9 @@ class DBusObject(DBusNode):
|
|||
def interfaces(self):
|
||||
return self._interfaces
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return 'object.png'
|
||||
|
||||
class DBusInterface(DBusNode):
|
||||
"""object to represent a DBus Interface"""
|
||||
|
@ -134,6 +146,9 @@ class DBusInterface(DBusNode):
|
|||
def signals(self):
|
||||
return self._signals
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return 'interface.png'
|
||||
|
||||
class DBusProperty(DBusNode):
|
||||
"""object to represent a DBus Property"""
|
||||
|
@ -165,6 +180,9 @@ class DBusProperty(DBusNode):
|
|||
def access(self):
|
||||
return self._access
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return 'property.png'
|
||||
|
||||
class DBusMethod(DBusNode):
|
||||
"""object to represent a DBus Method"""
|
||||
|
@ -190,6 +208,9 @@ class DBusMethod(DBusNode):
|
|||
def returns_str(self):
|
||||
return ', '.join([(ty+' '+name).strip() for name, ty in self._returns])
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return 'method.png'
|
||||
|
||||
class DBusSignal(DBusNode):
|
||||
"""object to represent a DBus Signal"""
|
||||
|
@ -206,6 +227,9 @@ class DBusSignal(DBusNode):
|
|||
def params_str(self):
|
||||
return ', '.join([(ty+' '+name).strip() for name, ty in self._params])
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return 'signal.png'
|
||||
|
||||
### Introspect a named service and return a list of DBusObjects
|
||||
def recursive_introspect(bus, named_service, object_path, ret_data=None):
|
||||
|
@ -407,39 +431,44 @@ class ObjectItemClass(GenlistItemClass):
|
|||
def __init__(self):
|
||||
GenlistItemClass.__init__(self, item_style="group_index")
|
||||
def text_get(self, gl, part, obj):
|
||||
return '[OBJ] ' + obj.name
|
||||
return obj.name
|
||||
def content_get(self, gl, part, obj):
|
||||
if part == 'elm.swallow.icon':
|
||||
return Icon(gl, file=theme_resource_get(obj.icon))
|
||||
|
||||
class NodeItemClass(GenlistItemClass):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
GenlistItemClass.__init__(self, item_style="default_style")
|
||||
|
||||
def text_get(self, gl, part, obj):
|
||||
if isinstance(obj, DBusInterface):
|
||||
return '<font %s>[IFACE] %s</>' % (options.stl_iface, obj.name)
|
||||
return '<font %s>%s</>' % (options.stl_iface, obj.name)
|
||||
if isinstance(obj, DBusProperty):
|
||||
if obj.value is not None:
|
||||
return '<font %s>[PROP] %s</> <font %s>%s</> %s <font %s>→</> <font %s>%s</>' % \
|
||||
return '<font %s>%s</> <font %s>%s</> %s <font %s>→</> <font %s>%s</>' % \
|
||||
(options.stl_name, obj.name, options.stl_ptype, obj.type,
|
||||
obj.access, options.stl_arrow, options.stl_value, str(obj.value))
|
||||
|
||||
else:
|
||||
return '<font %s>[PROP] %s</> <font %s>%s</> %s <font %s>→</>' % \
|
||||
return '<font %s>%s</> <font %s>%s</> %s <font %s>→</>' % \
|
||||
(options.stl_name, obj.name, options.stl_ptype, obj.type,
|
||||
obj.access, options.stl_arrow)
|
||||
if isinstance(obj, DBusMethod):
|
||||
params = colored_params(obj.params)
|
||||
if obj.returns:
|
||||
rets = colored_params(obj.returns)
|
||||
return '<font %s>[METH] %s</> %s <font %s>→</> %s' % \
|
||||
return '<font %s>%s</> %s <font %s>→</> %s' % \
|
||||
(options.stl_name, obj.name, params, options.stl_arrow, rets)
|
||||
else:
|
||||
return '<font %s>[METH] %s</> %s' % (options.stl_name, obj.name, params)
|
||||
return '<font %s>%s</> %s' % (options.stl_name, obj.name, params)
|
||||
if isinstance(obj, DBusSignal):
|
||||
params = colored_params(obj.params)
|
||||
return '<font %s>[SIGN] %s</> %s' % (options.stl_name, obj.name, params)
|
||||
return '<font %s>%s</> %s' % (options.stl_name, obj.name, params)
|
||||
|
||||
def content_get(self, gl, part, obj):
|
||||
if part == 'elm.swallow.icon':
|
||||
return Icon(gl, file=theme_resource_get(obj.icon))
|
||||
|
||||
class DetailList(Genlist):
|
||||
def __init__(self, parent):
|
||||
Genlist.__init__(self, parent)
|
||||
|
@ -552,7 +581,7 @@ class MethodRunner(StandardWindow):
|
|||
self._param_entry = en
|
||||
vbox.pack_end(en)
|
||||
en.show()
|
||||
|
||||
|
||||
# returns label + entry
|
||||
label = Entry(self, editable=False)
|
||||
label.size_hint_weight = EVAS_HINT_EXPAND, 0.0
|
||||
|
@ -661,7 +690,10 @@ class SignalItemClass(GenlistItemClass):
|
|||
return '<font %s>%s</> <font %s>iface: %s</> <font %s>path: %s</> <font %s>sender: %s</>' % \
|
||||
(options.stl_name, data['signal'], options.stl_ptype, data['iface'],
|
||||
options.stl_pname, data['path'], options.stl_value, data['sender'])
|
||||
|
||||
def content_get(self, gl, part, data):
|
||||
if part == 'elm.swallow.icon':
|
||||
return Icon(gl, file=theme_resource_get('signal.png'))
|
||||
|
||||
class SignalReceiver(Frame):
|
||||
def __init__(self, parent):
|
||||
Frame.__init__(self, parent, text="Signals")
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in New Issue