[f-spot/cleanup-backend: 14/23] Remove Selection from IconView and use IBrowseableItem's one
- From: Mike Gemünde <mgemuende src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/cleanup-backend: 14/23] Remove Selection from IconView and use IBrowseableItem's one
- Date: Fri, 16 Jul 2010 17:26:31 +0000 (UTC)
commit f6d6d120b70e08515eabecfb44d28864881834a1
Author: Mike Gemünde <mike gemuende de>
Date: Fri Jul 16 11:03:16 2010 +0200
Remove Selection from IconView and use IBrowseableItem's one
.../FacebookExport/FacebookExportDialog.cs | 2 +-
src/MainWindow.cs | 34 ++++----
src/SingleView.cs | 28 +++---
src/UI.Dialog/AdjustTimeDialog.cs | 10 +-
src/UI.Dialog/ImportDialog.cs | 4 +-
src/Widgets/IconView.cs | 97 +++++++++-----------
6 files changed, 84 insertions(+), 91 deletions(-)
---
diff --git a/extensions/Exporters/FacebookExport/FacebookExportDialog.cs b/extensions/Exporters/FacebookExport/FacebookExportDialog.cs
index cf6d6e2..fe958b9 100644
--- a/extensions/Exporters/FacebookExport/FacebookExportDialog.cs
+++ b/extensions/Exporters/FacebookExport/FacebookExportDialog.cs
@@ -89,7 +89,7 @@ namespace FSpot.Exporter.Facebook
thumbnail_iconview.DisplayTags = false;
thumbnail_iconview.DisplayRatings = false;
thumbnail_iconview.ButtonPressEvent += HandleThumbnailIconViewButtonPressEvent;
- thumbnail_iconview.KeyPressEvent += delegate (object sender, KeyPressEventArgs e) {(sender as FSpot.Widgets.IconView).Selection.Clear(); };
+ thumbnail_iconview.KeyPressEvent += delegate (object sender, KeyPressEventArgs e) {selection.Selection.Clear(); };
thumbnails_scrolled_window.Add (thumbnail_iconview);
thumbnail_iconview.Show ();
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index 6e634f4..b9fb4a8 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -600,7 +600,7 @@ namespace FSpot
display_filmstrip.Sensitive = true;
group_selector.Visible = false;
- JumpTo (icon_view.Selection.FocusedIndex);
+ JumpTo (query.Selection.FocusedIndex);
zoom_scale.Value = photo_view.NormalizedZoom;
photo_view.View.GrabFocus();
@@ -697,7 +697,7 @@ namespace FSpot
else {
switch (ViewMode) {
case ModeType.IconView:
- ids = icon_view.Selection.ToArray ();
+ ids = query.Selection.ToArray ();
break;
default:
case ModeType.PhotoView:
@@ -716,8 +716,8 @@ namespace FSpot
public MainSelection (MainWindow win)
{
this.win = win;
- win.icon_view.Selection.Changed += HandleSelectionChanged;
- //win.icon_view.Selection.FocusChanged += HandleSelectionItemsChanged;
+ win.query.Selection.Changed += HandleSelectionChanged;
+ //win.query.Selection.FocusChanged += HandleSelectionItemsChanged;
win.photo_view.PhotoChanged += HandlePhotoChanged;
win.query.ItemsChanged += HandleQueryItemsChanged;
win.query.ItemsChanged += HandleSelectionItemsChanged;
@@ -729,7 +729,7 @@ namespace FSpot
case ModeType.PhotoView:
return win.photo_view.Item.IsValid ? 1 : 0;
case ModeType.IconView:
- return win.icon_view.Selection.Count;
+ return win.query.Selection.Count;
}
return 0;
}
@@ -741,7 +741,7 @@ namespace FSpot
case ModeType.PhotoView:
return item == win.photo_view.Item.Current ? 0 : -1;
case ModeType.IconView:
- return win.icon_view.Selection.IndexOf (item);
+ return win.query.Selection.IndexOf (item);
}
return -1;
}
@@ -752,7 +752,7 @@ namespace FSpot
case ModeType.PhotoView:
return item == win.photo_view.Item.Current ? true : false;
case ModeType.IconView:
- return win.icon_view.Selection.Contains (item);
+ return win.query.Selection.Contains (item);
}
return false;
}
@@ -776,7 +776,7 @@ namespace FSpot
return win.photo_view.Item.Current;
break;
case ModeType.IconView:
- return null; //win.icon_view.Selection [index];
+ return null; //win.query.Selection [index];
}
throw new ArgumentOutOfRangeException ();
}
@@ -791,7 +791,7 @@ namespace FSpot
break;
case ModeType.IconView:
- return win.icon_view.Selection.Photos.ToArray ();
+ return win.query.Selection.Photos.ToArray ();
}
return new IBrowsableItem [0];
}
@@ -1179,7 +1179,7 @@ namespace FSpot
//Console.WriteLine ("Drop cell = {0} ({1},{2})", item, args.X, args.Y);
if (item >= 0) {
- if (icon_view.Selection.Contains (item))
+ if (query.Selection.Contains (item))
AttachTags (tag_selection_widget.TagHighlight, SelectedIds());
else
AttachTags (tag_selection_widget.TagHighlight, new int [] {item});
@@ -1209,13 +1209,13 @@ namespace FSpot
args.Y + (int) icon_view.Vadjustment.Value);
if (p_item >= 0) {
- if (icon_view.Selection.Contains (p_item)) //We don't want to reparent ourselves!
+ if (query.Selection.Contains (p_item)) //We don't want to reparent ourselves!
return;
PhotoVersionCommands.Reparent cmd = new PhotoVersionCommands.Reparent ();
Photo[] photos_to_reparent = SelectedPhotos ();
// Give feedback to user that something happened, and leave the parent selected after reparenting
- icon_view.Selection.Select (p_item);
- icon_view.Selection.FocusedIndex = p_item;
+ query.Selection.Select (p_item);
+ query.Selection.FocusedIndex = p_item;
cmd.Execute (Database.Photos, photos_to_reparent, query.Photos [p_item], GetToplevel (null));
UpdateQuery ();
}
@@ -1236,7 +1236,7 @@ namespace FSpot
switch (ViewMode) {
case ModeType.IconView:
- icon_view.Selection.FocusedIndex = args.Items[0];
+ query.Selection.FocusedIndex = args.Items[0];
SetViewMode (ModeType.PhotoView);
break;
case ModeType.PhotoView:
@@ -2150,19 +2150,19 @@ namespace FSpot
return;
}
- icon_view.Selection.SelectAll ();
+ query.Selection.SelectAll ();
UpdateStatusLabel ();
}
void HandleSelectNoneCommand (object sender, EventArgs args)
{
- icon_view.Selection.Clear ();
+ query.Selection.Clear ();
UpdateStatusLabel ();
}
void HandleSelectInvertCommand (object sender, EventArgs args)
{
- icon_view.Selection.ToggleAll ();
+ query.Selection.ToggleAll ();
UpdateStatusLabel ();
}
diff --git a/src/SingleView.cs b/src/SingleView.cs
index 7bb0812..76eef80 100644
--- a/src/SingleView.cs
+++ b/src/SingleView.cs
@@ -103,7 +103,7 @@ namespace FSpot {
};
directory_view = new FSpot.Widgets.IconView (collection);
- directory_view.Selection.Changed += HandleSelectionChanged;
+ collection.Selection.Changed += HandleSelectionChanged;
directory_view.DragDataReceived += HandleDragDataReceived;
Gtk.Drag.DestSet (directory_view, DestDefaults.All, dest_table,
DragAction.Copy | DragAction.Move);
@@ -171,8 +171,8 @@ namespace FSpot {
UpdateStatusLabel ();
if (collection.Count > 0) {
- directory_view.Selection.Select (0);
- directory_view.Selection.FocusedIndex = 0;
+ collection.Selection.Select (0);
+ collection.Selection.FocusedIndex = 0;
}
export.Submenu = (Mono.Addins.AddinManager.GetExtensionNode ("/FSpot/Menus/Exports") as FSpot.Extensions.SubmenuNode).GetMenuItem (this).Submenu;
@@ -189,16 +189,16 @@ namespace FSpot {
void HandleExportActivated (object o, EventArgs e)
{
FSpot.Extensions.ExportMenuItemNode.SelectedImages = delegate () {
- return new PhotoList (directory_view.Selection.Photos.ToArray ());
+ return new PhotoList (collection.Selection.Photos.ToArray ());
};
}
public void HandleCollectionChanged (IBrowsableCollection collection)
{
- if (collection.Count > 0 && directory_view.Selection.Count == 0) {
+ if (collection.Count > 0 && collection.Selection.Count == 0) {
Log.Debug ("Added selection");
- directory_view.Selection.Select (0);
- directory_view.Selection.FocusedIndex = 0;
+ collection.Selection.Select (0);
+ collection.Selection.FocusedIndex = 0;
}
if (collection.Count > 1)
@@ -259,7 +259,7 @@ namespace FSpot {
private void HandleSelectionChanged (object sender, EventArgs e)
{
- int first = directory_view.Selection.FirstIndex;
+ int first = collection.Selection.FirstIndex;
if (first != -1) {
image_view.Item.Index = first;
@@ -274,11 +274,11 @@ namespace FSpot {
if (pointer == null)
return;
- directory_view.Selection.FocusedIndex = pointer.Index;
- directory_view.Selection.Clear ();
+ collection.Selection.FocusedIndex = pointer.Index;
+ collection.Selection.Clear ();
if (collection.Count > 0) {
- directory_view.Selection.Select (directory_view.Selection.FocusedIndex);
- directory_view.ScrollTo (directory_view.Selection.FocusedIndex);
+ collection.Selection.Select (collection.Selection.FocusedIndex);
+ directory_view.ScrollTo (collection.Selection.FocusedIndex);
}
}
@@ -383,9 +383,9 @@ namespace FSpot {
private void HandleFullScreenViewDestroy (object sender, System.EventArgs args)
{
- directory_view.Selection.Clear ();
+ collection.Selection.Clear ();
if (fsview.View.Item.IsValid)
- directory_view.Selection.Select (fsview.View.Item.Index);
+ collection.Selection.Select (fsview.View.Item.Index);
fsview = null;
}
diff --git a/src/UI.Dialog/AdjustTimeDialog.cs b/src/UI.Dialog/AdjustTimeDialog.cs
index cc53ce4..3898c78 100644
--- a/src/UI.Dialog/AdjustTimeDialog.cs
+++ b/src/UI.Dialog/AdjustTimeDialog.cs
@@ -53,7 +53,7 @@ namespace FSpot.UI.Dialog {
tray = new TrayView (collection);
tray_scrolled.Add (tray);
- tray.Selection.Changed += HandleSelectionChanged;
+ collection.Selection.Changed += HandleSelectionChanged;
view = new PhotoImageView (collection);
view_scrolled.Add (view);
@@ -135,9 +135,9 @@ namespace FSpot.UI.Dialog {
}
HandleTimeChanged (this, System.EventArgs.Empty);
- if (!tray.Selection.Contains (Item.Index)) {
- tray.Selection.Clear ();
- tray.Selection.Select (Item.Index);
+ if (!collection.Selection.Contains (Item.Index)) {
+ collection.Selection.Clear ();
+ collection.Selection.Select (Item.Index);
}
photo_spin.Value = Item.Index + 1;
@@ -253,7 +253,7 @@ namespace FSpot.UI.Dialog {
void HandleSelectionChanged (object sender, EventArgs e)
{
- int first = tray.Selection.FirstIndex;
+ int first = collection.Selection.FirstIndex;
if (first != -1) {
view.Item.Index = first;
diff --git a/src/UI.Dialog/ImportDialog.cs b/src/UI.Dialog/ImportDialog.cs
index 9414fad..b968ffd 100644
--- a/src/UI.Dialog/ImportDialog.cs
+++ b/src/UI.Dialog/ImportDialog.cs
@@ -59,8 +59,8 @@ namespace FSpot.UI.Dialog
GtkUtil.ModifyColors (photo_view);
var tray = new ScalingIconView (Controller.Photos);
- tray.Selection.Changed += delegate {
- int first = tray.Selection.FirstIndex;
+ Controller.Photos.Selection.Changed += delegate {
+ int first = Controller.Photos.Selection.FirstIndex;
if (first != -1)
photo_view.Item.Index = first;
diff --git a/src/Widgets/IconView.cs b/src/Widgets/IconView.cs
index 9233d88..c836877 100644
--- a/src/Widgets/IconView.cs
+++ b/src/Widgets/IconView.cs
@@ -230,14 +230,13 @@ namespace FSpot.Widgets
public IconView (FSpot.IBrowsableCollection collection) : this ()
{
this.collection = collection;
- this.selection = new FSpot.Collections.PhotoSelection (collection);
Name = "ImageContainer";
collection.Changed += HandleChanged;
collection.ItemsChanged += HandleItemsChanged;
- selection.Changed += HandleSelectionChanged;
- selection.FocusChanged += delegate {
+ collection.Selection.Changed += HandleSelectionChanged;
+ collection.Selection.FocusChanged += delegate {
QueueDraw ();
};;
}
@@ -275,12 +274,6 @@ namespace FSpot.Widgets
}
}
- protected FSpot.Collections.PhotoSelection selection;
- public FSpot.Collections.PhotoSelection Selection {
- get { return selection; }
- }
-
-
// Updating.
public void UpdateThumbnail (int thumbnail_num)
{
@@ -323,7 +316,7 @@ namespace FSpot.Widgets
displayed.Offset (-cell_border_padding, -cell_border_padding);
if (displayed.Contains (x, y))
return cell_num;
- else if (selection.Contains (cell_num))
+ else if (collection.Selection.Contains (cell_num))
return cell_num;
else
return -1;
@@ -499,7 +492,7 @@ namespace FSpot.Widgets
else
entry.Data = thumbnail_num;
- bool selected = selection.Contains (thumbnail_num);
+ bool selected = collection.Selection.Contains (thumbnail_num);
StateType cell_state = selected ? (HasFocus ? StateType.Selected : StateType.Active) : State;
if (cell_state != State)
@@ -510,7 +503,7 @@ namespace FSpot.Widgets
Gdk.Rectangle focus = Gdk.Rectangle.Inflate (bounds, -3, -3);
- if (HasFocus && thumbnail_num == Selection.FocusedIndex) {
+ if (HasFocus && thumbnail_num == collection.Selection.FocusedIndex) {
Style.PaintFocus(Style, BinWindow,
cell_state, area,
this, null,
@@ -736,7 +729,7 @@ namespace FSpot.Widgets
{
for (int row = start_row; row < end_row; row++)
for (int line = start_line; line < end_line; line++) {
- Selection.QuietSelect (line*cells_per_row + row);
+ collection.Selection.QuietSelect (line*cells_per_row + row);
}
}
@@ -745,10 +738,10 @@ namespace FSpot.Widgets
for (int row = start_row; row < end_row; row++)
for (int line = start_line; line < end_line; line++) {
int index = line*cells_per_row + row;
- if (Selection.Contains (index))
- Selection.QuietUnselect (index);
+ if (collection.Selection.Contains (index))
+ collection.Selection.QuietUnselect (index);
else
- Selection.QuietSelect (index);
+ collection.Selection.QuietSelect (index);
}
}
@@ -1206,10 +1199,10 @@ namespace FSpot.Widgets
int end_y = y1 > y2 ? y1 : y2;
// Restore initial selection
-// BitArray initial_selection = selection.ToBitArray();
- selection.Clear (false);
+// BitArray initial_selection = collection.Selection.ToBitArray();
+ collection.Selection.Clear (false);
foreach (int i in start_select_selection)
- selection.QuietSelect (i);
+ collection.Selection.QuietSelect (i);
// Select or toggle according to modifiers
int start_row = (start_x - BORDER_SIZE) / cell_width;
@@ -1222,7 +1215,7 @@ namespace FSpot.Widgets
end_row = cells_per_row;
- Selection.FocusedIndex = start_line * cells_per_row + start_row;
+ collection.Selection.FocusedIndex = start_line * cells_per_row + start_row;
if ((mod & ModifierType.ControlMask) == 0)
SelectRect (start_row, end_row, start_line, end_line);
@@ -1230,14 +1223,14 @@ namespace FSpot.Widgets
ToggleRect (start_row, end_row, start_line, end_line);
// fire events for cells which have changed selection flag
-// BitArray new_selection = selection.ToBitArray();
-// BitArray selection_changed = initial_selection.Xor (new_selection);
+// BitArray new_selection = collection.Selection.ToBitArray();
+// BitArray selection_changed = initial_collection.Selection.Xor (new_selection);
System.Collections.Generic.List<int> changed = new System.Collections.Generic.List<int>();
// for (int i = 0; i < selection_changed.Length; i++)
// if (selection_changed.Get(i))
// changed.Add (i);
//if (selection_changed.Length != 0)
- // selection.SignalChange (changed.ToArray());
+ // collection.Selection.SignalChange (changed.ToArray());
// redraw selection box
if (BinWindow != null) {
@@ -1305,7 +1298,7 @@ namespace FSpot.Widgets
SelectMotion ();
} else {
int cell_num = CellAtPosition (start_press_x, start_press_y, false, false);
- if (selection.Contains (cell_num)) {
+ if (collection.Selection.Contains (cell_num)) {
// on a selected cell : do drag&drop
isDragDrop = true;
if (StartDrag != null) {
@@ -1326,9 +1319,9 @@ namespace FSpot.Widgets
// ctrl : toggle selected, shift : keep selected
if ((args.Event.State & (ModifierType.ShiftMask | ModifierType.ControlMask)) == 0)
- selection.Clear ();
+ collection.Selection.Clear ();
- start_select_selection = selection.ToArray (); // keep initial selection
+ start_select_selection = collection.Selection.ToArray (); // keep initial selection
// no rect draw at beginning
rect_select = new Rectangle ();
@@ -1400,15 +1393,15 @@ namespace FSpot.Widgets
int cell_num = CellAtPosition ((int) args.Event.X, (int) args.Event.Y, false, true);
if (cell_num != -1) {
if ((args.Event.State & ModifierType.ControlMask) != 0) {
- selection.ToggleSelect (cell_num);
+ collection.Selection.ToggleSelect (cell_num);
} else if ((args.Event.State & ModifierType.ShiftMask) != 0) {
- selection.SelectRange (Selection.FocusedIndex, cell_num);
+ collection.Selection.SelectRange (collection.Selection.FocusedIndex, cell_num);
} else {
- selection.Clear (false);
- selection.Select (cell_num);
- selection.FocusedIndex = cell_num;
+ collection.Selection.Clear (false);
+ collection.Selection.Select (cell_num);
+ collection.Selection.FocusedIndex = cell_num;
}
- Selection.FocusedIndex = cell_num;
+ collection.Selection.FocusedIndex = cell_num;
}
}
isDragDrop = false;
@@ -1421,56 +1414,56 @@ namespace FSpot.Widgets
bool shift = ModifierType.ShiftMask == (args.Event.State & ModifierType.ShiftMask);
bool control = ModifierType.ControlMask == (args.Event.State & ModifierType.ControlMask);
- focus_old = Selection.FocusedIndex;
+ focus_old = collection.Selection.FocusedIndex;
switch (args.Event.Key) {
case Gdk.Key.Down:
case Gdk.Key.J:
case Gdk.Key.j:
- Selection.FocusedIndex += cells_per_row;
+ collection.Selection.FocusedIndex += cells_per_row;
break;
case Gdk.Key.Left:
case Gdk.Key.H:
case Gdk.Key.h:
if (control && shift)
- Selection.FocusedIndex -= Selection.FocusedIndex % cells_per_row;
+ collection.Selection.FocusedIndex -= collection.Selection.FocusedIndex % cells_per_row;
else
- Selection.FocusedIndex--;
+ collection.Selection.FocusedIndex--;
break;
case Gdk.Key.Right:
case Gdk.Key.L:
case Gdk.Key.l:
if (control && shift)
- Selection.FocusedIndex += cells_per_row - (Selection.FocusedIndex % cells_per_row) - 1;
+ collection.Selection.FocusedIndex += cells_per_row - (collection.Selection.FocusedIndex % cells_per_row) - 1;
else
- Selection.FocusedIndex++;
+ collection.Selection.FocusedIndex++;
break;
case Gdk.Key.Up:
case Gdk.Key.K:
case Gdk.Key.k:
- Selection.FocusedIndex -= cells_per_row;
+ collection.Selection.FocusedIndex -= cells_per_row;
break;
case Gdk.Key.Page_Up:
- Selection.FocusedIndex -= cells_per_row * displayed_rows;
+ collection.Selection.FocusedIndex -= cells_per_row * displayed_rows;
break;
case Gdk.Key.Page_Down:
- Selection.FocusedIndex += cells_per_row * displayed_rows;
+ collection.Selection.FocusedIndex += cells_per_row * displayed_rows;
break;
case Gdk.Key.Home:
- Selection.FocusedIndex = 0;
+ collection.Selection.FocusedIndex = 0;
break;
case Gdk.Key.End:
- Selection.FocusedIndex = collection.Count - 1;
+ collection.Selection.FocusedIndex = collection.Count - 1;
break;
case Gdk.Key.R:
case Gdk.Key.r:
- Selection.FocusedIndex = new Random().Next(0, collection.Count - 1);
+ collection.Selection.FocusedIndex = new Random().Next(0, collection.Count - 1);
break;
case Gdk.Key.space:
- selection.ToggleSelect (Selection.FocusedIndex);
+ collection.Selection.ToggleSelect (collection.Selection.FocusedIndex);
break;
case Gdk.Key.Return:
if (DoubleClicked != null)
- DoubleClicked (this, new BrowsableEventArgs (Selection.FocusedIndex, null));
+ DoubleClicked (this, new BrowsableEventArgs (collection.Selection.FocusedIndex, null));
break;
default:
args.RetVal = false;
@@ -1478,16 +1471,16 @@ namespace FSpot.Widgets
}
if (shift) {
- if (focus_old != Selection.FocusedIndex && selection.Contains (focus_old) && selection.Contains (Selection.FocusedIndex))
- selection.UnselectRange (Selection.FocusedIndex, focus_old);
+ if (focus_old != collection.Selection.FocusedIndex && collection.Selection.Contains (focus_old) && collection.Selection.Contains (collection.Selection.FocusedIndex))
+ collection.Selection.UnselectRange (collection.Selection.FocusedIndex, focus_old);
else
- selection.SelectRange (focus_old, Selection.FocusedIndex);
+ collection.Selection.SelectRange (focus_old, collection.Selection.FocusedIndex);
} else if (!control) {
- selection.Clear (false);
- selection.Select (Selection.FocusedIndex);
+ collection.Selection.Clear (false);
+ collection.Selection.Select (collection.Selection.FocusedIndex);
}
- ScrollTo (Selection.FocusedIndex);
+ ScrollTo (collection.Selection.FocusedIndex);
}
private void HandleDestroyed (object sender, System.EventArgs args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]