[Gtk-sharp-list] Entry/Viewport tweaks

Lee Mallabone gnome@fonicmonkey.net
28 Mar 2003 09:06:01 +0000


--=-ffC/dhjASGdyKlkUCG0C
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi all,

I've made a minor tweak to Entry.custom to allow an Entry to be
constructed with initial text in it. It surprised me this wasn't already
in Gtk+, so I added it here.

I've also made a sample using Viewport, attached. Should I commit it to
the sample directory?

Regards,

Lee.


--=-ffC/dhjASGdyKlkUCG0C
Content-Disposition: attachment; filename=entry.diff
Content-Type: text/x-patch; name=entry.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

Index: gtk/Entry.custom
===================================================================
RCS file: /cvs/public/gtk-sharp/gtk/Entry.custom,v
retrieving revision 1.2
diff -u -r1.2 Entry.custom
--- gtk/Entry.custom	24 Feb 2003 03:13:08 -0000	1.2
+++ gtk/Entry.custom	28 Mar 2003 09:02:20 -0000
@@ -12,3 +12,8 @@
 
 	return position;
 }
+
+public Entry(string initialText): this()
+{
+	Text = initialText;
+}

--=-ffC/dhjASGdyKlkUCG0C
Content-Disposition: attachment; filename=ViewportApp.cs
Content-Type: text/plain; name=ViewportApp.cs; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

// ViewportApp.cs - Gtk.Viewport class Test implementation
//
// Author: Lee Mallabone <gnome@fonicmonkey.net>
//
// (c) 2003 Lee Mallabone

namespace GtkSamples {

	using Gtk;
	using GtkSharp;
	using System;
	using System.Drawing;

	public class ViewportApp  {

		public static ScrolledWindow CreateViewport()
		{
			ScrolledWindow scroller = new ScrolledWindow();
			Viewport viewer = new Viewport();
			
			Table widgets = new Table(1, 2, false);
			
			widgets.Attach(new Entry("This is example Entry 1"), 0, 1, 0, 1);
			widgets.Attach(new Entry("This is example Entry 2"), 1, 2, 0, 1);
			
			// Place the widgets in a Viewport, and the Viewport in a ScrolledWindow
			viewer.Add(widgets);
			scroller.Add(viewer);
			return scroller;
		}
		public static int Main (string[] args)
		{
			Application.Init ();
			Window win = new Window ("Viewport Tester");
			win.DefaultSize = new Size (180, 50);
			win.DeleteEvent += new DeleteEventHandler (Window_Delete);
			ScrolledWindow scroller = CreateViewport();
			win.Add (scroller);
			win.ShowAll ();
			Application.Run ();
			return 0;
		}

		static void Window_Delete (object obj, DeleteEventArgs args)
		{
			Application.Quit ();
			args.RetVal = true;
		}

	}
}

--=-ffC/dhjASGdyKlkUCG0C--