Ticket #3827: 0001-Reset-Layout-when-the-allocation-changes-SL-3827.patch

File 0001-Reset-Layout-when-the-allocation-changes-SL-3827.patch, 2.3 KB (added by erikos, 12 years ago)

Reset Layout when the allocation changes

  • src/jarabe/desktop/favoriteslayout.py

    From 40e9de99743b7d594b70ff638e78533fd28313c2 Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@laptop.org>
    Date: Mon, 8 Oct 2012 15:31:15 +0200
    Subject: [PATCH shell] Reset Layout when the allocation changes, SL #3827
    
    In the HomeWindow we listen to the size-changed signal and
    resize the window in that case. This will be triggered by
    the ViewContainer and the ViewLayout. In those cases we
    have to recreate the grid with the new dimensions.
    
    Signed-off-by: Simon Schampijer <simon@laptop.org>
    ---
     src/jarabe/desktop/favoriteslayout.py | 8 +++++++-
     src/jarabe/desktop/viewcontainer.py   | 3 +++
     2 files changed, 10 insertions(+), 1 deletion(-)
    
    diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
    index e9f614e..3c9be8b 100644
    a b class Layout(object): 
    5555class ViewLayout(Layout):
    5656    def __init__(self):
    5757        self._grid = None
     58        self._width = 0
     59        self._height = 0
    5860
    5961    def setup(self, allocation, owner_icon, activity_icon=None):
    6062        if self._grid is not None:
    61             return
     63            if self._width == allocation.width and \
     64                    self._height == allocation.height:
     65                return
     66        self._width = allocation.width
     67        self._height = allocation.height
    6268        self._grid = Grid(int(allocation.width / _CELL_SIZE),
    6369                          int(allocation.height / _CELL_SIZE))
    6470        self._grid.connect('child-changed', self.__grid_child_changed_cb)
  • src/jarabe/desktop/viewcontainer.py

    diff --git a/src/jarabe/desktop/viewcontainer.py b/src/jarabe/desktop/viewcontainer.py
    index 76f5a69..5e39a80 100644
    a b  
    1717# along with this program; if not, write to the Free Software
    1818# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1919
     20import logging
     21
    2022from gi.repository import Gtk
    2123
    2224
    class ViewContainer(Gtk.Container): 
    6264                self.queue_resize()
    6365
    6466    def do_size_allocate(self, allocation):
     67        logging.debug('==> Viewcontainer: w=%s h=%s', allocation.width, allocation.height)
    6568        self.set_allocation(allocation)
    6669        if self._owner_icon:
    6770            self._layout.setup(allocation, self._owner_icon,