[f-spot] More little changes this time in Core
- From: Stephen Shaw <sshaw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] More little changes this time in Core
- Date: Tue, 10 Apr 2012 21:42:38 +0000 (UTC)
commit 29ba3800121c9643c49eba92f21e799e27b0cc8e
Author: Stephen Shaw <sshaw decriptor com>
Date: Fri Mar 23 18:07:11 2012 -0600
More little changes this time in Core
Again thanks to jetbrains for a license
to resharper and the help of their tool
to suggest most of these changes.
None of the changes should have affected
the logic of the code.
src/Core/FSpot.Bling/FSpot.Bling/BackEase.cs | 3 +-
src/Core/FSpot.Bling/FSpot.Bling/CubicEase.cs | 7 +-
src/Core/FSpot.Bling/FSpot.Bling/EasedAnimation.cs | 2 +-
src/Core/FSpot.Bling/FSpot.Bling/QuinticEase.cs | 6 +-
src/Core/FSpot.Cms/Cms/CmsException.cs | 4 +-
src/Core/FSpot.Cms/Cms/Profile.cs | 24 +-
src/Core/FSpot.Cms/Cms/SaveException.cs | 6 +-
src/Core/FSpot.Cms/FSpot.Cms.csproj | 3 +-
src/Core/FSpot.Core/FSpot.Core.csproj | 3 +-
.../FSpot.Core/BrowsableCollectionProxy.cs | 15 +-
src/Core/FSpot.Core/FSpot.Core/BrowsablePointer.cs | 50 +-
.../FSpot.Core/BrowsablePointerChangedEventArgs.cs | 2 +-
src/Core/FSpot.Core/FSpot.Core/DbItem.cs | 4 +-
src/Core/FSpot.Core/FSpot.Core/PhotoChanges.cs | 35 +-
src/Core/FSpot.Core/FSpot.Core/PhotoList.cs | 9 +-
src/Core/FSpot.Core/FSpot.Core/PhotosChanges.cs | 25 +-
src/Core/FSpot.Core/FSpot.Core/Tag.cs | 14 +-
src/Core/FSpot.Gui/FSpot.Gui.csproj | 3 +-
src/Core/FSpot.Gui/FSpot.Gui/WindowOpacityFader.cs | 4 +-
.../FSpot.Gui/FSpot.Transitions/CairoTransition.cs | 4 +-
.../FSpot.Transitions/SlideShowTransition.cs | 17 +-
.../FSpot.Widgets/ApplicationActivatedEventArgs.cs | 2 +-
src/Core/FSpot.Gui/FSpot.Widgets/CellGridView.cs | 906 ++++++++++----------
src/Core/FSpot.Gui/FSpot.Widgets/Curve.cs | 3 +-
.../FSpot.Gui/FSpot.Widgets/CustomPrintWidget.cs | 48 +-
src/Core/FSpot.Gui/FSpot.Widgets/DateEdit.cs | 10 +-
src/Core/FSpot.Gui/FSpot.Widgets/HighlightedBox.cs | 2 +-
src/Core/FSpot.Gui/FSpot.Widgets/ImageView.cs | 44 +-
.../FSpot.Gui/FSpot.Widgets/ImageView_Container.cs | 239 +++---
src/Core/FSpot.Gui/FSpot.Widgets/Layout.cs | 79 +-
src/Core/FSpot.Gui/FSpot.Widgets/MenuButton.cs | 32 +-
src/Core/FSpot.Gui/FSpot.Widgets/OpenWithMenu.cs | 23 +-
src/Core/FSpot.Gui/FSpot.Widgets/RatingRenderer.cs | 29 +-
src/Core/FSpot.Gui/FSpot.Widgets/ScrolledView.cs | 3 +-
.../FSpot.Gui/FSpot.Widgets/SelectionCollection.cs | 95 +--
.../FSpot.JobScheduler/Banshee.Base/FSpotCompat.cs | 12 +-
.../Banshee.Kernel/IntervalHeap.cs | 2 +-
.../FSpot.Platform/PreferenceBackend.cs | 10 +-
src/Core/FSpot.Query/FSpot.Query/LogicalTerm.cs | 47 +-
src/Core/FSpot.Utils/FSpot.Utils.csproj | 3 +-
src/Core/FSpot.Utils/FSpot.Utils/Cache.cs | 7 +-
.../FSpot.Utils/FSpot.Utils/DelayedOperation.cs | 6 +-
src/Core/FSpot.Utils/FSpot.Utils/FileExtensions.cs | 1 +
src/Core/FSpot.Utils/FSpot.Utils/PixbufUtils.cs | 40 +-
.../FSpot.Utils/RecursiveFileEnumerator.cs | 1 +
.../FSpot.Utils/SidecarXmpExtensions.cs | 113 ++--
src/Core/FSpot.Utils/FSpot.Utils/UriList.cs | 9 +-
.../FSpot.Utils/FSpot.Utils/XdgThumbnailSpec.cs | 6 +-
48 files changed, 942 insertions(+), 1070 deletions(-)
---
diff --git a/src/Core/FSpot.Bling/FSpot.Bling/BackEase.cs b/src/Core/FSpot.Bling/FSpot.Bling/BackEase.cs
index 25b12ce..aab49bc 100644
--- a/src/Core/FSpot.Bling/FSpot.Bling/BackEase.cs
+++ b/src/Core/FSpot.Bling/FSpot.Bling/BackEase.cs
@@ -30,6 +30,7 @@
using System;
namespace FSpot.Bling
+ // FIXME: This is never used
{ public abstract class BackEase : EasingFunction
{
double amplitude;
@@ -38,7 +39,7 @@ namespace FSpot.Bling
{
}
- public BackEase (double amplitude) : base ()
+ public BackEase (double amplitude)
{
if (amplitude < 0)
throw new ArgumentOutOfRangeException ("amplitude");
diff --git a/src/Core/FSpot.Bling/FSpot.Bling/CubicEase.cs b/src/Core/FSpot.Bling/FSpot.Bling/CubicEase.cs
index a31e93c..d945cf7 100644
--- a/src/Core/FSpot.Bling/FSpot.Bling/CubicEase.cs
+++ b/src/Core/FSpot.Bling/FSpot.Bling/CubicEase.cs
@@ -29,11 +29,8 @@
namespace FSpot.Bling
{ public class CubicEase : EasingFunction
- {
- public CubicEase () : base ()
- {
- }
-
+ {
+
public CubicEase (EasingMode easingMode) : base (easingMode)
{
}
diff --git a/src/Core/FSpot.Bling/FSpot.Bling/EasedAnimation.cs b/src/Core/FSpot.Bling/FSpot.Bling/EasedAnimation.cs
index dad8e71..3a76f9e 100644
--- a/src/Core/FSpot.Bling/FSpot.Bling/EasedAnimation.cs
+++ b/src/Core/FSpot.Bling/FSpot.Bling/EasedAnimation.cs
@@ -37,7 +37,7 @@ namespace FSpot.Bling
{
}
- public EasedAnimation (EasingFunction easingFunction) : base ()
+ public EasedAnimation (EasingFunction easingFunction)
{
EasingFunction = easingFunction;
}
diff --git a/src/Core/FSpot.Bling/FSpot.Bling/QuinticEase.cs b/src/Core/FSpot.Bling/FSpot.Bling/QuinticEase.cs
index f1c0fb0..53afcea 100644
--- a/src/Core/FSpot.Bling/FSpot.Bling/QuinticEase.cs
+++ b/src/Core/FSpot.Bling/FSpot.Bling/QuinticEase.cs
@@ -28,9 +28,11 @@
//
namespace FSpot.Bling
-{ public abstract class QuinticEase : EasingFunction
+{
+ // FIXME: This is never used
+ public abstract class QuinticEase : EasingFunction
{
- public QuinticEase () : base ()
+ public QuinticEase ()
{
}
diff --git a/src/Core/FSpot.Cms/Cms/CmsException.cs b/src/Core/FSpot.Cms/Cms/CmsException.cs
index b4bb642..2ae00f1 100644
--- a/src/Core/FSpot.Cms/Cms/CmsException.cs
+++ b/src/Core/FSpot.Cms/Cms/CmsException.cs
@@ -32,7 +32,7 @@ using System.Runtime.Serialization;
namespace Cms {
[Serializable]
- public class CmsException : System.Exception {
+ public class CmsException : Exception {
public CmsException (string message) : base (message)
{
}
@@ -45,7 +45,7 @@ namespace Cms {
{
}
- public CmsException () : base ()
+ public CmsException ()
{
}
}
diff --git a/src/Core/FSpot.Cms/Cms/Profile.cs b/src/Core/FSpot.Cms/Cms/Profile.cs
index deef8ed..138e4fb 100644
--- a/src/Core/FSpot.Cms/Cms/Profile.cs
+++ b/src/Core/FSpot.Cms/Cms/Profile.cs
@@ -83,14 +83,13 @@ namespace Cms {
return new Profile (NativeMethods.CmsCreateLabProfile (IntPtr.Zero));
}
- public static Profile CreateGray (ColorCIExyY whitePoint, GammaTable transfer)
- {
+ public static Profile CreateGray (ColorCIExyY whitePoint, GammaTable transfer)
+ {
if (transfer == null)
- return new Profile (NativeMethods.CmsCreateGrayProfile (ref whitePoint, new GammaTable (4096, 2.2).Handle));
- else
- return new Profile (NativeMethods.CmsCreateGrayProfile (ref whitePoint, transfer.Handle));
- }
-
+ return new Profile (NativeMethods.CmsCreateGrayProfile (ref whitePoint, new GammaTable (4096, 2.2).Handle));
+ return new Profile (NativeMethods.CmsCreateGrayProfile (ref whitePoint, transfer.Handle));
+ }
+
public static Profile GetScreenProfile (Gdk.Screen screen)
{
if (screen == null)
@@ -98,10 +97,7 @@ namespace Cms {
IntPtr profile = NativeMethods.FScreenGetProfile (screen.Handle);
- if (profile == IntPtr.Zero)
- return null;
-
- return new Profile (profile);
+ return profile == IntPtr.Zero ? null : new Profile (profile);
}
@@ -237,9 +233,9 @@ namespace Cms {
}
if (profileh == IntPtr.Zero)
- throw new CmsException ("Invalid Profile Data");
- else
- Handle = new HandleRef (this, profileh);
+ throw new CmsException ("Invalid Profile Data");
+
+ Handle = new HandleRef (this, profileh);
}
public ColorCIEXYZ MediaWhitePoint {
diff --git a/src/Core/FSpot.Cms/Cms/SaveException.cs b/src/Core/FSpot.Cms/Cms/SaveException.cs
index 4edf837..5675ff1 100644
--- a/src/Core/FSpot.Cms/Cms/SaveException.cs
+++ b/src/Core/FSpot.Cms/Cms/SaveException.cs
@@ -43,10 +43,6 @@ namespace Cms {
public SaveException (string message, Exception innerException) : base (message, innerException)
{
- }
-
- public SaveException () : base ()
- {
- }
+ }
}
}
diff --git a/src/Core/FSpot.Cms/FSpot.Cms.csproj b/src/Core/FSpot.Cms/FSpot.Cms.csproj
index eed3c93..0ef7004 100644
--- a/src/Core/FSpot.Cms/FSpot.Cms.csproj
+++ b/src/Core/FSpot.Cms/FSpot.Cms.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+ï<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -87,6 +87,7 @@
</ProjectExtensions>
<ItemGroup>
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
diff --git a/src/Core/FSpot.Core/FSpot.Core.csproj b/src/Core/FSpot.Core/FSpot.Core.csproj
index f5b48ae..4bc2f6a 100644
--- a/src/Core/FSpot.Core/FSpot.Core.csproj
+++ b/src/Core/FSpot.Core/FSpot.Core.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+ï<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -96,6 +96,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="System.Xml" />
<Reference Include="Mono.Posix" />
diff --git a/src/Core/FSpot.Core/FSpot.Core/BrowsableCollectionProxy.cs b/src/Core/FSpot.Core/FSpot.Core/BrowsableCollectionProxy.cs
index d2c9fba..4dc47c9 100644
--- a/src/Core/FSpot.Core/FSpot.Core/BrowsableCollectionProxy.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/BrowsableCollectionProxy.cs
@@ -65,17 +65,16 @@ namespace FSpot.Core {
return collection.IndexOf (item);
}
- public bool Contains (IPhoto item)
- {
- if (collection == null)
- return false;
- return collection.Contains (item);
- }
-
- public IPhoto this [int index] {
+ public bool Contains (IPhoto item)
+ {
+ return collection != null && collection.Contains (item);
+ }
+
+ public IPhoto this [int index] {
get {
if (collection == null)
throw new System.IndexOutOfRangeException ();
+
return collection [index];
}
}
diff --git a/src/Core/FSpot.Core/FSpot.Core/BrowsablePointer.cs b/src/Core/FSpot.Core/FSpot.Core/BrowsablePointer.cs
index d9e59ef..c35034a 100644
--- a/src/Core/FSpot.Core/FSpot.Core/BrowsablePointer.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/BrowsablePointer.cs
@@ -46,7 +46,7 @@ namespace FSpot.Core
throw new ArgumentNullException ("collection");
this.collection = collection;
- this.Index = index;
+ Index = index;
item = Current;
collection.Changed += HandleCollectionChanged;
@@ -58,12 +58,10 @@ namespace FSpot.Core
}
public IPhoto Current {
- get {
- if (!this.IsValid)
- return null;
- else
- return collection [index];
- }
+ get
+ {
+ return !IsValid ? null : collection [index];
+ }
}
private bool Valid (int val)
@@ -72,7 +70,7 @@ namespace FSpot.Core
}
public bool IsValid {
- get { return Valid (this.Index); }
+ get { return Valid (Index); }
}
public void MoveFirst ()
@@ -83,14 +81,9 @@ namespace FSpot.Core
public void MoveLast ()
{
Index = collection.Count - 1;
- }
-
- public void MoveNext ()
- {
- MoveNext (false);
- }
-
- public void MoveNext (bool wrap)
+ }
+
+ public void MoveNext (bool wrap = false)
{
int val = Index;
@@ -99,14 +92,9 @@ namespace FSpot.Core
val = wrap ? 0 : Index;
Index = val;
- }
-
- public void MovePrevious ()
- {
- MovePrevious (false);
- }
-
- public void MovePrevious (bool wrap)
+ }
+
+ public void MovePrevious (bool wrap = false)
{
int val = Index;
@@ -124,14 +112,9 @@ namespace FSpot.Core
SetIndex (value);
}
}
- }
-
- private void SetIndex (int value)
- {
- SetIndex (value, null);
- }
-
- private void SetIndex (int value, IBrowsableItemChanges changes)
+ }
+
+ private void SetIndex (int value, IBrowsableItemChanges changes = null)
{
BrowsablePointerChangedEventArgs args = new BrowsablePointerChangedEventArgs (Current, index, changes);
@@ -154,12 +137,13 @@ namespace FSpot.Core
{
if (collection == null)
throw new ArgumentNullException ("collection");
+
int old_location = Index;
int next_location = collection.IndexOf (item);
if (old_location == next_location) {
if (! Valid (next_location))
- SetIndex (0, null);
+ SetIndex (0);
return;
}
diff --git a/src/Core/FSpot.Core/FSpot.Core/BrowsablePointerChangedEventArgs.cs b/src/Core/FSpot.Core/FSpot.Core/BrowsablePointerChangedEventArgs.cs
index 741dc0d..b3f77bf 100644
--- a/src/Core/FSpot.Core/FSpot.Core/BrowsablePointerChangedEventArgs.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/BrowsablePointerChangedEventArgs.cs
@@ -37,7 +37,7 @@ namespace FSpot.Core
public int PreviousIndex { get; private set; }
public IBrowsableItemChanges Changes { get; private set; }
- public BrowsablePointerChangedEventArgs (IPhoto previous_item, int previous_index, IBrowsableItemChanges changes) : base ()
+ public BrowsablePointerChangedEventArgs (IPhoto previous_item, int previous_index, IBrowsableItemChanges changes)
{
PreviousItem = previous_item;
PreviousIndex = previous_index;
diff --git a/src/Core/FSpot.Core/FSpot.Core/DbItem.cs b/src/Core/FSpot.Core/FSpot.Core/DbItem.cs
index ac4b77e..90ff619 100644
--- a/src/Core/FSpot.Core/FSpot.Core/DbItem.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/DbItem.cs
@@ -47,12 +47,12 @@ namespace FSpot.Core
{
public T [] Items { get; private set; }
- public DbItemEventArgs (T [] items) : base ()
+ public DbItemEventArgs (T [] items)
{
Items = items;
}
- public DbItemEventArgs (T item) : base ()
+ public DbItemEventArgs (T item)
{
Items = new T [] { item };
}
diff --git a/src/Core/FSpot.Core/FSpot.Core/PhotoChanges.cs b/src/Core/FSpot.Core/FSpot.Core/PhotoChanges.cs
index 9652153..8d3b283 100644
--- a/src/Core/FSpot.Core/FSpot.Core/PhotoChanges.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/PhotoChanges.cs
@@ -48,9 +48,8 @@ namespace FSpot.Core
get {
if (tags_added == null)
return null;
- if (tags_added.Count == 0)
- return null;
- return tags_added.ToArray ();
+
+ return tags_added.Count == 0 ? null : tags_added.ToArray ();
}
set {
foreach (Tag t in value)
@@ -73,9 +72,8 @@ namespace FSpot.Core
get {
if (tags_removed == null)
return null;
- if (tags_removed.Count == 0)
- return null;
- return tags_removed.ToArray ();
+
+ return tags_removed.Count == 0 ? null : tags_removed.ToArray ();
}
set {
foreach (Tag t in value)
@@ -98,9 +96,8 @@ namespace FSpot.Core
get {
if (versions_added == null)
return null;
- if (versions_added.Count == 0)
- return null;
- return versions_added.ToArray ();
+
+ return versions_added.Count == 0 ? null : versions_added.ToArray ();
}
set {
foreach (uint u in value)
@@ -120,9 +117,8 @@ namespace FSpot.Core
get {
if (versions_removed == null)
return null;
- if (versions_removed.Count == 0)
- return null;
- return versions_removed.ToArray ();
+
+ return versions_removed.Count == 0 ? null : versions_removed.ToArray ();
}
set {
foreach (uint u in value)
@@ -141,15 +137,13 @@ namespace FSpot.Core
versions_removed.Add (v);
}
-
List<uint> versions_modified = null;
public uint [] VersionsModified {
get {
if (versions_modified == null)
return null;
- if (versions_modified.Count == 0)
- return null;
- return versions_modified.ToArray ();
+
+ return versions_modified.Count == 0 ? null : versions_modified.ToArray ();
}
set {
foreach (uint u in value)
@@ -161,15 +155,14 @@ namespace FSpot.Core
{
if (versions_modified == null)
versions_modified = new List<uint> ();
+
if (versions_added != null && versions_added.Contains (v))
return;
+
if (versions_removed != null && versions_removed.Contains (v))
return;
- versions_modified.Add (v);
- }
- public PhotoChanges ()
- {
- }
+ versions_modified.Add (v);
+ }
}
}
diff --git a/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs b/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs
index 91ee84a..dec1f47 100644
--- a/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs
@@ -115,13 +115,8 @@ namespace FSpot.Core
}
public IPhoto[] Items {
- get {
- if (cache == null)
- cache = list.ToArray ();
-
- return cache;
- }
- set {
+ get { return cache ?? (cache = list.ToArray()); }
+ set {
list.Clear ();
Add (value);
}
diff --git a/src/Core/FSpot.Core/FSpot.Core/PhotosChanges.cs b/src/Core/FSpot.Core/FSpot.Core/PhotosChanges.cs
index c9657cb..34ad629 100644
--- a/src/Core/FSpot.Core/FSpot.Core/PhotosChanges.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/PhotosChanges.cs
@@ -106,17 +106,12 @@ namespace FSpot.Core
else
changes &= ~ Changes.Description;
}
- }
- bool tags_changed = false;
- public virtual bool TagsChanged {
- get { return tags_changed; }
- private set { tags_changed = value; }
- }
- bool versions_changed = false;
- public virtual bool VersionsChanged {
- get { return versions_changed; }
- private set { versions_changed = value; }
- }
+ }
+
+ public virtual bool TagsChanged { get; private set; }
+
+ public virtual bool VersionsChanged { get; private set; }
+
public bool RollIdChanged {
get { return (changes & Changes.RollId) == Changes.RollId; }
set {
@@ -152,8 +147,10 @@ namespace FSpot.Core
return changes;
}
- public PhotosChanges ()
- {
- }
+ public PhotosChanges ()
+ {
+ TagsChanged = false;
+ VersionsChanged = false;
+ }
}
}
diff --git a/src/Core/FSpot.Core/FSpot.Core/Tag.cs b/src/Core/FSpot.Core/FSpot.Core/Tag.cs
index bd4efc4..87564e2 100644
--- a/src/Core/FSpot.Core/FSpot.Core/Tag.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/Tag.cs
@@ -144,14 +144,14 @@ namespace FSpot.Core
if (tag == null)
throw new ArgumentNullException ("tag");
- if (Category == tag.Category) {
+ if (Category == tag.Category)
+ {
if (SortPriority == tag.SortPriority)
- return Name.CompareTo (tag.Name);
- else
- return SortPriority - tag.SortPriority;
- } else {
- return Category.CompareTo (tag.Category);
- }
+ return Name.CompareTo (tag.Name);
+ return SortPriority - tag.SortPriority;
+ }
+
+ return Category.CompareTo (tag.Category);
}
public bool IsAncestorOf (Tag tag)
diff --git a/src/Core/FSpot.Gui/FSpot.Gui.csproj b/src/Core/FSpot.Gui/FSpot.Gui.csproj
index c6300c3..53543f7 100644
--- a/src/Core/FSpot.Gui/FSpot.Gui.csproj
+++ b/src/Core/FSpot.Gui/FSpot.Gui.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+ï<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -96,6 +96,7 @@
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
+ <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
diff --git a/src/Core/FSpot.Gui/FSpot.Gui/WindowOpacityFader.cs b/src/Core/FSpot.Gui/FSpot.Gui/WindowOpacityFader.cs
index e2040e2..a4fb285 100644
--- a/src/Core/FSpot.Gui/FSpot.Gui/WindowOpacityFader.cs
+++ b/src/Core/FSpot.Gui/FSpot.Gui/WindowOpacityFader.cs
@@ -43,9 +43,7 @@ namespace FSpot.Gui
this.win = win;
win.Mapped += HandleMapped;
win.Unmapped += HandleUnmapped;
- fadin = new DoubleAnimation (0.0, target, TimeSpan.FromMilliseconds (msec), opacity => {
- CompositeUtils.SetWinOpacity (win, opacity);
- });
+ fadin = new DoubleAnimation (0.0, target, TimeSpan.FromMilliseconds (msec), opacity => CompositeUtils.SetWinOpacity (win, opacity));
}
[GLib.ConnectBefore]
diff --git a/src/Core/FSpot.Gui/FSpot.Transitions/CairoTransition.cs b/src/Core/FSpot.Gui/FSpot.Transitions/CairoTransition.cs
index a09ec85..6dac90e 100644
--- a/src/Core/FSpot.Gui/FSpot.Transitions/CairoTransition.cs
+++ b/src/Core/FSpot.Gui/FSpot.Transitions/CairoTransition.cs
@@ -33,8 +33,8 @@ using Gdk;
namespace FSpot.Transitions
{
public abstract class CairoTransition : SlideShowTransition
- {
- public CairoTransition (string name) : base (name)
+ {
+ protected CairoTransition (string name) : base (name)
{
}
diff --git a/src/Core/FSpot.Gui/FSpot.Transitions/SlideShowTransition.cs b/src/Core/FSpot.Gui/FSpot.Transitions/SlideShowTransition.cs
index afcc74a..b25a3d7 100644
--- a/src/Core/FSpot.Gui/FSpot.Transitions/SlideShowTransition.cs
+++ b/src/Core/FSpot.Gui/FSpot.Transitions/SlideShowTransition.cs
@@ -32,17 +32,14 @@ using Gdk;
namespace FSpot.Transitions
{
public abstract class SlideShowTransition
- {
- public SlideShowTransition (string name)
+ {
+ protected SlideShowTransition (string name)
{
- this.name = name;
- }
-
- string name;
- public string Name {
- get { return name; }
- }
-
+ Name = name;
+ }
+
+ public string Name { get; private set; }
+
public abstract void Draw (Drawable d, Pixbuf prev, Pixbuf next, int width, int height, double progress);
}
}
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/ApplicationActivatedEventArgs.cs b/src/Core/FSpot.Gui/FSpot.Widgets/ApplicationActivatedEventArgs.cs
index 4e1d439..65d5ac9 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/ApplicationActivatedEventArgs.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/ApplicationActivatedEventArgs.cs
@@ -36,7 +36,7 @@ namespace FSpot.Widgets
{
public AppInfo AppInfo { get; private set; }
- public ApplicationActivatedEventArgs (AppInfo app) : base ()
+ public ApplicationActivatedEventArgs (AppInfo app)
{
AppInfo = app;
}
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/CellGridView.cs b/src/Core/FSpot.Gui/FSpot.Widgets/CellGridView.cs
index 1e521f1..fed0c9d 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/CellGridView.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/CellGridView.cs
@@ -35,538 +35,524 @@ using Gdk;
namespace FSpot.Widgets
{
- /// <summary>
- /// This class provides the base functionality for displaying cells in a grid. The
- /// paramters to set up the grid are gathered by abstract properties which must be
- /// implemented by a subclass.
- /// </summary>
- public abstract class CellGridView : Gtk.Layout
- {
-
-#region Constructors
-
- public CellGridView (IntPtr raw) : base (raw)
- {
- }
-
- public CellGridView () : base (null, null)
- {
- }
+ /// <summary>
+ /// This class provides the base functionality for displaying cells in a grid. The
+ /// paramters to set up the grid are gathered by abstract properties which must be
+ /// implemented by a subclass.
+ /// </summary>
+ public abstract class CellGridView : Gtk.Layout
+ {
+
+#region Constructors
+
+ protected CellGridView (IntPtr raw) : base (raw)
+ {
+ }
+
+ protected CellGridView () : base (null, null)
+ {
+ }
#endregion
#region Abstract Layout Description
- /// <summary>
- /// Must return the width which each cell should have.
- /// </summary>
- protected abstract int MinCellWidth { get; }
+ /// <summary>
+ /// Must return the width which each cell should have.
+ /// </summary>
+ protected abstract int MinCellWidth { get; }
- /// <summary>
- /// Must return the height which each cell should have.
- /// </summary>
- protected abstract int MinCellHeight { get; }
+ /// <summary>
+ /// Must return the height which each cell should have.
+ /// </summary>
+ protected abstract int MinCellHeight { get; }
- /// <summary>
- /// Must return the number of cells which should be displayed.
- /// </summary>
- protected abstract int CellCount { get; }
+ /// <summary>
+ /// Must return the number of cells which should be displayed.
+ /// </summary>
+ protected abstract int CellCount { get; }
#endregion
#region Abstract Drawing Functions
- /// <summary>
- /// The function is called to draw a Cell.
- /// </summary>
- protected abstract void DrawCell (int cell_num, Rectangle cell_area, Rectangle expose_area);
+ /// <summary>
+ /// The function is called to draw a Cell.
+ /// </summary>
+ protected abstract void DrawCell (int cell_num, Rectangle cell_area, Rectangle expose_area);
- /// <summary>
- /// The function is called to preload a cell.
- /// </summary>
- protected abstract void PreloadCell (int cell_num);
+ /// <summary>
+ /// The function is called to preload a cell.
+ /// </summary>
+ protected abstract void PreloadCell (int cell_num);
#endregion
-#region Private Layout Values
-
- /// <summary>
- /// The number of cells per row (columns).
- /// </summary>
- protected int cells_per_row;
-
- /// <summary>
- /// The width of each cell. It is set, when the layout is updated. The
- /// property <see cref="MinCellWidth"/> is only used when the layout is updated.
- /// </summary>
- protected int cell_width;
-
- /// <summary>
- /// The height of each cell. It is set, when the layout is updated. The
- /// property <see cref="MinCellHeight"/> is only used when the layout is updated.
- /// </summary>
- protected int cell_height;
-
- /// <summary>
- /// The total number of cells the layout is computed with. It is set, when the
- /// layout is updated. The property <see cref="CellCount"/> is only used when
- /// the layout is updated.
- /// </summary>
- private int cell_count;
-
- /// <summary>
- /// Holds the number of rows which are displayed at once regarded to the current
- /// size of the widget.
- /// </summary>
- private int displayed_rows;
-
- /// <summary>
- /// The number of rows which are needed to display all cells.
- /// </summary>
- private int total_rows;
-
- /// <summary>
- /// The border size the current layout is computed with.
- /// </summary>
- private int border_size = 6;
-
- /// <summary>
- /// The maximal number of columns.
- /// </summary>
- private int max_columns = -1;
-
- // preserve the scroll postion when possible
- private bool scroll;
- private double scroll_value;
-
- // suppress scroll is currently not used. where do we need it?
- private bool suppress_scroll = false;
+#region Private Layout Values
+
+ /// <summary>
+ /// The width of each cell. It is set, when the layout is updated. The
+ /// property <see cref="MinCellWidth"/> is only used when the layout is updated.
+ /// </summary>
+ private int cell_width;
+
+ /// <summary>
+ /// The height of each cell. It is set, when the layout is updated. The
+ /// property <see cref="MinCellHeight"/> is only used when the layout is updated.
+ /// </summary>
+ private int cell_height;
+
+ /// <summary>
+ /// The total number of cells the layout is computed with. It is set, when the
+ /// layout is updated. The property <see cref="CellCount"/> is only used when
+ /// the layout is updated.
+ /// </summary>
+ private int cell_count;
+
+ /// <summary>
+ /// The number of rows which are needed to display all cells.
+ /// </summary>
+ private int total_rows;
+
+ /// <summary>
+ /// The border size the current layout is computed with.
+ /// </summary>
+ private int border_size = 6;
+
+ /// <summary>
+ /// The maximal number of columns.
+ /// </summary>
+ private int max_columns = -1;
+
+ // preserve the scroll postion when possible
+ private bool scroll;
+ private double scroll_value;
+
+ // suppress scroll is currently not used. where do we need it?
+ private bool suppress_scroll = false;
#endregion
#region Public Layout Properties
- public int MaxColumns {
- get { return max_columns; }
- set {
- max_columns = value;
- QueueResize ();
- }
- }
-
- public int BorderSize {
- get { return border_size; }
- set {
- if (value < 0)
- throw new ArgumentException ("value");
-
- border_size = value;
- QueueResize ();
- }
- }
-
- public int VisibleRows {
- get { return displayed_rows; }
- }
-
- public int VisibleColums {
- get { return cells_per_row; }
- }
-
-#endregion
+ public int MaxColumns {
+ get { return max_columns; }
+ set {
+ max_columns = value;
+ QueueResize ();
+ }
+ }
+
+ public int BorderSize {
+ get { return border_size; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("value");
+
+ border_size = value;
+ QueueResize ();
+ }
+ }
+
+ public int VisibleRows { get; private set; }
+
+ public int VisibleColums { get; private set; }
+
+ #endregion
#region Public Methods
- public int CellAtPosition (Point p)
- {
- return CellAtPosition (p.X, p.Y);
- }
+ public int CellAtPosition (Point p)
+ {
+ return CellAtPosition (p.X, p.Y);
+ }
- public int CellAtPosition (int x, int y)
- {
- return CellAtPosition (x, y, true);
- }
+ public int CellAtPosition (int x, int y)
+ {
+ return CellAtPosition (x, y, true);
+ }
- public int CellAtPosition (int x, int y, bool crop_visible)
- {
- if (crop_visible
- && ((y < (int)Vadjustment.Value || y > (int)Vadjustment.Value + Allocation.Height)
- || (x < (int)Hadjustment.Value || x > (int)Hadjustment.Value + Allocation.Width)))
- return -1;
+ public int CellAtPosition (int x, int y, bool crop_visible)
+ {
+ if (crop_visible
+ && ((y < (int)Vadjustment.Value || y > (int)Vadjustment.Value + Allocation.Height)
+ || (x < (int)Hadjustment.Value || x > (int)Hadjustment.Value + Allocation.Width)))
+ return -1;
- if (x < border_size || x >= border_size + cells_per_row * cell_width)
- return -1;
+ if (x < border_size || x >= border_size + VisibleColums * cell_width)
+ return -1;
- if (y < border_size || y >= border_size + (cell_count / cells_per_row + 1) * cell_height)
- return -1;
+ if (y < border_size || y >= border_size + (cell_count / VisibleColums + 1) * cell_height)
+ return -1;
- int column = (int) ((x - border_size) / cell_width);
- int row = (int) ((y - border_size) / cell_height);
+ int column = (int) ((x - border_size) / cell_width);
+ int row = (int) ((y - border_size) / cell_height);
- int cell_num = column + row * cells_per_row;
- if (cell_num >= cell_count)
- return -1;
+ int cell_num = column + row * VisibleColums;
+ if (cell_num >= cell_count)
+ return -1;
- return cell_num;
- }
+ return cell_num;
+ }
- public int TopLeftVisibleCell ()
- {
- // TODO: Where does the 8 come from?
- return CellAtPosition (border_size, (int) (Vadjustment.Value + Allocation.Height * (Vadjustment.Value / Vadjustment.Upper)) + border_size + 8);
- }
+ public int TopLeftVisibleCell ()
+ {
+ // TODO: Where does the 8 come from?
+ return CellAtPosition (border_size, (int) (Vadjustment.Value + Allocation.Height * (Vadjustment.Value / Vadjustment.Upper)) + border_size + 8);
+ }
- public void CellPosition (int cell_num, out int x, out int y)
- {
- // TODO: compare the values with the ones in GetCellCenter.
- if (cells_per_row == 0) {
- x = 0;
- y = 0;
- return;
- }
+ public void CellPosition (int cell_num, out int x, out int y)
+ {
+ // TODO: compare the values with the ones in GetCellCenter.
+ if (VisibleColums == 0) {
+ x = 0;
+ y = 0;
+ return;
+ }
- int col = cell_num % cells_per_row;
- int row = cell_num / cells_per_row;
+ int col = cell_num % VisibleColums;
+ int row = cell_num / VisibleColums;
- x = col * cell_width + border_size;
- y = row * cell_height + border_size;
- }
+ x = col * cell_width + border_size;
+ y = row * cell_height + border_size;
+ }
- public void CellCenter (int cell_num, out int x, out int y)
- {
- // TODO: compare the values with the ones in GetCellPosition.
- if (cell_num == -1) {
- x = -1;
- y = -1;
- }
+ public void CellCenter (int cell_num, out int x, out int y)
+ {
+ // TODO: compare the values with the ones in GetCellPosition.
+ if (cell_num == -1) {
+ x = -1;
+ y = -1;
+ }
- CellPosition (cell_num, out x, out y);
+ CellPosition (cell_num, out x, out y);
- x += cell_width / 2;
- y += cell_height / 2;
- }
+ x += cell_width / 2;
+ y += cell_height / 2;
+ }
- public Gdk.Rectangle CellBounds (int cell_num)
- {
- Rectangle bounds;
+ public Gdk.Rectangle CellBounds (int cell_num)
+ {
+ Rectangle bounds;
- CellPosition (cell_num, out bounds.X, out bounds.Y);
+ CellPosition (cell_num, out bounds.X, out bounds.Y);
- bounds.Width = cell_width;
- bounds.Height = cell_height;
+ bounds.Width = cell_width;
+ bounds.Height = cell_height;
- return bounds;
- }
+ return bounds;
+ }
- public IEnumerable<int> CellsInRect (Rectangle area)
- {
- if (cell_width <= 0 || cell_height <= 0) {
- yield break;
- }
+ public IEnumerable<int> CellsInRect (Rectangle area)
+ {
+ if (cell_width <= 0 || cell_height <= 0) {
+ yield break;
+ }
- int start_cell_column = Math.Max (0, (area.X - border_size) / cell_width);
- int start_cell_row = Math.Max (0, (area.Y - border_size) / cell_height);
+ int start_cell_column = Math.Max (0, (area.X - border_size) / cell_width);
+ int start_cell_row = Math.Max (0, (area.Y - border_size) / cell_height);
- int end_cell_column = Math.Max (0, (area.X + area.Width - border_size) / cell_width);
- int end_cell_row = Math.Max (0, (area.Y + area.Height - border_size) / cell_height);
+ int end_cell_column = Math.Max (0, (area.X + area.Width - border_size) / cell_width);
+ int end_cell_row = Math.Max (0, (area.Y + area.Height - border_size) / cell_height);
- for (int cell_row = start_cell_row; cell_row <= end_cell_row; cell_row ++) {
+ for (int cell_row = start_cell_row; cell_row <= end_cell_row; cell_row ++) {
- for (int cell_column = start_cell_column; cell_column <= end_cell_column; cell_column ++) {
+ for (int cell_column = start_cell_column; cell_column <= end_cell_column; cell_column ++) {
- int cell_num = cell_column + cell_row * cells_per_row;
+ int cell_num = cell_column + cell_row * VisibleColums;
- if (cell_num < cell_count)
- yield return cell_num;
- }
- }
- }
+ if (cell_num < cell_count)
+ yield return cell_num;
+ }
+ }
+ }
- public void ScrollTo (int cell_num)
- {
- ScrollTo (cell_num, true);
- }
+ public void ScrollTo (int cell_num)
+ {
+ ScrollTo (cell_num, true);
+ }
- public void ScrollTo (int cell_num, bool center)
- {
- if (!IsRealized)
- return;
+ public void ScrollTo (int cell_num, bool center)
+ {
+ if (!IsRealized)
+ return;
- Adjustment adjustment = Vadjustment;
- int x;
- int y;
+ Adjustment adjustment = Vadjustment;
+ int x;
+ int y;
- CellPosition (cell_num, out x, out y);
+ CellPosition (cell_num, out x, out y);
- if (center)
- y += cell_height / 2 - Allocation.Height / 2;
+ if (center)
+ y += cell_height / 2 - Allocation.Height / 2;
- // the maximal possible adjustment value
- // (otherwise, we are scrolling to far ...)
- int max = (int) (Height - Allocation.Height);
+ // the maximal possible adjustment value
+ // (otherwise, we are scrolling to far ...)
+ int max = (int) (Height - Allocation.Height);
- adjustment.Value = Math.Min (y, max);
- adjustment.ChangeValue ();
- }
+ adjustment.Value = Math.Min (y, max);
+ adjustment.ChangeValue ();
+ }
- public void InvalidateCell (int cell_num)
- {
- Rectangle cell_area = CellBounds (cell_num);
+ public void InvalidateCell (int cell_num)
+ {
+ Rectangle cell_area = CellBounds (cell_num);
- // FIXME where are we computing the bounds incorrectly
- cell_area.Width -= 1;
- cell_area.Height -= 1;
+ // FIXME where are we computing the bounds incorrectly
+ cell_area.Width -= 1;
+ cell_area.Height -= 1;
- Gdk.Rectangle visible =
- new Gdk.Rectangle ((int) Hadjustment.Value,
- (int) Vadjustment.Value,
- Allocation.Width,
- Allocation.Height);
+ Gdk.Rectangle visible =
+ new Gdk.Rectangle ((int) Hadjustment.Value,
+ (int) Vadjustment.Value,
+ Allocation.Width,
+ Allocation.Height);
- if (BinWindow != null && cell_area.Intersect (visible, out cell_area))
- BinWindow.InvalidateRect (cell_area, false);
- }
+ if (BinWindow != null && cell_area.Intersect (visible, out cell_area))
+ BinWindow.InvalidateRect (cell_area, false);
+ }
#endregion
#region Event Handlers
- [GLib.ConnectBefore]
- private void HandleAdjustmentValueChanged (object sender, EventArgs args)
- {
- Scroll ();
- }
+ [GLib.ConnectBefore]
+ private void HandleAdjustmentValueChanged (object sender, EventArgs args)
+ {
+ Scroll ();
+ }
#endregion
#region Determine Layout
- protected override void OnSizeAllocated (Gdk.Rectangle allocation)
- {
- scroll_value = (Vadjustment.Value)/ (Vadjustment.Upper);
- scroll = ! suppress_scroll;
- suppress_scroll = false;
- UpdateLayout (allocation);
-
- base.OnSizeAllocated (allocation);
- }
-
- protected override void OnScrollAdjustmentsSet (Adjustment hadjustment, Adjustment vadjustment)
- {
- base.OnScrollAdjustmentsSet (hadjustment, vadjustment);
-
- if (vadjustment != null)
- vadjustment.ValueChanged += new EventHandler (HandleAdjustmentValueChanged);
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose args)
- {
- foreach (Rectangle area in args.Region.GetRectangles ()) {
- DrawAllCells (area);
- }
- return base.OnExposeEvent (args);
- }
-
- private void UpdateLayout ()
- {
- UpdateLayout (Allocation);
- }
-
- private void UpdateLayout (Gdk.Rectangle allocation)
- {
- // get the basic values for the layout ...
- cell_width = MinCellWidth;
- cell_height = MinCellHeight;
- cell_count = CellCount;
-
- // ... and compute the remaining ones.
- int available_width = allocation.Width - 2 * border_size;
- int available_height = allocation.Height - 2 * border_size;
-
- cells_per_row = Math.Max ((int) (available_width / cell_width), 1);
- if (MaxColumns > 0)
- cells_per_row = Math.Min (MaxColumns, cells_per_row);
-
- cell_width += (available_width - cells_per_row * cell_width) / cells_per_row;
-
- displayed_rows = (int) Math.Max (available_height / cell_height, 1);
-
- total_rows = cell_count / cells_per_row;
- if (cell_count % cells_per_row != 0)
- total_rows ++;
-
- int height = total_rows * cell_height + 2 * border_size;
-
- Vadjustment.StepIncrement = cell_height;
- int x = (int)(Hadjustment.Value);
- int y = (int)(height * scroll_value);
- SetSize (x, y, (int) allocation.Width, (int) height);
- }
-
- private void SetSize (int x, int y, int width, int height)
- {
- Hadjustment.Upper = System.Math.Max (Allocation.Width, width);
- Vadjustment.Upper = System.Math.Max (Allocation.Height, height);
-
- bool xchange = scroll && (int)(Hadjustment.Value) != x;
- bool ychange = scroll && (int)(Vadjustment.Value) != y;
-
- // reset scroll
- scroll = false;
-
- if (IsRealized)
- BinWindow.FreezeUpdates ();
-
- if (xchange || ychange) {
- if (IsRealized)
- BinWindow.MoveResize (-x, -y, (int)(Hadjustment.Upper), (int)(Vadjustment.Upper));
- Vadjustment.Value = y;
- Hadjustment.Value = x;
- }
-
- if (this.Width != Allocation.Width || this.Height != Allocation.Height)
- SetSize ((uint)Allocation.Width, (uint)height);
-
- if (xchange || ychange) {
- Vadjustment.ChangeValue ();
- Hadjustment.ChangeValue ();
- }
-
- if (IsRealized) {
- BinWindow.ThawUpdates ();
- BinWindow.ProcessUpdates (true);
- }
- }
-
- private void DrawAllCells (Gdk.Rectangle area)
- {
- foreach (var cell_num in CellsInRect (area)) {
- DrawCell (cell_num, CellBounds (cell_num), area);
- }
- }
-
- // The first pixel line that is currently on the screen (i.e. in the current
- // scroll region). Used to compute the area that went offscreen in the "changed"
- // signal handler for the vertical GtkAdjustment.
- private int y_offset;
- private int x_offset;
- private void Scroll ()
- {
- int ystep = (int)(Vadjustment.Value - y_offset);
- int xstep = (int)(Hadjustment.Value - x_offset);
-
- if (xstep > 0)
- xstep = Math.Max (xstep, Allocation.Width);
- else
- xstep = Math.Min (xstep, -Allocation.Width);
-
- if (ystep > 0)
- ystep = Math.Max (ystep, Allocation.Height);
- else
- ystep = Math.Min (ystep, -Allocation.Height);
-
- Gdk.Rectangle area;
-
- Gdk.Region offscreen = new Gdk.Region ();
- /*
- Log.Debug ("step ({0}, {1}) allocation ({2},{3},{4},{5})",
- xstep, ystep, Hadjustment.Value, Vadjustment.Value,
- Allocation.Width, Allocation.Height);
- */
- /*
- area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + 4 * xstep), 0),
- Math.Max ((int) (Vadjustment.Value + 4 * ystep), 0),
- Allocation.Width,
- Allocation.Height);
- offscreen.UnionWithRect (area);
- area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + 3 * xstep), 0),
- Math.Max ((int) (Vadjustment.Value + 3 * ystep), 0),
- Allocation.Width,
- Allocation.Height);
- offscreen.UnionWithRect (area);
- */
- area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + 2 * xstep), 0),
- Math.Max ((int) (Vadjustment.Value + 2 * ystep), 0),
- Allocation.Width,
- Allocation.Height);
- offscreen.UnionWithRect (area);
- area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + xstep), 0),
- Math.Max ((int) (Vadjustment.Value + ystep), 0),
- Allocation.Width,
- Allocation.Height);
- offscreen.UnionWithRect (area);
- area = new Gdk.Rectangle ((int) Hadjustment.Value,
- (int) Vadjustment.Value,
- Allocation.Width,
- Allocation.Height);
-
- // always load the onscreen area last to make sure it
- // is first in the loading
- Gdk.Region onscreen = Gdk.Region.Rectangle (area);
- offscreen.Subtract (onscreen);
-
- PreloadRegion (offscreen, ystep);
- Preload (area, false);
-
- y_offset = (int) Vadjustment.Value;
- x_offset = (int) Hadjustment.Value;
- }
-
- private void PreloadRegion (Gdk.Region region, int step)
- {
- Gdk.Rectangle [] rects = region.GetRectangles ();
-
- if (step < 0)
- System.Array.Reverse (rects);
-
- foreach (Gdk.Rectangle preload in rects) {
- Preload (preload, false);
- }
- }
-
- private void Preload (Gdk.Rectangle area, bool back)
- {
- if (cells_per_row ==0)
- return;
-
- int start_cell_column = Math.Max ((area.X - border_size) / cell_width, 0);
- int start_cell_row = Math.Max ((area.Y - border_size) / cell_height, 0);
- int start_cell_num = start_cell_column + start_cell_row * cells_per_row;
-
- int end_cell_column = Math.Max ((area.X + area.Width - border_size) / cell_width, 0);
- int end_cell_row = Math.Max ((area.Y + area.Height - border_size) / cell_height, 0);
-
- int i;
-
- int cols = end_cell_column - start_cell_column + 1;
- int rows = end_cell_row - start_cell_row + 1;
- int len = rows * cols;
- int scell = start_cell_num;
- int ecell = scell + len;
- if (scell > cell_count - len) {
- ecell = cell_count;
- scell = System.Math.Max (0, scell - len);
- } else
- ecell = scell + len;
-
- int mid = (ecell - scell) / 2;
- for (i = 0; i < mid; i++) {
-
- // The order of Preloading is kept from the previous version, because it provides
- // smooth appearance (alternating for begin and end of the viewport) of the cells.
- // Maybe, this can be done better in a subclass ? (e.g. by calling a PreloadCells
- // with an Array/Enumeration of all cells to be preloaded, or with lower and upper
- // bound of cells to be preloaded)
- int cell = back ? ecell - i - 1 : scell + mid + i;
- PreloadCell (cell);
-
- cell = back ? scell + i : scell + mid - i - 1;
- PreloadCell (cell);
- }
- }
+ protected override void OnSizeAllocated (Gdk.Rectangle allocation)
+ {
+ scroll_value = (Vadjustment.Value)/ (Vadjustment.Upper);
+ scroll = ! suppress_scroll;
+ suppress_scroll = false;
+ UpdateLayout (allocation);
+
+ base.OnSizeAllocated (allocation);
+ }
+
+ protected override void OnScrollAdjustmentsSet (Adjustment hadjustment, Adjustment vadjustment)
+ {
+ base.OnScrollAdjustmentsSet (hadjustment, vadjustment);
+
+ if (vadjustment != null)
+ vadjustment.ValueChanged += new EventHandler (HandleAdjustmentValueChanged);
+ }
+
+ protected override bool OnExposeEvent (Gdk.EventExpose args)
+ {
+ foreach (Rectangle area in args.Region.GetRectangles ()) {
+ DrawAllCells (area);
+ }
+ return base.OnExposeEvent (args);
+ }
+
+ // FIXME: This is never used
+ private void UpdateLayout ()
+ {
+ UpdateLayout (Allocation);
+ }
+
+ private void UpdateLayout (Gdk.Rectangle allocation)
+ {
+ // get the basic values for the layout ...
+ cell_width = MinCellWidth;
+ cell_height = MinCellHeight;
+ cell_count = CellCount;
+
+ // ... and compute the remaining ones.
+ int available_width = allocation.Width - 2 * border_size;
+ int available_height = allocation.Height - 2 * border_size;
+
+ VisibleColums = Math.Max ((int) (available_width / cell_width), 1);
+ if (MaxColumns > 0)
+ VisibleColums = Math.Min (MaxColumns, VisibleColums);
+
+ cell_width += (available_width - VisibleColums * cell_width) / VisibleColums;
+
+ VisibleRows = (int) Math.Max (available_height / cell_height, 1);
+
+ total_rows = cell_count / VisibleColums;
+ if (cell_count % VisibleColums != 0)
+ total_rows ++;
+
+ int height = total_rows * cell_height + 2 * border_size;
+
+ Vadjustment.StepIncrement = cell_height;
+ int x = (int)(Hadjustment.Value);
+ int y = (int)(height * scroll_value);
+ SetSize (x, y, (int) allocation.Width, (int) height);
+ }
+
+ private void SetSize (int x, int y, int width, int height)
+ {
+ Hadjustment.Upper = System.Math.Max (Allocation.Width, width);
+ Vadjustment.Upper = System.Math.Max (Allocation.Height, height);
+
+ bool xchange = scroll && (int)(Hadjustment.Value) != x;
+ bool ychange = scroll && (int)(Vadjustment.Value) != y;
+
+ // reset scroll
+ scroll = false;
+
+ if (IsRealized)
+ BinWindow.FreezeUpdates ();
+
+ if (xchange || ychange) {
+ if (IsRealized)
+ BinWindow.MoveResize (-x, -y, (int)(Hadjustment.Upper), (int)(Vadjustment.Upper));
+ Vadjustment.Value = y;
+ Hadjustment.Value = x;
+ }
+
+ if (this.Width != Allocation.Width || this.Height != Allocation.Height)
+ SetSize ((uint)Allocation.Width, (uint)height);
+
+ if (xchange || ychange) {
+ Vadjustment.ChangeValue ();
+ Hadjustment.ChangeValue ();
+ }
+
+ if (IsRealized) {
+ BinWindow.ThawUpdates ();
+ BinWindow.ProcessUpdates (true);
+ }
+ }
+
+ private void DrawAllCells (Gdk.Rectangle area)
+ {
+ foreach (var cell_num in CellsInRect (area)) {
+ DrawCell (cell_num, CellBounds (cell_num), area);
+ }
+ }
+
+ // The first pixel line that is currently on the screen (i.e. in the current
+ // scroll region). Used to compute the area that went offscreen in the "changed"
+ // signal handler for the vertical GtkAdjustment.
+ private int y_offset;
+ private int x_offset;
+ private void Scroll ()
+ {
+ int ystep = (int)(Vadjustment.Value - y_offset);
+ int xstep = (int)(Hadjustment.Value - x_offset);
+
+ if (xstep > 0)
+ xstep = Math.Max (xstep, Allocation.Width);
+ else
+ xstep = Math.Min (xstep, -Allocation.Width);
+
+ if (ystep > 0)
+ ystep = Math.Max (ystep, Allocation.Height);
+ else
+ ystep = Math.Min (ystep, -Allocation.Height);
+
+ Gdk.Rectangle area;
+
+ Gdk.Region offscreen = new Gdk.Region ();
+ /*
+ Log.Debug ("step ({0}, {1}) allocation ({2},{3},{4},{5})",
+ xstep, ystep, Hadjustment.Value, Vadjustment.Value,
+ Allocation.Width, Allocation.Height);
+ */
+ /*
+ area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + 4 * xstep), 0),
+ Math.Max ((int) (Vadjustment.Value + 4 * ystep), 0),
+ Allocation.Width,
+ Allocation.Height);
+ offscreen.UnionWithRect (area);
+ area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + 3 * xstep), 0),
+ Math.Max ((int) (Vadjustment.Value + 3 * ystep), 0),
+ Allocation.Width,
+ Allocation.Height);
+ offscreen.UnionWithRect (area);
+ */
+ area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + 2 * xstep), 0),
+ Math.Max ((int) (Vadjustment.Value + 2 * ystep), 0),
+ Allocation.Width,
+ Allocation.Height);
+ offscreen.UnionWithRect (area);
+ area = new Gdk.Rectangle (Math.Max ((int) (Hadjustment.Value + xstep), 0),
+ Math.Max ((int) (Vadjustment.Value + ystep), 0),
+ Allocation.Width,
+ Allocation.Height);
+ offscreen.UnionWithRect (area);
+ area = new Gdk.Rectangle ((int) Hadjustment.Value,
+ (int) Vadjustment.Value,
+ Allocation.Width,
+ Allocation.Height);
+
+ // always load the onscreen area last to make sure it
+ // is first in the loading
+ Gdk.Region onscreen = Gdk.Region.Rectangle (area);
+ offscreen.Subtract (onscreen);
+
+ PreloadRegion (offscreen, ystep);
+ Preload (area, false);
+
+ y_offset = (int) Vadjustment.Value;
+ x_offset = (int) Hadjustment.Value;
+ }
+
+ private void PreloadRegion (Gdk.Region region, int step)
+ {
+ Gdk.Rectangle [] rects = region.GetRectangles ();
+
+ if (step < 0)
+ System.Array.Reverse (rects);
+
+ foreach (Gdk.Rectangle preload in rects) {
+ Preload (preload, false);
+ }
+ }
+
+ private void Preload (Gdk.Rectangle area, bool back)
+ {
+ if (VisibleColums ==0)
+ return;
+
+ int start_cell_column = Math.Max ((area.X - border_size) / cell_width, 0);
+ int start_cell_row = Math.Max ((area.Y - border_size) / cell_height, 0);
+ int start_cell_num = start_cell_column + start_cell_row * VisibleColums;
+
+ int end_cell_column = Math.Max ((area.X + area.Width - border_size) / cell_width, 0);
+ int end_cell_row = Math.Max ((area.Y + area.Height - border_size) / cell_height, 0);
+
+ int i;
+
+ int cols = end_cell_column - start_cell_column + 1;
+ int rows = end_cell_row - start_cell_row + 1;
+ int len = rows * cols;
+ int scell = start_cell_num;
+ int ecell = scell + len;
+ if (scell > cell_count - len) {
+ ecell = cell_count;
+ scell = System.Math.Max (0, scell - len);
+ } else
+ ecell = scell + len;
+
+ int mid = (ecell - scell) / 2;
+ for (i = 0; i < mid; i++) {
+
+ // The order of Preloading is kept from the previous version, because it provides
+ // smooth appearance (alternating for begin and end of the viewport) of the cells.
+ // Maybe, this can be done better in a subclass ? (e.g. by calling a PreloadCells
+ // with an Array/Enumeration of all cells to be preloaded, or with lower and upper
+ // bound of cells to be preloaded)
+ int cell = back ? ecell - i - 1 : scell + mid + i;
+ PreloadCell (cell);
+
+ cell = back ? scell + i : scell + mid - i - 1;
+ PreloadCell (cell);
+ }
+ }
#endregion
- }
+ }
}
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/Curve.cs b/src/Core/FSpot.Gui/FSpot.Widgets/Curve.cs
index d93e8f7..811b4af 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/Curve.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/Curve.cs
@@ -35,10 +35,11 @@ using Gtk;
namespace FSpot.Widgets
{
+ // FIXME: This class is never used
public class Curve : DrawingArea
{
#region public API
- public Curve () : base ()
+ public Curve ()
{
Events |= EventMask.ExposureMask
| EventMask.PointerMotionMask
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/CustomPrintWidget.cs b/src/Core/FSpot.Gui/FSpot.Widgets/CustomPrintWidget.cs
index 29b74a6..388562a 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/CustomPrintWidget.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/CustomPrintWidget.cs
@@ -45,9 +45,8 @@ namespace FSpot.Widgets
Zoom,
Scaled,
Fill,
- }
-
- Gtk.Image preview_image;
+ }
+
CheckButton fullpage;
RadioButton ppp1, ppp2, ppp4, ppp9, ppp20, ppp30;
@@ -94,32 +93,31 @@ namespace FSpot.Widgets
}
public FitMode Fitmode {
- get {
- if (zoom.Active) return FitMode.Zoom;
- else if (fill.Active) return FitMode.Fill;
- else if (scaled.Active) return FitMode.Scaled;
- else
- throw new Exception ("Something is wrong on this GUI");
- }
+ get
+ {
+ if (zoom.Active) return FitMode.Zoom;
+ if (fill.Active) return FitMode.Fill;
+ if (scaled.Active) return FitMode.Scaled;
+
+ throw new Exception ("Something is wrong on this GUI");
+ }
}
public int PhotosPerPage {
get {
if (ppp1.Active) return 1;
- else if (ppp2.Active) return 2;
- else if (ppp4.Active) return 4;
- else if (ppp9.Active) return 9;
- else if (ppp20.Active) return 20;
- else if (ppp30.Active) return 30;
- else
- throw new Exception ("Something is wrong on this GUI");
+ if (ppp2.Active) return 2;
+ if (ppp4.Active) return 4;
+ if (ppp9.Active) return 9;
+ if (ppp20.Active) return 20;
+ if (ppp30.Active) return 30;
+
+ throw new Exception ("Something is wrong on this GUI");
}
- }
-
- public Gtk.Image PreviewImage {
- get { return preview_image; }
- }
-
+ }
+
+ public Image PreviewImage { get; private set; }
+
public bool Repeat {
get { return repeat.Active; }
}
@@ -136,8 +134,8 @@ namespace FSpot.Widgets
{
this.print_operation = print_operation;
- preview_image = new Gtk.Image ();
- Attach (preview_image, 0, 2, 0, 1);
+ PreviewImage = new Gtk.Image ();
+ Attach (PreviewImage, 0, 2, 0, 1);
Frame page_frame = new Frame (Catalog.GetString ("Page Setup"));
VBox page_box = new VBox ();
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/DateEdit.cs b/src/Core/FSpot.Gui/FSpot.Widgets/DateEdit.cs
index c8d5cf4..56f0b5d 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/DateEdit.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/DateEdit.cs
@@ -43,13 +43,9 @@ namespace FSpot.Widgets
#region public API
public DateEdit () : this (DateTimeOffset.Now)
{
- }
-
- public DateEdit (DateTimeOffset dateTimeOffset) : this (dateTimeOffset, DateEditFlags.None)
- {
- }
-
- public DateEdit (DateTimeOffset dateTimeOffset, DateEditFlags dateEditFlags) : base ()
+ }
+
+ public DateEdit (DateTimeOffset dateTimeOffset, DateEditFlags dateEditFlags = DateEditFlags.None)
{
this.dateEditFlags = dateEditFlags;
this.dateTimeOffset = dateTimeOffset;
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/HighlightedBox.cs b/src/Core/FSpot.Gui/FSpot.Widgets/HighlightedBox.cs
index 5f3b439..1e50201 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/HighlightedBox.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/HighlightedBox.cs
@@ -39,7 +39,7 @@ namespace FSpot.Widgets
protected HighlightedBox (IntPtr raw) : base (raw) {}
- public HighlightedBox (Widget child) : base ()
+ public HighlightedBox (Widget child)
{
Child = child;
AppPaintable = true;
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/ImageView.cs b/src/Core/FSpot.Gui/FSpot.Widgets/ImageView.cs
index b464b31..12a060b 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/ImageView.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/ImageView.cs
@@ -45,10 +45,16 @@ namespace FSpot.Widgets
public partial class ImageView : Container
{
#region public API
- protected ImageView (IntPtr raw) : base (raw) { }
-
- public ImageView (Adjustment hadjustment, Adjustment vadjustment, bool can_select) : base ()
- {
+ protected ImageView (IntPtr raw) : base (raw)
+ {
+ MIN_ZOOM = 0.1;
+ MAX_ZOOM = 10.0;
+ }
+
+ public ImageView (Adjustment hadjustment, Adjustment vadjustment, bool can_select)
+ {
+ MIN_ZOOM = 0.1;
+ MAX_ZOOM = 10.0;
OnSetScrollAdjustments (hadjustment, vadjustment);
AdjustmentsChanged += ScrollToAdjustments;
WidgetFlags &= ~WidgetFlags.NoWindow;
@@ -73,7 +79,7 @@ namespace FSpot.Widgets
return;
pixbuf = value;
- min_zoom = ComputeMinZoom (upscale);
+ MIN_ZOOM = ComputeMinZoom (upscale);
ComputeScaledSize ();
AdjustmentsChanged -= ScrollToAdjustments;
@@ -91,7 +97,7 @@ namespace FSpot.Widgets
if (value == pixbuf_orientation)
return;
pixbuf_orientation = value;
- min_zoom = ComputeMinZoom (upscale);
+ MIN_ZOOM = ComputeMinZoom (upscale);
ComputeScaledSize ();
QueueDraw ();
}
@@ -214,7 +220,7 @@ namespace FSpot.Widgets
if (scrolled != null)
scrolled.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
- min_zoom = ComputeMinZoom (upscale);
+ MIN_ZOOM = ComputeMinZoom (upscale);
this.upscale = upscale;
@@ -222,9 +228,7 @@ namespace FSpot.Widgets
DoZoom (MIN_ZOOM, Allocation.Width / 2, Allocation.Height / 2);
if (scrolled != null) {
- ThreadAssist.ProxyToMain (() => {
- scrolled.SetPolicy (Gtk.PolicyType.Automatic, Gtk.PolicyType.Automatic);
- });
+ ThreadAssist.ProxyToMain (() => scrolled.SetPolicy (Gtk.PolicyType.Automatic, Gtk.PolicyType.Automatic));
}
}
@@ -251,18 +255,12 @@ namespace FSpot.Widgets
#region protected API
- protected static double ZOOM_FACTOR = 1.1;
-
- protected double max_zoom = 10.0;
- protected double MAX_ZOOM {
- get { return max_zoom; }
- }
-
- protected double min_zoom = 0.1;
- protected double MIN_ZOOM {
- get { return min_zoom; }
- }
-
+ protected static double ZOOM_FACTOR = 1.1;
+
+ protected double MAX_ZOOM { get; set; }
+
+ protected double MIN_ZOOM { get; set; }
+
bool upscale;
protected void ZoomFit ()
{
@@ -356,7 +354,7 @@ namespace FSpot.Widgets
protected override void OnSizeAllocated (Gdk.Rectangle allocation)
{
- min_zoom = ComputeMinZoom (upscale);
+ MIN_ZOOM = ComputeMinZoom (upscale);
if (Fit || zoom < MIN_ZOOM)
zoom = MIN_ZOOM;
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/ImageView_Container.cs b/src/Core/FSpot.Gui/FSpot.Widgets/ImageView_Container.cs
index 02157bb..a623642 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/ImageView_Container.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/ImageView_Container.cs
@@ -28,132 +28,125 @@
//
using System.Collections.Generic;
-
+using System.Linq;
using Gtk;
namespace FSpot.Widgets
{
- public partial class ImageView : Container
- {
- List<LayoutChild> children = new List<LayoutChild> ();
-
- #region container
-
- protected override void OnAdded (Gtk.Widget widget)
- {
- Put (widget, 0, 0);
- }
-
- protected override void OnRemoved (Gtk.Widget widget)
- {
- LayoutChild child = null;
- foreach (var c in children) {
- if (child.Widget == widget) {
- child = c;
- break;
- }
- }
-
- if (child != null) {
- widget.Unparent ();
- children.Remove (child);
- }
- }
-
- protected override void ForAll (bool include_internals, Gtk.Callback callback)
- {
- foreach (var child in children) {
- callback (child.Widget);
- }
- }
-
- #endregion
-
-
- #region children
-
- class LayoutChild
- {
- Gtk.Widget widget;
- public Gtk.Widget Widget {
- get { return widget; }
- }
-
- public int X { get; set; }
- public int Y { get; set; }
-
- public LayoutChild (Gtk.Widget widget, int x, int y)
- {
- this.widget = widget;
- X = x;
- Y = y;
- }
- }
-
- LayoutChild GetChild (Gtk.Widget widget)
- {
- foreach (var child in children) {
- if (child.Widget == widget)
- return child;
- }
- return null;
- }
-
- #endregion
-
- #region Public API
-
- public void Put (Gtk.Widget widget, int x, int y)
- {
- children.Add (new LayoutChild (widget, x, y));
- if (IsRealized)
- widget.ParentWindow = GdkWindow;
- widget.Parent = this;
- }
-
- public void Move (Gtk.Widget widget, int x, int y)
- {
- LayoutChild child = GetChild (widget);
- if (child == null)
- return;
-
- child.X = x;
- child.Y = y;
- if (Visible && widget.Visible)
- QueueResize ();
- }
-
- private void OnRealizedChildren ()
- {
- foreach (var child in children) {
- child.Widget.ParentWindow = GdkWindow;
- }
- }
-
- private void OnMappedChildren ()
- {
- foreach (var child in children) {
- if (child.Widget.Visible && !child.Widget.IsMapped)
- child.Widget.Map ();
- }
- }
-
- private void OnSizeRequestedChildren ()
- {
- foreach (var child in children) {
- child.Widget.SizeRequest ();
- }
- }
-
- private void OnSizeAllocatedChildren ()
- {
- foreach (var child in children) {
- Gtk.Requisition req = child.Widget.ChildRequisition;
- child.Widget.SizeAllocate (new Gdk.Rectangle (child.X, child.Y, req.Width, req.Height));
- }
- }
-
- #endregion
- }
+ public partial class ImageView : Container
+ {
+ readonly List<LayoutChild> children = new List<LayoutChild> ();
+
+ #region container
+
+ protected override void OnAdded (Gtk.Widget widget)
+ {
+ Put (widget, 0, 0);
+ }
+
+ protected override void OnRemoved (Gtk.Widget widget)
+ {
+ LayoutChild child = null;
+ foreach (var c in children.Where(c => child.Widget == widget))
+ {
+ child = c;
+ break;
+ }
+
+ if (child == null)
+ return;
+
+ widget.Unparent ();
+ children.Remove (child);
+ }
+
+ protected override void ForAll (bool include_internals, Gtk.Callback callback)
+ {
+ foreach (var child in children) {
+ callback (child.Widget);
+ }
+ }
+
+ #endregion
+
+
+ #region children
+
+ class LayoutChild
+ {
+ public Widget Widget { get; private set; }
+
+ public int X { get; set; }
+ public int Y { get; set; }
+
+ public LayoutChild (Gtk.Widget widget, int x, int y)
+ {
+ Widget = widget;
+ X = x;
+ Y = y;
+ }
+ }
+
+ LayoutChild GetChild (Gtk.Widget widget)
+ {
+ return children.FirstOrDefault(child => child.Widget == widget);
+ }
+
+ #endregion
+
+ #region Public API
+
+ public void Put (Gtk.Widget widget, int x, int y)
+ {
+ children.Add (new LayoutChild (widget, x, y));
+ if (IsRealized)
+ widget.ParentWindow = GdkWindow;
+ widget.Parent = this;
+ }
+
+ public void Move (Gtk.Widget widget, int x, int y)
+ {
+ LayoutChild child = GetChild (widget);
+ if (child == null)
+ return;
+
+ child.X = x;
+ child.Y = y;
+ if (Visible && widget.Visible)
+ QueueResize ();
+ }
+
+ private void OnRealizedChildren ()
+ {
+ foreach (var child in children) {
+ child.Widget.ParentWindow = GdkWindow;
+ }
+ }
+
+ private void OnMappedChildren ()
+ {
+ foreach (var child in children) {
+ if (child.Widget.Visible && !child.Widget.IsMapped)
+ child.Widget.Map ();
+ }
+ }
+
+ private void OnSizeRequestedChildren ()
+ {
+ foreach (var child in children) {
+ child.Widget.SizeRequest ();
+ }
+ }
+
+ private void OnSizeAllocatedChildren ()
+ {
+ foreach (var child in children) {
+ Gtk.Requisition req = child.Widget.ChildRequisition;
+ child.Widget.SizeAllocate (new Gdk.Rectangle (child.X, child.Y, req.Width, req.Height));
+ }
+ }
+
+ #endregion
+ }
}
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/Layout.cs b/src/Core/FSpot.Gui/FSpot.Widgets/Layout.cs
index 3f2a2f2..3af7e9f 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/Layout.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/Layout.cs
@@ -28,29 +28,30 @@
//
using System;
-using System.Collections.Generic;
-
+using System.Collections.Generic;
+using Gdk;
using Hyena;
namespace FSpot.Widgets
{
+ // FIXME: This class is never used
public class Layout : Gtk.Container
{
public Layout () : this (null, null)
{
}
- public Layout (Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment) : base ()
- {
+ public Layout (Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment)
+ {
+ Height = 100;
+ Width = 100;
+ BinWindow = null;
OnSetScrollAdjustments (hadjustment, vadjustment);
children = new List<LayoutChild> ();
- }
-
- Gdk.Window bin_window = null;
- public Gdk.Window BinWindow {
- get { return bin_window; }
- }
-
+ }
+
+ public Window BinWindow { get; private set; }
+
Gtk.Adjustment hadjustment;
public Gtk.Adjustment Hadjustment {
get { return hadjustment; }
@@ -61,18 +62,12 @@ namespace FSpot.Widgets
public Gtk.Adjustment Vadjustment {
get { return vadjustment; }
set { OnSetScrollAdjustments (Hadjustment, vadjustment); }
- }
-
- uint width = 100;
- public uint Width {
- get { return width; }
- }
-
- uint height = 100;
- public uint Height {
- get { return height; }
- }
-
+ }
+
+ public uint Width { get; private set; }
+
+ public uint Height { get; private set; }
+
class LayoutChild {
public Gtk.Widget Widget { get; private set; }
@@ -92,7 +87,7 @@ namespace FSpot.Widgets
{
children.Add (new LayoutChild (widget, x, y));
if (IsRealized)
- widget.ParentWindow = bin_window;
+ widget.ParentWindow = BinWindow;
widget.Parent = this;
}
@@ -110,11 +105,11 @@ namespace FSpot.Widgets
public void SetSize (uint width, uint height)
{
- Hadjustment.Upper = this.width = width;
- Vadjustment.Upper = this.height = height;
+ Hadjustment.Upper = Width = width;
+ Vadjustment.Upper = Height = height;
if (IsRealized) {
- bin_window.Resize ((int)Math.Max (width, Allocation.Width), (int)Math.Max (height, Allocation.Height));
+ BinWindow.Resize ((int)Math.Max (width, Allocation.Width), (int)Math.Max (height, Allocation.Height));
}
}
@@ -151,29 +146,29 @@ namespace FSpot.Widgets
WindowType = Gdk.WindowType.Child,
X = (int)-Hadjustment.Value,
Y = (int)-Vadjustment.Value,
- Width = (int)Math.Max (width, Allocation.Width),
- Height = (int)Math.Max (height, Allocation.Height),
+ Width = (int)Math.Max (Width, Allocation.Width),
+ Height = (int)Math.Max (Height, Allocation.Height),
Wclass = Gdk.WindowClass.InputOutput,
Visual = this.Visual,
Colormap = this.Colormap,
Mask = Gdk.EventMask.ExposureMask | Gdk.EventMask.ScrollMask | this.Events };
- bin_window = new Gdk.Window (GdkWindow, attributes,
+ BinWindow = new Gdk.Window (GdkWindow, attributes,
Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y | Gdk.WindowAttributesType.Visual | Gdk.WindowAttributesType.Colormap);
- bin_window.UserData = Handle;
+ BinWindow.UserData = Handle;
Style.Attach (GdkWindow);
- Style.SetBackground (bin_window, Gtk.StateType.Normal);
+ Style.SetBackground (BinWindow, Gtk.StateType.Normal);
foreach (var child in children) {
- child.Widget.ParentWindow = bin_window;
+ child.Widget.ParentWindow = BinWindow;
}
}
protected override void OnUnrealized ()
{
- bin_window.Destroy ();
- bin_window = null;
+ BinWindow.Destroy ();
+ BinWindow = null;
base.OnUnrealized ();
}
@@ -182,7 +177,7 @@ namespace FSpot.Widgets
{
base.OnStyleSet (old_style);
if (IsRealized)
- Style.SetBackground (bin_window, Gtk.StateType.Normal);
+ Style.SetBackground (BinWindow, Gtk.StateType.Normal);
}
protected override void OnMapped ()
@@ -193,7 +188,7 @@ namespace FSpot.Widgets
if (child.Widget.Visible && !child.Widget.IsMapped)
child.Widget.Map ();
}
- bin_window.Show ();
+ BinWindow.Show ();
GdkWindow.Show ();
}
@@ -215,24 +210,24 @@ namespace FSpot.Widgets
if (IsRealized) {
GdkWindow.MoveResize (allocation.X, allocation.Y, allocation.Width, allocation.Height);
- bin_window.Resize ((int)Math.Max (width, allocation.Width), (int)Math.Max (height, allocation.Height));
+ BinWindow.Resize ((int)Math.Max (Width, allocation.Width), (int)Math.Max (Height, allocation.Height));
}
Hadjustment.PageSize = allocation.Width;
Hadjustment.PageIncrement = Width * .9;
Hadjustment.Lower = 0;
- Hadjustment.Upper = Math.Max (width, allocation.Width);
+ Hadjustment.Upper = Math.Max (Width, allocation.Width);
Vadjustment.PageSize = allocation.Height;
Vadjustment.PageIncrement = Height * .9;
Vadjustment.Lower = 0;
- Vadjustment.Upper = Math.Max (height, allocation.Height);
+ Vadjustment.Upper = Math.Max (Height, allocation.Height);
base.OnSizeAllocated (allocation);
}
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
- if (evnt.Window != bin_window)
+ if (evnt.Window != BinWindow)
return false;
return base.OnExposeEvent (evnt);
@@ -266,7 +261,7 @@ namespace FSpot.Widgets
void HandleAdjustmentsValueChanged (object sender, EventArgs e)
{
if (IsRealized)
- bin_window.Move (-(int)Hadjustment.Value, -(int)Vadjustment.Value);
+ BinWindow.Move (-(int)Hadjustment.Value, -(int)Vadjustment.Value);
}
#endregion widgetry
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/MenuButton.cs b/src/Core/FSpot.Gui/FSpot.Widgets/MenuButton.cs
index 362aca4..c4ed846 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/MenuButton.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/MenuButton.cs
@@ -34,9 +34,8 @@ namespace FSpot.Widgets
public class MenuButton : Button
{
Label label;
- Arrow arrow;
- Menu popup_menu;
-
+ Arrow arrow;
+
public new string Label {
get { return label.Text; }
set { label.Text = value; }
@@ -47,26 +46,19 @@ namespace FSpot.Widgets
public ArrowType ArrowType {
get { return arrow.ArrowType; }
set { arrow.ArrowType = value; }
- }
-
- public Menu Menu {
- get { return popup_menu; }
- set { popup_menu = value; }
- }
-
+ }
+
+ public Menu Menu { get; set; }
+
public MenuButton () : this (null)
{
- }
-
- public MenuButton (string label) : this (label, null)
- {
- }
-
- public MenuButton (string label, Menu menu) : this (label, menu, ArrowType.Down)
+ }
+
+ public MenuButton (string label, Menu menu = null) : this (label, menu, ArrowType.Down)
{
}
- public MenuButton (string label, Menu menu, ArrowType arrow_type) : base ()
+ public MenuButton (string label, Menu menu, ArrowType arrow_type)
{
HBox hbox = new HBox ();
@@ -91,10 +83,10 @@ namespace FSpot.Widgets
protected override void OnPressed ()
{
- if (popup_menu == null)
+ if (Menu == null)
return;
- popup_menu.Popup (null, null, Position, 0, Gtk.Global.CurrentEventTime);
+ Menu.Popup (null, null, Position, 0, Gtk.Global.CurrentEventTime);
}
void Position (Menu menu, out int x, out int y, out bool push_in)
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/OpenWithMenu.cs b/src/Core/FSpot.Gui/FSpot.Widgets/OpenWithMenu.cs
index d71b604..71cd3e1 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/OpenWithMenu.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/OpenWithMenu.cs
@@ -51,20 +51,17 @@ namespace FSpot.Widgets {
return null;
return ignore_apps.ToArray ();
}
- }
-
- bool show_icons = true;
- public bool ShowIcons {
- get { return show_icons; }
- set { show_icons = value; }
- }
-
+ }
+
+ public bool ShowIcons { get; set; }
+
public OpenWithMenu (TypeFetcher type_fetcher) : this (type_fetcher, null)
{
}
public OpenWithMenu (TypeFetcher type_fetcher, params string [] ignore_apps)
- {
+ {
+ ShowIcons = true;
this.type_fetcher = type_fetcher;
this.ignore_apps = new List<string> (ignore_apps);
}
@@ -73,11 +70,11 @@ namespace FSpot.Widgets {
public void Populate (object sender, EventArgs args)
{
Widget [] dead_pool = Children;
- for (int i = 0; i < dead_pool.Length; i++)
- dead_pool [i].Destroy ();
-
+ foreach (Widget t in dead_pool)
+ t.Destroy ();
+
foreach (AppInfo app in ApplicationsFor (type_fetcher ())) {
- AppMenuItem i = new AppMenuItem (app, show_icons);
+ AppMenuItem i = new AppMenuItem (app, ShowIcons);
i.Activated += HandleItemActivated;
Append (i);
}
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/RatingRenderer.cs b/src/Core/FSpot.Gui/FSpot.Widgets/RatingRenderer.cs
index 9d03d94..c693cb1 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/RatingRenderer.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/RatingRenderer.cs
@@ -36,10 +36,10 @@ using Hyena.Gui;
namespace FSpot.Widgets
{
public class RatingRenderer : Hyena.Gui.RatingRenderer
- {
- private static int REQUESTED_ICON_SIZE = 16;
-
-#region Shared Pixbufs
+ {
+ private const int REQUESTED_ICON_SIZE = 16;
+
+ #region Shared Pixbufs
// cache the unscaled pixbufs for all instances
private static Pixbuf icon_rated;
@@ -177,27 +177,18 @@ namespace FSpot.Widgets
#endregion
-#region Constructors / Destructor
-
- public RatingRenderer ()
- {
- }
-
- ~RatingRenderer ()
+#region Constructors / Destructor
+
+ ~RatingRenderer ()
{
ResetCachedPixbufs ();
}
#endregion
-#region Drawing Code
-
- public Pixbuf RenderPixbuf ()
- {
- return RenderPixbuf (false);
- }
-
- public Pixbuf RenderPixbuf (bool showEmptyStars)
+#region Drawing Code
+
+ public Pixbuf RenderPixbuf (bool showEmptyStars = false)
{
return RenderPixbuf (showEmptyStars, false, MinRating - 1, 0.0, 0.0, 1.0);
}
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/ScrolledView.cs b/src/Core/FSpot.Gui/FSpot.Widgets/ScrolledView.cs
index bf7a40e..9ff285f 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/ScrolledView.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/ScrolledView.cs
@@ -41,7 +41,8 @@ namespace FSpot.Widgets {
public ScrolledView (IntPtr raw) : base (raw) {}
- public ScrolledView () : base () {
+ public ScrolledView ()
+ {
ScrolledWindow = new ScrolledWindow (null, null);
this.Put (ScrolledWindow, 0, 0);
ScrolledWindow.Show ();
diff --git a/src/Core/FSpot.Gui/FSpot.Widgets/SelectionCollection.cs b/src/Core/FSpot.Gui/FSpot.Widgets/SelectionCollection.cs
index 787f133..227195c 100644
--- a/src/Core/FSpot.Gui/FSpot.Widgets/SelectionCollection.cs
+++ b/src/Core/FSpot.Gui/FSpot.Widgets/SelectionCollection.cs
@@ -47,11 +47,11 @@ namespace FSpot.Widgets
public SelectionCollection (IBrowsableCollection collection)
{
- this.selected_cells = new Dictionary<IPhoto, int> ();
- this.parent = collection;
- this.bit_array = new BitArray (this.parent.Count);
- this.parent.Changed += HandleParentChanged;
- this.parent.ItemsChanged += HandleParentItemsChanged;
+ selected_cells = new Dictionary<IPhoto, int> ();
+ parent = collection;
+ bit_array = new BitArray (this.parent.Count);
+ parent.Changed += HandleParentChanged;
+ parent.ItemsChanged += HandleParentItemsChanged;
}
private void HandleParentChanged (IBrowsableCollection collection)
@@ -67,16 +67,16 @@ namespace FSpot.Widgets
for (i = 0; i < local.Length; i++) {
int parent_index = parent.IndexOf (local [i]);
if (parent_index >= 0)
- this.Add (parent_index, false);
+ Add (parent_index, false);
}
}
// Call the directly so that we don't reset old immediately this way the old selection
// set isn't actually lost until we change it.
- if (this.Changed != null)
+ if (Changed != null)
Changed (this);
- if (this.DetailedChanged != null)
+ if (DetailedChanged != null)
DetailedChanged (this, null);
}
@@ -87,16 +87,16 @@ namespace FSpot.Widgets
private void HandleParentItemsChanged (IBrowsableCollection collection, BrowsableEventArgs args)
{
- if (this.ItemsChanged == null)
+ if (ItemsChanged == null)
return;
List<int> local_ids = new List<int> ();
foreach (int parent_index in args.Items) {
// If the item isn't part of the selection ignore it
- if (!this.Contains (collection [parent_index]))
+ if (!Contains (collection [parent_index]))
return;
- int local_index = this.IndexOf (parent_index);
+ int local_index = IndexOf (parent_index);
if (local_index >= 0)
local_ids.Add (local_index);
}
@@ -122,7 +122,7 @@ namespace FSpot.Widgets
public IPhoto this [int index] {
get {
- int [] ids = this.Ids;
+ int [] ids = Ids;
return parent [ids [index]];
}
}
@@ -132,21 +132,16 @@ namespace FSpot.Widgets
if (items != null)
return items;
- int [] ids = this.Ids;
+ int [] ids = Ids;
items = new IPhoto [ids.Length];
for (int i = 0; i < items.Length; i++) {
items [i] = parent [ids [i]];
}
return items;
}
- }
-
- public void Clear ()
- {
- Clear (true);
- }
-
- public void Clear (bool update)
+ }
+
+ public void Clear (bool update = true)
{
int [] ids = Ids;
selected_cells.Clear ();
@@ -157,11 +152,11 @@ namespace FSpot.Widgets
public void Add (IPhoto item)
{
- if (this.Contains (item))
+ if (Contains (item))
return;
int index = parent.IndexOf (item);
- this.Add (index);
+ Add (index);
}
public int Count {
@@ -180,20 +175,15 @@ namespace FSpot.Widgets
if (num < 0 || num >= parent.Count)
return false;
- return this.Contains (parent [num]);
- }
-
- public void Add (int num)
- {
- this.Add (num, true);
- }
-
- public void Add (int num, bool notify)
+ return Contains (parent [num]);
+ }
+
+ public void Add (int num, bool notify = true)
{
if (num == -1)
return;
- if (this.Contains (num))
+ if (Contains (num))
return;
IPhoto item = parent [num];
@@ -215,7 +205,7 @@ namespace FSpot.Widgets
int [] ids = new int [count];
for (int i = 0; i < count; i++) {
- this.Add (current, false);
+ Add (current, false);
ids [i] = current;
current++;
}
@@ -223,25 +213,15 @@ namespace FSpot.Widgets
SignalChange (ids);
}
- public void Remove (int cell, bool notify)
+ public void Remove (int cell, bool notify = true)
{
IPhoto item = parent [cell];
if (item != null)
- this.Remove (item, notify);
+ Remove (item, notify);
}
-
- public void Remove (IPhoto item)
- {
- Remove (item, true);
- }
-
- public void Remove (int cell)
- {
- Remove (cell, true);
- }
-
- private void Remove (IPhoto item, bool notify)
+
+ private void Remove (IPhoto item, bool notify = true)
{
if (item == null)
return;
@@ -266,7 +246,7 @@ namespace FSpot.Widgets
int [] ids = new int [count];
for (int i = 0; i < count; i++) {
- this.Remove (current, false);
+ Remove (current, false);
ids [i] = current;
current++;
}
@@ -276,31 +256,26 @@ namespace FSpot.Widgets
public int IndexOf (int parent_index)
{
- return System.Array.IndexOf (this.Ids, parent_index);
+ return System.Array.IndexOf (Ids, parent_index);
}
public int IndexOf (IPhoto item)
{
- if (!this.Contains (item))
+ if (!Contains (item))
return -1;
int parent_index = (int)selected_cells [item];
return System.Array.IndexOf (Ids, parent_index);
}
- public void ToggleCell (int cell_num, bool notify)
+ public void ToggleCell (int cell_num, bool notify = true)
{
if (Contains (cell_num))
Remove (cell_num, notify);
else
Add (cell_num, notify);
- }
-
- public void ToggleCell (int cell_num)
- {
- ToggleCell (cell_num, true);
- }
-
+ }
+
public void SelectionInvert ()
{
int [] changed_cell = new int[parent.Count];
@@ -327,7 +302,7 @@ namespace FSpot.Widgets
public void SignalChange (int [] ids)
{
ClearCached ();
- old = this.Items;
+ old = Items;
if (Changed != null)
diff --git a/src/Core/FSpot.JobScheduler/Banshee.Base/FSpotCompat.cs b/src/Core/FSpot.JobScheduler/Banshee.Base/FSpotCompat.cs
index fa0b572..e94ce7e 100644
--- a/src/Core/FSpot.JobScheduler/Banshee.Base/FSpotCompat.cs
+++ b/src/Core/FSpot.JobScheduler/Banshee.Base/FSpotCompat.cs
@@ -30,10 +30,12 @@
namespace Banshee.Base
{
public static class Globals
- {
- static bool debugging = false;
- public static bool Debugging {
- get { return debugging; }
- }
+ {
+ static Globals()
+ {
+ Debugging = false;
+ }
+
+ public static bool Debugging { get; private set; }
}
}
diff --git a/src/Core/FSpot.JobScheduler/Banshee.Kernel/IntervalHeap.cs b/src/Core/FSpot.JobScheduler/Banshee.Kernel/IntervalHeap.cs
index d470044..fba27f3 100644
--- a/src/Core/FSpot.JobScheduler/Banshee.Kernel/IntervalHeap.cs
+++ b/src/Core/FSpot.JobScheduler/Banshee.Kernel/IntervalHeap.cs
@@ -62,7 +62,7 @@ using System.Collections.Generic;
namespace Banshee.Kernel
{
- public class IntervalHeap<T> : ICollection<T>, ICollection, IEnumerable<T>, IEnumerable
+ public class IntervalHeap<T> : ICollection<T>, ICollection
{
private const int MIN_CAPACITY = 16;
diff --git a/src/Core/FSpot.Platform/FSpot.Platform/PreferenceBackend.cs b/src/Core/FSpot.Platform/FSpot.Platform/PreferenceBackend.cs
index fcd95d2..db08246 100644
--- a/src/Core/FSpot.Platform/FSpot.Platform/PreferenceBackend.cs
+++ b/src/Core/FSpot.Platform/FSpot.Platform/PreferenceBackend.cs
@@ -50,7 +50,7 @@ namespace FSpot.Platform
[Serializable]
public class NoSuchKeyException : Exception
{
- public NoSuchKeyException () : base ()
+ public NoSuchKeyException ()
{
}
@@ -80,12 +80,8 @@ namespace FSpot.Platform
return client;
}
}
- }
-
- public PreferenceBackend ()
- {
- }
-
+ }
+
public object Get (string key)
{
try {
diff --git a/src/Core/FSpot.Query/FSpot.Query/LogicalTerm.cs b/src/Core/FSpot.Query/FSpot.Query/LogicalTerm.cs
index ae7b618..222a986 100644
--- a/src/Core/FSpot.Query/FSpot.Query/LogicalTerm.cs
+++ b/src/Core/FSpot.Query/FSpot.Query/LogicalTerm.cs
@@ -29,7 +29,7 @@
using System;
using System.Collections.Generic;
-
+using System.Linq;
using FSpot.Core;
using Hyena;
@@ -57,9 +57,8 @@ namespace FSpot.Query
internal static string SqlClause (params TagTerm [] tags)
{
- List<string> list = new List<string> (tags.Length);
- foreach (TagTerm tag in tags)
- list.Add (tag.Tag.Id.ToString ());
+ List<string> list = new List<string> (tags.Length);
+ list.AddRange(tags.Select(tag => tag.Tag.Id.ToString()));
return SqlClause (list.ToArray ());
}
@@ -68,9 +67,9 @@ namespace FSpot.Query
if (tagids.Length == 0)
return null;
if (tagids.Length == 1)
- return String.Format (" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0})) ", tagids[0]);
- else
- return String.Format (" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id IN ({0}))) ", String.Join (", ", tagids));
+ return String.Format (" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0})) ", tagids[0]);
+
+ return String.Format (" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id IN ({0}))) ", String.Join (", ", tagids));
}
public void Dispose ()
@@ -88,6 +87,7 @@ namespace FSpot.Query
}
}
+ // FIXME: This is never used
public class TextTerm : LogicalTerm
{
public string Text { get; private set; }
@@ -102,9 +102,8 @@ namespace FSpot.Query
public static OrTerm SearchMultiple (string text, params string[] fields)
{
- List<TextTerm> terms = new List<TextTerm> (fields.Length);
- foreach (string field in fields)
- terms.Add (new TextTerm (text, field));
+ List<TextTerm> terms = new List<TextTerm> (fields.Length);
+ terms.AddRange(fields.Select(field => new TextTerm(text, field)));
return new OrTerm (terms.ToArray ());
}
@@ -112,8 +111,9 @@ namespace FSpot.Query
{
return String.Format (" {0} LIKE %{1}% ", Field, Text);
}
- }
-
+ }
+
+ // FIXME: This is never used
public class NotTerm : LogicalTerm
{
public LogicalTerm Term { get; private set; }
@@ -138,20 +138,18 @@ namespace FSpot.Query
protected string [] ToStringArray ()
{
- List<string> ls = new List<string> (terms.Count);
- foreach (LogicalTerm term in terms)
- ls.Add (term.SqlClause ());
+ List<string> ls = new List<string> (terms.Count);
+ ls.AddRange(terms.Select(term => term.SqlClause()));
return ls.ToArray ();
}
- public static string SqlClause (string op, string[] items)
- {
+ public static string SqlClause (string op, string[] items)
+ {
if (items.Length == 1)
- return items [0];
- else
- return " (" + String.Join (String.Format (" {0} ", op), items) + ") ";
- }
-
+ return items [0];
+
+ return " (" + String.Join (String.Format (" {0} ", op), items) + ") ";
+ }
}
public class OrTerm : NAryOperator
@@ -184,8 +182,9 @@ namespace FSpot.Query
otherterms.Insert (0, TagTerm.SqlClause (tagterms.ToArray ()));
return SqlClause ("OR", otherterms.ToArray ());
}
- }
-
+ }
+
+ // FIXME: This is never used
public class AndTerm : NAryOperator
{
public AndTerm (params LogicalTerm[] terms)
diff --git a/src/Core/FSpot.Utils/FSpot.Utils.csproj b/src/Core/FSpot.Utils/FSpot.Utils.csproj
index a0c2868..ab60ba0 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils.csproj
+++ b/src/Core/FSpot.Utils/FSpot.Utils.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+ï<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -100,6 +100,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="Mono.Cairo" />
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/Cache.cs b/src/Core/FSpot.Utils/FSpot.Utils/Cache.cs
index 7481461..ced84b9 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/Cache.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/Cache.cs
@@ -115,11 +115,7 @@ namespace FSpot.Utils
}
public class DisposableCache<TKey, TValue> : Cache<TKey, TValue>, IDisposable
- {
- public DisposableCache () : base ()
- {
- }
-
+ {
public DisposableCache (int max_count) : base (max_count)
{
}
@@ -163,7 +159,6 @@ namespace FSpot.Utils
}
}
-
public void Dispose ()
{
Clear ();
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/DelayedOperation.cs b/src/Core/FSpot.Utils/FSpot.Utils/DelayedOperation.cs
index bff34ac..44296df 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/DelayedOperation.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/DelayedOperation.cs
@@ -65,7 +65,7 @@ namespace FSpot.Utils
public void Start ()
{
lock (syncHandle) {
- if (this.IsPending)
+ if (IsPending)
return;
if (interval != 0)
@@ -88,13 +88,13 @@ namespace FSpot.Utils
private void HandleDestroy (object sender, System.EventArgs args)
{
- this.Stop ();
+ Stop ();
}
public void Stop ()
{
lock (syncHandle) {
- if (this.IsPending) {
+ if (IsPending) {
GLib.Source.Remove (source);
source = 0;
}
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/FileExtensions.cs b/src/Core/FSpot.Utils/FSpot.Utils/FileExtensions.cs
index 054e939..f20114e 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/FileExtensions.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/FileExtensions.cs
@@ -35,6 +35,7 @@ using GLib;
namespace FSpot.Utils
{
+ // FIXME: This class is never used
public static class FileExtensions
{
public static bool CopyRecursive (this GLib.File source, GLib.File target, GLib.FileCopyFlags flags, GLib.Cancellable cancellable, GLib.FileProgressCallback callback)
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/PixbufUtils.cs b/src/Core/FSpot.Utils/FSpot.Utils/PixbufUtils.cs
index ae563a6..4829076 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/PixbufUtils.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/PixbufUtils.cs
@@ -29,6 +29,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+// FIXME: What's the difference between having this one and the other in Clients?
+
using Gdk;
using TagLib.Image;
@@ -37,26 +39,26 @@ namespace FSpot.Utils
{
public static class PixbufUtils
{
- static public ImageOrientation Rotate270 (ImageOrientation orientation)
- {
- if (orientation == ImageOrientation.None) {
- orientation = ImageOrientation.TopLeft;
- }
+ static public ImageOrientation Rotate270 (ImageOrientation orientation)
+ {
+ if (orientation == ImageOrientation.None) {
+ orientation = ImageOrientation.TopLeft;
+ }
- ImageOrientation [] rot = new ImageOrientation [] {
- ImageOrientation.LeftBottom,
- ImageOrientation.LeftTop,
- ImageOrientation.RightTop,
- ImageOrientation.RightBottom,
- ImageOrientation.BottomLeft,
- ImageOrientation.TopLeft,
- ImageOrientation.TopRight,
- ImageOrientation.BottomRight
- };
+ ImageOrientation [] rot = new ImageOrientation [] {
+ ImageOrientation.LeftBottom,
+ ImageOrientation.LeftTop,
+ ImageOrientation.RightTop,
+ ImageOrientation.RightBottom,
+ ImageOrientation.BottomLeft,
+ ImageOrientation.TopLeft,
+ ImageOrientation.TopRight,
+ ImageOrientation.BottomRight
+ };
- orientation = rot [((int)orientation) -1];
- return orientation;
- }
+ orientation = rot [((int)orientation) -1];
+ return orientation;
+ }
static public ImageOrientation Rotate90 (ImageOrientation orientation)
{
@@ -110,8 +112,6 @@ namespace FSpot.Utils
area.Width = args.Height;
area.Height = args.Width;
break;
- default:
- break;
}
return area;
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/RecursiveFileEnumerator.cs b/src/Core/FSpot.Utils/FSpot.Utils/RecursiveFileEnumerator.cs
index 9aeafda..821b723 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/RecursiveFileEnumerator.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/RecursiveFileEnumerator.cs
@@ -29,6 +29,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+// FIXME: What's bring in System.Collections
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/SidecarXmpExtensions.cs b/src/Core/FSpot.Utils/FSpot.Utils/SidecarXmpExtensions.cs
index 9d0fb8f..03ce611 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/SidecarXmpExtensions.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/SidecarXmpExtensions.cs
@@ -39,67 +39,68 @@ using TagLib.Xmp;
namespace FSpot.Utils
{
- public static class SidecarXmpExtensions
- {
- /// <summary>
- /// Parses the XMP file identified by resource and replaces the XMP
- /// tag of file by the parsed data.
- /// </summary>
- public static bool ParseXmpSidecar (this TagLib.Image.File file, TagLib.File.IFileAbstraction resource)
- {
- string xmp;
+ // FIXME: This class is never used
+ public static class SidecarXmpExtensions
+ {
+ /// <summary>
+ /// Parses the XMP file identified by resource and replaces the XMP
+ /// tag of file by the parsed data.
+ /// </summary>
+ public static bool ParseXmpSidecar (this TagLib.Image.File file, TagLib.File.IFileAbstraction resource)
+ {
+ string xmp;
- try {
- using (var stream = resource.ReadStream) {
- using (var reader = new StreamReader (stream)) {
- xmp = reader.ReadToEnd ();
- }
- }
- } catch (Exception e) {
- Log.DebugFormat ("Sidecar cannot be read for file {0}", file.Name);
- Log.DebugException (e);
- return false;
- }
+ try {
+ using (var stream = resource.ReadStream) {
+ using (var reader = new StreamReader (stream)) {
+ xmp = reader.ReadToEnd ();
+ }
+ }
+ } catch (Exception e) {
+ Log.DebugFormat ("Sidecar cannot be read for file {0}", file.Name);
+ Log.DebugException (e);
+ return false;
+ }
- XmpTag tag = null;
- try {
- tag = new XmpTag (xmp, file);
- } catch (Exception e) {
- Log.DebugFormat ("Metadata of Sidecar cannot be parsed for file {0}", file.Name);
- Log.DebugException (e);
- return false;
- }
+ XmpTag tag = null;
+ try {
+ tag = new XmpTag (xmp, file);
+ } catch (Exception e) {
+ Log.DebugFormat ("Metadata of Sidecar cannot be parsed for file {0}", file.Name);
+ Log.DebugException (e);
+ return false;
+ }
- var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, true) as XmpTag;
- xmp_tag.ReplaceFrom (tag);
- return true;
- }
+ var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, true) as XmpTag;
+ xmp_tag.ReplaceFrom (tag);
+ return true;
+ }
- public static bool SaveXmpSidecar (this TagLib.Image.File file, TagLib.File.IFileAbstraction resource)
- {
- var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, false) as XmpTag;
- if (xmp_tag == null) {
- // TODO: Delete File
- return true;
- }
+ public static bool SaveXmpSidecar (this TagLib.Image.File file, TagLib.File.IFileAbstraction resource)
+ {
+ var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, false) as XmpTag;
+ if (xmp_tag == null) {
+ // TODO: Delete File
+ return true;
+ }
- var xmp = xmp_tag.Render ();
+ var xmp = xmp_tag.Render ();
- try {
- using (var stream = resource.WriteStream) {
- stream.SetLength (0);
- using (var writer = new StreamWriter (stream)) {
- writer.Write (xmp);
- }
- resource.CloseStream (stream);
- }
- } catch (Exception e) {
- Log.DebugFormat ("Sidecar cannot be saved: {0}", resource.Name);
- Log.DebugException (e);
- return false;
- }
+ try {
+ using (var stream = resource.WriteStream) {
+ stream.SetLength (0);
+ using (var writer = new StreamWriter (stream)) {
+ writer.Write (xmp);
+ }
+ resource.CloseStream (stream);
+ }
+ } catch (Exception e) {
+ Log.DebugFormat ("Sidecar cannot be saved: {0}", resource.Name);
+ Log.DebugException (e);
+ return false;
+ }
- return true;
- }
- }
+ return true;
+ }
+ }
}
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/UriList.cs b/src/Core/FSpot.Utils/FSpot.Utils/UriList.cs
index a6853c2..7826e33 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/UriList.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/UriList.cs
@@ -29,6 +29,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
using Hyena;
@@ -83,11 +84,9 @@ namespace FSpot.Utils
{
StringBuilder list = new StringBuilder ();
- foreach (SafeUri uri in this) {
- if (uri == null)
- break;
-
- list.Append (uri.ToString () + Environment.NewLine);
+ foreach (SafeUri uri in this.TakeWhile(uri => uri != null))
+ {
+ list.Append (uri + Environment.NewLine);
}
return list.ToString ();
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/XdgThumbnailSpec.cs b/src/Core/FSpot.Utils/FSpot.Utils/XdgThumbnailSpec.cs
index 00d3371..5ccb071 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/XdgThumbnailSpec.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/XdgThumbnailSpec.cs
@@ -163,11 +163,7 @@ namespace FSpot.Utils
var info = file.QueryInfo ("time::modified", GLib.FileQueryInfoFlags.None, null);
- if (pixbuf.GetOption (ThumbMTimeOpt) != info.GetAttributeULong ("time::modified").ToString ()) {
- return false;
- }
-
- return true;
+ return pixbuf.GetOption (ThumbMTimeOpt) == info.GetAttributeULong ("time::modified").ToString ();
}
#endregion
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]