f-spot r3610 - in trunk/src: . Core
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r3610 - in trunk/src: . Core
- Date: Wed, 30 Jan 2008 09:37:24 +0000 (GMT)
Author: sdelcroix
Date: Wed Jan 30 09:37:24 2008
New Revision: 3610
URL: http://svn.gnome.org/viewvc/f-spot?rev=3610&view=rev
Log:
more class splitting
Added:
trunk/src/Core/BrowsablePointer.cs
trunk/src/Core/IBrowsableCollection.cs
trunk/src/Core/IBrowsableItem.cs
- copied, changed from r3609, /trunk/src/IBrowsableItem.cs
Removed:
trunk/src/IBrowsableItem.cs
Modified:
trunk/src/Makefile.am
Added: trunk/src/Core/BrowsablePointer.cs
==============================================================================
--- (empty file)
+++ trunk/src/Core/BrowsablePointer.cs Wed Jan 30 09:37:24 2008
@@ -0,0 +1,163 @@
+/*
+ * FSpot.BrowsablePointer.cs
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace FSpot
+{
+ public delegate void ItemChangedHandler (BrowsablePointer pointer, BrowsablePointerChangedArgs old);
+
+ public class BrowsablePointerChangedArgs {
+ IBrowsableItem previous_item;
+ int previous_index;
+
+ public IBrowsableItem PreviousItem {
+ get { return previous_item; }
+ }
+
+ public int PreviousIndex {
+ get { return previous_index; }
+ }
+
+ public BrowsablePointerChangedArgs (IBrowsableItem old_item, int old_index)
+ {
+ previous_item = old_item;
+ previous_index = old_index;
+ }
+ }
+
+ public class BrowsablePointer {
+ IBrowsableCollection collection;
+ IBrowsableItem item;
+ int index;
+ public event ItemChangedHandler Changed;
+
+ public BrowsablePointer (IBrowsableCollection collection, int index)
+ {
+ this.collection = collection;
+ this.Index = index;
+ item = Current;
+
+ collection.Changed += HandleCollectionChanged;
+ collection.ItemsChanged += HandleCollectionItemsChanged;
+ }
+
+ public IBrowsableCollection Collection {
+ get { return collection; }
+ }
+
+ public IBrowsableItem Current {
+ get {
+ if (!this.IsValid)
+ return null;
+ else
+ return collection [index];
+ }
+ }
+
+ private bool Valid (int val)
+ {
+ return val >= 0 && val < collection.Count;
+ }
+
+ public bool IsValid {
+ get { return Valid (this.Index); }
+ }
+
+ public void MoveFirst ()
+ {
+ Index = 0;
+ }
+
+ public void MoveLast ()
+ {
+ Index = collection.Count - 1;
+ }
+
+ public void MoveNext ()
+ {
+ MoveNext (false);
+ }
+
+ public void MoveNext (bool wrap)
+ {
+ int val = Index;
+
+ val++;
+ if (!Valid (val))
+ val = wrap ? 0 : Index;
+
+ Index = val;
+ }
+
+ public void MovePrevious ()
+ {
+ MovePrevious (false);
+ }
+
+ public void MovePrevious (bool wrap)
+ {
+ int val = Index;
+
+ val--;
+ if (!Valid (val))
+ val = wrap ? collection.Count - 1 : Index;
+
+ Index = val;
+ }
+
+ public int Index {
+ get { return index; }
+ set {
+ if (index != value) {
+ SetIndex (value);
+ }
+ }
+ }
+
+ private void SetIndex (int value)
+ {
+ BrowsablePointerChangedArgs args;
+
+ args = new BrowsablePointerChangedArgs (Current, index);
+
+ index = value;
+ item = Current;
+
+ if (Changed != null)
+ Changed (this, args);
+ }
+
+ protected void HandleCollectionItemsChanged (IBrowsableCollection collection,
+ BrowsableArgs event_args)
+ {
+ foreach (int item in event_args.Items)
+ if (item == Index)
+ SetIndex (Index);
+ }
+
+ protected void HandleCollectionChanged (IBrowsableCollection collection)
+ {
+ int old_location = Index;
+ int next_location = collection.IndexOf (item);
+
+ if (old_location == next_location) {
+ if (! Valid (next_location))
+ SetIndex (0);
+
+ return;
+ }
+
+ if (Valid (next_location))
+ SetIndex (next_location);
+ else if (Valid (old_location))
+ SetIndex (old_location);
+ else
+ SetIndex (0);
+ }
+ }
+}
Added: trunk/src/Core/IBrowsableCollection.cs
==============================================================================
--- (empty file)
+++ trunk/src/Core/IBrowsableCollection.cs Wed Jan 30 09:37:24 2008
@@ -0,0 +1,62 @@
+/*
+ * FSpot.IBrowsableCollection.cs
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace FSpot
+{
+ public delegate void IBrowsableCollectionChangedHandler (IBrowsableCollection collection);
+ public delegate void IBrowsableCollectionItemsChangedHandler (IBrowsableCollection collection, BrowsableArgs args);
+
+ public class BrowsableArgs : System.EventArgs {
+ int [] items;
+
+ public int [] Items {
+ get { return items; }
+ }
+
+ public BrowsableArgs (int num)
+ {
+ items = new int [] { num };
+ }
+
+ public BrowsableArgs (int [] items)
+ {
+ this.items = items;
+ }
+ }
+
+ public interface IBrowsableCollection {
+ // FIXME this should really be ToArray ()
+ IBrowsableItem [] Items {
+ get;
+ }
+
+ int IndexOf (IBrowsableItem item);
+
+ IBrowsableItem this [int index] {
+ get;
+ }
+
+ int Count {
+ get;
+ }
+
+ bool Contains (IBrowsableItem item);
+
+ // FIXME the Changed event needs to pass along information
+ // about the items that actually changed if possible. For things like
+ // TrayView everything has to be redrawn when a single
+ // item has been added or removed which adds too much
+ // overhead.
+ event IBrowsableCollectionChangedHandler Changed;
+ event IBrowsableCollectionItemsChangedHandler ItemsChanged;
+
+ void MarkChanged (int index);
+ }
+}
+
Copied: trunk/src/Core/IBrowsableItem.cs (from r3609, /trunk/src/IBrowsableItem.cs)
==============================================================================
--- /trunk/src/IBrowsableItem.cs (original)
+++ trunk/src/Core/IBrowsableItem.cs Wed Jan 30 09:37:24 2008
@@ -1,62 +1,14 @@
-namespace FSpot {
- public delegate void IBrowsableCollectionChangedHandler (IBrowsableCollection collection);
- public delegate void IBrowsableCollectionItemsChangedHandler (IBrowsableCollection collection, BrowsableArgs args);
-
- /*
- public interface IBrowsableSelection : IBrowsableCollection {
- int [] ParentPositions ();
- public void Clear ();
- public void SelectAll ();
- }.
- */
-
- public class BrowsableArgs : System.EventArgs {
- int [] items;
-
- public int [] Items {
- get { return items; }
- }
-
- public BrowsableArgs (int num)
- {
- items = new int [] { num };
- }
-
- public BrowsableArgs (int [] items)
- {
- this.items = items;
- }
- }
-
- public interface IBrowsableCollection {
- // FIXME this should really be ToArray ()
- IBrowsableItem [] Items {
- get;
- }
-
- int IndexOf (IBrowsableItem item);
-
- IBrowsableItem this [int index] {
- get;
- }
-
- int Count {
- get;
- }
-
- bool Contains (IBrowsableItem item);
-
- // FIXME the Changed event needs to pass along information
- // about the items that actually changed if possible. For things like
- // TrayView everything has to be redrawn when a single
- // item has been added or removed which adds too much
- // overhead.
- event IBrowsableCollectionChangedHandler Changed;
- event IBrowsableCollectionItemsChangedHandler ItemsChanged;
-
- void MarkChanged (int index);
- }
+/*
+ * FSpot.IBrowsableItem.cs
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+namespace FSpot
+{
public interface IBrowsableItem {
System.DateTime Time {
get;
@@ -84,156 +36,4 @@
}
- public class BrowsablePointerChangedArgs {
- IBrowsableItem previous_item;
- int previous_index;
-
- public IBrowsableItem PreviousItem {
- get { return previous_item; }
- }
-
- public int PreviousIndex {
- get { return previous_index; }
- }
-
- public BrowsablePointerChangedArgs (IBrowsableItem old_item, int old_index)
- {
- previous_item = old_item;
- previous_index = old_index;
- }
- }
-
- public delegate void ItemChangedHandler (BrowsablePointer pointer, BrowsablePointerChangedArgs old);
-
- public class BrowsablePointer {
- IBrowsableCollection collection;
- IBrowsableItem item;
- int index;
- public event ItemChangedHandler Changed;
-
- public BrowsablePointer (IBrowsableCollection collection, int index)
- {
- this.collection = collection;
- this.Index = index;
- item = Current;
-
- collection.Changed += HandleCollectionChanged;
- collection.ItemsChanged += HandleCollectionItemsChanged;
- }
-
- public IBrowsableCollection Collection {
- get { return collection; }
- }
-
- public IBrowsableItem Current {
- get {
- if (!this.IsValid)
- return null;
- else
- return collection [index];
- }
- }
-
- private bool Valid (int val)
- {
- return val >= 0 && val < collection.Count;
- }
-
- public bool IsValid {
- get { return Valid (this.Index); }
- }
-
- public void MoveFirst ()
- {
- Index = 0;
- }
-
- public void MoveLast ()
- {
- Index = collection.Count - 1;
- }
-
- public void MoveNext ()
- {
- MoveNext (false);
- }
-
- public void MoveNext (bool wrap)
- {
- int val = Index;
-
- val++;
- if (!Valid (val))
- val = wrap ? 0 : Index;
-
- Index = val;
- }
-
- public void MovePrevious ()
- {
- MovePrevious (false);
- }
-
- public void MovePrevious (bool wrap)
- {
- int val = Index;
-
- val--;
- if (!Valid (val))
- val = wrap ? collection.Count - 1 : Index;
-
- Index = val;
- }
-
- public int Index {
- get { return index; }
- set {
- if (index != value) {
- SetIndex (value);
- }
- }
- }
-
- private void SetIndex (int value)
- {
- BrowsablePointerChangedArgs args;
-
- args = new BrowsablePointerChangedArgs (Current, index);
-
- index = value;
- item = Current;
-
- if (Changed != null)
- Changed (this, args);
- }
-
- protected void HandleCollectionItemsChanged (IBrowsableCollection collection,
- BrowsableArgs event_args)
- {
- foreach (int item in event_args.Items)
- if (item == Index)
- SetIndex (Index);
- }
-
- protected void HandleCollectionChanged (IBrowsableCollection collection)
- {
- int old_location = Index;
- int next_location = collection.IndexOf (item);
-
- if (old_location == next_location) {
- if (! Valid (next_location))
- SetIndex (0);
-
- return;
- }
-
- if (Valid (next_location))
- SetIndex (next_location);
- else if (Valid (old_location))
- SetIndex (old_location);
- else
- SetIndex (0);
- }
-
- }
}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Jan 30 09:37:24 2008
@@ -11,10 +11,13 @@
$(srcdir)/Cms/CctTable.cs
CORE_CSDISTFILES = \
+ $(srcdir)/Core/BrowsablePointer.cs \
$(srcdir)/Core/Category.cs \
$(srcdir)/Core/DbItem.cs \
$(srcdir)/Core/Tag.cs \
$(srcdir)/Core/Global.cs \
+ $(srcdir)/Core/IBrowsableItem.cs \
+ $(srcdir)/Core/IBrowsableCollection.cs \
$(srcdir)/Core/IPreferenceBackend.cs
F_SPOT_CSDISTFILES = \
@@ -123,7 +126,6 @@
$(srcdir)/GroupSelector.cs \
$(srcdir)/Accelerometer.cs \
$(srcdir)/Histogram.cs \
- $(srcdir)/IBrowsableItem.cs \
$(srcdir)/ImageView.cs \
$(srcdir)/ImageTest.cs \
$(srcdir)/ImportBackend.cs \
@@ -385,5 +387,5 @@
DISTCLEANFILES = \
- makefile
+ Makefile
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]