roundabout,
created on Sunday, 3 August 2025, 20:41:14 (1754253674),
received on Sunday, 3 August 2025, 20:41:18 (1754253678)
Author identity: Vlad <vlad.muntoiu@gmail.com>
87a037af6984c5d73786bd080e0e63ff50228483
applets/wf-window-list/__init__.py
@@ -34,7 +34,7 @@ import gi
gi.require_version("Gtk", "4.0") gi.require_version("GdkWayland", "4.0") from gi.repository import Gtk, GLib, Gtk4LayerShell, Gio, Gdk, Pangofrom gi.repository import Gtk, GLib, Gtk4LayerShell, Gio, Gdk, Pango, GObjectimport ctypes
@@ -169,6 +169,30 @@ class WindowButton(Gtk.ToggleButton):
self.set_hexpand(True) self.set_vexpand(True) self.drag_source = Gtk.DragSource(actions=Gdk.DragAction.MOVE) self.drag_source.connect("prepare", self.provide_drag_data) self.drag_source.connect("drag-begin", self.drag_begin) self.drag_source.connect("drag-cancel", self.drag_cancel) self.add_controller(self.drag_source) 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)) return Gdk.ContentProvider.new_for_value(value) def drag_begin(self, source: Gtk.DragSource, drag: Gdk.Drag): paintable = Gtk.WidgetPaintable.new(self).get_current_image() source.set_icon(paintable, 0, 0) self.hide() def drag_cancel(self, source: Gtk.DragSource, drag: Gdk.Drag, reason: Gdk.DragCancelReason): self.show() return False @property def window_title(self): return self.label.get_text()
@@ -241,6 +265,44 @@ class WFWindowList(panorama_panel.Applet):
self.options_window = None # Support button reordering 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_button) self.add_controller(self.drop_target) def drop_button(self, drop_target: Gtk.DropTarget, value: int, x: float, y: float): button: WindowButton = self.get_root().get_application().drags.pop(value) if button.get_parent() is not self: # Prevent dropping a button from another window list return False self.remove(button) # Find the position where to insert the applet # Probably we could use the assumption that buttons are homogeneous here for efficiency child = self.get_first_child() while child: allocation = child.get_allocation() child_x, child_y = self.translate_coordinates(self, 0, 0) if self.get_orientation() == Gtk.Orientation.HORIZONTAL: midpoint = child_x + allocation.width / 2 if x < midpoint: button.insert_before(self, child) break elif self.get_orientation() == Gtk.Orientation.VERTICAL: midpoint = child_y + allocation.height / 2 if y < midpoint: button.insert_before(self, child) break child = child.get_next_sibling() else: self.append(button) button.show() self.set_all_rectangles() return True def get_wl_resources(self): ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p ctypes.pythonapi.PyCapsule_GetPointer.argtypes = (ctypes.py_object,)
shared/panorama_panel.py
@@ -28,7 +28,6 @@ class Applet(Gtk.Box):
value = GObject.Value() value.init(GObject.TYPE_UINT64) value.set_uint64(id(self)) print(value)return Gdk.ContentProvider.new_for_value(value) def drag_begin(self, source: Gtk.DragSource, drag: Gdk.Drag):