f-spot r4396 - in trunk: . src src/Utils
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4396 - in trunk: . src src/Utils
- Date: Wed, 17 Sep 2008 12:00:32 +0000 (UTC)
Author: sdelcroix
Date: Wed Sep 17 12:00:32 2008
New Revision: 4396
URL: http://svn.gnome.org/viewvc/f-spot?rev=4396&view=rev
Log:
Workaround for gsd 2.24
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/PixbufCache.cs
trunk/src/Preferences.cs
trunk/src/Utils/Unix.cs
trunk/src/main.cs
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Sep 17 12:00:32 2008
@@ -1,7 +1,7 @@
include $(top_srcdir)/Makefile.include
UNSAFE = -unsafe
NOWARN = -nowarn:0169 -nowarn:0612 -nowarn:0414
-EXTRAFLAGS = -d:TEST_METADATA -d:BROKEN_RSVG $(CSC_DEFINES)
+EXTRAFLAGS = -d:TEST_METADATA -d:BROKEN_RSVG -d:GSD_2_24 $(CSC_DEFINES)
CMS_CSDISTFILES = \
$(srcdir)/Cms/CctTable.cs \
Modified: trunk/src/PixbufCache.cs
==============================================================================
--- trunk/src/PixbufCache.cs (original)
+++ trunk/src/PixbufCache.cs Wed Sep 17 12:00:32 2008
@@ -57,6 +57,11 @@
}
Monitor.Pulse (items);
}
+#if GSD_2_24
+ if (!System.IO.File.Exists (path))
+ return;
+ Utils.Unix.Touch (path);
+#endif
}
public void Update (string path, Gdk.Pixbuf pixbuf)
Modified: trunk/src/Preferences.cs
==============================================================================
--- trunk/src/Preferences.cs (original)
+++ trunk/src/Preferences.cs Wed Sep 17 12:00:32 2008
@@ -82,6 +82,9 @@
public const string PROXY_PASSWORD = "/system/http_proxy/authentication_password";
public const string PROXY_BYPASS_LIST = "/system/http_proxy/ignore_hosts";
+ public const string GSD_THUMBS_MAX_AGE = "/desktop/gnome/thumbnail_cache/maximum_age";
+ public const string GSD_THUMBS_MAX_SIZE = "/desktop/gnome/thumbnail_cache/maximum_size";
+
private static IPreferenceBackend backend;
private static NotifyChangedHandler changed_handler;
@@ -202,28 +205,37 @@
}
}
- public static T Get<T> (string key)
+ //return true if the key exists in the backend
+ public static bool TryGet<T> (string key, out T value)
{
lock (cache) {
- T val = default (T);
+ value = default (T);
object o;
- if (cache.TryGetValue (key, out o))
- return (T)o;
+ if (cache.TryGetValue (key, out o)) {
+ value = (T)o;
+ return true;
+ }
try {
- try {
- val = (T) Backend.Get (key);
- } catch (NoSuchKeyException) {
- val = (T) GetDefault (key);
- } catch (InvalidCastException) {
- val = (T) GetDefault (key);
- }
- } catch {
- val = default(T);
+ value = (T) Backend.Get (key);
+ } catch { //catching NoSuchKeyException
+ return false;
}
- cache.Add (key, val);
+ cache.Add (key, value);
+ return true;
+ }
+ }
+
+ public static T Get<T> (string key)
+ {
+ T val;
+ if (TryGet<T> (key, out val))
return val;
+ try {
+ return (T) GetDefault (key);
+ } catch { //catching InvalidCastException
+ return default (T);
}
}
Modified: trunk/src/Utils/Unix.cs
==============================================================================
--- trunk/src/Utils/Unix.cs (original)
+++ trunk/src/Utils/Unix.cs Wed Sep 17 12:00:32 2008
@@ -13,6 +13,9 @@
[DllImport("libc", EntryPoint="prctl")]
public static extern int PrCtl(int option, string name, ulong arg3, ulong arg4, ulong arg5);
+
+ [DllImport("libc", EntryPoint="utime")]
+ public static extern int UTime (string filename, IntPtr buf);
}
public static int Rename (string oldpath, string newpath)
@@ -47,5 +50,11 @@
/* noop */
}
}
+
+ public static void Touch (string filename)
+ {
+ if (NativeMethods.UTime (filename, IntPtr.Zero) != 0)
+ Log.DebugFormat ("touch on {0} failed", filename);
+ }
}
}
Modified: trunk/src/main.cs
==============================================================================
--- trunk/src/main.cs (original)
+++ trunk/src/main.cs Wed Sep 17 12:00:32 2008
@@ -300,13 +300,42 @@
if (import_uri != null || !view) {
control.Organize ();
Gdk.Global.NotifyStartupComplete ();
- foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
- service.Initialize ();
- service.Start ();
- }
-
+ foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
+ service.Initialize ();
+ service.Start ();
+ }
}
+#if GSD_2_24
+ Log.Information ("Hack for gnome-settings-daemon engaged");
+ int max_age, max_size;
+ if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age)) {
+ if (max_age < 0)
+ Log.Debug ("maximum_age check already disabled, good");
+ else if (max_age == 0)
+ Log.Warning ("maximum_age is 0 (tin-hat mode), not overriding");
+ else if (max_age < 180) {
+ Log.Debug ("Setting maximum_age to a saner value");
+ Preferences.Set (Preferences.GSD_THUMBS_MAX_AGE, 180);
+ }
+ }
+
+ if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size)) {
+ int count = Core.Database.Photos.Count ("photos");
+ // average thumbs are taking 70K, so this will push the threshold
+ //if f-spot takes more than 70% of the thumbs space
+ int size = count / 10;
+ if (max_size < 0)
+ Log.Debug ("maximum_size check already disabled, good");
+ else if (max_size == 0)
+ Log.Warning ("maximum_size is 0 (tin-hat mode), not overriding");
+ else if (max_size < size) {
+ Log.DebugFormat ("Setting maximum_size to a saner value ({0}MB), according to your db size", size);
+ Preferences.Set (Preferences.GSD_THUMBS_MAX_SIZE, size);
+ }
+ }
+
+#endif
if (program != null)
program.Run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]