roundabout,
created on Tuesday, 22 July 2025, 09:50:45 (1753177845),
received on Saturday, 9 August 2025, 12:22:36 (1754742156)
Author identity: vlad <vlad.muntoiu@gmail.com>
782e0e6f1b877188bd4119c3d87f175248bae670
config.yaml
@@ -6,6 +6,8 @@ panels:
left:
- LabelApplet:
text: Hello, world
- LabelApplet:
text: Multi-panel support
centre: []
right:
- ClockApplet:
@@ -15,7 +17,5 @@ panels:
size: 40
applets:
left: []
centre:
- LabelApplet:
text: Multi-panel support
centre: []
right: []
main.py
@@ -173,13 +173,34 @@ class AppletArea(Gtk.Box):
def __init__(self, orientation=Gtk.Orientation.HORIZONTAL):
super().__init__()
self.drop_target = Gtk.DropTarget.new(GObject.TYPE_UINT64, Gdk.DragAction.MOVE)
self.drop_target.set_gtypes([GObject.TYPE_UINT64])
self.drop_target.connect("drop", self.drop_applet)
def drop_applet(self, drop_target: Gtk.DropTarget, value: int, x: float, y: float):
print(f"Dropping applet: {value}")
applet: panorama_panel.Applet = self.get_root().get_application().drags.pop(value)
print(f"Type: {applet.__class__.__name__}")
old_area: AppletArea = applet.get_parent()
old_area.remove(applet)
self.append(applet)
return True
def set_edit_mode(self, value):
child = self.get_first_child()
while child is not None:
child.set_sensitive(not value)
if value:
child.make_draggable()
else:
child.restore_drag()
child.set_opacity(0.75 if value else 1)
child = child.get_next_sibling()
if value:
self.add_controller(self.drop_target)
else:
self.remove_controller(self.drop_target)
class Panel(Gtk.Window):
def __init__(self, application: Gtk.Application, monitor: Gdk.Monitor, position: Gtk.PositionType = Gtk.PositionType.TOP, size: int = 40, monitor_index: int = 0):
@@ -349,6 +370,7 @@ class PanoramaPanel(Gtk.Application):
self.panels: list[Panel] = []
self.manager_window = None
self.edit_mode = False
self.drags = {}
def do_startup(self):
Gtk.Application.do_startup(self)
shared/panorama_panel.py
@@ -1,7 +1,7 @@
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
from gi.repository import Gtk, Gdk, GObject
class Applet(Gtk.Box):
@@ -17,12 +17,30 @@ class Applet(Gtk.Box):
self.set_vexpand(True)
self.set_hexpand(False)
self.drag_source = Gtk.DragSource(actions=Gdk.DragAction.MOVE)
self.drag_source.connect("prepare", self.provide_drag_data)
def provide_drag_data(self, source: Gtk.DragSource, x: float, y: float):
app = self.get_root().get_application()
app.drags[id(self)] = self
value = GObject.Value()
value.init(GObject.TYPE_UINT64)
value.set_uint64(id(self))
print(value)
return Gdk.ContentProvider.new_for_value(value)
def get_config(self):
return {}
def set_panel_position(self, position: Gtk.PositionType):
return
def make_draggable(self):
self.add_controller(self.drag_source)
def restore_drag(self):
self.remove_controller(self.drag_source)
def get_panel_position(applet: Applet) -> Gtk.PositionType:
return applet.get_root().position