Use GObject constructor for Gtk.Alignment

With PyGTK, all parameters of the Alignment constructor had defaults [1].
With GTK3+pygi, when using the explicit constructor (Alignment.new() resp.
gtk_alignment_new() [2]), all values would need to be passed. However when
using the GObject constructor, named properties can be passed in instead and
we only need to pass those that different from the default.

[1] http://developer.gnome.org/pygtk/stable/class-gtkalignment.html#constructor-gtkalignment
[2] http://developer.gnome.org/gtk/stable/GtkAlignment.html#gtk-alignment-new

Signed-off-by: Simon Schampijer <simon@schampijer.de>
[assembled from several patches; replaced description]
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
This commit is contained in:
Simon Schampijer 2011-10-30 14:54:53 +01:00
parent c82a775267
commit 20319cb3c4
5 changed files with 6 additions and 6 deletions

View File

@ -342,7 +342,7 @@ class _TimeoutIcon(Gtk.Alignment):
__gtype_name__ = 'SugarTimeoutIcon' __gtype_name__ = 'SugarTimeoutIcon'
def __init__(self): def __init__(self):
GObject.GObject.__init__(self, 0, 0, 1, 1) Gtk.Alignment.__init__(self, xalign=0, yalign=0, xscale=1, yscale=1)
self.set_app_paintable(True) self.set_app_paintable(True)
self._text = Gtk.Label() self._text = Gtk.Label()
self._text.set_alignment(0.5, 0.5) self._text.set_alignment(0.5, 0.5)

View File

@ -67,8 +67,8 @@ class Palette(PaletteWindow):
primary_box.pack_start(self._icon_box, False, True, 0) primary_box.pack_start(self._icon_box, False, True, 0)
labels_box = Gtk.VBox() labels_box = Gtk.VBox()
self._label_alignment = Gtk.Alignment.new(xalign=0, yalign=0.5, self._label_alignment = Gtk.Alignment(xalign=0, yalign=0.5, xscale=1,
xscale=1, yscale=0.33) yscale=0.33)
self._label_alignment.set_padding(0, 0, style.DEFAULT_SPACING, self._label_alignment.set_padding(0, 0, style.DEFAULT_SPACING,
style.DEFAULT_SPACING) style.DEFAULT_SPACING)
self._label_alignment.add(labels_box) self._label_alignment.add(labels_box)

View File

@ -309,7 +309,7 @@ def _setup_page(page_widget, color, hpad):
def _embed_page(box_class, page): def _embed_page(box_class, page):
page.show() page.show()
alignment = Gtk.Alignment.new(0.0, 0.0, 1.0, 1.0) alignment = Gtk.Alignment(xscale=1.0, yscale=1.0)
alignment.add(page) alignment.add(page)
alignment.show() alignment.show()

View File

@ -65,7 +65,7 @@ class Toolbox(Gtk.VBox):
event_box = Gtk.EventBox() event_box = Gtk.EventBox()
alignment = Gtk.Alignment.new(0.0, 0.0, 1.0, 1.0) alignment = Gtk.Alignment(xscale=1.0, yscale=1.0)
alignment.set_padding(0, 0, style.TOOLBOX_HORIZONTAL_PADDING, alignment.set_padding(0, 0, style.TOOLBOX_HORIZONTAL_PADDING,
style.TOOLBOX_HORIZONTAL_PADDING) style.TOOLBOX_HORIZONTAL_PADDING)

View File

@ -175,7 +175,7 @@ class _TrayScrollButton(ToolButton):
icon_size=Gtk.IconSize.SMALL_TOOLBAR) icon_size=Gtk.IconSize.SMALL_TOOLBAR)
# The alignment is a hack to work around Gtk.ToolButton code # The alignment is a hack to work around Gtk.ToolButton code
# that sets the icon_size when the icon_widget is a Gtk.Image # that sets the icon_size when the icon_widget is a Gtk.Image
alignment = Gtk.Alignment.new(0.5, 0.5) alignment = Gtk.Alignment(xalign=0.5, yalign=0.5)
alignment.add(self.icon) alignment.add(self.icon)
self.set_icon_widget(alignment) self.set_icon_widget(alignment)
alignment.show_all() alignment.show_all()