From 7d7e0fcd27812a42286ba736ed6d5217d87080a5 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Mon, 12 Feb 2024 14:54:00 -0500 Subject: Add new sidebar APIs to the sidebar example --- python/examples/hellosidebar.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'python/examples/hellosidebar.py') diff --git a/python/examples/hellosidebar.py b/python/examples/hellosidebar.py index 2fc0cbf7..5f798d09 100644 --- a/python/examples/hellosidebar.py +++ b/python/examples/hellosidebar.py @@ -21,7 +21,8 @@ # This is an example UI plugin which demonstrates how to add sidebar widgets to Binary Ninja. # See .../api/ui/sidebar.h for interface details. -from binaryninjaui import SidebarWidget, SidebarWidgetType, Sidebar, UIActionHandler +from binaryninjaui import SidebarWidget, SidebarWidgetType, Sidebar, UIActionHandler, SidebarWidgetLocation, \ + SidebarContextSensitivity from PySide6 import QtCore from PySide6.QtCore import Qt, QRectF from PySide6.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QLabel, QWidget @@ -104,6 +105,18 @@ class HelloSidebarWidgetType(SidebarWidgetType): # widget is visible and the BinaryView becomes active. return HelloSidebarWidget("Hello", frame, data) + def defaultLocation(self): + # Default location in the sidebar where this widget will appear + return SidebarWidgetLocation.RightContent + + def contextSensitivity(self): + # Context sensitivity controls which contexts have separate instances of the sidebar widget. + # Using `contextSensitivity` instead of the deprecated `viewSensitive` callback allows sidebar + # widget implementations to reduce resource usage. + + # This example widget uses a single instance and detects view changes. + return SidebarContextSensitivity.SelfManagedSidebarContext + # Register the sidebar widget type with Binary Ninja. This will make it appear as an icon in the # sidebar and the `createWidget` method will be called when a widget is required. -- cgit v1.3.1