Merge pull request #296 from ways/master

Rewritten autocomplete
This commit is contained in:
Hylke Bons 2011-07-23 06:06:22 -07:00
commit 943dfcc767
3 changed files with 67 additions and 3 deletions

View file

@ -132,6 +132,27 @@ namespace SparkleLib {
}
public List<string> FolderPaths {
get {
List<string> folders = new List<string> ();
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
Uri uri = new Uri (node_folder ["url"].InnerText);
String path = uri.LocalPath;
if (!folders.Contains (path))
folders.Add (path);
if (1 < path.Length && "/" == path.Substring (0, 1))
if (!folders.Contains (path.Substring (1)))
folders.Add (path.Substring (1));
}
return folders;
}
}
public void AddFolder (string name, string url, string backend)
{
XmlNode node_name = CreateElement ("name");
@ -215,6 +236,21 @@ namespace SparkleLib {
}
public List<string> HostsWithUsername {
get {
List<string> hosts = new List<string> ();
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
Uri uri = new Uri (node_folder ["url"].InnerText);
if ("git" != uri.UserInfo && !hosts.Contains (uri.UserInfo + "@" + uri.Host))
hosts.Add (uri.UserInfo + "@" + uri.Host);
}
return hosts;
}
}
public string GetAnnouncementsForFolder (string name)
{
return this.GetFolderValue(name, "announcements");

View file

@ -224,6 +224,25 @@ namespace SparkleShare {
}
public List<string> FolderPaths {
get {
List<string> folders = SparkleConfig.DefaultConfig.FolderPaths;
folders.Sort ();
return folders;
}
}
public List<string> PreviousHosts {
get {
List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername;
hosts.AddRange(SparkleConfig.DefaultConfig.Hosts);
hosts.Sort ();
return hosts;
}
}
public List<string> UnsyncedFolders {
get {
List<string> unsynced_folders = new List<string> ();
@ -236,7 +255,7 @@ namespace SparkleShare {
return unsynced_folders;
}
}
public List<SparkleChangeSet> GetLog ()
{

View file

@ -150,8 +150,8 @@ namespace SparkleShare {
ListStore server_store = new ListStore (typeof (string));
//TODO foreach (string host in SparkleShare.Controller.PreviousHosts)
// server_store.AppendValues (host);
foreach (string host in SparkleShare.Controller.PreviousHosts)
server_store.AppendValues (host);
ServerEntry.Completion.Model = server_store;
ServerEntry.Completion.TextColumn = 0;
@ -236,6 +236,15 @@ namespace SparkleShare {
FolderEntry = new SparkleEntry ();
FolderEntry.ExampleText = _("Folder");
FolderEntry.Completion = new EntryCompletion();
ListStore folder_store = new ListStore (typeof (string));
foreach (string host in SparkleShare.Controller.FolderPaths)
folder_store.AppendValues (host);
FolderEntry.Completion.Model = folder_store;
FolderEntry.Completion.TextColumn = 0;
FolderEntry.Changed += delegate {
CheckAddPage ();