gnome-scan r680 - in trunk: . lib



Author: bersace
Date: Sun Dec 14 15:58:58 2008
New Revision: 680
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=680&view=rev

Log:
Auto scroll long option page.

Modified:
   trunk/ChangeLog
   trunk/lib/gnome-scan-dialog.vala
   trunk/lib/gnome-scan-option-page.vala

Modified: trunk/lib/gnome-scan-dialog.vala
==============================================================================
--- trunk/lib/gnome-scan-dialog.vala	(original)
+++ trunk/lib/gnome-scan-dialog.vala	Sun Dec 14 15:58:58 2008
@@ -252,7 +252,7 @@
 				return;
 			}
 
-			this.append_page(page_id, label, new OptionVPage());
+			this.append_page(page_id, label, new OptionVPage(true));
 		}
 
 		private void append_page(int tab, string? label, Container page)
@@ -262,7 +262,8 @@
 
 			if (label != null) {
 				Widget tab_label = new Label.with_mnemonic(label);
-				page.border_width = 12;
+				if (page.border_width == 0)
+					page.border_width = 12;
 				this.notebook.append_page(page, tab_label);
 			}
 			this.pages[tab] = page;

Modified: trunk/lib/gnome-scan-option-page.vala
==============================================================================
--- trunk/lib/gnome-scan-option-page.vala	(original)
+++ trunk/lib/gnome-scan-option-page.vala	Sun Dec 14 15:58:58 2008
@@ -25,14 +25,46 @@
 namespace Gnome.Scan {
 	// waiting for Gtk+ 2.16 for extendings directly Gtk.Box :)
     public abstract class OptionPage : Alignment {
-		public Box container { get;set construct; }
+		public bool scrolled {get; set construct; default = false; }
+		private Box _container;
+		public Box container {
+			get {
+				return _container;
+			}
+			set {
+				if (this.scrolled) {
+					value.border_width = 6;
+					viewport.add(value);
+				}
+				else {
+					this.add(value);
+				}
+				_container = value;
+			}
+		}
+		private ScrolledWindow scrowin;
+		private Viewport viewport;
 		private HashTable<string,OptionBox> boxes;
+		int scroll_height;
 		int box_visible_count = 0;
 		int box_expanding_count = 0;
 
 		construct {
 			this.boxes = new HashTable<string,OptionBox>(GLib.str_hash, GLib.str_equal);
 			this.no_show_all = true;
+			if (scrolled) {
+				this.border_width = 6;
+				scrowin = new ScrolledWindow(null, null);
+				this.add(scrowin);
+				scrowin.shadow_type = ShadowType.NONE;
+				scrowin.hscrollbar_policy = PolicyType.NEVER;
+				scrowin.vscrollbar_policy = PolicyType.AUTOMATIC;
+				this.viewport = new Viewport(scrowin.hadjustment, scrowin.vadjustment);
+				viewport.shadow_type = ShadowType.NONE;
+				scrowin.add(viewport);
+				scrowin.size_allocate += this.on_size_allocate;
+				viewport.size_allocate += this.on_viewport_size_allocate;
+			}
 		}
 
 		public void pack_option(Option option)
@@ -77,19 +109,45 @@
 				this.show_all();
 			}
 		}
+
+		private void update_shadow_type()
+		{
+			Requisition req;
+			viewport.size_request(out req);
+			if (this.scroll_height < req.height) {
+				scrowin.shadow_type = ShadowType.IN;
+			}
+			else {
+				scrowin.shadow_type = ShadowType.NONE;
+			}
+		}
+
+		private void on_size_allocate(ScrolledWindow scrowin, Gdk.Rectangle alloc)
+		{
+			this.scroll_height = alloc.height;
+			this.update_shadow_type();
+		}
+
+		private void on_viewport_size_allocate(Viewport vp, Gdk.Rectangle alloc)
+		{
+			this.update_shadow_type();
+		}
     }
 
     public class OptionVPage : OptionPage {
 		construct {
 			this.container = new VBox(false, 6);
-			this.add(this.container);
+		}
+
+		public OptionVPage(bool scrolled = false)
+		{
+			this.scrolled = scrolled;
 		}
     }
 
     public class OptionHPage : OptionPage {
 		construct {
 			this.container = new HBox(false, 6);
-			this.add(this.container);
 		}
     }
 }



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