[baobab/wip/grid-layout: 3/9] Autoresize horizontal paned
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/grid-layout: 3/9] Autoresize horizontal paned
- Date: Sun, 15 Apr 2012 13:27:32 +0000 (UTC)
commit d602576bdb667487d78827d4aed19e00739c354a
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, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index dae5689..552f193 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -35,6 +35,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;
@@ -128,10 +129,13 @@ 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);
+ setup_paned_autoresize ();
+
var infobar_close_button = builder.get_object ("infobar-close-button") as Gtk.Button;
infobar_close_button.clicked.connect (() => { clear_message (); });
@@ -438,6 +442,28 @@ namespace Baobab {
});
}
+ void setup_paned_autoresize () {
+ double fraction = 0.5;
+ bool manual_resize = true;
+
+ configure_event.connect ((event) => {
+ horizontal_paned.position = (int) ( ((Gdk.EventConfigure) event).width * fraction);
+ manual_resize = false;
+
+ return false;
+ });
+
+ horizontal_paned.notify["position"].connect ((sender, property) => {
+ if (!manual_resize) {
+ manual_resize = true;
+ return;
+ }
+
+ var width = get_allocated_width ();
+ fraction = (double) horizontal_paned.position / width;
+ });
+ }
+
void message (string primary_msg, string secondary_msg, Gtk.MessageType type) {
infobar.message_type = type;
infobar_primary.set_label ("<b>%s</b>".printf (_(primary_msg)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]