[Sugar-devel] [PATCH shell 2/2] Use proper constructor for Gtk.Alignment

Manuel Quiñones manuq at laptop.org
Wed Sep 19 23:52:31 EDT 2012


Found a regression in the Journal: the progress bar when a volume is
clicked gets the whole height of the window.

2012/9/20 Manuel Quiñones <manuq at laptop.org>:
> Is better to pass keyword arguments, like the toolkit does.  See
> sugar-toolkit-gtk commit 20319cb3c4b2be4e8f584703d704ffda4b1cff29 .
>
> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
> ---
>  extensions/cpsection/aboutme/view.py | 4 ++--
>  extensions/cpsection/updater/view.py | 3 +--
>  extensions/deviceicon/network.py     | 6 +++---
>  src/jarabe/desktop/activitieslist.py | 3 ++-
>  src/jarabe/intro/window.py           | 2 +-
>  src/jarabe/journal/detailview.py     | 2 +-
>  src/jarabe/journal/expandedentry.py  | 6 +++---
>  src/jarabe/journal/listview.py       | 6 +++---
>  src/jarabe/journal/modalalert.py     | 3 +--
>  src/jarabe/view/launcher.py          | 2 +-
>  10 files changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py
> index 293923d..a17d41a 100644
> --- a/extensions/cpsection/aboutme/view.py
> +++ b/extensions/cpsection/aboutme/view.py
> @@ -204,7 +204,7 @@ class AboutMe(SectionView):
>              self._nick_alert.props.msg = self.restart_msg
>              self._nick_alert.show()
>
> -        self._center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
> +        self._center_in_panel = Gtk.Alignment(xalign=0.5)
>          self._center_in_panel.add(self._nick_box)
>          self.pack_start(self._center_in_panel, False, False, 0)
>          self.pack_start(self._nick_alert_box, False, False, 0)
> @@ -246,7 +246,7 @@ class AboutMe(SectionView):
>              self._color_alert.props.msg = self.restart_msg
>              self._color_alert.show()
>
> -        self._center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
> +        self._center_in_panel = Gtk.Alignment(xalign=0.5)
>          self._center_in_panel.add(self._color_box)
>          self.pack_start(self._color_label, False, False, 0)
>          self.pack_start(self._center_in_panel, False, False, 0)
> diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
> index 2a1f643..64867d2 100644
> --- a/extensions/cpsection/updater/view.py
> +++ b/extensions/cpsection/updater/view.py
> @@ -202,8 +202,7 @@ class ProgressPane(Gtk.VBox):
>          self.pack_start(self._label, True, True, 0)
>          self._label.show()
>
> -        alignment_box = Gtk.Alignment.new(xalign=0.5, yalign=0.5,
> -                                          xscale=0, yscale=0)
> +        alignment_box = Gtk.Alignment(xalign=0.5, yalign=0.5)
>          self.pack_start(alignment_box, True, True, 0)
>          alignment_box.show()
>
> diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
> index b4a5393..855a514 100644
> --- a/extensions/deviceicon/network.py
> +++ b/extensions/deviceicon/network.py
> @@ -89,7 +89,7 @@ class WirelessPalette(Palette):
>          self._info.pack_start(separator, True, True, 0)
>
>          def _padded(child, xalign=0, yalign=0.5):
> -            padder = Gtk.Alignment.new(xalign=xalign, yalign=yalign,
> +            padder = Gtk.Alignment(xalign=xalign, yalign=yalign,
>                                     xscale=1, yscale=0.33)
>              padder.set_padding(style.DEFAULT_SPACING,
>                                 style.DEFAULT_SPACING,
> @@ -162,7 +162,7 @@ class WiredPalette(Palette):
>          self._info = Gtk.VBox()
>
>          def _padded(child, xalign=0, yalign=0.5):
> -            padder = Gtk.Alignment.new(xalign=xalign, yalign=yalign,
> +            padder = Gtk.Alignment(xalign=xalign, yalign=yalign,
>                                     xscale=1, yscale=0.33)
>              padder.set_padding(style.DEFAULT_SPACING,
>                                 style.DEFAULT_SPACING,
> @@ -256,7 +256,7 @@ class GsmPalette(Palette):
>          self.set_state(_GSM_STATE_NOT_READY)
>
>      def _add_widget_with_padding(self, child, xalign=0, yalign=0.5):
> -        alignment = Gtk.Alignment.new(xalign=xalign, yalign=yalign,
> +        alignment = Gtk.Alignment(xalign=xalign, yalign=yalign,
>                                    xscale=1, yscale=0.33)
>          alignment.set_padding(style.DEFAULT_SPACING,
>                                style.DEFAULT_SPACING,
> diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py
> index b111164..2d3e9a8 100644
> --- a/src/jarabe/desktop/activitieslist.py
> +++ b/src/jarabe/desktop/activitieslist.py
> @@ -311,7 +311,8 @@ class ClearMessageBox(Gtk.EventBox):
>          self.modify_bg(Gtk.StateType.NORMAL,
>                         style.COLOR_WHITE.get_gdk_color())
>
> -        alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
> +        alignment = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.1,
> +                                  yscale=0.1)
>          self.add(alignment)
>          alignment.show()
>
> diff --git a/src/jarabe/intro/window.py b/src/jarabe/intro/window.py
> index 3c979fb..b10d51e 100644
> --- a/src/jarabe/intro/window.py
> +++ b/src/jarabe/intro/window.py
> @@ -98,7 +98,7 @@ class _NamePage(_Page):
>          _Page.__init__(self)
>          self._intro = intro
>
> -        alignment = Gtk.Alignment.new(0.5, 0.5, 0, 0)
> +        alignment = Gtk.Alignment(xalign=0.5, yalign=0.5)
>          self.pack_start(alignment, expand=True, fill=True, padding=0)
>
>          hbox = Gtk.HBox(spacing=style.DEFAULT_SPACING)
> diff --git a/src/jarabe/journal/detailview.py b/src/jarabe/journal/detailview.py
> index c7748ed..f1b5c18 100644
> --- a/src/jarabe/journal/detailview.py
> +++ b/src/jarabe/journal/detailview.py
> @@ -92,7 +92,7 @@ class BackBar(Gtk.EventBox):
>
>          label = Gtk.Label()
>          label.set_text(_('Back'))
> -        halign = Gtk.Alignment.new(0, 0.5, 0, 1)
> +        halign = Gtk.Alignment(yalign=0.5, yscale=1)
>          halign.add(label)
>          hbox.pack_start(halign, True, True, 0)
>          hbox.show()
> diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
> index 21a3c5f..1650df7 100644
> --- a/src/jarabe/journal/expandedentry.py
> +++ b/src/jarabe/journal/expandedentry.py
> @@ -280,7 +280,7 @@ class ExpandedEntry(Gtk.EventBox):
>          text = Gtk.Label()
>          text.set_markup('<span foreground="%s">%s</span>' % (
>                  style.COLOR_BUTTON_GREY.get_html(), label))
> -        halign = Gtk.Alignment.new(0, 0, 0, 0)
> +        halign = Gtk.Alignment()
>          halign.add(text)
>          vbox.pack_start(halign, False, False, 0)
>
> @@ -306,7 +306,7 @@ class ExpandedEntry(Gtk.EventBox):
>          text = Gtk.Label()
>          text.set_markup('<span foreground="%s">%s</span>' % (
>                  style.COLOR_BUTTON_GREY.get_html(), _('Participants:')))
> -        halign = Gtk.Alignment.new(0, 0, 0, 0)
> +        halign = Gtk.Alignment()
>          halign.add(text)
>          vbox.pack_start(halign, False, False, 0)
>
> @@ -325,7 +325,7 @@ class ExpandedEntry(Gtk.EventBox):
>          text.set_markup('<span foreground="%s">%s</span>' % (
>                  style.COLOR_BUTTON_GREY.get_html(), label))
>
> -        halign = Gtk.Alignment.new(0, 0, 0, 0)
> +        halign = Gtk.Alignment()
>          halign.add(text)
>          vbox.pack_start(halign, False, False, 0)
>
> diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
> index 369f364..f91cff1 100644
> --- a/src/jarabe/journal/listview.py
> +++ b/src/jarabe/journal/listview.py
> @@ -357,8 +357,7 @@ class BaseListView(Gtk.Bin):
>              self._last_progress_bar_pulse = time.time()
>
>      def _start_progress_bar(self):
> -        alignment = Gtk.Alignment.new(xalign=0.5, yalign=0.5,
> -                                      xscale=0.5, yscale=0)
> +        alignment = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.5)
>          self.remove(self.get_child())
>          self.add(alignment)
>          alignment.show()
> @@ -384,7 +383,8 @@ class BaseListView(Gtk.Bin):
>                                   style.COLOR_WHITE.get_gdk_color())
>          self.add(background_box)
>
> -        alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
> +        alignment = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.1,
> +                                  yscale=0.1)
>          background_box.add(alignment)
>
>          box = Gtk.VBox()
> diff --git a/src/jarabe/journal/modalalert.py b/src/jarabe/journal/modalalert.py
> index db7a81f..bc48548 100644
> --- a/src/jarabe/journal/modalalert.py
> +++ b/src/jarabe/journal/modalalert.py
> @@ -74,8 +74,7 @@ class ModalAlert(Gtk.Window):
>                                fill=False, padding=0)
>          self._message.show()
>
> -        alignment = Gtk.Alignment.new(xalign=0.5, yalign=0.5,
> -                                      xscale=0.0, yscale=0.0)
> +        alignment = Gtk.Alignment(xalign=0.5, yalign=0.5)
>          self._vbox.pack_start(alignment, expand=False, fill=True, padding=0)
>          alignment.show()
>
> diff --git a/src/jarabe/view/launcher.py b/src/jarabe/view/launcher.py
> index aae07d2..f0fe523 100644
> --- a/src/jarabe/view/launcher.py
> +++ b/src/jarabe/view/launcher.py
> @@ -68,7 +68,7 @@ class LaunchWindow(Gtk.Window):
>          self.error_text.props.use_markup = True
>          footer.pack_start(self.error_text, False, True, 0)
>
> -        button_box = Gtk.Alignment.new(0.5, 0, 0, 0)
> +        button_box = Gtk.Alignment(xalign=0.5)
>          button_box.show()
>          footer.pack_start(button_box, False, True, 0)
>          self.cancel_button = Gtk.Button(stock=Gtk.STOCK_STOP)
> --
> 1.7.11.4
>



-- 
.. manuq ..


More information about the Sugar-devel mailing list