[Sugar-devel] [PATCH sugar-toolkit-gtk3] Fixing deprecations: Using Gtk.Orientation

Daniel Francis francis at sugarlabs.org
Tue Jun 26 22:56:46 EDT 2012


---
 src/sugar3/activity/widgets.py      |    3 ++-
 src/sugar3/graphics/alert.py        |    9 ++++++---
 src/sugar3/graphics/notebook.py     |    6 ++++--
 src/sugar3/graphics/palette.py      |   27 +++++++++++++++++++--------
 src/sugar3/graphics/panel.py        |    3 ++-
 src/sugar3/graphics/radiopalette.py |    3 ++-
 src/sugar3/graphics/toolbarbox.py   |    3 ++-
 src/sugar3/graphics/toolbox.py      |    6 ++++--
 src/sugar3/graphics/toolcombobox.py |    3 ++-
 src/sugar3/graphics/tray.py         |    6 ++++--
 src/sugar3/graphics/window.py       |    6 ++++--
 11 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/src/sugar3/activity/widgets.py b/src/sugar3/activity/widgets.py
index c4015ce..ffb3503 100644
--- a/src/sugar3/activity/widgets.py
+++ b/src/sugar3/activity/widgets.py
@@ -226,7 +226,8 @@ class DescriptionItem(Gtk.ToolItem):
         description_button.set_tooltip(_('Description'))
         self._palette = description_button.get_palette()
 
-        description_box = Gtk.HBox()
+        description_box = Gtk.Box()
+        description_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         sw = Gtk.ScrolledWindow()
         sw.set_size_request(int(Gdk.Screen.width() / 2),
                             2 * style.GRID_CELL_SIZE)
diff --git a/src/sugar3/graphics/alert.py b/src/sugar3/graphics/alert.py
index 16392cd..358fea4 100644
--- a/src/sugar3/graphics/alert.py
+++ b/src/sugar3/graphics/alert.py
@@ -97,11 +97,13 @@ class Alert(Gtk.EventBox):
         self._icon = None
         self._buttons = {}
 
-        self._hbox = Gtk.HBox()
+        self._hbox = Gtk.Box()
+        self._hbox.set_orientation(Gtk.Orientation.HORIZONTAL)
         self._hbox.set_border_width(style.DEFAULT_SPACING)
         self._hbox.set_spacing(style.DEFAULT_SPACING)
 
-        self._msg_box = Gtk.VBox()
+        self._msg_box = Gtk.Box()
+        self._msg_box.set_orientation(Gtk.Orientation.VERTICAL)
         self._title_label = Gtk.Label()
         self._title_label.set_alignment(0, 0.5)
         self._msg_box.pack_start(self._title_label, False, False, 0)
@@ -111,7 +113,8 @@ class Alert(Gtk.EventBox):
         self._msg_box.pack_start(self._msg_label, False, False, 0)
         self._hbox.pack_start(self._msg_box, False, False, 0)
 
-        self._buttons_box = Gtk.HButtonBox()
+        self._buttons_box = Gtk.ButtonBox()
+        self._buttons_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         self._buttons_box.set_layout(Gtk.ButtonBoxStyle.END)
         self._buttons_box.set_spacing(style.DEFAULT_SPACING)
         self._hbox.pack_start(self._buttons_box, True, True, 0)
diff --git a/src/sugar3/graphics/notebook.py b/src/sugar3/graphics/notebook.py
index e14bf0e..0f3e858 100644
--- a/src/sugar3/graphics/notebook.py
+++ b/src/sugar3/graphics/notebook.py
@@ -74,7 +74,8 @@ class Notebook(Gtk.Notebook):
             raise AssertionError
 
     def _add_icon_to_button(self, button):
-        icon_box = Gtk.HBox()
+        icon_box = Gtk.Box()
+        icon_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         image = Gtk.Image()
         image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
         Gtk.Button.set_relief(button, Gtk.ReliefStyle.NONE)
@@ -91,7 +92,8 @@ class Notebook(Gtk.Notebook):
     def _create_custom_tab(self, text, child):
         event_box = Gtk.EventBox()
 
-        tab_box = Gtk.HBox(False, 2)
+        tab_box = Gtk.Box(False, 2)
+        tab_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         tab_label = Gtk.Label(label=text)
 
         tab_button = Gtk.Button()
diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
index 4bb72ce..b389896 100644
--- a/src/sugar3/graphics/palette.py
+++ b/src/sugar3/graphics/palette.py
@@ -79,14 +79,17 @@ class Palette(PaletteWindow):
         self._icon_visible = True
         self._palette_state = self.PRIMARY
 
-        self._primary_box = Gtk.HBox()
+        self._primary_box = Gtk.Box()
+        self._primary_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         self._primary_box.show()
 
-        self._icon_box = Gtk.HBox()
+        self._icon_box = Gtk.Box()
+        self._icon_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         self._icon_box.set_size_request(style.GRID_CELL_SIZE, -1)
         self._primary_box.pack_start(self._icon_box, False, True, 0)
 
-        labels_box = Gtk.VBox()
+        labels_box = Gtk.Box()
+        labels_box.set_orientation(Gtk.Orientation.VERTICAL)
         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,
@@ -113,9 +116,11 @@ class Palette(PaletteWindow):
 
         labels_box.pack_start(self._secondary_label, True, True, 0)
 
-        self._secondary_box = Gtk.VBox()
+        self._secondary_box = Gtk.Box()
+        self._secondary_box.set_orientation(Gtk.Orientation.VERTICAL)
 
-        self._separator = Gtk.HSeparator()
+        self._separator = Gtk.Separator()
+        self._separator.set_orientation(Gtk.Orientation.HORIZONTAL)
         self._secondary_box.pack_start(self._separator, True, True, 0)
 
         self._secondary_anim = animator.Animator(2.0, 10)
@@ -204,7 +209,8 @@ class Palette(PaletteWindow):
 
     def _add_content(self):
         # The content is not shown until a widget is added
-        self._content = Gtk.VBox()
+        self._content = Gtk.Box()
+        self._content.set_orientation(Gtk.Orientation.VERTICAL)
         self._content.set_border_width(style.DEFAULT_SPACING)
         self._secondary_box.pack_start(self._content, True, True, 0)
 
@@ -304,7 +310,8 @@ class Palette(PaletteWindow):
             self._widget = _PaletteWindowWidget(self)
             self._setup_widget()
 
-            self._palette_box = Gtk.VBox()
+            self._palette_box = Gtk.Box()
+            self._palette_box.set_orientation(Gtk.Orientation.VERTICAL)
             self._palette_box.pack_start(self._primary_box, False, True, 0)
             self._palette_box.pack_start(self._secondary_box, True, True, 0)
 
@@ -396,7 +403,7 @@ class Palette(PaletteWindow):
     menu = GObject.property(type=object, getter=get_menu)
 
 
-class PaletteActionBar(Gtk.HButtonBox):
+class PaletteActionBar(Gtk.ButtonBox):
 
     def add_action(self, label, icon_name=None):
         button = Gtk.Button(label)
@@ -409,6 +416,10 @@ class PaletteActionBar(Gtk.HButtonBox):
         self.pack_start(button, True, True, 0)
         button.show()
 
+    def __init__(self):
+        GObject.GObject.__init__(self)
+        self.set_orientation(Gtk.Orientation.HORIZONTAL)
+
 
 class _SecondaryAnimation(animator.Animation):
 
diff --git a/src/sugar3/graphics/panel.py b/src/sugar3/graphics/panel.py
index c254c21..8b7126d 100644
--- a/src/sugar3/graphics/panel.py
+++ b/src/sugar3/graphics/panel.py
@@ -23,9 +23,10 @@ from gi.repository import Gtk
 from gi.repository import GObject
 
 
-class Panel(Gtk.VBox):
+class Panel(Gtk.Box):
 
     __gtype_name__ = 'SugarPanel'
 
     def __init__(self):
         GObject.GObject.__init__(self)
+        self.set_orientation(Gtk.Orientation.VERTICAL)
diff --git a/src/sugar3/graphics/radiopalette.py b/src/sugar3/graphics/radiopalette.py
index c2ff4f6..beae120 100644
--- a/src/sugar3/graphics/radiopalette.py
+++ b/src/sugar3/graphics/radiopalette.py
@@ -63,7 +63,8 @@ class RadioPalette(Palette):
     def __init__(self, **kwargs):
         Palette.__init__(self, **kwargs)
 
-        self.button_box = Gtk.HBox()
+        self.button_box = Gtk.Box()
+        self.button_box.set_orientation(Gtk.Orientation.HORIZONTAL)
         self.button_box.show()
         self.set_content(self.button_box)
 
diff --git a/src/sugar3/graphics/toolbarbox.py b/src/sugar3/graphics/toolbarbox.py
index 7e317f7..8ff63b8 100644
--- a/src/sugar3/graphics/toolbarbox.py
+++ b/src/sugar3/graphics/toolbarbox.py
@@ -140,10 +140,11 @@ class ToolbarButton(ToolButton):
         return False
 
 
-class ToolbarBox(Gtk.VBox):
+class ToolbarBox(Gtk.Box):
 
     def __init__(self, padding=style.TOOLBOX_HORIZONTAL_PADDING):
         GObject.GObject.__init__(self)
+        self.set_orientation(Gtk.Orientation.VERTICAL)
         self._expanded_button_index = -1
         self.background = None
 
diff --git a/src/sugar3/graphics/toolbox.py b/src/sugar3/graphics/toolbox.py
index fedca0b..60700ce 100644
--- a/src/sugar3/graphics/toolbox.py
+++ b/src/sugar3/graphics/toolbox.py
@@ -25,7 +25,7 @@ from gi.repository import GObject
 from sugar3.graphics import style
 
 
-class Toolbox(Gtk.VBox):
+class Toolbox(Gtk.Box):
 
     __gtype_name__ = 'SugarToolbox'
 
@@ -36,6 +36,7 @@ class Toolbox(Gtk.VBox):
 
     def __init__(self):
         GObject.GObject.__init__(self)
+        self.set_orientation(Gtk.Orientation.VERTICAL)
 
         self._notebook = Gtk.Notebook()
         self._notebook.set_tab_pos(Gtk.PositionType.BOTTOM)
@@ -46,7 +47,8 @@ class Toolbox(Gtk.VBox):
         self.pack_start(self._notebook, True, True, 0)
         self._notebook.show()
 
-        self._separator = Gtk.HSeparator()
+        self._separator = Gtk.Separator()
+        self._separator.set_orientation(Gtk.Orientation.HORIZONTAL)
         self._separator.modify_bg(Gtk.StateType.NORMAL,
                                   style.COLOR_PANEL_GREY.get_gdk_color())
         self._separator.set_size_request(1, style.TOOLBOX_SEPARATOR_HEIGHT)
diff --git a/src/sugar3/graphics/toolcombobox.py b/src/sugar3/graphics/toolcombobox.py
index 90bd1f4..798726c 100644
--- a/src/sugar3/graphics/toolcombobox.py
+++ b/src/sugar3/graphics/toolcombobox.py
@@ -40,7 +40,8 @@ class ToolComboBox(Gtk.ToolItem):
 
         self.set_border_width(style.DEFAULT_PADDING)
 
-        hbox = Gtk.HBox(False, style.DEFAULT_SPACING)
+        hbox = Gtk.Box(False, style.DEFAULT_SPACING)
+        hbox.set_orientation(Gtk.Orientation.HORIZONTAL)
 
         self.label = Gtk.Label(label=self._label_text)
         hbox.pack_start(self.label, False, False, 0)
diff --git a/src/sugar3/graphics/tray.py b/src/sugar3/graphics/tray.py
index d1c0cfd..a9d6d79 100644
--- a/src/sugar3/graphics/tray.py
+++ b/src/sugar3/graphics/tray.py
@@ -223,7 +223,7 @@ ALIGN_TO_START = 0
 ALIGN_TO_END = 1
 
 
-class HTray(Gtk.HBox):
+class HTray(Gtk.Box):
 
     __gtype_name__ = 'SugarHTray'
 
@@ -238,6 +238,7 @@ class HTray(Gtk.HBox):
         self.align = ALIGN_TO_START
 
         GObject.GObject.__init__(self, **kwargs)
+        self.set_orientation(Gtk.Orientation.HORIZONTAL)
 
         scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE)
         self.pack_start(scroll_left, False, False, 0)
@@ -309,7 +310,7 @@ class HTray(Gtk.HBox):
         self._viewport.scroll_to_item(item)
 
 
-class VTray(Gtk.VBox):
+class VTray(Gtk.Box):
 
     __gtype_name__ = 'SugarVTray'
 
@@ -324,6 +325,7 @@ class VTray(Gtk.VBox):
         self.align = ALIGN_TO_START
 
         GObject.GObject.__init__(self, **kwargs)
+        self..set_orientation(Gtk.Orientation.VERTICAL)
 
         scroll_up = _TrayScrollButton('go-up', _PREVIOUS_PAGE)
         self.pack_start(scroll_up, False, False, 0)
diff --git a/src/sugar3/graphics/window.py b/src/sugar3/graphics/window.py
index 2d9764d..1a955c7 100644
--- a/src/sugar3/graphics/window.py
+++ b/src/sugar3/graphics/window.py
@@ -99,8 +99,10 @@ class Window(Gtk.Window):
         self._canvas = None
         self.tray = None
 
-        self.__vbox = Gtk.VBox()
-        self.__hbox = Gtk.HBox()
+        self.__vbox = Gtk.Box()
+        self.__vbox.set_orientation(Gtk.Orientation.VERTICAL)
+        self.__hbox = Gtk.Box()
+        self.__hbox.set_orientation(Gtk.Orientation.HORIZONTAL)
         self.__vbox.pack_start(self.__hbox, True, True, 0)
         self.__hbox.show()
 
-- 
1.7.10.2



More information about the Sugar-devel mailing list