Commit 9fc8df89 authored by Clint Rogers's avatar Clint Rogers

Disables the 'rotate' button in direct mode until a rotate has actually finished; closes #4904.

(This fixes the case where repeated clicks on the 'rotate' button appear to do nothing on very large images and/or slower computers.)
parent b4650053
......@@ -296,6 +296,8 @@ public abstract class Photo : PhotoSource, Dateable {
private OneShotScheduler reimport_editable_scheduler = null;
private OneShotScheduler update_editable_attributes_scheduler = null;
private OneShotScheduler remove_editable_scheduler = null;
protected bool can_rotate_now = true;
// The first time we have to run the pipeline on an image, we'll precache
// a copy of the unscaled, unmodified version; this allows us to operate
......@@ -2628,6 +2630,10 @@ public abstract class Photo : PhotoSource, Dateable {
return committed;
}
public bool check_can_rotate() {
return can_rotate_now;
}
public virtual void rotate(Rotation rotation) {
lock (row) {
set_orientation(get_orientation().perform(rotation));
......
......@@ -893,7 +893,11 @@ public abstract class EditingHostPage : SinglePhotoPage {
break;
}
}
protected void enable_rotate(bool should_enable) {
rotate_button.set_sensitive(should_enable);
}
// This function should be called if the viewport has changed and the pixbuf cache needs to be
// regenerated. Use refresh_caches() if the contents of the ViewCollection have changed
// but not the viewport.
......@@ -1334,7 +1338,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
Photo? photo = get_photo();
Scaling scaling = get_canvas_scaling();
rotate_button.sensitive = ((photo != null) && (!photo_missing)) ?
rotate_button.sensitive = ((photo != null) && (!photo_missing) && photo.check_can_rotate()) ?
is_rotate_available(photo) : false;
crop_button.sensitive = ((photo != null) && (!photo_missing)) ?
EditingTools.CropTool.is_available(photo, scaling) : false;
......
......@@ -9,6 +9,8 @@ public class DirectPhoto : Photo {
public static DirectPhotoSourceCollection global = null;
public signal void can_rotate_changed(bool b);
private Gdk.Pixbuf preview = null;
private bool loaded = false;
......@@ -102,6 +104,19 @@ public class DirectPhoto : Photo {
return scaling.perform_on_pixbuf(preview, Gdk.InterpType.BILINEAR, true);
}
public override void rotate(Rotation rotation) {
can_rotate_now = false;
can_rotate_changed(false);
base.rotate(rotation);
}
public override Gdk.Pixbuf get_pixbuf(Scaling scaling) throws Error {
Gdk.Pixbuf ret = base.get_pixbuf(scaling);
can_rotate_changed(true);
can_rotate_now = true;
return ret;
}
public override Gdk.Pixbuf? get_thumbnail(int scale) throws Error {
return (get_metadata().get_preview_count() == 0) ? null :
get_orientation().rotate_pixbuf(get_metadata().get_preview(0).get_pixbuf());
......
......@@ -243,7 +243,21 @@ public class DirectPhotoPage : EditingHostPage {
}
protected override void photo_changing(Photo new_photo) {
if (get_photo() != null) {
DirectPhoto tmp = get_photo() as DirectPhoto;
if (tmp != null) {
tmp.can_rotate_changed.disconnect(on_dphoto_can_rotate_changed);
}
}
((DirectPhoto) new_photo).demand_load();
DirectPhoto tmp = new_photo as DirectPhoto;
if (tmp != null) {
tmp.can_rotate_changed.connect(on_dphoto_can_rotate_changed);
}
}
public File get_current_file() {
......@@ -540,6 +554,10 @@ public class DirectPhotoPage : EditingHostPage {
}
}
private void on_dphoto_can_rotate_changed(bool should_allow_rotation) {
enable_rotate(should_allow_rotation);
}
protected override DataView create_photo_view(DataSource source) {
return new DirectView((DirectPhoto) source);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment