From 20319cb3c4b2be4e8f584703d704ffda4b1cff29 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Sun, 30 Oct 2011 14:54:53 +0100 Subject: [PATCH] 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 [assembled from several patches; replaced description] Signed-off-by: Sascha Silbe --- src/sugar3/graphics/alert.py | 2 +- src/sugar3/graphics/palette.py | 4 ++-- src/sugar3/graphics/toolbarbox.py | 2 +- src/sugar3/graphics/toolbox.py | 2 +- src/sugar3/graphics/tray.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sugar3/graphics/alert.py b/src/sugar3/graphics/alert.py index f72a2bdb..239afc25 100644 --- a/src/sugar3/graphics/alert.py +++ b/src/sugar3/graphics/alert.py @@ -342,7 +342,7 @@ class _TimeoutIcon(Gtk.Alignment): __gtype_name__ = 'SugarTimeoutIcon' 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._text = Gtk.Label() self._text.set_alignment(0.5, 0.5) diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py index 6c24d27c..b23a28d4 100644 --- a/src/sugar3/graphics/palette.py +++ b/src/sugar3/graphics/palette.py @@ -67,8 +67,8 @@ class Palette(PaletteWindow): primary_box.pack_start(self._icon_box, False, True, 0) labels_box = Gtk.VBox() - self._label_alignment = Gtk.Alignment.new(xalign=0, yalign=0.5, - xscale=1, yscale=0.33) + self._label_alignment = Gtk.Alignment(xalign=0, yalign=0.5, xscale=1, + yscale=0.33) self._label_alignment.set_padding(0, 0, style.DEFAULT_SPACING, style.DEFAULT_SPACING) self._label_alignment.add(labels_box) diff --git a/src/sugar3/graphics/toolbarbox.py b/src/sugar3/graphics/toolbarbox.py index 458c2d67..b3217156 100644 --- a/src/sugar3/graphics/toolbarbox.py +++ b/src/sugar3/graphics/toolbarbox.py @@ -309,7 +309,7 @@ def _setup_page(page_widget, color, hpad): def _embed_page(box_class, page): 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.show() diff --git a/src/sugar3/graphics/toolbox.py b/src/sugar3/graphics/toolbox.py index e67ff164..e4e4c324 100644 --- a/src/sugar3/graphics/toolbox.py +++ b/src/sugar3/graphics/toolbox.py @@ -65,7 +65,7 @@ class Toolbox(Gtk.VBox): 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, style.TOOLBOX_HORIZONTAL_PADDING) diff --git a/src/sugar3/graphics/tray.py b/src/sugar3/graphics/tray.py index 83c59e59..f14569b0 100644 --- a/src/sugar3/graphics/tray.py +++ b/src/sugar3/graphics/tray.py @@ -175,7 +175,7 @@ class _TrayScrollButton(ToolButton): icon_size=Gtk.IconSize.SMALL_TOOLBAR) # The alignment is a hack to work around Gtk.ToolButton code # 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) self.set_icon_widget(alignment) alignment.show_all()