[mistelix] Fixes issues #583087, #583085 and #583080
- From: Jordi Mas <jmas src gnome org>
- To: svn-commits-list gnome org
- Subject: [mistelix] Fixes issues #583087, #583085 and #583080
- Date: Tue, 19 May 2009 07:50:17 -0400 (EDT)
commit 57f57da2bec8588095be276aca7335512d4bb396
Author: Jordi Mas <jmas softcatala org>
Date: Tue May 19 13:50:11 2009 +0200
Fixes issues #583087, #583085 and #583080
---
src/widgets/SlideShowImageView.cs | 69 ++++++++++++++++++++++++++----------
1 files changed, 50 insertions(+), 19 deletions(-)
diff --git a/src/widgets/SlideShowImageView.cs b/src/widgets/SlideShowImageView.cs
index 2576d18..1ea5ce7 100644
--- a/src/widgets/SlideShowImageView.cs
+++ b/src/widgets/SlideShowImageView.cs
@@ -26,6 +26,7 @@ using Gtk;
using System.IO;
using System.Text;
using System.Collections.Generic;
+using System.Collections;
using System.ComponentModel;
using Gdk;
using Cairo;
@@ -101,7 +102,7 @@ namespace Mistelix.Widgets
//
// Displays the images selected by the user when creating a slideshow. Drop target.
//
- public class SlideShowImageView : TreeView, IDisposable
+ public class SlideShowImageView : TreeView, IDisposable, IComparer <Gtk.TreeIter>
{
enum ImageSortType
{
@@ -114,7 +115,7 @@ namespace Mistelix.Widgets
ListStore store;
Gtk.Image image;
BackgroundWorker thumbnailing;
- int cnt = 1;
+ int next_id = 1;
bool paint_control = false;
readonly int thumbnail_height;
readonly int thumbnail_width;
@@ -146,7 +147,6 @@ namespace Mistelix.Widgets
thumbnail_height = ThumbnailSizeManager.Current.Height;
thumbnail_width = ThumbnailSizeManager.Current.Width;
- store.SetSortFunc (0, new Gtk.TreeIterCompareFunc (ImageSortFunc));
Selection.Mode = SelectionMode.Multiple;
DragDrop += new DragDropHandler (HandleTargetDragDrop);
DragDataReceived += new DragDataReceivedHandler (HandleTargetDragDataReceived);
@@ -180,7 +180,7 @@ namespace Mistelix.Widgets
protected virtual void Dispose (bool disposing)
{
Logger.Debug ("SlideShowImageView.Disposing");
- store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter)
+ store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter)
{
DataImageSurface image = (DataImageSurface) store.GetValue (iter, COL_CAIROIMAGE);
@@ -202,10 +202,10 @@ namespace Mistelix.Widgets
foreach (SlideShow.Image image in slideshow.images)
{
FileInfo fi = new FileInfo (image.image);
- store.AppendValues (cnt.ToString (), null,
+ store.AppendValues (next_id.ToString (), null,
image.Title == null ? notitle : image.Title,
image);
- cnt++;
+ next_id++;
}
if (thumbnailing.IsBusy == false)
@@ -302,9 +302,9 @@ namespace Mistelix.Widgets
void LoadFile (string file)
{
FileInfo fi = new FileInfo (file);
- store.AppendValues (cnt.ToString (), null, notitle,
+ store.AppendValues (next_id.ToString (), null, notitle,
new SlideImage (fi.FullName));
- cnt++;
+ next_id++;
}
void HandleDropBegin (object sender, DragBeginArgs a)
@@ -409,7 +409,7 @@ namespace Mistelix.Widgets
TreeIter prev = TreeIter.Zero, first, iter;
TreePath[] paths;
bool more;
-
+
paths = Selection.GetSelectedRows ();
if (paths.Length == 0)
@@ -540,40 +540,72 @@ namespace Mistelix.Widgets
{
store.Clear ();
UpdateButtonSensitivity ();
+ next_id = 1;
}
void OnSortAscendingbyDate (object obj, EventArgs e)
{
sort_type = ImageSortType.Date_Ascending;
- store.SetSortColumnId (0, SortType.Ascending);
+ DoSort ();
}
void OnSortDescendingbyDate (object obj, EventArgs e)
{
sort_type = ImageSortType.Date_Descending;
- store.SetSortColumnId (0, SortType.Descending);
+ DoSort ();
}
void OnSortAscendingbyName (object obj, EventArgs e)
{
sort_type = ImageSortType.FileName_Ascending;
- store.SetSortColumnId (0, SortType.Ascending);
+ DoSort ();
}
void OnSortDescendingbyName (object obj, EventArgs e)
{
sort_type = ImageSortType.FileName_Descending;
- store.SetSortColumnId (0, SortType.Descending);
+ DoSort ();
+ }
+
+ // ListStore sort capabilities are for displaying proposes, we need to sort the actual elements
+ void DoSort ()
+ {
+ List <Gtk.TreeIter> items = new List <Gtk.TreeIter> ();
+
+ store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter)
+ {
+ items.Add (iter);
+ return false;
+ });
+
+ items.Sort (this);
+
+ Gtk.ListStore new_model = CreateStore ();
+
+ next_id = 1;
+ foreach (Gtk.TreeIter iter in items)
+ {
+ new_model.AppendValues (next_id.ToString (),
+ store.GetValue (iter, COL_CAIROIMAGE),
+ store.GetValue (iter, COL_DESCRIPTION),
+ store.GetValue (iter, COL_OBJECT));
+
+ next_id++;
+ }
+ Model = store = new_model;
+
+ if (thumbnailing.IsBusy == false)
+ thumbnailing.RunWorkerAsync (store);
}
// Sorts the images in the view following the option selected in the contextual menu
- int ImageSortFunc (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b)
+ public int Compare (Gtk.TreeIter a, Gtk.TreeIter b)
{
SlideImage slide_a, slide_b;
FileInfo file_a, file_b;
-
- slide_a = (SlideImage) model.GetValue (a, SlideShowImageView.COL_OBJECT);
- slide_b = (SlideImage) model.GetValue (b, SlideShowImageView.COL_OBJECT);
+
+ slide_a = (SlideImage) store.GetValue (a, SlideShowImageView.COL_OBJECT);
+ slide_b = (SlideImage) store.GetValue (b, SlideShowImageView.COL_OBJECT);
if (slide_a == null || slide_b == null)
return 0;
@@ -696,7 +728,6 @@ namespace Mistelix.Widgets
if (prev_image != null)
((IDisposable)prev_image).Dispose ();
}
- }
-
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]