[Mono-docs-list] Patch for monodoc

Richard Torkar richard.torkar@htu.se
Sun, 12 Oct 2003 02:17:30 +0200


--=-6uB8h7tKeSc8uQn+Ag8q
Content-Type: text/plain
Content-Transfer-Encoding: 7bit


Attached is a patch for monodoc adding Alt_L+Left|Right for back and
forward functionality. I rarely use a mice *grin*

What this patch does is:

browser.cs
1. Add an eventhandler for keypress
2. Add keypress_event_cb for dealing with these events

history.cs
3. Add internal as an access modifier to BackClicked and ForwardClicked,
thus reusing these methods instead of using code duplication.

/Richard
-- 
"UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity."

--=-6uB8h7tKeSc8uQn+Ag8q
Content-Disposition: attachment; filename=keypress.diff
Content-Type: text/x-patch; name=keypress.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Index: browser.cs
===================================================================
RCS file: /mono/monodoc/browser/browser.cs,v
retrieving revision 1.68
diff -u -p -r1.68 browser.cs
--- browser.cs	2 Oct 2003 22:59:36 -0000	1.68
+++ browser.cs	12 Oct 2003 00:01:23 -0000
@@ -149,8 +149,9 @@ class Browser {
 
 		MainWindow = (Gtk.Window) ui["window1"];
 		MainWindow.DeleteEvent += new DeleteEventHandler (delete_event_cb);
-                
-                Stream icon = GetResourceImage ("monodoc.png");
+		MainWindow.KeyPressEvent += new KeyPressEventHandler (keypress_event_cb);
+		
+		Stream icon = GetResourceImage ("monodoc.png");
 
                 if (icon != null){
 			monodoc_pixbuf = new Gdk.Pixbuf (icon);
@@ -389,6 +390,24 @@ class Browser {
 			statusbar.Pop (context_id);
 			statusbar.Push (context_id, new_url);
 			last_url = new_url;
+		}
+	}
+	
+	void keypress_event_cb (object o, KeyPressEventArgs args)
+	{
+		switch (args.Event.Key) {
+		case Gdk.Key.Left:
+			if (((Gdk.ModifierType) args.Event.state & 
+					Gdk.ModifierType.Mod1Mask) !=0)
+				history.BackClicked (this, EventArgs.Empty);
+			args.RetVal = true;
+			break;
+		case Gdk.Key.Right:
+			if (((Gdk.ModifierType) args.Event.state & 
+					Gdk.ModifierType.Mod1Mask) !=0)
+			history.ForwardClicked (this, EventArgs.Empty);
+			args.RetVal = true;
+			break;
 		}
 	}
 	
Index: history.cs
===================================================================
RCS file: /mono/monodoc/browser/history.cs,v
retrieving revision 1.5
diff -u -p -r1.5 history.cs
--- history.cs	5 Sep 2003 04:31:34 -0000	1.5
+++ history.cs	12 Oct 2003 00:01:23 -0000
@@ -52,7 +52,7 @@ public class History {
 		p.Go ();
 	}
 
-	void BackClicked (object o, EventArgs args)
+	internal void BackClicked (object o, EventArgs args)
 	{
 		if (pos < 1)
 			return;
@@ -66,7 +66,7 @@ public class History {
 		forward.Sensitive = true;
 	}
 
-	void ForwardClicked (object o, EventArgs args)
+	internal void ForwardClicked (object o, EventArgs args)
 	{
 		if (pos+1 == history.Count)
 			return;

--=-6uB8h7tKeSc8uQn+Ag8q--