beagle r4576 - in branches/beagle-rdf: . BeagleClient Filters Util beagled beagled/EvolutionMailQueryable beagled/FileSystemQueryable beagled/KMailQueryable beagled/KonqHistoryQueryable beagled/ThunderbirdQueryable beagled/webinterface po search search/Beagle.Search search/Beagle.Search.Tiles tools
- From: dbera svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4576 - in branches/beagle-rdf: . BeagleClient Filters Util beagled beagled/EvolutionMailQueryable beagled/FileSystemQueryable beagled/KMailQueryable beagled/KonqHistoryQueryable beagled/ThunderbirdQueryable beagled/webinterface po search search/Beagle.Search search/Beagle.Search.Tiles tools
- Date: Mon, 3 Mar 2008 21:50:13 +0000 (GMT)
Author: dbera
Date: Mon Mar 3 21:50:12 2008
New Revision: 4576
URL: http://svn.gnome.org/viewvc/beagle?rev=4576&view=rev
Log:
Merge from trunk: 4487-4575
Added:
branches/beagle-rdf/beagled/webinterface/opensearch.xml
- copied unchanged from r4575, /trunk/beagle/beagled/webinterface/opensearch.xml
branches/beagle-rdf/search/Beagle.Search/SearchWindow.cs
- copied unchanged from r4575, /trunk/beagle/search/Beagle.Search/SearchWindow.cs
branches/beagle-rdf/tools/StaticQuery.cs
- copied unchanged from r4575, /trunk/beagle/tools/StaticQuery.cs
Modified:
branches/beagle-rdf/BeagleClient/Hit.cs
branches/beagle-rdf/BeagleClient/Indexable.cs
branches/beagle-rdf/BeagleClient/Property.cs
branches/beagle-rdf/BeagleClient/Query.cs
branches/beagle-rdf/BeagleClient/Snippet.cs
branches/beagle-rdf/ChangeLog
branches/beagle-rdf/Filters/FilterEbuild.cs
branches/beagle-rdf/Filters/FilterXslt.cs
branches/beagle-rdf/Util/SafeProcess.cs
branches/beagle-rdf/Util/StringFu.cs
branches/beagle-rdf/Util/SystemInformation.cs
branches/beagle-rdf/beagled/BuildIndex.cs
branches/beagle-rdf/beagled/EvolutionMailQueryable/EvolutionMailQueryable.cs
branches/beagle-rdf/beagled/FileSystemQueryable/FileSystemQueryable.cs
branches/beagle-rdf/beagled/Filter.cs
branches/beagle-rdf/beagled/FilterFactory.cs
branches/beagle-rdf/beagled/Flavor.cs
branches/beagle-rdf/beagled/KMailQueryable/KMailIndexer.cs
branches/beagle-rdf/beagled/KonqHistoryQueryable/KonqQueryable.cs
branches/beagle-rdf/beagled/LuceneIndexingDriver.cs
branches/beagle-rdf/beagled/Makefile.am
branches/beagle-rdf/beagled/ThunderbirdQueryable/ThunderbirdQueryable.cs
branches/beagle-rdf/beagled/WebServer.cs
branches/beagle-rdf/beagled/webinterface/index.xsl
branches/beagle-rdf/po/ChangeLog
branches/beagle-rdf/po/POTFILES.in
branches/beagle-rdf/po/ca.po
branches/beagle-rdf/po/es.po
branches/beagle-rdf/po/eu.po
branches/beagle-rdf/po/fi.po
branches/beagle-rdf/po/ja.po
branches/beagle-rdf/po/nb.po
branches/beagle-rdf/po/oc.po
branches/beagle-rdf/po/pt_BR.po
branches/beagle-rdf/po/sv.po
branches/beagle-rdf/search/Beagle.Search.Tiles/File.cs
branches/beagle-rdf/search/Beagle.Search.Tiles/Tile.cs
branches/beagle-rdf/search/Beagle.Search/Driver.cs
branches/beagle-rdf/search/Beagle.Search/ISearch.cs
branches/beagle-rdf/search/Beagle.Search/Search.cs
branches/beagle-rdf/search/Beagle.Search/UIManager.cs
branches/beagle-rdf/search/Makefile.am
branches/beagle-rdf/tools/ (props changed)
branches/beagle-rdf/tools/Makefile.am
branches/beagle-rdf/tools/Query.cs
Modified: branches/beagle-rdf/BeagleClient/Hit.cs
==============================================================================
--- branches/beagle-rdf/BeagleClient/Hit.cs (original)
+++ branches/beagle-rdf/BeagleClient/Hit.cs Mon Mar 3 21:50:12 2008
@@ -93,6 +93,7 @@
set { parent_uri = value; }
}
+
[XmlAttribute ("ParentUri")]
public string EscapedParentUri {
get {
@@ -110,25 +111,34 @@
}
}
- // File, WebHistory, MailMessage, IMLog, etc.
+ /// <value>
+ /// File, WebHistory, MailMessage, IMLog, etc.
+ /// </value>
[XmlIgnore]
public string Type {
get { return GetFirstProperty ("beagle:HitType"); }
}
- // If applicable otherwise can be null.
+ /// <value>
+ /// If applicable otherwise can be null.
+ /// </value>
[XmlIgnore]
public string MimeType {
get { return GetFirstProperty ("beagle:MimeType"); }
}
- // IndexUser, IndexSystem, Google, Addressbook, iFolder, etc.
+
+ /// <value>
+ /// IndexUser, IndexSystem, Google, Addressbook, iFolder, etc.
+ /// </value>
[XmlIgnore]
public string Source {
get { return GetFirstProperty ("beagle:Source"); }
}
- // document, archive, image etc.
+ /// <summary>
+ /// document, archive, image etc.
+ /// </summary>
[XmlIgnore]
public string FileType {
get { return GetFirstProperty ("beagle:FileType"); }
@@ -332,7 +342,7 @@
return null;
if (top - first != 1) {
- Logger.Log.Warn ("Accessed multi-property key '(0}' with Hit's indexer.");
+ Logger.Log.Warn ("Accessed multi-property key '{0}' with Hit's indexer.", key);
return null;
}
Modified: branches/beagle-rdf/BeagleClient/Indexable.cs
==============================================================================
--- branches/beagle-rdf/BeagleClient/Indexable.cs (original)
+++ branches/beagle-rdf/BeagleClient/Indexable.cs Mon Mar 3 21:50:12 2008
@@ -91,9 +91,12 @@
// Is this being indexed because of crawling or other
// background activity?
- // If crawl is set, then the underlying file will be flushed
+ // If set, then the underlying file will be flushed
// from buffer cache as soon as it is indexed.
- private bool crawled = true;
+ // Set it to true when the buffer cache should not
+ // be disturbed due to this indexable (e.g. during
+ // crawling).
+ private bool flush_buffer_cache = false;
// Is this object inherently contentless?
private bool no_content = false;
@@ -277,10 +280,10 @@
get { return ! DeleteContent && ContentUri.IsFile && ParentUri == null; }
}
- [XmlAttribute]
- public bool Crawled {
- get { return crawled; }
- set { crawled = value; }
+ [XmlAttribute ("Crawled")]
+ public bool FlushBufferCache {
+ get { return flush_buffer_cache; }
+ set { flush_buffer_cache = value; }
}
[XmlAttribute]
Modified: branches/beagle-rdf/BeagleClient/Property.cs
==============================================================================
--- branches/beagle-rdf/BeagleClient/Property.cs (original)
+++ branches/beagle-rdf/BeagleClient/Property.cs Mon Mar 3 21:50:12 2008
@@ -41,7 +41,9 @@
Date = 3
}
- /* IEnumerable class to serialize properties with non-private namespace. */
+ /// <summary>
+ /// IEnumerable class to serialize properties with non-private namespace.
+ /// </summary>
public class PropertyList : IEnumerable {
private ArrayList property_list;
@@ -144,34 +146,45 @@
set { this.value = StringFu.CleanupInvalidXmlCharacters (value); }
}
- // If IsSearched is true, this property will can be matched by a
- // general match-any-propety query.
- // You can always query against the specific property, even if
- // IsSearched is false.
+
+ /// <value>
+ /// If IsSearched is true, this property will can be matched by a
+ /// general match-any-propety query.
+ /// You can always query against the specific property, even if
+ /// IsSearched is false.
+ /// </value>
[XmlAttribute]
public bool IsSearched {
get { return is_searched; }
set { is_searched = value; }
}
- // When IsMutable is true, the property is stored in the secondary
- // index so that it can more efficiently be changed later on.
+
+ /// <value>
+ /// When IsMutable is true, the property is stored in the secondary
+ /// index so that it can more efficiently be changed later on.
+ /// </value>
[XmlAttribute]
public bool IsMutable {
get { return is_mutable; }
set { is_mutable = value; }
}
- // When IsStored is false, the property will be stored as an
- // "unstored lucene field".
+ /// <value>
+ /// When IsStored is false, the property will be stored as an
+ /// "unstored lucene field".
+ /// </value>
[XmlAttribute]
public bool IsStored {
get { return is_stored; }
set { is_stored = value; }
}
- // When true, this property is persisted across documents being
- // readded, for instance if a file is touched on disk.
+
+ /// <value>
+ /// When true, this property is persisted across documents being
+ /// readded, for instance if a file is touched on disk.
+ /// </value>
[XmlAttribute]
public bool IsPersistent {
get { return is_persistent; }
@@ -306,8 +319,19 @@
return String.Format ("{0}={1}", Key, Value);
}
- // Standard properties for files
- // Used by FileSystem backend and filters which produce file child-indexables
+ /// <summary>
+ /// Standard properties for files
+ /// Used by FileSystem backend and filters which produce file child-indexables
+ /// </summary>
+ /// <param name="name">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <param name="mutable">
+ /// A <see cref="System.Boolean"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="IEnumerable"/>
+ /// </returns>
public static IEnumerable StandardFileProperties (string name, bool mutable)
{
StringBuilder sb;
Modified: branches/beagle-rdf/BeagleClient/Query.cs
==============================================================================
--- branches/beagle-rdf/BeagleClient/Query.cs (original)
+++ branches/beagle-rdf/BeagleClient/Query.cs Mon Mar 3 21:50:12 2008
@@ -151,8 +151,13 @@
parts.Add (part);
}
- // This is a human-entered query string that will be parsed in
- // the daemon.
+ /// <summary>
+ /// This is a human-entered query string that will be parsed in
+ /// the daemon.
+ /// </summary>
+ /// <param name="str">
+ /// A <see cref="System.String"/>
+ /// </param>
public void AddText (string str)
{
QueryPart_Human part = new QueryPart_Human ();
Modified: branches/beagle-rdf/BeagleClient/Snippet.cs
==============================================================================
--- branches/beagle-rdf/BeagleClient/Snippet.cs (original)
+++ branches/beagle-rdf/BeagleClient/Snippet.cs Mon Mar 3 21:50:12 2008
@@ -103,16 +103,22 @@
[System.Xml.Serialization.XmlRoot("SnippetLine", Namespace="", IsNullable=false)]
[System.Xml.Serialization.XmlType("SnippetLine", Namespace="")]
public class SnippetLine {
- // Line number of the snippet
+ /// <value>
+ /// Line number of the snippet
+ /// </value>
[XmlAttribute]
public ulong Line;
- // List of fragments
+ /// <value>
+ /// List of fragments
+ /// </value>
[XmlElement (ElementName="Fragment", Type=typeof(Fragment))]
[XmlArrayItem (ElementName="Fragment", Type=typeof (Fragment))]
public ArrayList Fragments;
- // Number of fragments
+ /// <value>
+ /// Number of fragments
+ /// </value>
[XmlIgnore]
public int Count {
get {
Modified: branches/beagle-rdf/Filters/FilterEbuild.cs
==============================================================================
--- branches/beagle-rdf/Filters/FilterEbuild.cs (original)
+++ branches/beagle-rdf/Filters/FilterEbuild.cs Mon Mar 3 21:50:12 2008
@@ -32,9 +32,9 @@
namespace Beagle.Filters {
public class FilterEbuild : FilterPackage {
- static Regex metadata_pattern = new Regex ("\\s*(?<key>([A-Z_]+))\\s*=\\s*\"(?<value>(.*))\"\\s*");
- static Regex einfo_pattern = new Regex ("\\s*(einfo|ewarn)\\s+\"(?<message>(.*))\"\\s*");
- static Regex package_pattern = new Regex ("(?<name>([^0-9]+))-(?<version>(.+)).ebuild");
+ static Regex metadata_pattern = new Regex ("\\s*(?<key>([A-Z_]+))\\s*=\\s*\"(?<value>(.*))\"\\s*", RegexOptions.Compiled);
+ static Regex einfo_pattern = new Regex ("\\s*(einfo|ewarn)\\s+\"(?<message>(.*))\"\\s*", RegexOptions.Compiled);
+ static Regex package_pattern = new Regex ("(?<name>([^0-9]+))-(?<version>(.+)).ebuild", RegexOptions.Compiled);
public FilterEbuild ()
{
@@ -113,21 +113,24 @@
if (desktop_file == null)
continue;
// verify this is a desktop file
- StreamReader desktop_reader = new StreamReader (new FileStream (desktop_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read));
- string desktop_line = null;
- bool desktop_valid = false;
- while ((desktop_line = desktop_reader.ReadLine ()) != null) {
- if (desktop_line.Trim ().Length > 0) {
- desktop_valid = desktop_line.Equals ("[Desktop Entry]");
- break;
+ using (StreamReader desktop_reader = new StreamReader (new FileStream (desktop_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))) {
+ string desktop_line = null;
+ bool desktop_valid = false;
+ while ((desktop_line = desktop_reader.ReadLine ()) != null) {
+ if (desktop_line.Trim ().Length > 0) {
+ desktop_valid = desktop_line.Equals ("[Desktop Entry]");
+ break;
+ }
}
- }
- // add property
- if (desktop_valid)
- AddProperty (Beagle.Property.NewUnsearched ("fixme:desktop_file", desktop_file.FullName));
+ // add property
+ if (desktop_valid)
+ AddProperty (Beagle.Property.NewUnsearched ("fixme:desktop_file", desktop_file.FullName));
+ }
}
+ contents_reader.Close ();
+
AddProperty (Beagle.Property.NewUnsearched ("fixme:contents_byte_count", byte_count));
AddProperty (Beagle.Property.NewUnsearched ("fixme:contents_file_count", file_count));
AddProperty (Beagle.Property.NewUnsearched ("fixme:contents_dir_count", dir_count));
Modified: branches/beagle-rdf/Filters/FilterXslt.cs
==============================================================================
--- branches/beagle-rdf/Filters/FilterXslt.cs (original)
+++ branches/beagle-rdf/Filters/FilterXslt.cs Mon Mar 3 21:50:12 2008
@@ -37,8 +37,8 @@
{
public class FilterXslt : Filter
{
- Regex xpath_variables_regex = new Regex ("\\$(?<name>[\\wS][\\wS\\d-:]*)");
- Regex xpath_functions_regex = new Regex ("(?<name>[\\wS][\\wS\\d-:]*)\\(");
+ static Regex xpath_variables_regex = new Regex ("\\$(?<name>[\\wS][\\wS\\d-:]*)", RegexOptions.Compiled);
+ static Regex xpath_functions_regex = new Regex ("(?<name>[\\wS][\\wS\\d-:]*)\\(", RegexOptions.Compiled);
public FilterXslt ()
{
Modified: branches/beagle-rdf/Util/SafeProcess.cs
==============================================================================
--- branches/beagle-rdf/Util/SafeProcess.cs (original)
+++ branches/beagle-rdf/Util/SafeProcess.cs Mon Mar 3 21:50:12 2008
@@ -128,7 +128,7 @@
env = new string [env_dict.Count + 2];
int count = 0;
foreach (DictionaryEntry entry in env_dict)
- if (entry.Key != "LANG")
+ if ((string) entry.Key != "LANG")
env [count ++] = String.Concat (entry.Key, "=", entry.Value);
env [count ++] = "LANG=C";
Modified: branches/beagle-rdf/Util/StringFu.cs
==============================================================================
--- branches/beagle-rdf/Util/StringFu.cs (original)
+++ branches/beagle-rdf/Util/StringFu.cs Mon Mar 3 21:50:12 2008
@@ -47,8 +47,16 @@
public static DateTime MinValueUtc = new DateTime (0, DateTimeKind.Utc);
public static DateTime MaxValueUtc = new DateTime (DateTime.MaxValue.Ticks, DateTimeKind.Utc);
- // We use this instead of DateTime.ToUniversalTime() because
- // we want to assume DateTimeKind.Unspecified dates are UTC
+ /// <summary>
+ /// We use this instead of DateTime.ToUniversalTime() because
+ /// we want to assume DateTimeKind.Unspecified dates are UTC
+ /// </summary>
+ /// <param name="dt">
+ /// A <see cref="DateTime"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="DateTime"/>
+ /// </returns>
static private DateTime ToUniversalTime (DateTime dt)
{
switch (dt.Kind) {
@@ -227,12 +235,20 @@
return String.Format (Catalog.GetString ("{0:0.0} MB"), len/(double)oneMb);
}
- // Here we:
- // (1) Replace non-alphanumeric characters with spaces
- // (2) Inject whitespace between lowercase-to-uppercase
- // transitions (so "FooBar" becomes "Foo Bar")
- // and transitions between letters and numbers
- // (so "cvs2svn" becomes "cvs 2 svn")
+ /// <summary>
+ /// Here we:
+ /// (1) Replace non-alphanumeric characters with spaces
+ /// (2) Inject whitespace between lowercase-to-uppercase
+ /// transitions (so "FooBar" becomes "Foo Bar")
+ /// and transitions between letters and numbers
+ /// (so "cvs2svn" becomes "cvs 2 svn")
+ /// </summary>
+ /// <param name="line">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
static public string FuzzyDivide (string line)
{
// Allocate a space slightly bigger than the
@@ -282,8 +298,19 @@
return FuzzyDivide (url.Substring (protocol_index + 3));
}
- // Match strings against patterns that are allowed to contain
- // glob-style * and ? wildcards.
+ /// <summary>
+ /// Match strings against patterns that are allowed to contain
+ /// glob-style * and ? wildcards.
+ /// </summary>
+ /// <param name="pattern">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <param name="str">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
static public bool GlobMatch (string pattern, string str)
{
if (pattern == null || str == null)
@@ -300,9 +327,26 @@
private const char WILDCARD_STRING = '*';
- // Copied from beagled/Lucene.Net/Search/WildcardTermEnum.cs
- // Simple string matching algorithm with wildcards
- // '*' matches 0 or more characters
+ /// <summary>
+ /// Copied from beagled/Lucene.Net/Search/WildcardTermEnum.cs
+ /// Simple string matching algorithm with wildcards
+ /// '*' matches 0 or more characters
+ /// </summary>
+ /// <param name="pattern">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <param name="patternIdx">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <param name="text">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <param name="stringIdx">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
private static bool WildcardEquals(System.String pattern, int patternIdx, System.String text, int stringIdx)
{
int p = patternIdx;
@@ -436,7 +480,15 @@
return builder.ToString ();
}
- // Translate all %xx codes into real characters
+ /// <summary>
+ /// Translate all %xx codes into real characters
+ /// </summary>
+ /// <param name="str">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
static public string HexUnescape (string str)
{
ArrayList bytes = new ArrayList ();
@@ -605,7 +657,21 @@
return new string (char_array);
}
- // Words of less than min_word_length characters are not counted
+ /// <summary>
+ /// Words of less than min_word_length characters are not counted
+ /// </summary>
+ /// <param name="str">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <param name="max_words">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <param name="min_word_length">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Int32"/>
+ /// </returns>
static public int CountWords (string str, int max_words, int min_word_length)
{
if (str == null)
@@ -645,7 +711,15 @@
return CountWords (str, -1);
}
- // Strip trailing slashes and make sure we only have 1 leading slash
+ /// <summary>
+ /// Strip trailing slashes and make sure we only have 1 leading slash
+ /// </summary>
+ /// <param name="path">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
static public string SanitizePath (string path)
{
if (path.StartsWith ("//")) {
@@ -662,12 +736,20 @@
return path;
}
- // This method will translate an email address like
- // "john doe+spamtrap foo com" to "john doe spamtrap foo"
- //
- // FIXME: Maybe we should only do the username part? Ie,
- // "john doe spamtrap"? That way searching for "foo" won't
- // turn up *everything*
+ /// <summary>
+ /// This method will translate an email address like
+ /// "john doe+spamtrap foo com" to "john doe spamtrap foo"
+ ///
+ /// FIXME: Maybe we should only do the username part? Ie,
+ /// "john doe spamtrap"? That way searching for "foo" won't
+ /// turn up *everything*
+ /// </summary>
+ /// <param name="email">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
static public string SanitizeEmail (string email)
{
char[] replace_array = { '@', '.', '-', '_', '+' };
@@ -691,10 +773,17 @@
return email;
}
- /**
- * expands environment variables in a string e.g.
- * folders=$HOME/.kde/share/...
- */
+
+ /// <summary>
+ /// expands environment variables in a string e.g.
+ /// folders=$HOME/.kde/share/...
+ /// </summary>
+ /// <param name="path">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
public static string ExpandEnvVariables (string path)
{
int dollar_pos = path.IndexOf ('$');
Modified: branches/beagle-rdf/Util/SystemInformation.cs
==============================================================================
--- branches/beagle-rdf/Util/SystemInformation.cs (original)
+++ branches/beagle-rdf/Util/SystemInformation.cs Mon Mar 3 21:50:12 2008
@@ -114,12 +114,16 @@
[DllImport ("libbeagleglue.so")]
extern static unsafe int screensaver_glue_init ();
- /*
- * BeagleDaemon needs to monitor screensaver status
- * for faster scheduling when user is idle.
- * IndexHelper does not need to monitor screensaver status.
- * XssInit is only called from the BeagleDaemon.
- */
+ /// <summary>
+ /// BeagleDaemon needs to monitor screensaver status
+ /// for faster scheduling when user is idle.
+ /// IndexHelper does not need to monitor screensaver status.
+ /// XssInit is only called from the BeagleDaemon.
+ ///
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public static bool XssInit ()
{
int has_xss = screensaver_glue_init ();
@@ -174,8 +178,10 @@
}
}
- // returns number of seconds since input was received
- // from the user on any input device
+ /// <value>
+ /// returns number of seconds since input was received
+ /// from the user on any input device
+ /// </value>
public static double InputIdleTime {
get {
CheckScreenSaver ();
@@ -345,19 +351,25 @@
///////////////////////////////////////////////////////////////
- [DllImport("libc")]
- private static extern int prctl (int option, byte [] arg2, ulong arg3, ulong arg4, ulong arg5);
-
// From /usr/include/linux/prctl.h
private const int PR_SET_NAME = 15;
+ [DllImport("libc")] // Linux
+ private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
+
+ [DllImport ("libc")] // BSD
+ private static extern void setproctitle (byte [] fmt, byte [] str_arg);
+
public static void SetProcessName(string name)
{
#if OS_LINUX
- if (prctl (PR_SET_NAME, Encoding.ASCII.GetBytes (name + '\0'), 0, 0, 0) < 0) {
+ if (prctl (PR_SET_NAME, Encoding.ASCII.GetBytes (name + '\0'),
+ IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) < 0) {
Logger.Log.Warn ("Couldn't set process name to '{0}': {1}", name,
Mono.Unix.Native.Stdlib.GetLastError ());
}
+#elif OS_FREEBSD
+ setproctitle (Encoding.ASCII.GetBytes ("%s\0"), Encoding.ASCII.GetBytes (name + "\0"));
#endif
}
Modified: branches/beagle-rdf/beagled/BuildIndex.cs
==============================================================================
--- branches/beagle-rdf/beagled/BuildIndex.cs (original)
+++ branches/beagle-rdf/beagled/BuildIndex.cs Mon Mar 3 21:50:12 2008
@@ -642,7 +642,7 @@
Uri uri = UriFu.PathToFileUri (file.FullName);
Indexable indexable = new Indexable (uri);
indexable.Timestamp = file.LastWriteTimeUtc;
- indexable.Crawled = true;
+ indexable.FlushBufferCache = true;
indexable.AddProperty (Property.NewUnsearched ("fixme:filesize", file.Length));
FSQ.AddStandardPropertiesToIndexable (indexable, file.Name, Guid.Empty, false);
Modified: branches/beagle-rdf/beagled/EvolutionMailQueryable/EvolutionMailQueryable.cs
==============================================================================
--- branches/beagle-rdf/beagled/EvolutionMailQueryable/EvolutionMailQueryable.cs (original)
+++ branches/beagle-rdf/beagled/EvolutionMailQueryable/EvolutionMailQueryable.cs Mon Mar 3 21:50:12 2008
@@ -170,7 +170,8 @@
internal void AddGenerator (EvolutionMailIndexableGenerator generator, bool inotify_event)
{
- running_generators.Add (generator);
+ lock (running_generators)
+ running_generators.Add (generator);
if (! inotify_event)
IsIndexing = true;
@@ -178,28 +179,32 @@
internal void RemoveGenerator (EvolutionMailIndexableGenerator generator)
{
- running_generators.Remove (generator);
+ lock (running_generators) {
+ running_generators.Remove (generator);
- if (running_generators.Count == 0)
- IsIndexing = false;
+ if (running_generators.Count == 0)
+ IsIndexing = false;
+ }
}
protected override int ProgressPercent {
get {
- if (running_generators.Count == 0)
- return -1;
-
- // An embarrassingly unscientific attempt at getting progress
- // information from the mail backend as a whole. Unfortunately
- // the IMAP and mbox backends don't have a common unit of
- // measurement (IMAP has number of messages, mbox number of
- // bytes), so we can't get anything really accurate.
- double total_percent = 0;
+ lock (running_generators) {
+ if (running_generators.Count == 0)
+ return -1;
+
+ // An embarrassingly unscientific attempt at getting progress
+ // information from the mail backend as a whole. Unfortunately
+ // the IMAP and mbox backends don't have a common unit of
+ // measurement (IMAP has number of messages, mbox number of
+ // bytes), so we can't get anything really accurate.
+ double total_percent = 0;
- foreach (EvolutionMailIndexableGenerator generator in running_generators)
- total_percent += generator.ProgressPercent;
+ foreach (EvolutionMailIndexableGenerator generator in running_generators)
+ total_percent += generator.ProgressPercent;
- return (int) (total_percent / running_generators.Count);
+ return (int) (total_percent / running_generators.Count);
+ }
}
}
Modified: branches/beagle-rdf/beagled/FileSystemQueryable/FileSystemQueryable.cs
==============================================================================
--- branches/beagle-rdf/beagled/FileSystemQueryable/FileSystemQueryable.cs (original)
+++ branches/beagle-rdf/beagled/FileSystemQueryable/FileSystemQueryable.cs Mon Mar 3 21:50:12 2008
@@ -219,7 +219,7 @@
public Indexable FileToIndexable (string path,
Guid id,
DirectoryModel parent,
- bool crawl_mode)
+ bool crawling)
{
Indexable indexable;
@@ -244,7 +244,7 @@
indexable.ContentUri = UriFu.PathToFileUri (path);
indexable.DisplayUri = UriFu.PathToFileUri (path);
- indexable.Crawled = crawl_mode;
+ indexable.FlushBufferCache = crawling;
indexable.Filtering = Beagle.IndexableFiltering.Always;
FileInfo fi = new FileInfo (path);
@@ -257,7 +257,7 @@
indexable.LocalState ["Path"] = path;
MergeExternalPendingIndexable (indexable);
- Indexable xmp_indexable = xmp_handler.MergeXmpData (ref indexable, path, id, parent, crawl_mode);
+ Indexable xmp_indexable = xmp_handler.MergeXmpData (ref indexable, path, id, parent, crawling);
// In full generality, the xmp_handler can request an entirely new indexable to be scheduled.
// So, we should do something with the returned xmp_indexable if it is not null.
Modified: branches/beagle-rdf/beagled/Filter.cs
==============================================================================
--- branches/beagle-rdf/beagled/Filter.cs (original)
+++ branches/beagle-rdf/beagled/Filter.cs Mon Mar 3 21:50:12 2008
@@ -128,8 +128,13 @@
set { this_extension = value; }
}
- // Filter may set the filetype to document, source, music etc.
- // Use lower case for file_type
+ /// <summary>
+ /// Filter may set the filetype to document, source, music etc.
+ /// Use lower case for file_type
+ /// </summary>
+ /// <param name="file_type">
+ /// A <see cref="System.String"/>
+ /// </param>
protected void SetFileType (string file_type)
{
this_file_type = file_type;
@@ -144,27 +149,14 @@
set { indexable = value; }
}
- //////////////////////////
-
- private bool crawl_mode = false;
-
- public void EnableCrawlMode ()
- {
- crawl_mode = true;
- }
- protected bool CrawlMode {
- get { return crawl_mode; }
- }
-
- //////////////////////////
-
- // Filters which deal with big files, and that don't need
- // to read in whole files may want to set this to false
- // to avoid wasting cycles in disk wait.
private bool preload = true;
-
+ /// <value>
+ /// Filters which deal with big files, and that don't need
+ /// to read in whole files may want to set this to false
+ /// to avoid wasting cycles in disk wait.
+ /// </value>
protected bool PreLoad {
get { return preload; }
set { preload = value; }
@@ -242,9 +234,11 @@
const string WHITESPACE = " ";
const string NEWLINE = "\n";
- /* Append text to the textpool. If IsHot is true, then also add to the hottext pool.
- * Handles null str.
- */
+
+ /// <summary>
+ /// Append text to the textpool. If IsHot is true, then also add to the hottext pool.
+ /// Handles null str.
+ /// </summary>
public bool AppendText (string str)
{
if (Debug)
@@ -308,7 +302,15 @@
*/
}
- // Add a word followed by a whitespace. word may not be whitespace or newline.
+ /// <summary>
+ /// Add a word followed by a whitespace. word may not be whitespace or newline.
+ /// </summary>
+ /// <param name="word">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public bool AppendWord (string word)
{
if (Debug)
@@ -317,7 +319,15 @@
return AppendWords (word, false);
}
- // Add a line followed by a newline.
+ /// <summary>
+ /// Add a line followed by a newline.
+ /// </summary>
+ /// <param name="line">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public bool AppendLine (string line)
{
if (Debug)
@@ -358,7 +368,21 @@
return UpdateCharsAdded (words.Length + 1);
}
- // Does not check for structural breaks
+ /// <summary>
+ /// Does not check for structural breaks
+ /// </summary>
+ /// <param name="buffer">
+ /// A <see cref="System.Char"/>
+ /// </param>
+ /// <param name="index">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <param name="count">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public bool AppendChars (char[] buffer, int index, int count)
{
if (Debug)
@@ -372,9 +396,14 @@
return UpdateCharsAdded (count);
}
- /*
- * Adds whitespace to the textpool.
- */
+
+
+ /// <summary>
+ /// Adds whitespace to the textpool.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public bool AppendWhiteSpace ()
{
if (Debug)
@@ -393,9 +422,14 @@
return UpdateCharsAdded (1);
}
- /*
- * Creates a new paragraph. Mainly useful for storing cached contents.
- */
+
+
+ /// <summary>
+ /// Creates a new paragraph. Mainly useful for storing cached contents.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public bool AppendStructuralBreak ()
{
if (Debug)
@@ -617,8 +651,19 @@
return Open (new FileInfo (tempFile));
}
- // This will throw an exception; callers should catch it and appropriately
- // display the error message showing the filename etc.
+ /// <summary>
+ /// This will throw an exception; callers should catch it and appropriately
+ /// display the error message showing the filename etc.
+ /// </summary>
+ /// <param name="stream">
+ /// A <see cref="Stream"/>
+ /// </param>
+ /// <param name="store_tempfile">
+ /// A <see cref="System.Boolean"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public bool Open (Stream stream, bool store_tempfile)
{
if (store_tempfile)
@@ -763,7 +808,7 @@
if (currentStream != null) {
// When crawling, give the OS a hint that we don't
// need to keep this file around in the page cache.
- if (CrawlMode && currentStream is FileStream)
+ if (indexable.FlushBufferCache && currentStream is FileStream)
FileAdvise.FlushCache ((FileStream) currentStream);
currentStream.Close ();
@@ -857,8 +902,16 @@
get { return generated_indexables.Count > 0; }
}
- // Good filters should replace this by an IEnumerable that does not require generating
- // all the indexables beforehand
+ /// <summary>
+ /// Good filters should replace this by an IEnumerable that does not require generating
+ /// all the indexables beforehand
+ /// </summary>
+ /// <param name="indexable">
+ /// A <see cref="Indexable"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
public virtual bool GenerateNextIndexable (out Indexable indexable)
{
indexable = null;
Modified: branches/beagle-rdf/beagled/FilterFactory.cs
==============================================================================
--- branches/beagle-rdf/beagled/FilterFactory.cs (original)
+++ branches/beagle-rdf/beagled/FilterFactory.cs Mon Mar 3 21:50:12 2008
@@ -309,9 +309,6 @@
}
}
- if (indexable.Crawled)
- candidate_filter.EnableCrawlMode ();
-
// Set the indexable on the filter.
candidate_filter.Indexable = indexable;
Modified: branches/beagle-rdf/beagled/Flavor.cs
==============================================================================
--- branches/beagle-rdf/beagled/Flavor.cs (original)
+++ branches/beagle-rdf/beagled/Flavor.cs Mon Mar 3 21:50:12 2008
@@ -96,10 +96,14 @@
get {
int weight = priority;
+ /* Uri matches are very important, next are extensions and then mimetype.
+ * This allows filters to override everything else by specifying matching Uris,
+ * and override mimetype by matching extensions.
+ */
if (Uri != null)
- weight += 1;
+ weight += 3;
if (Extension != null)
- weight += 1;
+ weight += 2;
if (MimeType != null)
weight += 1;
@@ -128,12 +132,17 @@
public class FlavorComparer : IComparer
{
// flav [larger wt] < flav [smaller wt]
+ // for same wt, use hashcode (never return obj1 == obj2 unless they are actually same)
public int Compare (object obj1, object obj2)
{
FilterFlavor flav1 = (FilterFlavor) obj1;
FilterFlavor flav2 = (FilterFlavor) obj2;
- return flav2.Weight.CompareTo (flav1.Weight);
+ int ret = flav2.Weight.CompareTo (flav1.Weight);
+ if (ret != 0)
+ return ret;
+ else
+ return obj1.GetHashCode () - obj2.GetHashCode ();
}
}
Modified: branches/beagle-rdf/beagled/KMailQueryable/KMailIndexer.cs
==============================================================================
--- branches/beagle-rdf/beagled/KMailQueryable/KMailIndexer.cs (original)
+++ branches/beagle-rdf/beagled/KMailQueryable/KMailIndexer.cs Mon Mar 3 21:50:12 2008
@@ -375,7 +375,7 @@
indexable.HitType = "MailMessage";
indexable.MimeType = "message/rfc822";
indexable.CacheContent = true;
- indexable.Crawled = crawl;
+ indexable.FlushBufferCache = crawl;
indexable.AddProperty (Property.NewUnsearched ("fixme:client", "kmail"));
indexable.AddProperty (Property.NewUnsearched ("fixme:account", account_name));
@@ -401,7 +401,6 @@
indexable.HitType = "MailMessage";
indexable.MimeType = "message/rfc822";
indexable.CacheContent = true;
- indexable.Crawled = true; // mbox files will be stored in temp files, so flush them when done
indexable.AddProperty (Property.NewUnsearched ("fixme:client", "kmail"));
indexable.AddProperty (Property.NewUnsearched ("fixme:account", account_name));
Modified: branches/beagle-rdf/beagled/KonqHistoryQueryable/KonqQueryable.cs
==============================================================================
--- branches/beagle-rdf/beagled/KonqHistoryQueryable/KonqQueryable.cs (original)
+++ branches/beagle-rdf/beagled/KonqHistoryQueryable/KonqQueryable.cs Mon Mar 3 21:50:12 2008
@@ -163,7 +163,7 @@
/////////////////////////////////////////////////
- private Indexable FileToIndexable (string path, bool crawl_mode) {
+ private Indexable FileToIndexable (string path, bool crawling) {
//Logger.Log.Debug ("KonqQ: Trying to index " + path);
FileStream stream;
@@ -207,7 +207,7 @@
indexable.AddProperty (Property.NewUnstored ("fixme:urltoken", StringFu.UrlFuzzyDivide (url)));
// hint for the filter about the charset
indexable.AddProperty (Property.NewUnsearched (StringFu.UnindexedNamespace + "charset", charset));
- indexable.Crawled = crawl_mode;
+ indexable.FlushBufferCache = crawling;
DateTime date = DateTimeUtil.UnixToDateTimeUtc (0);
date = date.AddSeconds (Int64.Parse (creation_date));
Modified: branches/beagle-rdf/beagled/LuceneIndexingDriver.cs
==============================================================================
--- branches/beagle-rdf/beagled/LuceneIndexingDriver.cs (original)
+++ branches/beagle-rdf/beagled/LuceneIndexingDriver.cs Mon Mar 3 21:50:12 2008
@@ -213,19 +213,23 @@
int num_delete = 0;
+ term = new Term ("Uri", uri_str);
// For property changes, only secondary index is modified
+ secondary_reader.Delete (term);
+
+ // Now remove from everywhere else (if asked to remove or if asked to add, in which case
+ // we first remove and then add)
+ // So we also need to remove child documents
if (indexable.Type != IndexableType.PropertyChange) {
- term = new Term ("Uri", uri_str);
num_delete = primary_reader.Delete (term);
+
+ // When we delete an indexable, also delete any children.
+ // FIXME: Shouldn't we also delete any children of children, etc.?
+ term = new Term ("ParentUri", uri_str);
+ num_delete += primary_reader.Delete (term);
secondary_reader.Delete (term);
}
- // When we delete an indexable, also delete any children.
- // FIXME: Shouldn't we also delete any children of children, etc.?
- term = new Term ("ParentUri", uri_str);
- num_delete += primary_reader.Delete (term);
- secondary_reader.Delete (term);
-
// If this is a strict removal (and not a deletion that
// we are doing in anticipation of adding something back),
// queue up a removed receipt.
Modified: branches/beagle-rdf/beagled/Makefile.am
==============================================================================
--- branches/beagle-rdf/beagled/Makefile.am (original)
+++ branches/beagle-rdf/beagled/Makefile.am Mon Mar 3 21:50:12 2008
@@ -8,6 +8,7 @@
$(srcdir)/webinterface/propname-table.js\
$(srcdir)/webinterface/help.html \
$(srcdir)/webinterface/mappings.xml \
+ $(srcdir)/webinterface/opensearch.xml \
$(srcdir)/webinterface/index.xsl \
$(srcdir)/webinterface/hitresult.xsl \
$(srcdir)/webinterface/statusresult.xsl \
Modified: branches/beagle-rdf/beagled/ThunderbirdQueryable/ThunderbirdQueryable.cs
==============================================================================
--- branches/beagle-rdf/beagled/ThunderbirdQueryable/ThunderbirdQueryable.cs (original)
+++ branches/beagle-rdf/beagled/ThunderbirdQueryable/ThunderbirdQueryable.cs Mon Mar 3 21:50:12 2008
@@ -394,9 +394,9 @@
indexable.MimeType = "message/rfc822";
indexable.Timestamp = DateTimeUtil.UnixToDateTimeUtc (Convert.ToInt64 (GetText (document, "Date")));
indexable.CacheContent = true;
- indexable.Crawled = true;
+ indexable.FlushBufferCache = true;
indexable.SetBinaryStream (message.Stream);
-
+
indexable.AddProperty (Property.NewKeyword ("fixme:client", "thunderbird"));
indexable.AddProperty (Property.NewKeyword ("fixme:folder", GetText (document, "Folder")));
indexable.AddProperty (Property.NewUnsearched ("ParentUri", GetText (document, "FolderFile")));
@@ -526,7 +526,7 @@
indexable.MimeType = "text/html";
indexable.Timestamp = DateTimeUtil.UnixToDateTimeUtc (Convert.ToInt64 (GetText (document, "Date")));
indexable.CacheContent = true;
- indexable.Crawled = true;
+ indexable.FlushBufferCache = true;
indexable.AddProperty (Property.NewKeyword ("fixme:client", "thunderbird"));
indexable.AddProperty (Property.NewKeyword ("fixme:folder", GetText (document, "Folder")));
Modified: branches/beagle-rdf/beagled/WebServer.cs
==============================================================================
--- branches/beagle-rdf/beagled/WebServer.cs (original)
+++ branches/beagle-rdf/beagled/WebServer.cs Mon Mar 3 21:50:12 2008
@@ -59,7 +59,7 @@
mappings.Add ("/", new PageMapping ("index.xml", "text/xml; charset=utf-8"));
mappings.Add ("/mappings.xml", new PageMapping ("mappings.xml", "text/xml; charset=utf-8"));
- mappings.Add ("/help.xml", new PageMapping ("help.xml", "text/xml; charset=utf-8"));
+ mappings.Add ("/opensearch.xml", new PageMapping ("opensearch.xml", "text/xml; charset=utf-8"));
mappings.Add ("/index.xsl", new PageMapping ("index.xsl", "text/xml; charset=utf-8"));
mappings.Add ("/statusresult.xsl", new PageMapping ("statusresult.xsl", "text/xml; charset=utf-8"));
mappings.Add ("/hitresult.xsl", new PageMapping ("hitresult.xsl", "text/xml; charset=utf-8"));
Modified: branches/beagle-rdf/beagled/webinterface/index.xsl
==============================================================================
--- branches/beagle-rdf/beagled/webinterface/index.xsl (original)
+++ branches/beagle-rdf/beagled/webinterface/index.xsl Mon Mar 3 21:50:12 2008
@@ -46,6 +46,7 @@
<script src="propname-table.js" type="text/javascript"/>
<script src="default.js" type="text/javascript"/>
<link rel="icon" href="images/favicon.png" type="image/png"/>
+ <link rel="search" type="application/opensearchdescription+xml" title="Beagle" href="opensearch.xml"/>
</head>
</xsl:template>
Modified: branches/beagle-rdf/po/POTFILES.in
==============================================================================
--- branches/beagle-rdf/po/POTFILES.in (original)
+++ branches/beagle-rdf/po/POTFILES.in Mon Mar 3 21:50:12 2008
@@ -56,6 +56,7 @@
search/Beagle.Search/NotificationArea.cs
search/Beagle.Search/Panes.cs
search/Beagle.Search/Search.cs
+search/Beagle.Search/SearchWindow.cs
search/Beagle.Search/SortedTileList.cs
search/Beagle.Search/Spinner.cs
search/Beagle.Search/TileCategory.cs
Modified: branches/beagle-rdf/search/Beagle.Search.Tiles/File.cs
==============================================================================
--- branches/beagle-rdf/search/Beagle.Search.Tiles/File.cs (original)
+++ branches/beagle-rdf/search/Beagle.Search.Tiles/File.cs Mon Mar 3 21:50:12 2008
@@ -21,6 +21,8 @@
public class TileFile : TileTemplate {
+ private static ThumbnailFactory thumbnailer = new ThumbnailFactory ();
+
public TileFile (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
{
Title = GetTitle (hit);
@@ -35,54 +37,50 @@
// AddAction (new TileAction (Catalog.GetString ("Instant-Message"), InstantMessage));
AddAction (new TileAction (Catalog.GetString ("Move to Trash"), Gtk.Stock.Delete, MoveToTrash));
- if (! String.IsNullOrEmpty (Hit.GetFirstProperty("dc:author"))) {
- AddAction(new TileAction ("Find Documents From Same Author", Gtk.Stock.Find, FindSameAuthor));
+ if (! String.IsNullOrEmpty (Hit.GetFirstProperty ("dc:author"))) {
+ AddAction(new TileAction (Catalog.GetString ("Find Documents From Same Author"), Gtk.Stock.Find, FindSameAuthor));
}
EnableOpenWith = true;
}
- static ThumbnailFactory thumbnailer = new ThumbnailFactory ();
-
protected override void LoadIcon (Gtk.Image image, int size)
{
// The File tile doesn't respect the icon size because
// 48 is too small for thumbnails
+
if (!thumbnailer.SetThumbnailIcon (image, Hit, size))
base.LoadIcon (image, size);
// FIXME: Multiple emblems
string emblem = Hit.GetFirstProperty ("nautilus:emblem");
- if (emblem == null)
+
+ if (String.IsNullOrEmpty (emblem))
return;
- Gdk.Pixbuf icon_pixbuf = image.Pixbuf.Copy ();
Gdk.Pixbuf emblem_pixbuf = WidgetFu.LoadThemeIcon ("emblem-" + emblem, 24);
- if (icon_pixbuf == null || emblem_pixbuf == null) {
- if (icon_pixbuf != null)
- icon_pixbuf.Dispose ();
-
- if (emblem_pixbuf == null)
- emblem_pixbuf.Dispose ();
-
+ if (emblem_pixbuf == null)
return;
- }
+
+ Gdk.Pixbuf icon = image.Pixbuf.Copy ();
// If the icon itself is smaller than our requested
- // emblem, just display the emblem.
- if (icon_pixbuf.Height < emblem_pixbuf.Height || icon_pixbuf.Width < emblem_pixbuf.Width) {
- icon_pixbuf.Dispose ();
- image.Pixbuf.Dispose ();
- image.Pixbuf = emblem_pixbuf;
+ // emblem, just display the icon.
+
+ if ((icon.Height < emblem_pixbuf.Height || icon.Width < emblem_pixbuf.Width) ||
+ (icon.Height < (emblem_pixbuf.Height * 2) && icon.Width < (emblem_pixbuf.Width * 2))) {
+ icon.Dispose ();
+ emblem_pixbuf.Dispose ();
return;
}
- emblem_pixbuf.Composite (icon_pixbuf, 0, 0,
- emblem_pixbuf.Width, emblem_pixbuf.Height,
+ emblem_pixbuf.Composite (icon, 0, 0, emblem_pixbuf.Width, emblem_pixbuf.Height,
0, 0, 1, 1, Gdk.InterpType.Bilinear, 255);
+ emblem_pixbuf.Dispose ();
+
image.Pixbuf.Dispose ();
- image.Pixbuf = icon_pixbuf;
+ image.Pixbuf = icon;
}
protected static string GetTitle (Beagle.Hit hit, bool get_parent)
Modified: branches/beagle-rdf/search/Beagle.Search.Tiles/Tile.cs
==============================================================================
--- branches/beagle-rdf/search/Beagle.Search.Tiles/Tile.cs (original)
+++ branches/beagle-rdf/search/Beagle.Search.Tiles/Tile.cs Mon Mar 3 21:50:12 2008
@@ -1,5 +1,11 @@
+//
+// Tile.cs
+//
+// Copyright (C) 2008 Lukas Lipka <lukaslipka gmail com>
+//
+
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Diagnostics;
@@ -13,84 +19,111 @@
public abstract class Tile : Gtk.EventBox {
+ private Beagle.Hit hit = null;
+ private Beagle.Query query = null;
+
+ private Gtk.HBox hbox = null;
+ private Gtk.Image icon = null;
+ private DetailsPane details = null;
+
+ private string title = null;
+ private string snippet = null;
+ private DateTime timestamp;
+ private double score = 0.0f;
+
+ // Default the tile group to documents, it is up
+ // to the each tile to set a specific group.
+
+ private TileGroup group = TileGroup.Documents;
+
+ // DND targets
+
+ static Gtk.TargetEntry[] targets = new Gtk.TargetEntry[] {
+ new Gtk.TargetEntry ("text/uri-list", 0, 0)
+ };
+
+ private List<TileAction> actions = new List<TileAction> ();
+
+ protected bool EnableOpenWith = false;
+
+ public event EventHandler Selected;
+
+ public delegate void GotSnippetHandler (string snippet);
+ public event GotSnippetHandler GotSnippet;
+
public Tile (Hit hit, Query query) : base ()
{
- AboveChild = true;
- AppPaintable = true;
- CanFocus = true;
+ base.AboveChild = true;
+ base.AppPaintable = true;
+ base.CanFocus = true;
this.hit = hit;
+ this.query = query;
this.timestamp = hit.Timestamp;
this.score = hit.Score;
- this.query = query;
- this.group = TileGroup.Documents;
- Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask,
- targets, Gdk.DragAction.Copy | Gdk.DragAction.Move);
+ Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask, targets,
+ Gdk.DragAction.Copy | Gdk.DragAction.Move);
+
+ int pad = (int)StyleGetProperty ("focus-line-width") + (int)StyleGetProperty ("focus-padding") + 1;
hbox = new Gtk.HBox (false, 5);
- hbox.BorderWidth = 2;
+ hbox.BorderWidth = (uint)(pad + Style.Xthickness);
hbox.Show ();
icon = new Gtk.Image ();
icon.Show ();
- HBox.PackStart (icon, false, false, 0);
+ hbox.PackStart (icon, false, false, 0);
Add (hbox);
}
- private Beagle.Hit hit;
- public Beagle.Hit Hit {
- get { return hit; }
- }
-
- private Beagle.Query query;
- public Beagle.Query Query {
- get { return query; }
+ protected void AddAction (TileAction action)
+ {
+ actions.Add (action);
}
- private TileGroup group;
- public TileGroup Group {
- get { return group; }
- set { group = value; }
+ protected void RemoveAction (TileAction action)
+ {
+ actions.Remove (action);
}
- private Gtk.HBox hbox;
- protected Gtk.HBox HBox {
- get { return hbox; }
- }
+ private void ShowPopupMenu ()
+ {
+ Gtk.Menu menu = new Gtk.Menu ();
+
+ // Add the default 'Open' menu item
- private Gtk.Image icon;
- public Gtk.Image Icon {
- get { return icon; }
- set { icon = value; }
- }
+ TileAction open = new TileAction (Catalog.GetString ("Open"), Stock.Open, Open);
- private string title;
- public virtual string Title {
- get { return title; }
- set { title = value; }
- }
+ ActionMenuItem open_menu_item = new ActionMenuItem (open);
+ menu.Append (open_menu_item);
- private DateTime timestamp;
- public virtual DateTime Timestamp {
- get { return timestamp; }
- set { timestamp = value; }
- }
+#if ENABLE_OPEN_WITH
+ if (EnableOpenWith) {
+ // FIXME: Not sure if going with the parent is
+ // the right thing to do in all cases.
+ string mimetype = Utils.GetFirstPropertyOfParent (hit, "beagle:MimeType");
- private double score;
- public virtual double Score {
- get { return score; }
- set { score = value; }
- }
+ OpenWithMenu owm = new OpenWithMenu (mimetype);
+ owm.ApplicationActivated += OpenWith;
+ owm.AppendToMenu (menu);
+ }
+#endif
- protected bool EnableOpenWith = false;
+ if (Actions.Count > 0) {
+ SeparatorMenuItem separator = new SeparatorMenuItem ();
+ menu.Append (separator);
- static Gtk.TargetEntry[] targets = new Gtk.TargetEntry[] {
- new Gtk.TargetEntry ("text/uri-list", 0, 0)
- };
+ foreach (TileAction action in Actions) {
+ ActionMenuItem item = new ActionMenuItem (action);
+ menu.Append (item);
+ }
+ }
- public event EventHandler Selected;
+ menu.ShowAll ();
+ menu.Popup ();
+ }
protected override void OnDragBegin (Gdk.DragContext context)
{
@@ -100,38 +133,35 @@
WidgetFu.SetDragImage (context, icon);
}
- protected override void OnDragDataGet (Gdk.DragContext dragContext,
- Gtk.SelectionData selectionData,
- uint info, uint time)
+ protected override void OnDragDataGet (Gdk.DragContext ctx, Gtk.SelectionData data, uint info, uint time)
{
- byte[] data = System.Text.Encoding.UTF8.GetBytes (Hit.EscapedUri + "\r\n");
- selectionData.Set (selectionData.Target, 8, data);
+ byte[] uri = System.Text.Encoding.UTF8.GetBytes (Hit.EscapedUri + "\r\n");
+ data.Set (data.Target, 8, uri);
}
- protected override void OnSizeRequested (ref Gtk.Requisition req)
+ /*protected override void OnSizeRequested (ref Gtk.Requisition req)
{
- // FIXME: "base.OnSizeRequested (ref req)" should work,
+ // base.OnSizeRequested (ref req) should work,
// but it doesn't
req = hbox.SizeRequest ();
- int pad = (int)StyleGetProperty ("focus-line-width") +
- (int)StyleGetProperty ("focus-padding") + 1;
+ int pad = (int)StyleGetProperty ("focus-line-width") + (int)StyleGetProperty ("focus-padding") + 1;
+
req.Width += 2 * (pad + Style.Xthickness);
req.Height += 2 * (pad + Style.Ythickness);
}
protected override void OnSizeAllocated (Gdk.Rectangle alloc)
{
- int pad = (int)StyleGetProperty ("focus-line-width") +
- (int)StyleGetProperty ("focus-padding") + 1;
+ int pad = (int)StyleGetProperty ("focus-line-width") + (int)StyleGetProperty ("focus-padding") + 1;
alloc.X += pad + Style.Xthickness;
- alloc.Width -= pad + Style.Xthickness;
alloc.Y += pad + Style.Ythickness;
+ alloc.Width -= pad + Style.Xthickness;
alloc.Height -= pad + Style.Ythickness;
base.OnSizeAllocated (alloc);
- }
+ }*/
protected override bool OnExposeEvent (Gdk.EventExpose evt)
{
@@ -156,8 +186,7 @@
int y = focus_padding + Style.Ythickness;
int width = Allocation.Width - 2 * (focus_padding + Style.Xthickness);
int height = Allocation.Height - 2 * (focus_padding + Style.Ythickness);
- Style.PaintFocus (Style, GdkWindow, State, evt.Area, this,
- null, x, y, width, height);
+ Style.PaintFocus (Style, GdkWindow, State, evt.Area, this, null, x, y, width, height);
}
CairoFu.DisposeContext (gr);
@@ -168,62 +197,20 @@
return false;
}
- ///////////////////////////////////////////////////
-
- public ArrayList actions = new ArrayList ();
- public ICollection Actions {
- get { return actions; }
- }
-
- protected void AddAction (TileAction action)
- {
- actions.Add (action);
- }
-
- private void ShowPopupMenu ()
- {
- Gtk.Menu menu = new Gtk.Menu ();
-
- ActionMenuItem mi = new ActionMenuItem (new TileAction (Catalog.GetString ("Open"), Stock.Open, Open));
- menu.Append (mi);
-
-#if ENABLE_OPEN_WITH
- if (EnableOpenWith) {
- // FIXME: Not sure if going with the parent is
- // the right thing to do in all cases.
- OpenWithMenu owm = new OpenWithMenu (Utils.GetFirstPropertyOfParent (hit, "beagle:MimeType"));
- owm.ApplicationActivated += OpenWith;
- owm.AppendToMenu (menu);
- }
-#endif
-
- if (Actions.Count > 0) {
- SeparatorMenuItem si = new SeparatorMenuItem ();
- menu.Append (si);
-
- foreach (TileAction action in Actions) {
- mi = new ActionMenuItem (action);
- menu.Append (mi);
- }
- }
-
- menu.ShowAll ();
- menu.Popup ();
- }
-
- ///////////////////////////////////////////////////
-
protected override bool OnButtonPressEvent (Gdk.EventButton b)
{
GrabFocus ();
if (b.Button == 3) {
ShowPopupMenu ();
+
return true;
} else if (b.Type == Gdk.EventType.TwoButtonPress) {
Open ();
+
if (b.Button == 2 || ((b.State & Gdk.ModifierType.ShiftMask) != 0))
Gtk.Application.Quit ();
+
return true;
}
@@ -234,6 +221,7 @@
{
if (Selected != null)
Selected (this, EventArgs.Empty);
+
return base.OnFocusInEvent (f);
}
@@ -241,8 +229,10 @@
{
if (k.Key == Gdk.Key.Return || k.Key == Gdk.Key.KP_Enter) {
Open ();
+
if ((k.State & Gdk.ModifierType.ShiftMask) != 0)
Gtk.Application.Quit ();
+
return true;
}
@@ -259,13 +249,11 @@
image.Pixbuf = WidgetFu.LoadMimeIcon (hit.MimeType, size);
}
- string snippet;
-
protected void RequestSnippet ()
{
- if (snippet != null)
+ if (snippet != null) {
EmitGotSnippet ();
- else {
+ } else {
SnippetRequest sreq = new SnippetRequest (query, hit);
sreq.RegisterAsyncResponseHandler (typeof (SnippetResponse), SnippetResponseReceived);
sreq.SendAsync ();
@@ -274,36 +262,31 @@
private void SnippetResponseReceived (ResponseMessage response)
{
- // The returned snippet uses
- // <font color="..."><b>blah</b></font>
+ // The returned snippet uses <font color="..."><b>blah</b></font>
// to mark matches. The rest of the snippet might be HTML, or
// it might be plain text, including unescaped '<'s and '&'s.
// So we escape it, fix the match highlighting, and leave any
// other tags escaped.
- // FIXME: hacky, fix the snippeting in the daemon
+ // FIXME: Use the new snippeting framework
snippet = GLib.Markup.EscapeText (((SnippetResponse)response).Snippet);
snippet = Regex.Replace (snippet, "<font color=".*?"><b>(.*?)</b></font>", "<b>$1</b>");
- if(snippet.Trim().Length > 0)
+ if (snippet.Trim ().Length > 0)
EmitGotSnippet ();
}
private void EmitGotSnippet ()
{
- if (!String.IsNullOrEmpty (snippet) && GotSnippet != null)
+ if (! String.IsNullOrEmpty (snippet) && GotSnippet != null)
GotSnippet (snippet);
}
- public delegate void GotSnippetHandler (string snippet);
- public event GotSnippetHandler GotSnippet;
-
protected virtual DetailsPane GetDetails ()
{
return null;
}
- DetailsPane details;
public Gtk.Widget Details {
get {
if (details == null) {
@@ -326,7 +309,7 @@
public virtual void Open ()
{
- System.Console.WriteLine ("Warning: Open method not implemented for this tile type");
+ System.Console.WriteLine ("Warning: Open method not implemented for '{0}'", this.GetType ());
}
#if ENABLE_OPEN_WITH
@@ -454,5 +437,48 @@
}
#endif
}
+
+ ///////////////////////////////////////////////////////
+
+ public Beagle.Hit Hit {
+ get { return hit; }
+ }
+
+ public Beagle.Query Query {
+ get { return query; }
+ }
+
+ public TileGroup Group {
+ get { return group; }
+ protected set { group = value; }
+ }
+
+ protected Gtk.HBox HBox {
+ get { return hbox; }
+ }
+
+ public Gtk.Image Icon {
+ get { return icon; }
+ set { icon = value; }
+ }
+
+ public virtual string Title {
+ get { return title; }
+ set { title = value; }
+ }
+
+ public virtual DateTime Timestamp {
+ get { return timestamp; }
+ set { timestamp = value; }
+ }
+
+ public virtual double Score {
+ get { return score; }
+ set { score = value; }
+ }
+
+ public IList<TileAction> Actions {
+ get { return actions; }
+ }
}
}
Modified: branches/beagle-rdf/search/Beagle.Search/Driver.cs
==============================================================================
--- branches/beagle-rdf/search/Beagle.Search/Driver.cs (original)
+++ branches/beagle-rdf/search/Beagle.Search/Driver.cs Mon Mar 3 21:50:12 2008
@@ -17,13 +17,33 @@
public class Driver {
- private const string INTERFACE_NAME = "org.gnome.Beagle.Search";
+ private const string BUS_NAME = "org.gnome.Beagle";
private const string PATH_NAME = "/org/gnome/Beagle/Search";
+ private static bool icon_enabled = false;
+ private static bool docs_enabled = false;
+
+ public static void PrintUsageAndExit ()
+ {
+ VersionFu.PrintHeader ();
+
+ string usage =
+ "Usage: beagle-search [OPTIONS] [<query string>]\n\n" +
+ "Options:\n" +
+ " --icon\t\t\tAdd an icon to the notification area rather than opening a search window.\n" +
+ " --search-docs\t\t\tAlso search the system-wide documentation index.\n" +
+ " --help\t\t\tPrint this usage message.\n" +
+ " --version\t\t\tPrint version information.\n";
+
+ Console.WriteLine (usage);
+
+ System.Environment.Exit (0);
+ }
+
private static string ParseArgs (String[] args)
{
- string query = String.Empty;
int i = 0;
+ string query = String.Empty;
while (i < args.Length) {
switch (args [i]) {
@@ -37,13 +57,13 @@
Environment.Exit (0);
break;
- //case "--icon":
- //IconEnabled = true;
- //break;
-
- //case "--search-docs":
- //search_docs = true;
- //break;
+ case "--icon":
+ icon_enabled = true;
+ break;
+
+ case "--search-docs":
+ docs_enabled = true;
+ break;
// Ignore session management
case "--sm-config-prefix":
@@ -69,57 +89,42 @@
return query;
}
- public static void PrintUsageAndExit ()
- {
- VersionFu.PrintHeader ();
-
- string usage =
- "Usage: beagle-search [OPTIONS] [<query string>]\n\n" +
- "Options:\n" +
- " --icon\t\t\tAdd an icon to the notification area rather than opening a search window.\n" +
- " --search-docs\t\t\tAlso search the system-wide documentation index.\n" +
- " --help\t\t\tPrint this usage message.\n" +
- " --version\t\t\tPrint version information.\n";
-
- Console.WriteLine (usage);
- System.Environment.Exit (0);
- }
-
public static void Main (string[] args)
{
- // Set our process name
-
- SystemInformation.SetProcessName ("beagle-search");
-
- // Initialize our translations catalog
-
- Catalog.Init ("beagle", ExternalStringsHack.LocaleDir);
-
- // Set up DBus for our GLib main loop
-
BusG.Init ();
- // Parse arguments
-
string query = ParseArgs (args);
- if (Bus.Session.RequestName (INTERFACE_NAME) != RequestNameReply.PrimaryOwner) {
- Console.WriteLine ("There is already an instance of beagle-search running!");
+ // If there is already an instance of beagle-search running
+ // request our search proxy object and open up a query in
+ // that instance.
+
+ if (Bus.Session.RequestName (BUS_NAME) != RequestNameReply.PrimaryOwner) {
+ if (icon_enabled == true) {
+ Console.WriteLine ("There is already an instance of beagle-search running.");
+ Console.WriteLine ("Cannot run in --icon mode! Exiting...");
+ Environment.Exit (1);
+ }
+
+ ISearch s = Bus.Session.GetObject<ISearch> (BUS_NAME, new ObjectPath (PATH_NAME));
+ s.Query (query);
+
return;
}
-
- // Init Gnome program
+ SystemInformation.SetProcessName ("beagle-search");
+ Catalog.Init ("beagle", ExternalStringsHack.LocaleDir);
+
Gnome.Program program = new Gnome.Program ("search", "0.0", Gnome.Modules.UI, args);
- Search window = new Search (query);
-
- Bus.Session.Register (INTERFACE_NAME, new ObjectPath (PATH_NAME), window);
+ // FIXME: Passing these icon and docs enabled properties
+ // sucks. We really need to do something about them.
+ Search search = new Search (icon_enabled, docs_enabled);
+
+ if (!String.IsNullOrEmpty (query) || !icon_enabled)
+ search.Query (query);
- //if (query != null && query != "" && !IconEnabled) {
- // window.entry.Text = query;
- // window.Search (true);
- //}
+ Bus.Session.Register (new ObjectPath (PATH_NAME), search);
program.Run ();
}
Modified: branches/beagle-rdf/search/Beagle.Search/ISearch.cs
==============================================================================
--- branches/beagle-rdf/search/Beagle.Search/ISearch.cs (original)
+++ branches/beagle-rdf/search/Beagle.Search/ISearch.cs Mon Mar 3 21:50:12 2008
@@ -11,9 +11,12 @@
namespace Beagle.Search {
- [Interface ("org.gnome.Beagle.Search")]
+ [Interface ("org.gnome.Beagle")]
public interface ISearch {
- void Show ();
- void Hide ();
+
+ bool IconEnabled { get; }
+ bool DocsEnabled { get; }
+
+ void Query (string query);
}
}
Modified: branches/beagle-rdf/search/Beagle.Search/Search.cs
==============================================================================
--- branches/beagle-rdf/search/Beagle.Search/Search.cs (original)
+++ branches/beagle-rdf/search/Beagle.Search/Search.cs Mon Mar 3 21:50:12 2008
@@ -1,7 +1,6 @@
//
// Search.cs
//
-// Copyright (c) 2006 Novell, Inc.
// Copyright (C) 2008 Lukas Lipka <lukaslipka gmail com>
//
@@ -9,558 +8,117 @@
using System.Collections;
using System.Diagnostics;
-using Gtk;
using NDesk.DBus;
using Mono.Unix;
-using Beagle;
using Beagle.Util;
-
-using Beagle.Search.Tiles;
using Beagle.Search.Tray;
namespace Beagle.Search {
- public class Search : Window, ISearch {
+ public class Search : ISearch {
- private Gtk.Button button;
- private Gtk.Tooltips tips;
- private Gtk.Notebook pages;
- private Gtk.Statusbar statusbar;
-
- private Beagle.Search.UIManager uim;
- private Beagle.Search.NotificationArea notification_area;
- private Beagle.Search.GroupView view;
- private Beagle.Search.Entry entry;
- private Beagle.Search.Spinner spinner;
- private Beagle.Search.Panes panes;
- private Beagle.Search.Tray.TrayIcon tray;
-
- private Beagle.Search.Pages.IndexInfo indexinfo;
- private Beagle.Search.Pages.QuickTips quicktips;
- private Beagle.Search.Pages.RootUser rootuser;
- private Beagle.Search.Pages.StartDaemon startdaemon;
- private Beagle.Search.Pages.NoMatch nomatch;
-
- private Beagle.Search.ScopeType scope = ScopeType.Everything;
- private Beagle.Search.SortType sort = SortType.Modified;
- private Beagle.Search.TypeFilter filter = null;
-
- private uint timeout_id = 0;
-
- private Beagle.Query current_query = null;
- private string query_text = null;
- private bool show_details = true;
- private int total_matches = -1;
+ // The reference count is only valid when
+ // we don't run in icon mode.
- private XKeybinder keybinder = new XKeybinder ();
+ private uint ref_count = 0;
- public static bool IconEnabled = false;
- private static bool search_docs = false;
+ private bool icon_enabled = false;
+ private bool docs_enabled = false;
- public Search (string query_text) : base (WindowType.Toplevel)
- {
- base.Title = Catalog.GetString ("Desktop Search");
- base.Icon = WidgetFu.LoadThemeIcon ("system-search", 16);
+ private SearchWindow icon_window = null;
+ private TrayIcon tray = null;
- base.DefaultWidth = 700;
- base.DefaultHeight = 550;
- base.DeleteEvent += OnWindowDelete;
-
- VBox vbox = new VBox ();
- vbox.Spacing = 3;
-
- uim = new UIManager (this);
- uim.DomainChanged += OnDomainChanged;
- uim.ScopeChanged += OnScopeChanged;
- uim.SortChanged += OnSortChanged;
- uim.ToggleDetails += OnToggleDetails;
- uim.ShowQuickTips += OnShowQuickTips;
- uim.ShowIndexInfo += OnShowIndexInfo;
- vbox.PackStart (uim.MenuBar, false, false, 0);
-
- HBox hbox = new HBox (false, 6);
-
- Label label = new Label (Catalog.GetString ("_Find:"));
- hbox.PackStart (label, false, false, 0);
-
- entry = new Entry ();
- entry.Activated += OnEntryActivated;
- hbox.PackStart (entry, true, true, 0);
-
- label.MnemonicWidget = entry;
- uim.FocusSearchEntry += delegate () { entry.GrabFocus (); };
-
- // The auto search after timeout feauture is now optional
- // and can be disabled.
-
- if (Conf.BeagleSearch.GetOption (Conf.Names.BeagleSearchAutoSearch, true)) {
- entry.Changed += OnEntryResetTimeout;
- entry.MoveCursor += OnEntryResetTimeout;
- }
+ public Search (bool icon_enabled, bool docs_enabled)
+ {
+ this.icon_enabled = icon_enabled;
+ this.docs_enabled = docs_enabled;
- button = new Gtk.Button ();
- Gtk.HBox button_hbox = new Gtk.HBox (false, 2);
- Gtk.Image icon = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Button);
- button_hbox.PackStart (icon, false, false, 0);
- label = new Gtk.Label (Catalog.GetString ("Find Now"));
- button_hbox.PackStart (label, false, false, 0);
- button.Add (button_hbox);
- button.Clicked += OnButtonClicked;
-
- Gtk.VBox buttonVBox = new Gtk.VBox (false, 0);
- buttonVBox.PackStart (button, true, false, 0);
- hbox.PackStart (buttonVBox, false, false, 0);
-
- spinner = new Spinner ();
- hbox.PackStart (spinner, false, false, 0);
-
- HBox padding_hbox = new HBox ();
- padding_hbox.PackStart (hbox, true, true, 9);
- vbox.PackStart (padding_hbox, false, true, 6);
-
- VBox view_box = new VBox (false, 3);
- vbox.PackStart (view_box, true, true, 0);
-
- HBox na_padding = new HBox ();
- view_box.PackStart (na_padding, false, true, 0);
-
- notification_area = new NotificationArea ();
- na_padding.PackStart (notification_area, true, true, 3);
-
- pages = new Gtk.Notebook ();
- pages.ShowTabs = false;
- pages.ShowBorder = false;
- pages.BorderWidth = 3;
- view_box.PackStart (pages, true, true, 0);
-
- quicktips = new Pages.QuickTips ();
- quicktips.Show ();
- pages.Add (quicktips);
-
- indexinfo = new Pages.IndexInfo ();
- indexinfo.Show ();
- pages.Add (indexinfo);
-
- rootuser = new Pages.RootUser ();
- rootuser.Show ();
- pages.Add (rootuser);
-
- startdaemon = new Pages.StartDaemon ();
- startdaemon.DaemonStarted += OnDaemonStarted;
- startdaemon.Show ();
- pages.Add (startdaemon);
-
- panes = new Beagle.Search.Panes ();
- panes.Show ();
- pages.Add (panes);
-
- view = new GroupView ();
- view.TileSelected += ShowInformation;
- view.CategoryToggled += OnCategoryToggled;
- panes.MainContents = view;
-
- this.statusbar = new Gtk.Statusbar ();
- vbox.PackEnd (this.statusbar, false, false, 0);
-
- Add (vbox);
-
- tips = new Gtk.Tooltips ();
- tips.SetTip (entry, Catalog.GetString ("Type in search terms"), "");
- tips.SetTip (button, Catalog.GetString ("Start searching"), "");
- tips.Enable ();
-
- if (Environment.UserName == "root" &&
- ! Conf.Daemon.GetOption (Conf.Names.AllowRoot, false)) {
- pages.CurrentPage = pages.PageNum (rootuser);
- entry.Sensitive = button.Sensitive = uim.Sensitive = false;
- } else {
- pages.CurrentPage = pages.PageNum (quicktips);
- }
+ if (icon_enabled) {
+ icon_window = new SearchWindow (this);
+ icon_window.QueryEvent += OnQueryEvent;
- if (IconEnabled) {
- tray = new Beagle.Search.Tray.TrayIcon ();
+ tray = new TrayIcon ();
tray.Clicked += OnTrayActivated;
tray.Search += OnTraySearch;
Config config = Conf.Get (Conf.Names.BeagleSearchConfig);
+
bool binding_ctrl = config.GetOption (Conf.Names.KeyBinding_Ctrl, false);
bool binding_alt = config.GetOption (Conf.Names.KeyBinding_Alt, false);
string binding_key = config.GetOption (Conf.Names.KeyBinding_Key, "F12");
- string binding = new KeyBinding (binding_key, binding_ctrl, binding_alt).ToString ();
string tip_text = Catalog.GetString ("Desktop Search");
+ string binding = new KeyBinding (binding_key, binding_ctrl, binding_alt).ToString ();
- if (binding != String.Empty) {
+ if (!String.IsNullOrEmpty (binding)) {
tip_text += String.Format (" ({0})", binding);
-
- // Attach the hide/show keybinding
+ XKeybinder keybinder = new XKeybinder ();
keybinder.Bind (binding, OnTrayActivated);
}
tray.TooltipText = tip_text;
- } else {
- ShowAll ();
- }
-
- StartCheckingIndexingStatus ();
-
- if (! String.IsNullOrEmpty (query_text)) {
- entry.Text = query_text;
- Query (true);
}
}
- private void SetWindowTitle (string query)
+ public void Query (string query_text)
{
- Title = String.Format ( Catalog.GetString ("Desktop Search: {0}"), query);
- }
+ if (icon_enabled) {
+ if (!String.IsNullOrEmpty (query_text))
+ icon_window.Search (query_text);
- private int TotalMatches {
- get { return this.total_matches; }
- set {
- if (this.total_matches != -1)
- this.statusbar.Pop (0);
-
- this.total_matches = value;
+ icon_window.ShowAll ();
+ } else {
+ SearchWindow window = new SearchWindow (this);
+ window.DeleteEvent += OnWindowDeleteEvent;
- if (this.total_matches > -1) {
- string message;
- int tile_count = view.TileCount;
-
- if (tile_count == this.total_matches)
- message = String.Format (Catalog.GetPluralString ("Showing {0} match", "Showing all {0} matches", this.total_matches), this.total_matches);
- else
- message = String.Format (Catalog.GetPluralString ("Showing the top {0} of {1} total matches", "Showing the top {0} of {1} total matches", this.total_matches), view.TileCount, this.total_matches);
-
- this.statusbar.Push (0, message);
- }
- }
- }
-
- private void DetachQuery ()
- {
- if (current_query != null) {
- TotalMatches = -1;
- current_query.HitsAddedEvent -= OnHitsAdded;
- current_query.HitsSubtractedEvent -= OnHitsSubtracted;
- current_query.Close ();
- }
- }
-
- // Whether we should grab focus from the text entry
- private bool grab_focus;
-
- private void Query (bool grab_focus)
- {
- if (timeout_id != 0) {
- GLib.Source.Remove (timeout_id);
- timeout_id = 0;
- }
+ if (!String.IsNullOrEmpty (query_text))
+ window.Search (query_text);
- string query = query_text = entry.Text;
- if (query == null || query == "")
- return;
-
- SetWindowTitle (query);
- ShowInformation (null);
-
- if (tray != null) {
- tray.AddSearch (query);
- }
-
- filter = TypeFilter.MakeFilter (ref query);
-
- view.Clear ();
- view.Scope = scope;
- view.SortType = sort;
- pages.CurrentPage = pages.PageNum (panes);
-
- this.grab_focus = grab_focus;
-
- try {
- // Clean up our previous query, if any exists.
- DetachQuery ();
-
- TotalMatches = 0;
-
- current_query = new Query ();
- current_query.AddDomain (QueryDomain.Neighborhood);
-
- // Don't search documentation by default
- if (! search_docs) {
- QueryPart_Property part = new QueryPart_Property ();
- part.Logic = QueryPartLogic.Prohibited;
- part.Type = PropertyType.Keyword;
- part.Key = "beagle:Source";
- part.Value = "documentation";
- current_query.AddPart (part);
- }
-
- current_query.AddText (query);
- current_query.HitsAddedEvent += OnHitsAdded;
- current_query.HitsSubtractedEvent += OnHitsSubtracted;
- current_query.FinishedEvent += OnFinished;
-
- current_query.SendAsync ();
- spinner.Start ();
- } catch (Beagle.ResponseMessageException) {
- pages.CurrentPage = pages.PageNum (startdaemon);
- } catch (Exception e) {
- Console.WriteLine ("Querying the Beagle daemon failed: {0}", e.Message);
+ window.ShowAll ();
+ ref_count++;
}
}
- private void OnEntryActivated (object obj, EventArgs args)
+ private void OnWindowDeleteEvent (object o, Gtk.DeleteEventArgs args)
{
- Query (true);
- }
-
- private void OnDaemonStarted ()
- {
- Query (true);
- }
-
- private void OnEntryResetTimeout (object o, EventArgs args)
- {
- if (timeout_id != 0)
- GLib.Source.Remove (timeout_id);
-
- timeout_id = GLib.Timeout.Add (1000, OnEntryTimeout);
- }
-
- private bool OnEntryTimeout ()
- {
- timeout_id = 0;
- Query (false);
-
- return false;
- }
-
- private void OnButtonClicked (object obj, EventArgs args)
- {
- Query (true);
- }
-
- private void OnWindowDelete (object o, Gtk.DeleteEventArgs args)
- {
- if (IconEnabled) {
- Hide ();
- args.RetVal = true;
- } else {
+ if (--ref_count < 1)
Gtk.Application.Quit ();
- }
}
- private void OnScopeChanged (ScopeType toggled, bool active)
- {
- if (active) {
- view.Scope = scope = scope | toggled;
- } else {
- view.Scope = scope = scope ^ toggled;
- }
-
- CheckNoMatch ();
- }
-
- private void OnCategoryToggled (ScopeType toggled)
- {
- string name = ScopeType.GetName (typeof (ScopeType), toggled);
-
- try {
- ToggleAction act = (ToggleAction) uim.GetAction ("/ui/MenuBar/Search/Scope/" + name);
- act.Active = !act.Active;
- } catch (Exception e) {
- Console.WriteLine ("Exception caught when trying to deactivate menu entry {0}:",name);
- Console.WriteLine (e);
- }
- }
-
- private void OnSortChanged (SortType value)
- {
- view.SortType = sort = value;
- }
-
- private void OnToggleDetails (bool active)
- {
- show_details = active;
- if (panes.Details != null)
- panes.ToggleDetails (show_details);
- else
- panes.ToggleDetails (false);
- }
-
- private void OnShowQuickTips ()
- {
- DetachQuery ();
- pages.CurrentPage = pages.PageNum (quicktips);
- }
-
- private void OnShowIndexInfo ()
- {
- DetachQuery ();
-
- if (! indexinfo.Refresh ())
- pages.CurrentPage = pages.PageNum (startdaemon);
- else
- pages.CurrentPage = pages.PageNum (indexinfo);
- }
-
- private void OnDomainChanged (QueryDomain domain, bool active)
- {
- if (current_query == null)
- return;
-
- // FIXME: Most likely refire the query.
- // Also keep the setting, so it can be used for future queries
- // in this running instance.
-
- if (active)
- current_query.AddDomain (domain);
- else
- current_query.RemoveDomain (domain);
- }
-
- private void ShowInformation (Tiles.Tile tile)
+ private void OnTrayActivated (object o, EventArgs args)
{
- if (tile != null) {
- panes.Details = tile.Details;
- if (tile.Details != null)
- panes.ToggleDetails (show_details);
- else
- panes.ToggleDetails (false);
+ if (! icon_window.Visible) {
+ icon_window.ShowAll ();
+ icon_window.Present ();
+ icon_window.GrabEntryFocus ();
} else {
- panes.Details = null;
- panes.ToggleDetails (false);
+ icon_window.Hide ();
}
}
- private void OnFinished (FinishedResponse response)
- {
- spinner.Stop ();
- view.Finished (grab_focus);
- grab_focus = false;
-
- CheckNoMatch ();
- }
-
- private void OnHitsAdded (HitsAddedResponse response)
- {
- foreach (Hit hit in response.Hits) {
- Tile tile = TileActivatorOrg.MakeTile (hit, current_query);
-
- if (tile == null) {
- Console.WriteLine ("No tile found for: {0} ({1})", hit.Uri, hit.Type);
- continue;
- }
-
- if (filter != null && !filter.Filter (tile))
- continue;
-
- view.AddHit (tile);
-
- if (pages.CurrentPageWidget != panes)
- pages.CurrentPage = pages.PageNum (panes);
- }
-
- if (response.NumMatches != -1)
- TotalMatches += response.NumMatches;
- }
-
- private void OnHitsSubtracted (HitsSubtractedResponse response)
- {
- foreach (Uri uri in response.Uris)
- view.SubtractHit (uri);
-
- TotalMatches -= response.Uris.Count;
-
- CheckNoMatch ();
- }
-
-#if ENABLE_AVAHI
- private void OnUnknownHostFound (object sender, AvahiEventArgs args)
- {
- NotificationMessage m = new NotificationMessage ();
- m.Pixbuf = WidgetFu.LoadThemeIcon ("network-workgroup", 48);
- m.Title = Catalog.GetString ("There are computers near you running Beagle");
- m.Message = Catalog.GetString ("You can select to search other computers from the \"Search\" menu.");
- m.AddAction ("Configure", OnNetworkConfigure);
- notification_area.Display (m);
- }
-
- private void OnNetworkConfigure (object o, EventArgs args)
- {
- Process p = new Process ();
- p.StartInfo.UseShellExecute = false;
- p.StartInfo.FileName = "beagle-settings";
- p.StartInfo.Arguments = "--networking";
-
- try {
- p.Start ();
- } catch (Exception e) {
- Console.WriteLine ("Could not start beagle-settings: {0}", e);
- }
- }
-#endif
-
- private void CheckNoMatch ()
+ private void OnTraySearch (string query)
{
- MatchType matches = view.MatchState;
- if (matches == MatchType.Matched) {
- pages.CurrentPage = pages.PageNum (panes);
- return;
- }
-
- if (nomatch != null)
- nomatch.Destroy ();
- nomatch = new Pages.NoMatch (query_text, matches == MatchType.NoneInScope);
- nomatch.Show ();
- pages.Add (nomatch);
- pages.CurrentPage = pages.PageNum (nomatch);
- }
-
- /////////////////////////////////////
+ if (!icon_window.Visible)
+ icon_window.ShowAll ();
- private void OnTrayActivated (object o, EventArgs args)
- {
- if (! Visible) {
- base.ShowAll ();
- base.Present ();
- entry.GrabFocus ();
- } else {
- base.Hide ();
- }
+ icon_window.Search (query);
}
- private void OnTraySearch (string query)
+ private void OnQueryEvent (string query)
{
- if (!Visible)
- ShowAll ();
+ // Update the list of searches in the tray
+ // icon menu.
- entry.Text = query;
- Query (true);
+ tray.AddSearch (query);
}
- //////////////////////////////////////
-
- private void StartCheckingIndexingStatus ()
- {
- InformationalMessagesRequest msg_request = new InformationalMessagesRequest ();
- msg_request.IndexingStatusEvent += OnIndexingStatusEvent;
- msg_request.SendAsync ();
+ public bool IconEnabled {
+ get { return icon_enabled; }
}
- private void OnIndexingStatusEvent (IndexingStatus status)
- {
- if (status == IndexingStatus.Running) {
- NotificationMessage m = new NotificationMessage ();
- m.Icon = Gtk.Stock.DialogInfo;
- m.Title = Catalog.GetString ("Your data is being indexed");
- m.Message = Catalog.GetString ("The search service is in the process of indexing your data. Search results may be incomplete until indexing has finished.");
- notification_area.Display (m);
- } else {
- notification_area.Hide ();
- }
+ public bool DocsEnabled {
+ get { return docs_enabled; }
}
}
}
Modified: branches/beagle-rdf/search/Beagle.Search/UIManager.cs
==============================================================================
--- branches/beagle-rdf/search/Beagle.Search/UIManager.cs (original)
+++ branches/beagle-rdf/search/Beagle.Search/UIManager.cs Mon Mar 3 21:50:12 2008
@@ -33,20 +33,20 @@
public class UIManager : Gtk.UIManager {
- private Search search = null;
+ private SearchWindow search = null;
private Gtk.ActionGroup actions;
private Gtk.RadioActionEntry[] sort_entries;
private Gtk.ToggleActionEntry[] scope_entries, view_entries, domain_entries;
- public UIManager (Search search)
+ public UIManager (SearchWindow search)
{
this.search = search;
this.actions = new ActionGroup ("Actions");
ActionEntry quit_action_entry;
- if (Search.IconEnabled) {
+ if (search.IconEnabled) {
quit_action_entry = new ActionEntry ("Quit", Gtk.Stock.Close,
null, "<control>Q",
Catalog.GetString ("Close Desktop Search"),
@@ -340,13 +340,13 @@
private void OnHideWindow (object obj, EventArgs args)
{
- if (Search.IconEnabled)
+ if (search.IconEnabled)
search.Hide ();
}
private void Quit (object obj, EventArgs args)
{
- if (Search.IconEnabled) {
+ if (search.IconEnabled) {
search.Hide ();
return;
}
@@ -404,13 +404,13 @@
public delegate void ScopeChangedDelegate (ScopeType scope, bool active);
public event ScopeChangedDelegate ScopeChanged;
- private void OnScopeChanged (object obj, EventArgs args)
+ private void OnScopeChanged (object o, EventArgs args)
{
if (ScopeChanged == null)
return;
- ScopeType scope = (ScopeType) System.Enum.Parse (typeof (ScopeType), ((Action) obj).Name);
- ScopeChanged (scope, ((ToggleAction) obj).Active);
+ ScopeType scope = (ScopeType) System.Enum.Parse (typeof (ScopeType), ((Gtk.Action) o).Name);
+ ScopeChanged (scope, ((ToggleAction) o).Active);
}
public delegate void SortChangedDelegate (SortType scope);
@@ -427,7 +427,7 @@
private void OnDomainChanged (object o, EventArgs args)
{
- QueryDomain domain = (QueryDomain)Enum.Parse (typeof (QueryDomain), ((Action)o).Name);
+ QueryDomain domain = (QueryDomain)Enum.Parse (typeof (QueryDomain), ((Gtk.Action) o).Name);
if (DomainChanged != null)
DomainChanged (domain, ((ToggleAction)o).Active);
Modified: branches/beagle-rdf/search/Makefile.am
==============================================================================
--- branches/beagle-rdf/search/Makefile.am (original)
+++ branches/beagle-rdf/search/Makefile.am Mon Mar 3 21:50:12 2008
@@ -81,6 +81,7 @@
$(srcdir)/Beagle.Search/NotificationArea.cs \
$(srcdir)/Beagle.Search/Panes.cs \
$(srcdir)/Beagle.Search/Search.cs \
+ $(srcdir)/Beagle.Search/SearchWindow.cs \
$(srcdir)/Beagle.Search/SortedTileList.cs \
$(srcdir)/Beagle.Search/Spinner.cs \
$(srcdir)/Beagle.Search/TileCategory.cs \
Modified: branches/beagle-rdf/tools/Makefile.am
==============================================================================
--- branches/beagle-rdf/tools/Makefile.am (original)
+++ branches/beagle-rdf/tools/Makefile.am Mon Mar 3 21:50:12 2008
@@ -5,7 +5,6 @@
LOCAL_ASSEMBLIES = \
../Util/Util.dll \
../BeagleClient/Beagle.dll \
- ../beagled/BeagleDaemonPlugins.dll \
../beagled/BeagleDaemonLib.dll
ASSEMBLIES = \
@@ -49,9 +48,10 @@
INFO_TARGET = Info.exe
INFO_WRAPPER = beagle-info
INFO_CSFILES = $(srcdir)/Info.cs
+INFO_ASSEMBLIES = ../beagled/BeagleDaemonPlugins.dll
-$(INFO_TARGET): $(INFO_CSFILES) $(LOCAL_ASSEMBLIES)
- $(CSC) -out:$@ $(CSFLAGS) $(INFO_CSFILES) $(ASSEMBLIES)
+$(INFO_TARGET): $(INFO_CSFILES) $(LOCAL_ASSEMBLIES) $(INFO_ASSEMBLIES)
+ $(CSC) -out:$@ $(CSFLAGS) $(INFO_CSFILES) $(ASSEMBLIES) $(INFO_ASSEMBLIES:%=-r:%)
$(INFO_WRAPPER): $(WRAPPER_IN)
$(WRAPPER_SED) -e "s|\ target\@|$(INFO_TARGET)|g" < $(srcdir)/$(WRAPPER_IN) > $@
@@ -79,6 +79,17 @@
$(WRAPPER_SED) -e "s|\ target\@|$(QUERY_TARGET)|g" < $(srcdir)/$(WRAPPER_IN) > $@
chmod +x $(QUERY_WRAPPER)
+STATIC_QUERY_TARGET = StaticQuery.exe
+STATIC_QUERY_WRAPPER = beagle-static-query
+STATIC_QUERY_CSFILES = $(srcdir)/StaticQuery.cs
+
+$(STATIC_QUERY_TARGET): $(STATIC_QUERY_CSFILES) $(LOCAL_ASSEMBLIES)
+ $(CSC) -out:$@ $(CSFLAGS) $(STATIC_QUERY_CSFILES) $(ASSEMBLIES)
+
+$(STATIC_QUERY_WRAPPER): $(WRAPPER_IN)
+ $(WRAPPER_SED) -e "s|\ target\@|$(STATIC_QUERY_TARGET)|g" < $(srcdir)/$(WRAPPER_IN) > $@
+ chmod +x $(STATIC_QUERY_WRAPPER)
+
CONFIG_TARGET = Config.exe
CONFIG_WRAPPER = beagle-config
CONFIG_CSFILES = $(srcdir)/Config.cs
@@ -131,6 +142,7 @@
$(INFO_TARGET) \
$(SHUTDOWN_TARGET) \
$(QUERY_TARGET) \
+ $(STATIC_QUERY_TARGET) \
$(CONFIG_TARGET)
if ENABLE_GUI
@@ -151,6 +163,7 @@
$(INFO_WRAPPER) \
$(SHUTDOWN_WRAPPER) \
$(QUERY_WRAPPER) \
+ $(STATIC_QUERY_WRAPPER) \
$(CONFIG_WRAPPER)
if ENABLE_GUI
@@ -234,6 +247,7 @@
$(INFO_CSFILES) \
$(SHUTDOWN_CSFILES) \
$(QUERY_CSFILES) \
+ $(STATIC_QUERY_CSFILES) \
$(CONFIG_CSFILES) \
$(SETTINGS_CSFILES) \
$(SETTINGS_RESOURCES) \
Modified: branches/beagle-rdf/tools/Query.cs
==============================================================================
--- branches/beagle-rdf/tools/Query.cs (original)
+++ branches/beagle-rdf/tools/Query.cs Mon Mar 3 21:50:12 2008
@@ -31,7 +31,6 @@
using System.Reflection;
using System.Threading;
using System.Text;
-using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
using GLib;
@@ -329,4 +328,3 @@
main_loop.Run ();
}
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]