Skip to content

Instantly share code, notes, and snippets.

@ryanbugden
Last active January 15, 2024 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbugden/2279e5378fa9a73245af30dfbae2904a to your computer and use it in GitHub Desktop.
Save ryanbugden/2279e5378fa9a73245af30dfbae2904a to your computer and use it in GitHub Desktop.
Selectively load individual extensions from the comfort of Safe Mode. (Requires 5.2b 2401121414)
# menuTitle: Cherry Picker
import ezui
from mojo.extensions import ExtensionBundle
from AppKit import NSApp
def safe_mode_state():
obj = NSApp().mainMenu().itemWithTitle_("Safe Mode...")
if obj:
return "🔴"
return "🟢"
class CherryPicker(ezui.WindowController):
def build(self):
mark = safe_mode_state()
self.statuses_and_names = [dict(status=mark, name=ext.split(".")[0]) for ext in ExtensionBundle.allExtensions()]
content = """
|-----------| @table
| One | Two |
|-----------|
| |
|-----------|
(Load) @loadButton
"""
status_width = 38
window_width = 270
descriptionData = dict(
table=dict(
columnDescriptions=[
dict(
identifier="status",
title="Status",
width=status_width,
minWidth=status_width,
maxWidth=status_width,
),
dict(
identifier="name",
title="Name",
minWidth=200,
)
],
items=self.statuses_and_names
),
loadButton=dict(
width="fill",
),
)
self.w = ezui.EZPanel(
content=content,
title="Cherry Picker",
descriptionData=descriptionData,
controller=self,
size=(window_width, 450),
minSize=(window_width, 200),
maxSize=(window_width, 800)
)
self.loaded = []
self.table = self.w.getItem("table")
self.w.getNSWindow().setTitlebarAppearsTransparent_(True)
def started(self):
self.w.open()
def loadButtonCallback(self, sender):
for i in self.table.getSelectedIndexes():
self.statuses_and_names[i]['status'] = "🟢"
ext_name = self.statuses_and_names[i]['name']
bundle = ExtensionBundle(ext_name)
bundle.loadBundle()
self.loaded.append(ext_name)
self.table.set(self.statuses_and_names)
CherryPicker()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment