f-spot r4260 - in trunk: . src/Editors src/Widgets
- From: rubenv svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4260 - in trunk: . src/Editors src/Widgets
- Date: Wed, 13 Aug 2008 22:54:41 +0000 (UTC)
Author: rubenv
Date: Wed Aug 13 22:54:41 2008
New Revision: 4260
URL: http://svn.gnome.org/viewvc/f-spot?rev=4260&view=rev
Log:
2008-08-14 Ruben Vermeersch <ruben savanne be>
Add progress reporting when updating multiple pictures.
* src/Editors/Editor.cs: Add events that can be used to observe the state
of the processing.
* src/Widgets/EditorPage.cs: When an editor starts processing, pop up a
progress dialog.
Modified:
trunk/ChangeLog
trunk/src/Editors/Editor.cs
trunk/src/Widgets/EditorPage.cs
Modified: trunk/src/Editors/Editor.cs
==============================================================================
--- trunk/src/Editors/Editor.cs (original)
+++ trunk/src/Editors/Editor.cs Wed Aug 13 22:54:41 2008
@@ -57,6 +57,14 @@
// This is the base class from which all editors inherit.
public abstract class Editor {
+ public delegate void ProcessingStartedHandler (string name, int count);
+ public delegate void ProcessingStepHandler (int done);
+ public delegate void ProcessingFinishedHandler ();
+
+ public event ProcessingStartedHandler ProcessingStarted;
+ public event ProcessingStepHandler ProcessingStep;
+ public event ProcessingFinishedHandler ProcessingFinished;
+
// Contains the current selection, the items being edited, ...
private EditorState state;
public EditorState State {
@@ -121,10 +129,24 @@
// Apply the editor's action to a photo.
public void Apply () {
+ try {
+ if (ProcessingStarted != null) {
+ ProcessingStarted (Label, State.Items.Length);
+ }
+ TryApply ();
+ } finally {
+ if (ProcessingFinished != null) {
+ ProcessingFinished ();
+ }
+ }
+ }
+
+ private void TryApply () {
if (NeedsSelection && !State.HasSelection) {
throw new Exception ("Cannot apply without selection!");
}
+ int done = 0;
foreach (Photo photo in State.Items) {
Pixbuf input;
Cms.Profile input_profile;
@@ -137,6 +159,11 @@
photo.SaveVersion (edited, create_version);
photo.Changes.DataChanged = true;
Core.Database.Photos.Commit (photo);
+
+ done++;
+ if (ProcessingStep != null) {
+ ProcessingStep (done);
+ }
}
Reset ();
Modified: trunk/src/Widgets/EditorPage.cs
==============================================================================
--- trunk/src/Widgets/EditorPage.cs (original)
+++ trunk/src/Widgets/EditorPage.cs Wed Aug 13 22:54:41 2008
@@ -72,8 +72,31 @@
private void OnExtensionChanged (object s, ExtensionNodeEventArgs args) {
// FIXME: We do not do run-time removal of editors yet!
- if (args.Change == ExtensionChange.Add)
- editors.Add ((args.ExtensionNode as EditorNode).GetEditor ());
+ if (args.Change == ExtensionChange.Add) {
+ Editor editor = (args.ExtensionNode as EditorNode).GetEditor ();
+ editor.ProcessingStarted += OnProcessingStarted;
+ editor.ProcessingStep += OnProcessingStep;
+ editor.ProcessingFinished += OnProcessingFinished;
+ editors.Add (editor);
+ }
+ }
+
+ private ProgressDialog progress;
+
+ private void OnProcessingStarted (string name, int count) {
+ progress = new ProgressDialog (name, ProgressDialog.CancelButtonType.None, count, MainWindow.Toplevel.Window);
+ }
+
+ private void OnProcessingStep (int done) {
+ if (progress != null)
+ progress.Update (String.Empty);
+ }
+
+ private void OnProcessingFinished () {
+ if (progress != null) {
+ progress.Destroy ();
+ progress = null;
+ }
}
internal void ChangeButtonVisibility () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]