diff options
author | Walter Bender <walter.bender@gmail.com> | 2013-02-25 13:08:35 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2013-02-27 13:48:18 (GMT) |
commit | 692c95f3fc673e039e56ab1f4ae538964031db89 (patch) | |
tree | 54a2ccc6a1e7142fe2969c09e2d08405afbace24 | |
parent | c6e19b4df9e8c1a4216aa09b9c579b43da9684d2 (diff) |
Control Panel: handle switching between landscape and portrait mode, SL #4444
When the control panel is opened for the first time, a table is
generated with a number of columns based on screen width. If the
screen is subsequently rotated, the column number is no longer
correct. In addition, the scrolled window holding the table needs to
be resized so that it fits on the screen.
This patch removes the section icons and sets it up again to
recompute the number of columns and to resize the window and
it's containing table.
Signed-off-by: Walter Bender <walter.bender@gmail.com>
Signed-off-by: Manuel QuiƱones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r-- | src/jarabe/controlpanel/gui.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/jarabe/controlpanel/gui.py b/src/jarabe/controlpanel/gui.py index f28b248..c61fb4e 100644 --- a/src/jarabe/controlpanel/gui.py +++ b/src/jarabe/controlpanel/gui.py @@ -42,14 +42,8 @@ class ControlPanel(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) - self._max_columns = int(0.285 * (float(Gdk.Screen.width()) / - style.GRID_CELL_SIZE - 3)) - + self._calculate_max_columns() self.set_border_width(style.LINE_WIDTH) - offset = style.GRID_CELL_SIZE - width = Gdk.Screen.width() - offset * 2 - height = Gdk.Screen.height() - offset * 2 - self.set_size_request(width, height) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_decorated(False) self.set_resizable(False) @@ -88,15 +82,31 @@ class ControlPanel(Gtk.Window): self._setup_main() self._setup_section() self._show_main_view() + Gdk.Screen.get_default().connect('size-changed', self.__size_changed_cb) def __realize_cb(self, widget): self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.get_window().set_accept_focus(True) + def __size_changed_cb(self, event): + self._calculate_max_columns() + def grab_focus(self): # overwrite grab focus in order to grab focus on the view self._main_view.get_child().grab_focus() + def _calculate_max_columns(self): + self._max_columns = int(0.285 * (float(Gdk.Screen.width()) / + style.GRID_CELL_SIZE - 3)) + offset = style.GRID_CELL_SIZE + width = Gdk.Screen.width() - offset * 2 + height = Gdk.Screen.height() - offset * 2 + self.set_size_request(width, height) + if hasattr(self, '_table'): + for child in self._table.get_children(): + child.destroy() + self._setup_options() + def _set_canvas(self, canvas): if self._canvas: self._main_view.remove(self._canvas) |