[baobab/wip/grid-layout: 6/8] Autoresize horizontal paned



commit 52a92989341c65eb86918071715e826a68773cd5
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Wed Apr 11 19:01:45 2012 +0200

    Autoresize horizontal paned

 src/baobab-window.vala |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 8c5b974..e87d014 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -33,6 +33,7 @@ namespace Baobab {
         Gtk.TreeView treeview;
         Gtk.Notebook chart_notebook;
         Gtk.Grid location_view;
+        Gtk.Paned horizontal_paned;
         Chart rings_chart;
         Chart treemap_chart;
         Gtk.Spinner spinner;
@@ -124,6 +125,7 @@ namespace Baobab {
             treemap_chart = builder.get_object ("treemap-chart") as Chart;
             spinner = builder.get_object ("spinner") as Gtk.Spinner;
             location_view = builder.get_object ("location-view") as Gtk.Grid;
+            horizontal_paned = builder.get_object ("hpaned") as Gtk.Paned;
 
             setup_home_page ();
             setup_treeview (builder);
@@ -146,8 +148,30 @@ namespace Baobab {
 
             add (builder.get_object ("window-contents") as Gtk.Widget);
             title = _("Disk Usage Analyzer");
-            set_default_size (800, 500);
+            set_default_size (900, 600);
             set_hide_titlebar_when_maximized (true);
+            maximize ();
+
+            double paned_fraction = 0.5;
+            bool manual_resize = true;
+            this.configure_event.connect ((sender, property) => {
+                    int width;
+                    get_size (out width, null);
+                    horizontal_paned.position = (int) (width * paned_fraction);
+                    manual_resize = false;
+
+                    return false;
+                });
+            horizontal_paned.notify["position"].connect ((sender, property) => {
+                    if (!manual_resize) {
+                        manual_resize = true;
+                        return;
+                    }
+
+                    int width;
+                    get_size (out width, null);
+                    paned_fraction = (double) horizontal_paned.position / width;
+                });
 
             set_ui_page (UIPage.HOME);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]