nemo r19 - in trunk: common metadata
- From: arj svn gnome org
- To: svn-commits-list gnome org
- Subject: nemo r19 - in trunk: common metadata
- Date: Mon, 7 Jan 2008 10:35:41 +0000 (GMT)
Author: arj
Date: Mon Jan 7 10:35:41 2008
New Revision: 19
URL: http://svn.gnome.org/viewvc/nemo?rev=19&view=rev
Log:
Refactoring
Modified:
trunk/common/Common.cs
trunk/metadata/MetadataStore.cs
Modified: trunk/common/Common.cs
==============================================================================
--- trunk/common/Common.cs (original)
+++ trunk/common/Common.cs Mon Jan 7 10:35:41 2008
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
+using System.Threading;
using System.IO;
namespace Nemo
@@ -28,7 +29,25 @@
{
return delegate { Gtk.Application.Invoke( delegate { b(); }); };
}
-
+
+ private static Timer update_timer;
+
+ public static void RunOnlyOnce(VoidFunction func, int timeout /* ms */)
+ {
+ if (update_timer != null)
+ return;
+
+ update_timer = new Timer(delegate(Object s) { RunOnlyOnceTimedOut(func); }, null,
+ timeout /* msecs */, Timeout.Infinite);
+ }
+
+ public static void RunOnlyOnceTimedOut(VoidFunction func)
+ {
+ func();
+ update_timer.Dispose();
+ update_timer = null;
+ }
+
public static Type load<Type>(string filename)
{
Type loaded = default(Type);
Modified: trunk/metadata/MetadataStore.cs
==============================================================================
--- trunk/metadata/MetadataStore.cs (original)
+++ trunk/metadata/MetadataStore.cs Mon Jan 7 10:35:41 2008
@@ -129,7 +129,6 @@
private VoidFunction<List<File>> query_result_changed_callback;
private VoidFunction<List<MetaLabel>> labels_changed_callback;
private VoidFunction<List<Tuple<FileTypeCategory, int>>> type_labels_changed_callback;
- private volatile Timer query_result_update_timer;
string[] exclude_dirs;
string[] excludes;
@@ -140,7 +139,6 @@
{
this.watch_path = new FileInfo(watch_path).FullName;
current_query = null;
- query_result_update_timer = null;
database_work_count = 0;
excludes = Singleton<Configuration>.Instance.data.exclude_files.Split(' ');
@@ -405,14 +403,6 @@
// FIXME
System.Console.WriteLine("error error");
}
-
- private void update_query_result(Object s)
- {
- trigger_query_result_changed();
- Timer t = query_result_update_timer;
- query_result_update_timer = null;
- t.Dispose();
- }
// db updater thread
private void db_runner()
@@ -476,16 +466,6 @@
return path.StartsWith(watch_path);
}
- private void db_schedule_query_result_update()
- {
- if (query_result_update_timer != null)
- return;
-
- query_result_update_timer
- = new Timer(update_query_result, null,
- 100 /* msecs */, Timeout.Infinite);
- }
-
private void db_handle_change(string path)
{
try {
@@ -519,7 +499,7 @@
bool is_in_query = database.file_path_is_in_query(path, current_query);
if (is_in_query || was_in_query != is_in_query)
- db_schedule_query_result_update();
+ Helpers.RunOnlyOnce(trigger_query_result_changed, 100);
}
catch (System.IO.FileNotFoundException) {
// these are ok
@@ -554,6 +534,11 @@
throw; // FIXME
}
}
+
+ private void db_schedule_query_result_update()
+ {
+ Helpers.RunOnlyOnce(trigger_query_result_changed, 100);
+ }
private void db_handle_rename(RenamedEventArgs e)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]