summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-14 16:41:51 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-14 16:41:51 (GMT)
commit370169058fc6f4a7ed6013d0f965ac75beff4f5e (patch)
tree5df84ac93eaed31402f41f97e2ede3a81265efe7
parent0081d76ba15b08be04cd2a7c7c65a7c0e6e7a6fe (diff)
Created a demo GUI panel.
-rw-r--r--python-plugins/hellopanel/__init__.py2
-rw-r--r--python-plugins/hellopanel/core.py33
-rw-r--r--python-plugins/hellopanel/panel.py43
3 files changed, 78 insertions, 0 deletions
diff --git a/python-plugins/hellopanel/__init__.py b/python-plugins/hellopanel/__init__.py
new file mode 100644
index 0000000..6c4d22c
--- /dev/null
+++ b/python-plugins/hellopanel/__init__.py
@@ -0,0 +1,2 @@
+
+from hellopanel.core import HelloPlugin as AutoLoad
diff --git a/python-plugins/hellopanel/core.py b/python-plugins/hellopanel/core.py
new file mode 100644
index 0000000..42eb44d
--- /dev/null
+++ b/python-plugins/hellopanel/core.py
@@ -0,0 +1,33 @@
+
+from pychrysalide.features import *
+from .panel import HelloPanel
+
+
+class HelloPlugin(PluginModule):
+ """Simple demo plugin to build a GUI panel."""
+
+
+ def get_interface(self):
+ """Provide the full plugin description."""
+
+ desc = {
+
+ 'name' : 'HelloPanel',
+ 'desc' : 'Say hello in the main GUI',
+ 'version' : '0.1',
+
+ 'actions' : [ PluginModule.PGA_PLUGIN_INIT ]
+
+ }
+
+ return desc
+
+
+ def init(self):
+ """Initialize the plugin."""
+
+ p = HelloPanel()
+
+ register_panel(p);
+
+ return True
diff --git a/python-plugins/hellopanel/panel.py b/python-plugins/hellopanel/panel.py
new file mode 100644
index 0000000..a06a08d
--- /dev/null
+++ b/python-plugins/hellopanel/panel.py
@@ -0,0 +1,43 @@
+
+from gi.repository import Gtk
+from pychrysalide.features import *
+
+
+DEFAULT_MSG = 'No active loaded binary'
+
+
+class HelloPanel(PanelItem):
+
+ def __init__(self):
+ """Initialize the GUI panel."""
+
+ self._label = Gtk.Label()
+ self._label.set_text(DEFAULT_MSG)
+
+ params = {
+
+ 'name' : 'Hello',
+ 'widget' : self._label,
+
+ 'personality' : PanelItem.PIP_SINGLETON,
+ 'lname' : 'Hello panel description',
+ 'dock' : True,
+ 'path' : 'MEN'
+
+ }
+
+ super(HelloPanel, self).__init__(**params)
+
+
+ def _change_content(self, old, new):
+ """Get notified about loaded content change."""
+
+ if type(new) is LoadedBinary:
+
+ count = len(list(new.processor.instrs))
+
+ self._label.set_text('Loaded binary with %u instructions' % count)
+
+ else:
+
+ self._label.set_text(DEFAULT_MSG)