Added support for resizing window/image.
authorStanislaw Klekot <dozzie@jarowit.net>
Tue, 22 Oct 2013 17:44:33 +0000 (19:44 +0200)
committerStanislaw Klekot <dozzie@jarowit.net>
Tue, 22 Oct 2013 17:44:33 +0000 (19:44 +0200)
rrdplot

diff --git a/rrdplot b/rrdplot
index 4838961..f4e8f38 100755 (executable)
--- a/rrdplot
+++ b/rrdplot
@@ -17,6 +17,8 @@ class Base:
   def __init__(self):
     self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
     self.window.connect("destroy", self.destroy)
+    # why this is false by default?
+    self.window.set_property("allow-shrink", True)
 
     # some time later I'll use more widgets than just canvas
     vbox = gtk.VBox()
@@ -28,6 +30,18 @@ class Base:
     vbox.add(self.image)
 
     #-------------------------------------------------------
+    # resize signals {{{
+
+    def size_allocate_handler(widget, rect):
+      if self.rrdplot.width != rect.width or \
+         self.rrdplot.height != rect.height:
+        self.rrdplot.resize(width = rect.width, height = rect.height)
+        self.reload_image()
+
+    self.image.connect("size-allocate", size_allocate_handler)
+
+    # }}}
+    #-------------------------------------------------------
     # RRD plot object {{{
 
     self.rrdplot = rrdplot.plot.RRDPlot()