[f-spot/cleanup-backend: 7/24] Base IconView.SelectionCollection on PhotoSelection
- From: Mike Gemünde <mgemuende src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/cleanup-backend: 7/24] Base IconView.SelectionCollection on PhotoSelection
- Date: Mon, 19 Jul 2010 06:41:54 +0000 (UTC)
commit 56d1a5c8d36b3a93d767eb692e466c06cb8c2c50
Author: Mike Gemünde <mike gemuende de>
Date: Fri Jul 16 10:24:20 2010 +0200
Base IconView.SelectionCollection on PhotoSelection
This required some breakage. Some methods are removed from
MainWindow.MainSelection. However, this should go and be replaced
by a global SelectionProxy. RatingMenuItem is also broken, this will
be fixed later.
src/MainWindow.cs | 24 ++++++++--------
src/Widgets/IconView.cs | 61 +++-------------------------------------
src/Widgets/RatingMenuItem.cs | 4 +-
3 files changed, 19 insertions(+), 70 deletions(-)
---
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index 7ce1627..9719ebb 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -708,7 +708,7 @@ namespace FSpot
return ids;
}
- public class MainSelection : IBrowsableCollection {
+ public class MainSelection {
MainWindow win;
public MainSelection (MainWindow win)
@@ -733,7 +733,7 @@ namespace FSpot
}
}
- public int IndexOf (IBrowsableItem item)
+/* public int IndexOf (IBrowsableItem item)
{
switch (win.ViewMode) {
case ModeType.PhotoView:
@@ -743,7 +743,7 @@ namespace FSpot
}
return -1;
}
-
+ */
public bool Contains (IBrowsableItem item)
{
switch (win.ViewMode) {
@@ -758,7 +758,7 @@ namespace FSpot
public void MarkChanged ()
{
if (Changed != null)
- Changed (this);
+ Changed (null);
}
public void MarkChanged (int index, IBrowsableItemChanges changes)
@@ -766,7 +766,7 @@ namespace FSpot
throw new System.NotImplementedException ("I didn't think you'd find me");
}
- public IBrowsableItem this [int index] {
+/* public IBrowsableItem this [int index] {
get {
switch (win.ViewMode) {
case ModeType.PhotoView:
@@ -774,12 +774,12 @@ namespace FSpot
return win.photo_view.Item.Current;
break;
case ModeType.IconView:
- return win.icon_view.Selection [index];
+ return null; //win.icon_view.Selection [index];
}
throw new ArgumentOutOfRangeException ();
}
}
-
+ */
public IBrowsableItem [] Items {
get {
switch (win.ViewMode) {
@@ -805,7 +805,7 @@ namespace FSpot
foreach (int item in args.Items) {
if (win.photo_view.Item.Index == item ) {
- ItemsChanged (this, new BrowsableEventArgs (item, args.Changes));
+ ItemsChanged (null, new BrowsableEventArgs (item, args.Changes));
break;
}
}
@@ -814,13 +814,13 @@ namespace FSpot
private void HandlePhotoChanged (PhotoView sender)
{
if (win.ViewMode == ModeType.PhotoView && Changed != null)
- Changed (this);
+ Changed (null);
}
public void HandleSelectionChanged (object sender, EventArgs e)
{
if (win.ViewMode == ModeType.IconView && Changed != null)
- Changed (this);
+ Changed (null);
}
@@ -828,7 +828,7 @@ namespace FSpot
private void HandleSelectionItemsChanged (IBrowsableCollection collection, BrowsableEventArgs args)
{
if (win.ViewMode == ModeType.IconView && ItemsChanged != null)
- ItemsChanged (this, args);
+ ItemsChanged (null, args);
}
public event IBrowsableCollectionChangedHandler Changed;
@@ -2160,7 +2160,7 @@ namespace FSpot
void HandleSelectInvertCommand (object sender, EventArgs args)
{
- icon_view.Selection.SelectionInvert ();
+ icon_view.Selection.ToggleAll ();
UpdateStatusLabel ();
}
diff --git a/src/Widgets/IconView.cs b/src/Widgets/IconView.cs
index ab5c3e1..f7b535d 100644
--- a/src/Widgets/IconView.cs
+++ b/src/Widgets/IconView.cs
@@ -284,19 +284,10 @@ namespace FSpot.Widgets
// FIXME right now a selection change triggers a complete view redraw
// This should be optimized away by directly notifyiing the view of changed
// indexes rather than having the view connect to the collection.Changed event.
- public class SelectionCollection : Hyena.Collections.Selection {
- IBrowsableCollection parent;
+ public class SelectionCollection : FSpot.Collections.PhotoSelection {
- public SelectionCollection (IBrowsableCollection collection)
- {
- this.parent = collection;
- this.parent.Changed += HandleParentChanged;
- }
-
- private void HandleParentChanged (IBrowsableCollection collection)
- {
- Clear ();
- }
+ public SelectionCollection (IBrowsableCollection collection) : base (collection)
+ {}
public int [] Ids {
get {
@@ -305,55 +296,13 @@ namespace FSpot.Widgets
}
}
- public IBrowsableItem this [int index] {
- get {
- int [] ids = this.Ids;
- return parent [ids[index]];
- }
- }
-
public IBrowsableItem [] Items {
get {
- List<IBrowsableItem> items = new List<IBrowsableItem> ();
-
- foreach (int index in this) {
- items.Add (parent [index]);
- }
+ List<IBrowsableItem> items = new List<IBrowsableItem> (this.Photos);
return items.ToArray ();
}
}
-
- public bool Contains (IBrowsableItem item)
- {
- return Contains (parent.IndexOf (item));
- }
-
- public int IndexOf (int parent_index)
- {
- return System.Array.IndexOf (this.Ids, parent_index);
- }
-
- public int IndexOf (IBrowsableItem item)
- {
- if (!this.Contains (item))
- return -1;
-
- return System.Array.IndexOf (Ids, parent.IndexOf (item));
- }
-
- public void SelectionInvert ()
- {
- for (int i = 0; i < parent.Count; i++) {
- if (Contains (i))
- QuietUnselect (i);
- else
- QuietSelect (i);
- }
-
- OnChanged ();
- }
-
}
// Updating.
diff --git a/src/Widgets/RatingMenuItem.cs b/src/Widgets/RatingMenuItem.cs
index 53d8f99..232f09a 100644
--- a/src/Widgets/RatingMenuItem.cs
+++ b/src/Widgets/RatingMenuItem.cs
@@ -61,8 +61,8 @@ namespace FSpot.Widgets
Log.Debug ("PARENT IS FSVIEW");
FullScreenView fsview = parent as FullScreenView;
entry = new Rating ((int)fsview.View.Item.Current.Rating, true);
- } else if (App.Instance.Organizer.Selection.Count == 1)
- entry = new Rating ((int)App.Instance.Organizer.Selection[0].Rating, true);
+ } /*else if (App.Instance.Organizer.Selection.Count == 1)
+ entry = new Rating ((int)App.Instance.Organizer.Selection [0].Rating, true);*/
else
entry = new Rating (-1, true);
entry.Changed += OnEntryChanged;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]