roundabout,
created on Tuesday, 22 July 2025, 11:49:03 (1753184943),
received on Saturday, 9 August 2025, 12:22:36 (1754742156)
Author identity: vlad <vlad.muntoiu@gmail.com>
00c1a28141af636bbe75cd8f7357cd6c08efb51c
config.yaml
@@ -6,8 +6,6 @@ panels:
left:
- LabelApplet:
text: Hello, world
- LabelApplet:
text: Multi-panel support
centre: []
right:
- ClockApplet:
@@ -17,5 +15,7 @@ panels:
size: 40
applets:
left: []
centre: []
centre:
- LabelApplet:
text: Multi-panel support
right: []
main.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import os
import sys
import importlib
import typing
from itertools import accumulate, chain
from pathlib import Path
import ruamel.yaml as yaml
@@ -23,6 +24,33 @@ sys.path.insert(0, str((Path(__file__).parent / "shared").resolve()))
import panorama_panel
custom_css = """
.panel-flash {
animation: flash 1000ms ease-in-out 0s 2;
}
@keyframes flash {
0% {
background-color: initial;
}
50% {
background-color: #ffff0080;
}
0% {
background-color: initial;
}
}
"""
css_provider = Gtk.CssProvider()
css_provider.load_from_data(custom_css)
Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(),
css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
@Gtk.Template(filename="panel-configurator.ui")
class PanelConfigurator(Gtk.Frame):
__gtype_name__ = "PanelConfigurator"
@@ -104,6 +132,7 @@ class PanelManager(Gtk.Window):
panel_editing_switch: Gtk.Switch = Gtk.Template.Child()
panel_stack: Gtk.Stack = Gtk.Template.Child()
current_panel: typing.Optional[Panel] = None
def __init__(self, application: Gtk.Application, **kwargs):
super().__init__(application=application, **kwargs)
@@ -125,6 +154,7 @@ class PanelManager(Gtk.Window):
self.panel_editing_switch.set_active(application.edit_mode)
self.panel_editing_switch.connect("state-set", self.set_edit_mode)
self.connect("close-request", lambda *args: self.unflash_old_panel())
self.connect("close-request", lambda *args: self.destroy())
if isinstance(self.get_application(), PanoramaPanel):
@@ -138,12 +168,24 @@ class PanelManager(Gtk.Window):
self.panel_stack.connect("notify::visible-child", self.set_visible_panel)
self.panel_stack.notify("visible-child")
def unflash_old_panel(self):
if self.current_panel:
for area in (self.current_panel.left_area, self.current_panel.centre_area, self.current_panel.right_area):
area.unflash()
def set_visible_panel(self, stack: Gtk.Stack, pspec: GObject.ParamSpec):
self.unflash_old_panel()
panel: Panel = stack.get_visible_child().panel
self.current_panel = panel
self.next_panel_action.set_enabled(stack.get_visible_child().get_next_sibling() is not None)
self.previous_panel_action.set_enabled(stack.get_visible_child().get_prev_sibling() is not None)
# Start an animation to show the user what panel is being edited
for area in (panel.left_area, panel.centre_area, panel.right_area):
area.flash()
def set_edit_mode(self, switch, value):
if isinstance(self.get_application(), PanoramaPanel):
self.get_application().set_edit_mode(value)
@@ -187,6 +229,7 @@ class AppletArea(Gtk.Box):
return True
def set_edit_mode(self, value):
panel: Panel = self.get_root()
child = self.get_first_child()
while child is not None:
if value:
@@ -198,8 +241,19 @@ class AppletArea(Gtk.Box):
if value:
self.add_controller(self.drop_target)
if panel.get_orientation() == Gtk.Orientation.HORIZONTAL:
self.set_size_request(48, 0)
elif panel.get_orientation() == Gtk.Orientation.VERTICAL:
self.set_size_request(0, 48)
else:
self.remove_controller(self.drop_target)
self.set_size_request(0, 0)
def flash(self):
self.add_css_class("panel-flash")
def unflash(self):
self.remove_css_class("panel-flash")
class Panel(Gtk.Window):