mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-24 07:16:40 -06:00
autodrawer: Fix centering
child_get_property bindings need a wrapper to make them useful
This commit is contained in:
parent
e7fb33e32d
commit
2d110816d6
@ -25,6 +25,7 @@
|
|||||||
# pylint: disable=E0611
|
# pylint: disable=E0611
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
# pylint: enable=E0611
|
# pylint: enable=E0611
|
||||||
|
|
||||||
@ -33,6 +34,12 @@ from gi.repository import Gtk
|
|||||||
# OverBox.set_over: Instance of 'OverBox' has no 'remove' member
|
# OverBox.set_over: Instance of 'OverBox' has no 'remove' member
|
||||||
|
|
||||||
|
|
||||||
|
def rect_print(name, rect):
|
||||||
|
# For debugging
|
||||||
|
print ("%s: height=%d, width=%d, x=%d, y=%d" %
|
||||||
|
(name, rect.height, rect.width, rect.x, rect.y))
|
||||||
|
|
||||||
|
|
||||||
class OverBox(Gtk.Box):
|
class OverBox(Gtk.Box):
|
||||||
"""
|
"""
|
||||||
Implementation of an overlapping box
|
Implementation of an overlapping box
|
||||||
@ -87,11 +94,9 @@ class OverBox(Gtk.Box):
|
|||||||
actual_min = self._get_actual_min()
|
actual_min = self._get_actual_min()
|
||||||
|
|
||||||
if self.overWidget:
|
if self.overWidget:
|
||||||
# XXX
|
expand = self.child_get_property(self.overWidget, "expand")
|
||||||
expand = self.child_get_property(self.overWidget, "expand", "")
|
fill = self.child_get_property(self.overWidget, "fill")
|
||||||
fill = self.child_get_property(self.overWidget, "fill", "")
|
padding = self.child_get_property(self.overWidget, "padding")
|
||||||
padding = self.child_get_property(self.overWidget, "padding", "")
|
|
||||||
padding = 0
|
|
||||||
|
|
||||||
if not expand:
|
if not expand:
|
||||||
width = min(self.overWidth, boxwidth - padding)
|
width = min(self.overWidth, boxwidth - padding)
|
||||||
@ -139,11 +144,9 @@ class OverBox(Gtk.Box):
|
|||||||
self.overWidth = over.width
|
self.overWidth = over.width
|
||||||
self.overHeight = over.height
|
self.overHeight = over.height
|
||||||
|
|
||||||
# XXXX
|
expand = self.child_get_property(self.overWidget, "expand")
|
||||||
expand = self.child_get_property(self.overWidget, "expand", "")
|
fill = self.child_get_property(self.overWidget, "fill")
|
||||||
fill = self.child_get_property(self.overWidget, "fill", "")
|
padding = self.child_get_property(self.overWidget, "padding")
|
||||||
padding = self.child_get_property(self.overWidget, "padding", "")
|
|
||||||
padding = 0
|
|
||||||
|
|
||||||
if expand or fill:
|
if expand or fill:
|
||||||
wpad = 0
|
wpad = 0
|
||||||
@ -159,6 +162,14 @@ class OverBox(Gtk.Box):
|
|||||||
# Custom functionality #
|
# Custom functionality #
|
||||||
########################
|
########################
|
||||||
|
|
||||||
|
def child_get_property(self, widget, propname):
|
||||||
|
# gtk3 bindings are crappy here, make it work like
|
||||||
|
# gobject.get_property()
|
||||||
|
value = GObject.Value()
|
||||||
|
value.init(GObject.TYPE_INT)
|
||||||
|
Gtk.Box.child_get_property(self, widget, propname, value)
|
||||||
|
return value.get_int()
|
||||||
|
|
||||||
def do_set_over(self, widget):
|
def do_set_over(self, widget):
|
||||||
self.set_over(widget)
|
self.set_over(widget)
|
||||||
|
|
||||||
@ -278,13 +289,19 @@ class OverBox(Gtk.Box):
|
|||||||
self.do_size_request(req)
|
self.do_size_request(req)
|
||||||
return (req.width, req.width)
|
return (req.width, req.width)
|
||||||
|
|
||||||
def do_get_preferred_heigh(self):
|
def do_get_preferred_height(self):
|
||||||
req = Gtk.Requisition()
|
req = Gtk.Requisition()
|
||||||
self.do_size_request(req)
|
self.do_size_request(req)
|
||||||
return (req.height, req.height)
|
return (req.height, req.height)
|
||||||
|
|
||||||
def do_size_allocate(self, newalloc):
|
def do_size_allocate(self, newalloc):
|
||||||
self.allocation = newalloc
|
tmpalloc = Gdk.Rectangle()
|
||||||
|
tmpalloc.width = newalloc.width
|
||||||
|
tmpalloc.height = newalloc.height
|
||||||
|
tmpalloc.x = newalloc.x
|
||||||
|
tmpalloc.y = newalloc.y
|
||||||
|
|
||||||
|
self.allocation = tmpalloc
|
||||||
|
|
||||||
over = self._get_over_window_geometry()
|
over = self._get_over_window_geometry()
|
||||||
under = self._get_under_window_geometry()
|
under = self._get_under_window_geometry()
|
||||||
@ -325,8 +342,6 @@ class Drawer(OverBox):
|
|||||||
self.timer_id = None
|
self.timer_id = None
|
||||||
|
|
||||||
|
|
||||||
# XXX: C version has a finalize impl
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Internal helpers #
|
# Internal helpers #
|
||||||
####################
|
####################
|
||||||
@ -407,7 +422,6 @@ class AutoDrawer(Drawer):
|
|||||||
self._update(True)
|
self._update(True)
|
||||||
self._refresh_packing()
|
self._refresh_packing()
|
||||||
|
|
||||||
# XXX: Has a finalize method
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Internal Helpers #
|
# Internal Helpers #
|
||||||
@ -478,7 +492,6 @@ class AutoDrawer(Drawer):
|
|||||||
grabbed = Gtk.grab_get_current()
|
grabbed = Gtk.grab_get_current()
|
||||||
|
|
||||||
if grabbed and isinstance(grabbed, Gtk.Menu):
|
if grabbed and isinstance(grabbed, Gtk.Menu):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
menuAttach = grabbed.get_attach_widget()
|
menuAttach = grabbed.get_attach_widget()
|
||||||
if not menuAttach:
|
if not menuAttach:
|
||||||
@ -508,7 +521,7 @@ class AutoDrawer(Drawer):
|
|||||||
self._enforce(False)
|
self._enforce(False)
|
||||||
else:
|
else:
|
||||||
self.delayConnection = GLib.timeout_add(self.delayValue,
|
self.delayConnection = GLib.timeout_add(self.delayValue,
|
||||||
self._on_enforce_delay)
|
self._on_enforce_delay)
|
||||||
|
|
||||||
|
|
||||||
def _refresh_packing(self):
|
def _refresh_packing(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user