From 1c59f5ea4d43ab8b549f8a05a2bcf58350f8096e Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 18 May 2010 20:44:15 +0100 Subject: [PATCH] allow filtering of event log by clicking authors --- SparkleShare/SparkleHelpers.cs | 2 +- SparkleShare/SparkleWindow.cs | 91 +++++++++++++++++++++------------- locale/nl.po | 56 ++++++++++++--------- 3 files changed, 90 insertions(+), 59 deletions(-) diff --git a/SparkleShare/SparkleHelpers.cs b/SparkleShare/SparkleHelpers.cs index 1ecf8e92..a4b1a53d 100644 --- a/SparkleShare/SparkleHelpers.cs +++ b/SparkleShare/SparkleHelpers.cs @@ -81,7 +81,7 @@ namespace SparkleShare { // Makes it possible to combine more than // two paths at once. public static string CombineMore (params string [] Parts) { - string NewPath = ""; + string NewPath = " "; foreach (string Part in Parts) NewPath = Path.Combine (NewPath, Part); return NewPath; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index 97d13867..1efbd4d1 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -33,6 +33,8 @@ namespace SparkleShare { } private SparkleRepo SparkleRepo; + private HBox LayoutHorizontal; + private ScrolledWindow LogScrolledWindow; public SparkleWindow (SparkleRepo Repo) : base ("") { @@ -51,11 +53,11 @@ namespace SparkleShare { VBox LayoutVertical = new VBox (false, 0); - HBox HBox = new HBox (true, 6); - HBox.PackStart (CreatePeopleList ()); - HBox.PackStart (CreateEventLog ()); + LayoutHorizontal = new HBox (true, 6); + LayoutHorizontal.PackStart (CreatePeopleList ()); + LayoutHorizontal.PackStart (CreateEventLog ("")); - LayoutVertical.PackStart (HBox, true, true, 6); + LayoutVertical.PackStart (LayoutHorizontal, true, true, 6); HButtonBox DialogButtons = new HButtonBox (); DialogButtons.Layout = ButtonBoxStyle.Edge; @@ -104,7 +106,14 @@ namespace SparkleShare { } - public ScrolledWindow CreateEventLog() { + public void UpdateEventLog (string UserEmail) { + LayoutHorizontal.Remove (LogScrolledWindow); + LogScrolledWindow = CreateEventLog (UserEmail); + LayoutHorizontal.Add (LogScrolledWindow); + ShowAll (); + } + + public ScrolledWindow CreateEventLog(string UserEmail) { ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf), typeof (string), @@ -117,16 +126,14 @@ namespace SparkleShare { Process.StartInfo.FileName = "git"; string Output = ""; - foreach (SparkleRepo SparkleRepo in SparkleShare.Repositories) { - // We're using the snowman here to separate messages :) - Process.StartInfo.Arguments = - "log --format=\"%at☃%an %s☃%cr\" -25"; + Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath; + // We're using the snowman here to separate messages :) + Process.StartInfo.Arguments = + "log --format=\"%at☃%an %s☃%cr☃%ae\" -25"; + Process.Start(); - Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath; - Process.Start(); - Output += "\n" + Process.StandardOutput.ReadToEnd().Trim (); - } + Output += "\n" + Process.StandardOutput.ReadToEnd().Trim (); Output = Output.TrimStart ("\n".ToCharArray ()); string [] Lines = Regex.Split (Output, "\n"); @@ -140,28 +147,32 @@ namespace SparkleShare { TreeIter Iter; foreach (string Line in LastTwentyFive) { - // Look for the snowman! - string [] Parts = Regex.Split (Line, "☃"); - string Message = Parts [1]; - string TimeAgo = Parts [2]; + if (Line.Contains (UserEmail)) { + Console.WriteLine ("!!!"); + // Look for the snowman! + string [] Parts = Regex.Split (Line, "☃"); + string Message = Parts [1]; + string TimeAgo = Parts [2]; - string IconFile = "document-edited"; + string IconFile = "document-edited"; - if (Message.IndexOf (" added ‘") > -1) - IconFile = "document-added"; + if (Message.IndexOf (" added ‘") > -1) + IconFile = "document-added"; - if (Message.IndexOf (" deleted ‘") > -1) - IconFile = "document-removed"; + if (Message.IndexOf (" deleted ‘") > -1) + IconFile = "document-removed"; - if (Message.IndexOf (" moved ‘") > -1 || - Message.IndexOf (" renamed ‘") > -1) - IconFile = "document-moved"; + if (Message.IndexOf (" moved ‘") > -1 || + Message.IndexOf (" renamed ‘") > -1) + IconFile = "document-moved"; - Gdk.Pixbuf ChangeIcon = SparkleHelpers.GetIcon (IconFile, 16); - Iter = LogStore.Append (); - LogStore.SetValue (Iter, 0, ChangeIcon); - LogStore.SetValue (Iter, 1, Message); - LogStore.SetValue (Iter, 2, " " + TimeAgo); + Gdk.Pixbuf ChangeIcon = SparkleHelpers.GetIcon (IconFile, 16); + Iter = LogStore.Append (); + LogStore.SetValue (Iter, 0, ChangeIcon); + LogStore.SetValue (Iter, 1, Message); + LogStore.SetValue (Iter, 2, " " + TimeAgo); + + } } @@ -184,10 +195,10 @@ namespace SparkleShare { Columns [1].Expand = true; Columns [1].MaxWidth = 150; - ScrolledWindow ScrolledWindow = new ScrolledWindow (); - ScrolledWindow.AddWithViewport (LogView); + LogScrolledWindow = new ScrolledWindow (); + LogScrolledWindow.AddWithViewport (LogView); - return ScrolledWindow; + return LogScrolledWindow; } @@ -210,7 +221,8 @@ namespace SparkleShare { string [] Lines = Regex.Split (Output, "\n"); ListStore PeopleStore = new ListStore (typeof (Gdk.Pixbuf), - typeof (string)); + typeof (string), + typeof (string)); int i = 0; TreeIter PeopleIter; @@ -237,6 +249,7 @@ namespace SparkleShare { "" + UserName + "\n" + "" + UserEmail + ""); + PeopleStore.SetValue (PeopleIter, 2, UserEmail); } @@ -251,6 +264,16 @@ namespace SparkleShare { PeopleView.Spacing = 6; PeopleView.ItemWidth = 200; PeopleView.Orientation = Orientation.Horizontal; + PeopleView.SelectionMode = SelectionMode.Single; + + PeopleView.SelectionChanged += delegate (object o, EventArgs args) { + if (PeopleView.SelectedItems.Length > 0) { + TreeIter Iter; + PeopleStore.GetIter (out Iter, PeopleView.SelectedItems [0]); + UpdateEventLog ((string) PeopleStore.GetValue (Iter, 2)); + } else UpdateEventLog (""); + }; + ScrolledWindow ScrolledWindow = new ScrolledWindow (); ScrolledWindow.AddWithViewport (PeopleView); diff --git a/locale/nl.po b/locale/nl.po index 1c807f3c..fd19910a 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -4,7 +4,6 @@ # FIRST AUTHOR , YEAR. # #: SparkleShare/SparkleDialog.cs:39 SparkleShare/SparkleHelpers.cs:78 -#: SparkleShare/SparkleHelpers.cs:84 #: SparkleShare/SparklePreferencesDialog.cs:36 SparkleShare/SparkleRepo.cs:202 #: SparkleShare/SparkleRepo.cs:332 SparkleShare/SparkleRepo.cs:336 #: SparkleShare/SparkleRepo.cs:345 SparkleShare/SparkleRepo.cs:349 @@ -20,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-05-18 19:36+0100\n" +"POT-Creation-Date: 2010-05-18 19:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -42,8 +41,12 @@ msgstr "" msgid "Folder Name: " msgstr "" -#: SparkleShare/SparkleDialog.cs:52 -msgid "Example: ‘Project’." +#: SparkleShare/SparkleDialog.cs:52 SparkleShare/SparkleDialog.cs:67 +msgid "Example: " +msgstr "" + +#: SparkleShare/SparkleDialog.cs:53 +msgid "‘Project’." msgstr "" #: SparkleShare/SparkleDialog.cs:58 @@ -66,14 +69,16 @@ msgstr "" msgid "ssh://git@gitorious.org" msgstr "" -#: SparkleShare/SparkleDialog.cs:67 -msgid "Example: ‘ssh://git@github.com’." +#: SparkleShare/SparkleDialog.cs:68 +msgid "‘ssh://git@github.com’." msgstr "" #: SparkleShare/SparkleDialog.cs:118 -msgid "" -"Downloading files,\n" -"this may take a while..." +msgid "Downloading files,\n" +msgstr "" + +#: SparkleShare/SparkleDialog.cs:119 +msgid "this may take a while..." msgstr "" #: SparkleShare/SparkleDialog.cs:132 SparkleShare/SparkleRepo.cs:70 @@ -141,6 +146,13 @@ msgstr "" msgid "-" msgstr "" +#: SparkleShare/SparkleHelpers.cs:84 SparkleShare/SparkleRepo.cs:262 +#: SparkleShare/SparkleShare.cs:86 SparkleShare/SparkleShare.cs:90 +#: SparkleShare/SparkleShare.cs:92 SparkleShare/SparkleShare.cs:95 +#: SparkleShare/SparkleShare.cs:99 SparkleShare/SparkleWindow.cs:164 +msgid " " +msgstr "" + #: SparkleShare/SparkleHelpers.cs:100 msgid "[a-z]+://(.)+" msgstr "" @@ -199,19 +211,26 @@ msgid "Preferences" msgstr "" #: SparkleShare/SparklePreferencesDialog.cs:48 -msgid "The folder " +msgid "The folder " msgstr "" #: SparkleShare/SparklePreferencesDialog.cs:49 -msgid "" -"\n" -"is linked to " +#: SparkleShare/SparklePreferencesDialog.cs:51 +#: SparkleShare/SparkleWindow.cs:237 +msgid "" msgstr "" +#: SparkleShare/SparklePreferencesDialog.cs:49 #: SparkleShare/SparklePreferencesDialog.cs:51 msgid "" msgstr "" +#: SparkleShare/SparklePreferencesDialog.cs:50 +msgid "" +"\n" +"is linked to " +msgstr "" + #: SparkleShare/SparklePreferencesDialog.cs:57 msgid "Notify me when something changes" msgstr "" @@ -382,13 +401,6 @@ msgstr "" msgid "log --format=\"%an\" -1" msgstr "" -#: SparkleShare/SparkleRepo.cs:262 SparkleShare/SparkleShare.cs:86 -#: SparkleShare/SparkleShare.cs:90 SparkleShare/SparkleShare.cs:92 -#: SparkleShare/SparkleShare.cs:95 SparkleShare/SparkleShare.cs:99 -#: SparkleShare/SparkleWindow.cs:164 -msgid " " -msgstr "" - #: SparkleShare/SparkleRepo.cs:269 msgid "] Nothing going on... " msgstr "" @@ -747,10 +759,6 @@ msgstr "" msgid " (that’s you!)" msgstr "" -#: SparkleShare/SparkleWindow.cs:237 -msgid "" -msgstr "" - #: SparkleShare/SparkleWindow.cs:237 msgid "" "\n"