Set alignment on widget and do not override with [x,y]fill

The alignment and fill properties are merged in GTK3 and the default value is FILL.
Also using properties in Gtk.Align is deprecated so it is better to set
directly alignment on the widget.

issue8799
review278121002
This commit is contained in:
Cédric Krier
2019-11-16 12:54:07 +01:00
parent 00ac259b79
commit cc11b151fe
2 changed files with 4 additions and 20 deletions
+4 -7
View File
@@ -34,7 +34,7 @@ from .form_gtk.dictionary import DictWidget
from .form_gtk.multiselection import MultiSelection
from .form_gtk.pyson import PYSON
from .form_gtk.state_widget import (Label, VBox, Image, Frame, ScrolledWindow,
Notebook, Alignment, Expander)
Notebook, Expander)
_ = gettext.gettext
@@ -91,12 +91,7 @@ class Container(object):
return
widget.set_vexpand(bool(attributes.get('yexpand')))
if attributes.get('yfill'):
widget.set_valign(Gtk.Align.FILL)
widget.set_hexpand(bool(attributes.get('xexpand', True)))
if attributes.get('xfill', True):
widget.set_valign(Gtk.Align.FILL)
if attributes.get('help'):
self.tooltips.set_tip(widget, attributes['help'])
@@ -227,7 +222,9 @@ class FormXMLViewParser(XMLViewParser):
int(attributes.get('width', -1)),
int(attributes.get('height', -1)))
self.container.add(Alignment(widget.widget, attributes), attributes)
widget.widget.set_halign(get_align(attributes.get('xalign', 0.5)))
widget.widget.set_valign(get_align(attributes.get('yalign', 0.5)))
self.container.add(widget.widget, attributes)
if name in self._mnemonics and widget.mnemonic_widget:
label = self._mnemonics.pop(name)
@@ -98,19 +98,6 @@ class Notebook(StateMixin, Gtk.Notebook):
widget._readonly_set(True)
class Alignment(Gtk.Alignment):
def __init__(self, widget, attrs):
super(Alignment, self).__init__()
self.props.xalign = float(attrs.get('xalign', 0.0))
self.props.yalign = float(attrs.get('yalign', 0.5))
self.props.xscale = float(attrs.get('xexpand', 1.0))
self.props.yscale = float(attrs.get('yexpand', 1.0))
self.add(widget)
widget.connect('show', lambda *a: self.show())
widget.connect('hide', lambda *a: self.hide())
class Expander(StateMixin, Gtk.Expander):
def __init__(self, label=None, attrs=None):