roundabout,
created on Thursday, 14 August 2025, 15:28:53 (1755185333),
received on Friday, 15 August 2025, 03:56:06 (1755230166)
Author identity: Vlad <vlad.muntoiu@gmail.com>
b2a9638d270f57e262fe80b1c725c5ada9005c97
applets/app-menu/__init__.py
@@ -131,11 +131,14 @@ class AppMenu(panorama_panel.Applet):
if config is None:
config = {}
self.category_mappings = config.get("category_mappings", CATEGORY_MAPPINGS)
self.trigger_name = config.get("trigger_name", "app-menu")
self.button = Gtk.MenuButton()
self.button.set_has_frame(False) # flat look
self.icon = Gtk.Image.new_from_icon_name("start-here")
self.button.set_child(self.icon)
self.apps_by_id: dict[int, Gio.AppInfo] = {}
# Wait for the widget to be in a layer-shell window before doing this
self.connect("realize", lambda *args: self.add_trigger_to_app())
self.menu = Gio.Menu()
self.popover = Gtk.PopoverMenu.new_from_model_full(self.menu, Gtk.PopoverMenuFlags.NESTED)
@@ -167,6 +170,12 @@ class AppMenu(panorama_panel.Applet):
self.options_window = None
def add_trigger_to_app(self):
app: Gtk.Application = self.get_root().get_application()
action = Gio.SimpleAction.new(self.trigger_name, None)
action.connect("activate", lambda *args: self.button.popup())
app.add_action(action)
def launch_app(self, action, id: GLib.Variant):
app = self.apps_by_id[int(id.get_string())]
app.launch()
@@ -194,8 +203,12 @@ class AppMenu(panorama_panel.Applet):
def show_options(self, _0=None, _1=None):
...
def shutdown(self):
app: Gtk.Application = self.get_root().get_application()
app.remove_action(self.trigger_name)
def get_config(self):
return {"category_mappings": self.category_mappings}
return {"category_mappings": self.category_mappings, "trigger_name": self.trigger_name}
def set_panel_position(self, position):
self.popover.set_position(panorama_panel.OPPOSITE_POSITION[position])
config.yaml
@@ -45,6 +45,7 @@ panels:
Other:
menu_name: Other
icon: applications-other
trigger_name: app-menu
- WFWindowList:
max_button_width: 256
centre: []
main.py
@@ -551,7 +551,10 @@ PANEL_POSITIONS_REVERSE = {
class PanoramaPanel(Gtk.Application):
def __init__(self):
super().__init__()
super().__init__(
application_id="com.roundabout_host.roundabout.PanoramaPanel",
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE
)
self.display = Gdk.Display.get_default()
self.monitors = self.display.get_monitors()
self.applets_by_name: dict[str, panorama_panel.Applet] = {}
@@ -560,6 +563,15 @@ class PanoramaPanel(Gtk.Application):
self.edit_mode = False
self.drags = {}
self.add_main_option(
"trigger",
ord("t"),
GLib.OptionFlags.NONE,
GLib.OptionArg.STRING,
_("Trigger an action which can be processed by the applets"),
_("NAME")
)
def do_startup(self):
Gtk.Application.do_startup(self)
for i, monitor in enumerate(self.monitors):
@@ -644,9 +656,29 @@ class PanoramaPanel(Gtk.Application):
def do_shutdown(self):
print("Shutting down")
for panel in self.panels:
for area in (panel.left_area, panel.centre_area, panel.right_area):
applet = area.get_first_child()
while applet is not None:
applet.shutdown()
applet = applet.get_next_sibling()
Gtk.Application.do_shutdown(self)
self.save_config()
def do_command_line(self, command_line: Gio.ApplicationCommandLine):
options = command_line.get_options_dict()
args = command_line.get_arguments()[1:]
trigger_variant = options.lookup_value("trigger", GLib.VariantType("s"))
if trigger_variant:
action_name = trigger_variant.get_string()
print(app.list_actions())
self.activate_action(action_name, None)
print(f"Triggered {action_name}")
return 0
def set_edit_mode(self, value):
self.edit_mode = value
for panel in self.panels:
shared/panorama_panel.py
@@ -42,6 +42,9 @@ class Applet(Gtk.Box):
def get_config(self):
return {}
def shutdown(self):
return
def set_panel_position(self, position: Gtk.PositionType):
return