From 0bfab3d5f5b1c74bf866402dd8cd5a33643cd7df Mon Sep 17 00:00:00 2001
From: Steven M. Parrish <smparrish@gmail.com>
Date: Fri, 1 Oct 2010 21:03:48 -0400
Subject: [PATCH] Fix for SL#2256

---
 sugar/view.py |   43 ++++++++++++++++++++++++++++++++-----------
 1 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/sugar/view.py b/sugar/view.py
index 640d2dd..bf7f239 100644
--- a/sugar/view.py
+++ b/sugar/view.py
@@ -1,4 +1,5 @@
 # Copyright (C) 2009 One Laptop per Child
+# Copyright (C) 2010 Plan Ceibal <comunidad@plan.ceibal.edu.uy>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -41,29 +42,38 @@ class SwitchDesktop(SectionView):
         self.set_border_width(style.DEFAULT_SPACING * 2)
         self.set_spacing(style.DEFAULT_SPACING)
 
+        self._scrollwindow = gtk.ScrolledWindow()
+        self._scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        self.pack_start(self._scrollwindow, expand=True)
+        self._scrollwindow.show()
+
+        self._vbox_section = gtk.VBox()
+        self._scrollwindow.add_with_viewport(self._vbox_section)
+        self._vbox_section.show()
+
         self._active_desktop_label = gtk.Label()
-        self.pack_start(self._active_desktop_label, False)
+        self._vbox_section.pack_start(self._active_desktop_label, False)
 
         self._sugar_desc_label = gtk.Label(
             _("Sugar is the graphical user interface that you are looking at. "
               "It is a learning environment designed for children."))
         self._sugar_desc_label.set_size_request(gtk.gdk.screen_width() / 2, -1)
         self._sugar_desc_label.set_line_wrap(True)
-        self.pack_start(self._sugar_desc_label, False)
+        self._vbox_section.pack_start(self._sugar_desc_label, False)
 
         self._gnome_opt_label = gtk.Label(
             _("As an alternative to Sugar, you can switch to the GNOME "
               "desktop environment by clicking the button below."))
         self._gnome_opt_label.set_line_wrap(True)
         self._gnome_opt_label.set_size_request(gtk.gdk.screen_width() / 2, -1)
-        self.pack_start(self._gnome_opt_label, False)
+        self._vbox_section.pack_start(self._gnome_opt_label, False)
 
         self._restart_label = gtk.Label(
             _("Restart your computer to complete the change to the GNOME "
               "desktop environment."))
         self._restart_label.set_line_wrap(True)
         self._restart_label.set_size_request(gtk.gdk.screen_width() / 2, -1)
-        self.pack_start(self._restart_label, False)
+        self._vbox_section.pack_start(self._restart_label, False)
 
         self._undo_return_label = gtk.Label()
         self._undo_return_label.set_markup(
@@ -73,11 +83,11 @@ class SwitchDesktop(SectionView):
               "continue using Sugar as your desktop environment."))
         self._undo_return_label.set_line_wrap(True)
         self._undo_return_label.set_size_request(gtk.gdk.screen_width() / 2, -1)
-        self.pack_start(self._undo_return_label, False)
+        self._vbox_section.pack_start(self._undo_return_label, False)
 
 
         self._switch_align = gtk.Alignment(xalign=0.5, yalign=0.5)
-        self.pack_start(self._switch_align)
+        self._vbox_section.pack_start(self._switch_align)
 
         self._switch_button = gtk.Button(_("Switch to GNOME"))
         self._switch_button.set_image(Icon(icon_name="module-switch-desktop"))
@@ -85,7 +95,7 @@ class SwitchDesktop(SectionView):
 
 
         self._undo_align = gtk.Alignment(xalign=0.5, yalign=0.5)
-        self.pack_start(self._undo_align)
+        self._vbox_section.pack_start(self._undo_align)
 
         hbox = gtk.HButtonBox()
         hbox.set_layout(gtk.BUTTONBOX_END)
@@ -101,7 +111,7 @@ class SwitchDesktop(SectionView):
         hbox.add(self._restart_button)
 
         self._unknown_align = gtk.Alignment(xalign=0.5, yalign=0.5)
-        self.pack_start(self._unknown_align)
+        self._vbox_section.pack_start(self._unknown_align)
 
         self._fix_unknown_button = gtk.Button(_("Set Sugar as active desktop"))
         self._fix_unknown_button.set_image(Icon(icon_name="computer-xo"))
@@ -114,10 +124,10 @@ class SwitchDesktop(SectionView):
               "from the GNOME <b>Applications</b> menu."))
         self._return_label.set_line_wrap(True)
         self._return_label.set_size_request(gtk.gdk.screen_width() / 2, -1)
-        self.pack_start(self._return_label, False)
+        self._vbox_section.pack_start(self._return_label, False)
 
         self._img_table = gtk.Table(rows=2, columns=2)
-        self.pack_start(self._img_table, False);
+        self._vbox_section.pack_start(self._img_table, False);
 
         img_path = os.path.join(config.ext_path, 'cpsection', 'switchdesktop')
 
@@ -151,7 +161,7 @@ class SwitchDesktop(SectionView):
 
     def _update(self):
         self.hide_all()
-        self.show()
+        self.show_all()
 
         active = self._model.get_active_desktop()
         self._active_desktop_label.set_markup("<big>" + _("Active desktop environment: ")
@@ -159,11 +169,22 @@ class SwitchDesktop(SectionView):
         self._active_desktop_label.show()
         
         if active == "Sugar":
+            self._restart_label.hide()
+            self._undo_return_label.hide()
+            self._undo_align.hide_all()
+            self._unknown_align.hide_all()
+
             self._sugar_desc_label.show()
             self._gnome_opt_label.show()
             self._switch_align.show_all()
             self._return_label.show()
         elif active == "GNOME":
+            self._unknown_align.hide_all()
+            self._sugar_desc_label.hide()
+            self._gnome_opt_label.hide()
+            self._switch_align.hide_all()
+            self._return_label.hide()
+
             self._restart_label.show()
             self._undo_return_label.show()
             self._undo_align.show_all()
-- 
1.7.2.3

