summaryrefslogtreecommitdiff
path: root/plugins/python/liveconv/panel.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/python/liveconv/panel.py')
-rw-r--r--plugins/python/liveconv/panel.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/plugins/python/liveconv/panel.py b/plugins/python/liveconv/panel.py
new file mode 100644
index 0000000..614940f
--- /dev/null
+++ b/plugins/python/liveconv/panel.py
@@ -0,0 +1,80 @@
+
+import os
+from gi.repository import Gtk
+from pychrysalide.analysis import LoadedBinary
+from pychrysalide.gui import core
+from pychrysalide.gui import PanelItem
+
+from .converters import *
+
+
+class ConvPanel(PanelItem):
+
+ def __init__(self):
+ """Initialize the GUI panel."""
+
+ directory = os.path.dirname(os.path.realpath(__file__))
+
+ self._builder = Gtk.Builder()
+ self._builder.add_from_file(os.path.join(directory, 'panel.ui'))
+
+ params = {
+
+ 'name' : 'Converter',
+ 'widget' : self._builder.get_object('content'),
+
+ 'personality' : PanelItem.PIP_SINGLETON,
+ 'lname' : 'Data live converter',
+ 'dock' : True,
+ 'path' : 'MES'
+
+ }
+
+ super(ConvPanel, self).__init__(**params)
+
+ self._conversions = {
+
+ 'int8': lambda c, a, o: data_to_number(c, a, o, 'b'),
+ 'uint8': lambda c, a, o: data_to_number(c, a, o, 'B'),
+ 'int16': lambda c, a, o: data_to_number(c, a, o, 'h'),
+ 'uint16': lambda c, a, o: data_to_number(c, a, o, 'H'),
+ 'int32': lambda c, a, o: data_to_number(c, a, o, 'l'),
+ 'uint32': lambda c, a, o: data_to_number(c, a, o, 'L'),
+ 'int64': lambda c, a, o: data_to_number(c, a, o, 'q'),
+ 'uint64': lambda c, a, o: data_to_number(c, a, o, 'Q'),
+ 'half_float': lambda c, a, o: data_to_number(c, a, o, 'e'),
+ 'float': lambda c, a, o: data_to_number(c, a, o, 'f'),
+ 'double': lambda c, a, o: data_to_number(c, a, o, 'd'),
+
+ 'time': lambda c, a, o: data_to_time(c, a, o, 'L'),
+ 'time64': lambda c, a, o: data_to_time(c, a, o, 'Q'),
+ 'filetime': data_to_filetime,
+ 'dostime': data_to_dos_time,
+ 'dosdate': data_to_dos_date,
+
+ 'char': data_to_char,
+ 'ansi': data_to_ansi,
+ 'utf8': data_to_utf8,
+ 'utf16': data_to_utf16,
+
+ }
+
+ self._order = '@'
+
+
+ def _track_cursor(self, source, cursor):
+ """Track moves from the current cursor."""
+
+ loaded = core.get_current_content()
+ assert(loaded)
+
+ for kind, func in self._conversions.items():
+
+ label = self._builder.get_object('%s_value' % kind)
+
+ try:
+ addr = cursor.retrieve()
+ label.set_text(func(loaded.content, addr, self._order))
+
+ except Exception as e:
+ label.set_text('-')