[Mono-dev] Monodoc patch

Kevin Reay kevintreay at gmail.com
Thu Mar 15 03:14:19 EDT 2007


Hi,

I'm wondering if I could get someone to look at the following patch
I've crafted to fix some bugs and add some features to the monodoc
tool. The patch is against subversion revision 74230 (current trunk).
I'm not sure if these should be grouped together in one patch; if the
expectation is different, please let me know.

The patch changes the following things:
- Fixes bug 80575 (http://bugzilla.ximian.com/show_bug.cgi?id=80575)
(missing compare for null class reference)
- Groups contribution-specific functionality to new dedicated menu (to
allow for more contribution specific functionality in the future)
- Adds contributor statistics feature
- A few minor code tweaks/nitpicks

Also, I uploaded to updates to the class doc. I'm just wondering if
anyone has had a chance to read them over. I'd like to know if I
should continue documenting things in that style.

Finally, I'm hoping to add some new contributor features (thus the
creation of the Contributing menu) and would like anyones opinion on
whether the creation of a small list window to display the
contributions pending for upload would be something people would want.
It is something I would use.

Thanks,
Kevin Reay

Ps, I've attached the patch, as well as uploaded it
(http://www.explodingrobot.com/mono/monodoc.patch0.txt) in case the
mailing list strips attachments. Code released with whatever license
is necessary, of course (MIT X11 is fine).
-------------- next part --------------
Index: browser.cs
===================================================================
--- browser.cs	(revision 74230)
+++ browser.cs	(working copy)
@@ -826,14 +826,14 @@
 		// postcomment.Sensitive = comments1.Active;
 
 		// refresh, so we can see the comments
-		if (CurrentTab.history != null) // catch the case when we are currently loading
+		if (CurrentTab != null && CurrentTab.history != null) // catch the case when we are currently loading
 			CurrentTab.history.ActivateCurrent ();
 	}
 	
 	void OnInheritedMembersActivate (object o, EventArgs args)
 	{
 		SettingsHandler.Settings.ShowInheritedMembers = showinheritedmembers.Active;
-		if (CurrentTab.history != null) // catch the case when we are currently loading
+		if (CurrentTab != null && CurrentTab.history != null) // catch the case when we are currently loading
 			CurrentTab.history.ActivateCurrent ();
 	}
 
@@ -842,7 +842,7 @@
 		SettingsHandler.Settings.EnableEditing = editing1.Active;
 
 		// refresh, so we can see the [edit] things
-		if (CurrentTab != null) // catch the case when we are currently loading
+		if (CurrentTab != null && CurrentTab.history != null) // catch the case when we are currently loading
 			CurrentTab.history.ActivateCurrent ();
 	}
 	
@@ -873,7 +873,6 @@
 	//
 	// Invoked when the user presses a key on the index_entry
 	//
-
 	public void OnIndexEntryKeyPress (object o, KeyPressEventArgs args)
 	{
 		args.RetVal = true;
@@ -1368,7 +1367,113 @@
 		}
 	}
 
+	void OnContributionStatistics (object sender, EventArgs a)
+	{
+		string email = SettingsHandler.Settings.Email;
+		string key = SettingsHandler.Settings.Key;
+		
+		if (key == null || key == "") {
+			MessageDialog md = new MessageDialog (null, 
+							      DialogFlags.DestroyWithParent,
+							      MessageType.Info, 
+							      ButtonsType.Close, 
+				                  "You have not obtained or used a contribution key yet.");
+			md.Title = "No contribution key";
+			
+			md.Run();
+			md.Destroy();
+		}
+		else
+			ContributionStatus.GetStatus (email, key);
+	}
+	
+	class ContributionStatus {
+		enum State {
+			GetStatusError,
+			NetworkError,
+			Done
+		}
 
+		State state;
+		Status status;
+		string contributoremail;
+		
+		ThreadNotify tn;
+		WebClientAsyncResult war;
+		ContributionsSoap d;
+		
+		public static void GetStatus (string email, string key)
+		{
+			new ContributionStatus(email, key);
+		}
+		
+		ContributionStatus (string email, string key)
+		{
+			tn = new ThreadNotify (new ReadyEvent (Update));
+			
+			d = new ContributionsSoap ();
+			if (Environment.GetEnvironmentVariable ("MONODOCTESTING") == null)
+				d.Url = "http://www.go-mono.com/docs/server.asmx";
+				
+			war = (WebClientAsyncResult) d.BeginGetStatus (email, key, new AsyncCallback (GetStatusDone), null);
+			contributoremail = email;
+		}
+		
+		void Update ()
+		{
+			MessageDialog md = null;
+			
+			switch (state) {
+			case State.GetStatusError:
+				md = new MessageDialog (null, 
+					              DialogFlags.DestroyWithParent,
+							      MessageType.Error, ButtonsType.Close, 
+				                  "Server returned error while requesting contributor statistics");
+				md.Title = "Contribution Statistics Error Occurred";
+				break;
+			case State.NetworkError:
+				md = new MessageDialog (null, 
+					              DialogFlags.DestroyWithParent,
+							      MessageType.Error, ButtonsType.Close, 
+				                  "Network error occurred while requesting contributor statistics");
+				md.Title = "Contribution Statistics Error Occurred";
+				break;
+			case State.Done:
+				md = new MessageDialog (null, 
+					              DialogFlags.DestroyWithParent,
+							      MessageType.Info, ButtonsType.Close, 
+				                  "Contribution statistics for " + contributoremail +
+					              "\n\nTotal contributions: " + status.Contributions +
+					              "\nContributions committed: " + status.Commited +
+					              "\nContributions pending: " + status.Pending);
+				md.Title = "Contribution Statistics";
+				break;
+			}
+
+			md.Run();
+			md.Destroy();
+		}
+				
+		void GetStatusDone (IAsyncResult iar)
+		{
+			try {
+				status = d.EndGetStatus (iar);
+				war = null;
+
+				if (status == null)
+					state = State.GetStatusError;
+				else
+					state = State.Done;
+
+			} catch (Exception e) {
+				state = State.NetworkError;
+				Console.WriteLine ("Error getting status: " + e);
+			}
+			if (tn != null)
+				tn.WakeupMain ();
+		}	
+	}
+
 	class NewComment {
 		[Glade.Widget] Window newcomment;
 		[Glade.Widget] Entry entry;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 74230)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2007-03-15  Kevin Reay  <kevintreay at gmail.com>
+
+	* browser.cs: Fix #80575. Add missing check for null CurrentTab.
+	* browser.glade: Added Contributing menu. Reordered some menu items.
+	* browser.cs: Added contributor statistics feature.
+
 2006-12-19  Ankit Jain  <jankit at novell.com>
 
 	* browser.cs (Main): Add a "--remote-mode" option and implement. With 
Index: browser.glade
===================================================================
--- browser.glade	(revision 74230)
+++ browser.glade	(working copy)
@@ -83,16 +83,6 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkMenuItem" id="contributor_settings1">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">_Upload Contributions</property>
-		      <property name="use_underline">True</property>
-		      <signal name="activate" handler="OnUpload" last_modification_time="Wed, 08 Oct 2003 02:53:43 GMT"/>
-		      <accelerator key="U" modifiers="GDK_CONTROL_MASK" signal="activate"/>
-		    </widget>
-		  </child>
-
-		  <child>
 		    <widget class="GtkImageMenuItem" id="print">
 		      <property name="visible">True</property>
 		      <property name="label">gtk-print</property>
@@ -189,22 +179,6 @@
 		      <accelerator key="A" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 		    </widget>
 		  </child>
-
-		  <child>
-		    <widget class="GtkMenuItem" id="separator1">
-		      <property name="visible">True</property>
-		    </widget>
-		  </child>
-
-		  <child>
-		    <widget class="GtkCheckMenuItem" id="editing1">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Editing</property>
-		      <property name="use_underline">True</property>
-		      <property name="active">False</property>
-		      <signal name="activate" handler="OnEditingActivate" last_modification_time="Fri, 03 Oct 2003 22:44:59 GMT"/>
-		    </widget>
-		  </child>
 		</widget>
 	      </child>
 	    </widget>
@@ -268,6 +242,53 @@
 	  </child>
 
 	  <child>
+	    <widget class="GtkMenuItem" id="contributingMenu">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">_Contributing</property>
+	      <property name="use_underline">True</property>
+
+	      <child>
+		<widget class="GtkMenu" id="contributingMenu_menu">
+		  <child>
+		    <widget class="GtkCheckMenuItem" id="editing1">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Edit Mode</property>
+		      <property name="use_underline">True</property>
+		      <property name="active">False</property>
+		      <signal name="activate" handler="OnEditingActivate" last_modification_time="Fri, 03 Oct 2003 22:44:59 GMT"/>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkMenuItem" id="separator1">
+		      <property name="visible">True</property>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkMenuItem" id="contributor_settings1">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_Upload Contributions</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="OnUpload" last_modification_time="Wed, 08 Oct 2003 02:53:43 GMT"/>
+		      <accelerator key="U" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkMenuItem" id="contributor_statistics1">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_View Contribution Statistics</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="OnContributionStatistics" last_modification_time="Wed, 08 Oct 2003 02:53:43 GMT"/>
+		    </widget>
+		  </child>
+		</widget>
+	      </child>
+	    </widget>
+	  </child>
+
+	  <child>
 	    <widget class="GtkMenuItem" id="menuitem7">
 	      <property name="visible">True</property>
 	      <property name="label" translatable="yes">_Help</property>
Index: BookmarkManager.cs
===================================================================
--- BookmarkManager.cs	(revision 74230)
+++ BookmarkManager.cs	(working copy)
@@ -324,10 +324,11 @@
 		public BookmarkManager (Browser browser){
 			_Browser = browser;
 			
-			
+			#if DEBUG
 			Console.WriteLine ("Bookmark Manager init");
+			#endif
 
-			//discoverig bookmark file
+			// discovering bookmark file
 			bookmark_file = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
 			bookmark_file = System.IO.Path.Combine (bookmark_file, "monodoc");
 			bookmark_file = System.IO.Path.Combine (bookmark_file, "bookmarks.xml");


More information about the Mono-devel-list mailing list