From d657edf783da2ed4294639d60d236d34a392f5d9 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 10 Jun 2011 02:32:36 +0100 Subject: [PATCH] add popupbutton and show most recent --- SparkleShare/Mac/SparkleLog.cs | 50 +++++++++++-------------------- SparkleShare/SparkleController.cs | 7 +++-- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/SparkleShare/Mac/SparkleLog.cs b/SparkleShare/Mac/SparkleLog.cs index 248ce428..03970d53 100644 --- a/SparkleShare/Mac/SparkleLog.cs +++ b/SparkleShare/Mac/SparkleLog.cs @@ -16,6 +16,7 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.IO; using System.Threading; @@ -24,6 +25,7 @@ using MonoMac.Foundation; using MonoMac.AppKit; using MonoMac.ObjCRuntime; using MonoMac.WebKit; +using SparkleLib; // Only used for SparkleChangeSet namespace SparkleShare { @@ -32,12 +34,11 @@ namespace SparkleShare { public readonly string LocalPath; private WebView WebView; - private NSButton CloseButton; - private NSButton OpenFolderButton; private NSBox Separator; private string HTML; + private NSPopUpButton popup_button; private NSProgressIndicator ProgressIndicator; - + private List change_sets = SparkleShare.Controller.GetLog (); public SparkleLog (IntPtr handle) : base (handle) { } @@ -76,44 +77,27 @@ namespace SparkleShare { private void CreateEventLog () { - OpenFolderButton = new NSButton (new RectangleF (16, 12, 120, 32)) { - Title = "Open Folder", - BezelStyle = NSBezelStyle.Rounded , - Font = SparkleUI.Font - }; - - OpenFolderButton.Activated += delegate { - SparkleShare.Controller.OpenSparkleShareFolder (LocalPath); - }; - - ContentView.AddSubview (OpenFolderButton); - - - CloseButton = new NSButton (new RectangleF (480 - 120 - 16, 12, 120, 32)) { - Title = "Close", - BezelStyle = NSBezelStyle.Rounded, - Font = SparkleUI.Font - }; - - CloseButton.Activated += delegate { - InvokeOnMainThread (delegate { - PerformClose (this); - }); - }; - - ContentView.AddSubview (CloseButton); - - string name = Path.GetFileName (LocalPath); Title = "Recent Events"; - Separator = new NSBox (new RectangleF (0, 58, 480, 1)) { + Separator = new NSBox (new RectangleF (0, 559, 480, 1)) { BorderColor = NSColor.LightGray, BoxType = NSBoxType.NSBoxCustom }; ContentView.AddSubview (Separator); + this.popup_button = new NSPopUpButton (new RectangleF (100, 570, 200, 26), false); + this.popup_button.AddItem ("All Folders"); + this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem); + this.popup_button.AddItems (SparkleShare.Controller.Folders.ToArray ()); + + + this.popup_button.Activated += delegate { + Console.WriteLine (this.popup_button.SelectedItem.Title); + }; + + ContentView.AddSubview (this.popup_button); ProgressIndicator = new NSProgressIndicator () { Style = NSProgressIndicatorStyle.Spinning, @@ -122,7 +106,7 @@ namespace SparkleShare { ProgressIndicator.StartAnimation (this); - WebView = new WebView (new RectangleF (0, 59, 480, 559), "", ""){ + WebView = new WebView (new RectangleF (0, 0, 480, 559), "", ""){ PolicyDelegate = new SparkleWebPolicyDelegate () }; diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 11c84539..f6b1e303 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -247,12 +247,15 @@ namespace SparkleShare { List list = new List (); foreach (SparkleRepoBase repo in Repositories) - list.AddRange (repo.GetChangeSets (10)); + list.AddRange (repo.GetChangeSets (30)); list.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp))); list.Reverse (); - return list; + if (list.Count > 50) + return list.GetRange (0, 50); + else + return list.GetRange (0, list.Count); }