diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-04-08 18:16:46 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-04-08 19:55:40 (GMT) |
commit | 8397d785c26616413891f6255e539a11eacb071e (patch) | |
tree | 8816c9815444029b8ec9f07dc976d84f2cf49dd2 | |
parent | dea0710410f69cac8c2f2464e0bff8f0048ba68a (diff) |
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 <gonzalo@laptop.org>
-rw-r--r-- | activity.py | 20 |
1 files changed, 16 insertions, 4 deletions
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) |