Author: miguel
Date: 2007-03-16 19:19:05 -0500 (Fri, 16 Mar 2007)
New Revision: 74505

Modified:
   trunk/mono-tools/docbrowser/BookmarkManager.cs
   trunk/mono-tools/docbrowser/ChangeLog
   trunk/mono-tools/docbrowser/browser.cs
   trunk/mono-tools/docbrowser/browser.glade
Log:
2007-03-15  Kevin Reay  <[EMAIL PROTECTED]>

        * 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.

Modified: trunk/mono-tools/docbrowser/BookmarkManager.cs
===================================================================
--- trunk/mono-tools/docbrowser/BookmarkManager.cs      2007-03-17 00:02:24 UTC 
(rev 74504)
+++ trunk/mono-tools/docbrowser/BookmarkManager.cs      2007-03-17 00:19:05 UTC 
(rev 74505)
@@ -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");

Modified: trunk/mono-tools/docbrowser/ChangeLog
===================================================================
--- trunk/mono-tools/docbrowser/ChangeLog       2007-03-17 00:02:24 UTC (rev 
74504)
+++ trunk/mono-tools/docbrowser/ChangeLog       2007-03-17 00:19:05 UTC (rev 
74505)
@@ -1,3 +1,9 @@
+2007-03-15  Kevin Reay  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * browser.cs (Main): Add a "--remote-mode" option and implement. With 

Modified: trunk/mono-tools/docbrowser/browser.cs
===================================================================
--- trunk/mono-tools/docbrowser/browser.cs      2007-03-17 00:02:24 UTC (rev 
74504)
+++ trunk/mono-tools/docbrowser/browser.cs      2007-03-17 00:19:05 UTC (rev 
74505)
@@ -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;

Modified: trunk/mono-tools/docbrowser/browser.glade
===================================================================
--- trunk/mono-tools/docbrowser/browser.glade   2007-03-17 00:02:24 UTC (rev 
74504)
+++ trunk/mono-tools/docbrowser/browser.glade   2007-03-17 00:19:05 UTC (rev 
74505)
@@ -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>

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to