[Gtk-sharp-list] gtkdemo patch

jasper van putten jas_lists@gmx.net
Sat, 24 Jul 2004 22:43:51 +0200


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

Hi,

I have updated the GtkDemo. DemoApplicationWindow now shows the row and
colomns correctly in the statusbar.


Jasper van Putten

--=-7H8zgMXmo72YBDsBDJQL
Content-Description: 
Content-Disposition: attachment; filename=file.diff
Content-Type: text/x-patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: DemoApplicationWindow.cs
===================================================================
RCS file: /mono/gtk-sharp/sample/GtkDemo/DemoApplicationWindow.cs,v
retrieving revision 1.4
diff -u -r1.4 DemoApplicationWindow.cs
--- DemoApplicationWindow.cs	10 Feb 2004 20:35:40 -0000	1.4
+++ DemoApplicationWindow.cs	24 Jul 2004 20:32:40 -0000
@@ -22,6 +22,7 @@
 	public class DemoApplicationWindow
 	{
 		private Gtk.Window window;
+		private Statusbar statusbar;
 		// static ItemFactoryEntry items[] = { new ItemFactoryEntry ("/_File", null, 0, 0, "<Branch>" )};		
 
 	public DemoApplicationWindow ()
@@ -45,10 +46,13 @@
 			vbox.PackStart (toolbar, false, false, 0);
 			
 			TextView textview = new TextView ();
+			 
+			textview.Buffer.MarkSet += new MarkSetHandler (OnMarkSet);
+			System.Console.Write("test1");
 			vbox.PackStart (textview, true, true, 0);
 			
-			Statusbar statusbar = new Statusbar ();
-			statusbar.Push (1, "Cursor at row 0 column 0 - 0 chars in document");
+			statusbar = new Statusbar ();
+			statusbar.Push (1, "Cursor at row {0} column {0} - {0} chars in document");
 			vbox.PackStart (statusbar, false, false, 0);
 
 			//ItemFactory itemFactory = new ItemFactory (typeof (MenuBar),"<main>", accelGroup);
@@ -65,7 +69,7 @@
 			
 			window.ShowAll ();
 		}
-		
+				
 		private MenuBar CreateMenu ()
 		{
 			MenuBar menubar = new MenuBar ();
@@ -92,6 +96,20 @@
 			
 			return toolbar;
 		}
+		
+		private void OnMarkSet(object o, MarkSetArgs args)
+		{
+		Gtk.TextBuffer  buffer =(Gtk.TextBuffer) o;		
+		TextIter iter = args.Location;
+		UpdateStatusBar(iter,buffer);
+		}
+		
+		private void UpdateStatusBar  (TextIter iter,Gtk.TextBuffer  buffer)
+		{	
+		String text=  String.Format("Cursor at row {0} column {1} - {2} chars in document",iter.Line,iter.Offset,buffer.CharCount);
+		statusbar.Push (1, text);
+		}
+		
 		
 		private void OnToolbarClicked (object o, EventArgs args)
 		{

--=-7H8zgMXmo72YBDsBDJQL--