From 8397d785c26616413891f6255e539a11eacb071e Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Mon, 08 Apr 2013 18:16:46 +0000 Subject: Resize scrolled window on screen rotate - SL #4479 Is needed to put the piano at the border of the screen. The implementatation is a little tricky, but I didn't found any other solution. Signed-off-by: Gonzalo Odiard --- diff --git a/activity.py b/activity.py index 9416d77..32266a6 100644 --- a/activity.py +++ b/activity.py @@ -15,6 +15,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk +from gi.repository import GLib from gi.repository import Gdk from gi.repository import GdkPixbuf import logging @@ -153,14 +154,25 @@ class SimplePianoActivity(activity.Activity): vbox.set_homogeneous(False) self.load_instruments() vbox.pack_end(self.piano, True, True, 0) - scrolled = Gtk.ScrolledWindow() - vbox.pack_start(scrolled, False, False, 0) - scrolled.add(self.instruments_iconview) + self.scrolled = Gtk.ScrolledWindow() + vbox.pack_start(self.scrolled, False, False, 0) + self.scrolled.add(self.instruments_iconview) vbox.show_all() self.set_canvas(vbox) piano_height = Gdk.Screen.width() / 2 - scrolled.set_size_request( + self.scrolled.set_size_request( -1, Gdk.Screen.height() - piano_height - style.GRID_CELL_SIZE) + self.connect('size-allocate', self.__allocate_cb) + + def __allocate_cb(self, widget, rect): + GLib.idle_add(self.resize, rect.width, rect.height) + return False + + def resize(self, width, height): + piano_height = width / 2 + self.scrolled.set_size_request( + -1, height - piano_height - style.GRID_CELL_SIZE) + return False def load_instruments(self): self._instruments_store = Gtk.ListStore(str, GdkPixbuf.Pixbuf, str) -- cgit v0.9.1