Commit 64aec6b0 authored by Jim Nelson's avatar Jim Nelson

Now builds with (and requires) Vala 0.14: Closes #3760

Mostly grunt-work to ensure that all delegates may be stored as unowned refs and that all
out parameters are assigned prior to exiting the method.  One binding change (Gdk.EventAny)
makes these changes incompatible with 0.12.
parent abf4f3c2
......@@ -9,8 +9,7 @@ ifndef VALAC
VALAC := valac
endif
VALAC_VERSION := `$(VALAC) --version | awk '{print $$2}'`
MIN_VALAC_VERSION := 0.11.7
MAX_VALAC_VERSION := 0.13.0
MIN_VALAC_VERSION := 0.14.0
INSTALL_PROGRAM := install
INSTALL_DATA := install -m 644
......
......@@ -21,7 +21,7 @@ Build-Depends: debhelper (>= 7),
libwebkitgtk-dev (>= 1.1.5),
libxml2 (>= 2.6.32),
m4 (>= 1.4.13),
valac (>= 0.11.7)
valac (>= 0.14.0)
Standards-Version: 3.8.3
Homepage: http://www.yorba.org/shotwell
......
......@@ -549,7 +549,7 @@ internal abstract class BatchUploader {
private int current_file = 0;
private Spit.Publishing.Publishable[] publishables = null;
private Session session = null;
private Spit.Publishing.ProgressCallback? status_updated = null;
private unowned Spit.Publishing.ProgressCallback? status_updated = null;
public signal void upload_complete(int num_photos_published);
public signal void upload_error(Spit.Publishing.PublishingError err);
......
......@@ -28,7 +28,7 @@ public class PiwigoService : Object, Spit.Pluggable, Spit.Publishing.Service {
return "Piwigo";
}
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Bruno Girin";
info.copyright = _("Copyright 2009-2011 Yorba Foundation");
info.translators = Resources.TRANSLATORS;
......
......@@ -19,7 +19,7 @@ public class YandexService : Object, Spit.Pluggable, Spit.Publishing.Service {
return "Yandex.Fotki";
}
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Evgeniy Polyakov <zbr@ioremap.net>";
info.copyright = _t("Copyright 2010+ Evgeniy Polyakov <zbr@ioremap.net>");
info.translators = Resources.TRANSLATORS;
......
......@@ -27,7 +27,7 @@ public class FacebookService : Object, Spit.Pluggable, Spit.Publishing.Service {
return "Facebook";
}
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Lucas Beeler";
info.copyright = _("Copyright 2009-2011 Yorba Foundation");
info.translators = Resources.TRANSLATORS;
......@@ -1924,7 +1924,7 @@ internal class FacebookUploader {
private FacebookRESTSession session = null;
private string aid;
private string privacy_setting;
private Spit.Publishing.ProgressCallback? status_updated = null;
private unowned Spit.Publishing.ProgressCallback? status_updated = null;
public signal void upload_complete(int num_photos_published);
public signal void upload_error(Spit.Publishing.PublishingError err);
......
......@@ -27,7 +27,7 @@ public class FlickrService : Object, Spit.Pluggable, Spit.Publishing.Service {
return "Flickr";
}
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Lucas Beeler";
info.copyright = _("Copyright 2009-2011 Yorba Foundation");
info.translators = Resources.TRANSLATORS;
......
......@@ -27,7 +27,7 @@ public class PicasaService : Object, Spit.Pluggable, Spit.Publishing.Service {
return "Picasa Web Albums";
}
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Lucas Beeler";
info.copyright = _("Copyright 2009-2011 Yorba Foundation");
info.translators = Resources.TRANSLATORS;
......
......@@ -27,7 +27,7 @@ public class YouTubeService : Object, Spit.Pluggable, Spit.Publishing.Service {
return "YouTube";
}
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Jani Monoses";
info.copyright = _("Copyright 2009-2011 Yorba Foundation");
info.translators = Resources.TRANSLATORS;
......
......@@ -63,7 +63,7 @@ public abstract class ShotwellTransitionDescriptor : Object, Spit.Pluggable, Spi
public abstract unowned string get_pluggable_name();
public void get_info(out Spit.PluggableInfo info) {
public void get_info(ref Spit.PluggableInfo info) {
info.authors = "Maxim Kartashev";
info.copyright = _("Copyright 2010 Maxim Kartashev, Copyright 2011 Yorba Foundation");
info.translators = Resources.TRANSLATORS;
......
......@@ -182,7 +182,7 @@ public class FullscreenWindow : PageWindow {
base.destroy();
}
public override bool delete_event(Gdk.Event event) {
public override bool delete_event(Gdk.EventAny event) {
on_close();
AppWindow.get_instance().destroy();
......
......@@ -207,6 +207,7 @@ public class FileImportJob : BatchImportJob {
}
public override bool determine_file_size(out uint64 filesize, out File file) {
filesize = 0;
file = file_or_dir;
return false;
......@@ -373,7 +374,7 @@ public class BatchImport : Object {
private string name;
private uint64 completed_bytes = 0;
private uint64 total_bytes = 0;
private ImportReporter reporter;
private unowned ImportReporter reporter;
private ImportManifest manifest;
private bool scheduled = false;
private bool completed = false;
......@@ -1517,7 +1518,7 @@ private class PrepareFilesJob : BackgroundImportJob {
public int prepared_files = 0;
private Gee.List<FileToPrepare> files_to_prepare;
private NotificationCallback notification;
private unowned NotificationCallback notification;
private File library_dir;
// these are for debugging and testing only
......@@ -1633,6 +1634,8 @@ private class PrepareFilesJob : BackgroundImportJob {
private ImportResult prepare_file(BatchImportJob job, File file, File? associated_file,
bool copy_to_library, out PreparedFile prepared_file) {
prepared_file = null;
bool is_video = VideoReader.is_supported_video_file(file);
if ((!is_video) && (!Photo.is_file_image(file)))
......
......@@ -43,7 +43,7 @@ public struct Box {
public int right;
public int bottom;
public Box(int left, int top, int right, int bottom) {
public Box(int left = 0, int top = 0, int right = 0, int bottom = 0) {
// Sanity check on top left vertex.
left = left.clamp(0, int.MAX);
top = top.clamp(0, int.MAX);
......@@ -142,11 +142,8 @@ public struct Box {
}
public void get_points(out Gdk.Point top_left, out Gdk.Point bottom_right) {
top_left.x = left;
top_left.y = top;
bottom_right.x = right;
bottom_right.y = bottom;
top_left = { left, top };
bottom_right = { right, bottom };
}
public Gdk.Rectangle get_rectangle() {
......@@ -217,7 +214,7 @@ public struct Box {
// There may be overlap between the two returned Boxes.
public BoxComplements resized_complements(Box resized, out Box horizontal, out bool horizontal_enlarged,
out Box vertical, out bool vertical_enlarged) {
bool horizontal_complement = true;
if (resized.top < top) {
// enlarged from top
......@@ -236,6 +233,8 @@ public struct Box {
horizontal = Box(resized.left, bottom, resized.right, resized.bottom);
horizontal_enlarged = true;
} else {
horizontal = Box();
horizontal_enlarged = false;
horizontal_complement = false;
}
......@@ -257,9 +256,11 @@ public struct Box {
vertical = Box(right, resized.top, resized.right, resized.bottom);
vertical_enlarged = true;
} else {
vertical = Box();
vertical_enlarged = false;
vertical_complement = false;
}
return BoxComplements.derive(horizontal_complement, vertical_complement);
}
......@@ -282,6 +283,8 @@ public struct Box {
horizontal_shifted = Box(shifted.left, bottom, shifted.right, shifted.bottom);
} else {
// no vertical shift
horizontal_this = Box();
horizontal_shifted = Box();
horizontal_complement = false;
}
......@@ -296,6 +299,8 @@ public struct Box {
vertical_shifted = Box(right, shifted.top, shifted.right, shifted.bottom);
} else {
// no horizontal shift
vertical_this = Box();
vertical_shifted = Box();
vertical_complement = false;
}
......
......@@ -1664,7 +1664,7 @@ public class CheckerboardLayout : Gtk.DrawingArea {
bg_color = this.get_style().bg[Gtk.StateType.NORMAL];
}
public override void size_allocate(Gdk.Rectangle allocation) {
public override void size_allocate(Gtk.Allocation allocation) {
base.size_allocate(allocation);
viewport_resized();
......
......@@ -317,8 +317,7 @@ public class RGBHistogramManipulator : Gtk.DrawingArea {
}
public override bool draw(Cairo.Context ctx) {
Gtk.Border padding = new Gtk.Border();
get_style_context().get_padding(Gtk.StateFlags.NORMAL, padding);
Gtk.Border padding = get_style_context().get_padding(Gtk.StateFlags.NORMAL);
Gdk.Rectangle area = Gdk.Rectangle();
area.x = padding.left;
......
......@@ -334,6 +334,9 @@ public class ExportDialog : Gtk.Dialog {
if (current_parameters.specified_format == PhotoFileFormat.JFIF)
parameters.quality = current_parameters.quality = QUALITY_ARRAY[quality_combo.get_active()];
}
} else {
scale = 0;
constraint = ScaleConstraint.ORIGINAL;
}
destroy();
......@@ -892,7 +895,7 @@ public class SetBackgroundSlideshowDialog {
public class TextEntryDialog : Gtk.Dialog {
public delegate bool OnModifyValidateType(string text);
private OnModifyValidateType on_modify_validate;
private unowned OnModifyValidateType on_modify_validate;
private Gtk.Entry entry;
private Gtk.Builder builder;
......@@ -1431,6 +1434,10 @@ public class AdjustDateTimeDialog : Gtk.Dialog {
Config.Facade.get_instance().set_modify_originals(modify_originals);
response = true;
} else {
time_shift = 0;
keep_relativity = true;
modify_originals = false;
}
destroy();
......
......@@ -316,6 +316,8 @@ public struct Scaling {
}
public bool is_best_fit(Dimensions original, out int pixels) {
pixels = 0;
if (scale == NO_SCALE)
return false;
......@@ -333,6 +335,8 @@ public struct Scaling {
}
public bool is_best_fit_dimensions(Dimensions original, out Dimensions scaled) {
scaled = Dimensions();
if (scale == NO_SCALE)
return false;
......@@ -352,6 +356,8 @@ public struct Scaling {
}
public bool is_for_viewport(Dimensions original, out Dimensions scaled) {
scaled = Dimensions();
if (scale != NO_SCALE)
return false;
......@@ -373,6 +379,8 @@ public struct Scaling {
}
public bool is_fill_viewport(Dimensions original, out Dimensions scaled) {
scaled = Dimensions();
if (constraint != ScaleConstraint.FILL_VIEWPORT)
return false;
......
......@@ -140,13 +140,21 @@ public class DirectoryMonitor : Object {
FileInfo? local_info = info;
if (local_info == null) {
local_info = map.get(file);
if (local_info == null)
if (local_info == null) {
normalized = null;
id = null;
return false;
}
}
string? file_id = get_file_info_id(local_info);
if (file_id == null)
if (file_id == null) {
normalized = null;
id = null;
return false;
}
File? known_file = id_map.get(file_id);
......@@ -1363,6 +1371,9 @@ public class DirectoryMonitor : Object {
return true;
}
old_file = null;
old_file_info = null;
return false;
}
......
......@@ -454,6 +454,8 @@ public abstract class EditingTool {
// a pixbuf with unsaved tool edits in it). That can be handled in the paint() virtual method.
public virtual Gdk.Pixbuf? get_display_pixbuf(Scaling scaling, Photo photo,
out Dimensions max_dim) throws Error {
max_dim = Dimensions();
return null;
}
......@@ -1129,8 +1131,11 @@ public class CropTool : EditingTool {
out Dimensions max_dim) throws Error {
// show the uncropped photo for editing, but return null if no crop so the current pixbuf
// is used
if (!photo.has_crop())
if (!photo.has_crop()) {
max_dim = Dimensions();
return null;
}
max_dim = photo.get_original_dimensions();
......@@ -3098,8 +3103,11 @@ public class AdjustTool : EditingTool {
public override Gdk.Pixbuf? get_display_pixbuf(Scaling scaling, Photo photo,
out Dimensions max_dim) throws Error {
if (!photo.has_color_adjustments())
if (!photo.has_color_adjustments()) {
max_dim = Dimensions();
return null;
}
max_dim = photo.get_dimensions();
......
......@@ -594,6 +594,8 @@ public class Event : EventSource, ContainerSource, Proxyable, Indexable {
if (exposure_time == 0 && event_name == null) {
debug("Skipping event assignment to %s: no exposure time and no event name", media.to_string());
new_event = false;
return null;
}
......@@ -624,6 +626,8 @@ public class Event : EventSource, ContainerSource, Proxyable, Indexable {
AppWindow.database_error(err);
}
new_event = false;
return null;
}
......
......@@ -111,10 +111,10 @@ public class Exporter : Object {
private bool avoid_copying;
private int completed_count = 0;
private Workers workers = new Workers(Workers.threads_per_cpu(), false);
private CompletionCallback? completion_callback = null;
private ExportFailedCallback? error_callback = null;
private OverwriteCallback? overwrite_callback = null;
private ProgressMonitor? monitor = null;
private unowned CompletionCallback? completion_callback = null;
private unowned ExportFailedCallback? error_callback = null;
private unowned OverwriteCallback? overwrite_callback = null;
private unowned ProgressMonitor? monitor = null;
private Cancellable cancellable;
private bool replace_all = false;
private bool aborted = false;
......@@ -303,7 +303,7 @@ public class ExporterUI {
private Exporter exporter;
private Cancellable cancellable = new Cancellable();
private ProgressDialog? progress_dialog = null;
private Exporter.CompletionCallback? completion_callback = null;
private unowned Exporter.CompletionCallback? completion_callback = null;
public ExporterUI(Exporter exporter) {
this.exporter = exporter;
......
......@@ -101,6 +101,8 @@ public class MetadataDateTime {
}
public static bool from_exif_date_time(string date_time, out time_t timestamp) {
timestamp = 0;
Time tm = Time();
bool found = false;
......
......@@ -367,8 +367,14 @@ public abstract class Page : Gtk.ScrolledWindow {
}
private bool get_modifiers(out bool ctrl, out bool alt, out bool shift, out bool super) {
if (AppWindow.get_instance().get_window() == null)
if (AppWindow.get_instance().get_window() == null) {
ctrl = false;
alt = false;
shift = false;
super = false;
return false;
}
int x, y;
Gdk.ModifierType mask;
......@@ -662,8 +668,13 @@ public abstract class Page : Gtk.ScrolledWindow {
//
// For more information, see: https://bugzilla.gnome.org/show_bug.cgi?id=599937
public bool get_event_source_pointer(out int x, out int y, out Gdk.ModifierType mask) {
if (event_source == null)
if (event_source == null) {
x = 0;
y = 0;
mask = 0;
return false;
}
event_source.get_window().get_pointer(out x, out y, out mask);
......
......@@ -1126,6 +1126,8 @@ public abstract class Photo : PhotoSource, Dateable {
protected BackingPhotoRow? query_backing_photo_row(File file, PhotoFileSniffer.Options options,
out DetectedPhotoInformation detected) throws Error {
detected = null;
BackingPhotoRow backing = new BackingPhotoRow();
// get basic file information
FileInfo info = null;
......@@ -1224,6 +1226,8 @@ public abstract class Photo : PhotoSource, Dateable {
// This method is thread-safe. If returns false the photo should be marked offline (in the
// main UI thread).
public bool prepare_for_reimport_master(out ReimportMasterState reimport_state) throws Error {
reimport_state = null;
File file = get_master_reader().get_file();
DetectedPhotoInformation detected;
......@@ -1356,6 +1360,8 @@ public abstract class Photo : PhotoSource, Dateable {
// This method is thread-safe. Returns false if the photo has no associated editable.
public bool prepare_for_reimport_editable(out ReimportEditableState state) throws Error {
state = null;
File? file = get_editable_file();
if (file == null)
return false;
......@@ -1413,6 +1419,8 @@ public abstract class Photo : PhotoSource, Dateable {
// This method is thread-safe. Returns false if the photo has no associated RAW developments.
public bool prepare_for_reimport_raw_development(out ReimportRawDevelopmentState state) throws Error {
state = null;
Gee.Collection<File>? files = get_raw_developer_files();
if (files == null)
return false;
......@@ -2354,6 +2362,8 @@ public abstract class Photo : PhotoSource, Dateable {
// unsupported) or the file is unavailable.
public bool persist_master_metadata(PhotoMetadata metadata, out ReimportMasterState state)
throws Error {
state = null;
PhotoFileReader master_reader = get_master_reader();
if (!master_reader.get_file_format().can_write_metadata())
......@@ -2375,6 +2385,8 @@ public abstract class Photo : PhotoSource, Dateable {
public bool persist_editable_metadata(PhotoMetadata metadata, out ReimportEditableState state)
throws Error {
state = null;
PhotoFileReader? editable_reader = get_editable_reader();
if (editable_reader == null)
return false;
......@@ -2597,6 +2609,8 @@ public abstract class Photo : PhotoSource, Dateable {
// Returns the crop in the raw photo's coordinate system
public bool get_raw_crop(out Box crop) {
crop = Box();
KeyValueMap map = get_transformation("crop");
if (map == null)
return false;
......@@ -2628,10 +2642,14 @@ public abstract class Photo : PhotoSource, Dateable {
private bool get_raw_straighten(out double angle) {
KeyValueMap map = get_transformation("straighten");
if (map == null)
return false;
if (map == null) {
angle = 0.0;
return false;
}
angle = map.get_double("angle", 0.0);
return true;
}
......@@ -3678,8 +3696,11 @@ public abstract class Photo : PhotoSource, Dateable {
// Returns the crop against the coordinate system of the rotated photo
public bool get_crop(out Box crop) {
Box raw;
if (!get_raw_crop(out raw))
if (!get_raw_crop(out raw)) {
crop = Box();
return false;
}
Dimensions dim = get_raw_dimensions();
Orientation orientation = get_orientation();
......@@ -3929,6 +3950,7 @@ public abstract class Photo : PhotoSource, Dateable {
public class LibraryPhotoSourceCollection : MediaSourceCollection {
public enum State {
UNKNOWN,
ONLINE,
OFFLINE,
TRASH,
......@@ -4393,6 +4415,8 @@ public class LibraryPhotoSourceCollection : MediaSourceCollection {
return photo;
}
state = State.UNKNOWN;
return null;
}
......@@ -4506,8 +4530,11 @@ public class LibraryPhoto : Photo, Flaggable, Monitorable {
public static ImportResult import_create(PhotoImportParams params, out LibraryPhoto photo) {
// add to the database
PhotoID photo_id = PhotoTable.get_instance().add(ref params.row);
if (photo_id.is_invalid())
if (photo_id.is_invalid()) {
photo = null;
return ImportResult.DATABASE_ERROR;
}
// create local object but don't add to global until thumbnails generated
photo = new LibraryPhoto.from_import_params(params);
......
......@@ -282,8 +282,11 @@ private class PhotoMonitor : MediaMonitor {
out Monitorable monitorable) {
LibraryPhotoSourceCollection.State state;
LibraryPhoto? photo = get_photo_state_by_file(file, out state);
if (photo == null)
if (photo == null) {
monitorable = null;
return MediaMonitor.DiscoveredFile.UNKNOWN;
}
switch (state) {
case LibraryPhotoSourceCollection.State.ONLINE:
......@@ -298,6 +301,8 @@ private class PhotoMonitor : MediaMonitor {
default:
// ignored ... trash always stays in trash, offline or not, and editables are
// simply attached to online/offline photos
monitorable = null;
return MediaMonitor.DiscoveredFile.IGNORE;
}
}
......
......@@ -75,7 +75,7 @@ public class PixbufCache : Object {
private PhotoType type;
private int max_count;
private Scaling scaling;
private CacheFilter? filter;
private unowned CacheFilter? filter;
private Gee.HashMap<Photo, Gdk.Pixbuf> cache = new Gee.HashMap<Photo, Gdk.Pixbuf>();
private Gee.ArrayList<Photo> lru = new Gee.ArrayList<Photo>();
private Gee.HashMap<Photo, FetchJob> in_progress = new Gee.HashMap<Photo, FetchJob>();
......
......@@ -24,7 +24,7 @@ public int64 file_comparator(void *a, void *b) {
public class SortedList<G> : Object, Gee.Iterable<G>, Gee.Collection<G> {
private Gee.ArrayList<G> list;
private Comparator? cmp;
private unowned Comparator? cmp;
public SortedList(Comparator? cmp = null) {
this.list = new Gee.ArrayList<G>();
......
......@@ -77,7 +77,7 @@ public class ThumbnailCache : Object {
public PhotoFileFormat source_format;
public Dimensions dim;
public Gdk.InterpType interp;
public AsyncFetchCallback callback;
public unowned AsyncFetchCallback callback;
public Gdk.Pixbuf unscaled;
public Gdk.Pixbuf scaled = null;
public Error err = null;
......
......@@ -34,7 +34,7 @@ public class TimedQueue<G> {
}
private uint hold_msec;
private DequeuedCallback<G> callback;
private unowned DequeuedCallback<G> callback;
private EqualFunc equal_func;
private int priority;
private uint timer_id = 0;
......
......@@ -88,8 +88,11 @@ private class VideoMonitor : MediaMonitor {
out Monitorable monitorable) {
VideoSourceCollection.State state;
Video? video = get_state(file, out state);
if (video == null)
if (video == null) {
monitorable = null;
return MediaMonitor.DiscoveredFile.UNKNOWN;
}
switch (state) {
case VideoSourceCollection.State.ONLINE:
......@@ -101,6 +104,8 @@ private class VideoMonitor : MediaMonitor {
case VideoSourceCollection.State.TRASH:
default:
// ignored ... trash always stays in trash
monitorable = null;
return MediaMonitor.DiscoveredFile.IGNORE;
}
}
......
......@@ -481,6 +481,8 @@ public class Video : VideoSource, Flaggable, Monitorable, Dateable {
}
public static ImportResult import_create(VideoImportParams params, out Video video) {
video = null;
// add to the database
try {
if (VideoTable.get_instance().add(ref params.row).is_invalid())
......@@ -951,6 +953,7 @@ public class Video : VideoSource, Flaggable, Monitorable, Dateable {
public class VideoSourceCollection : MediaSourceCollection {
public enum State {
UNKNOWN,
ONLINE,
OFFLINE,
TRASH
......@@ -1061,6 +1064,8 @@ public class VideoSourceCollection : MediaSourceCollection {
return video;
}
state = State.UNKNOWN;
return null;
}
......
......@@ -21,7 +21,7 @@ public class AlienDatabaseImportDialog : Gtk.Dialog {
private Gtk.Notebook message_notebook;
private Gtk.ProgressBar prepare_progress_bar;
private Gtk.Label error_message_label;
private BatchImport.ImportReporter reporter;
private unowned BatchImport.ImportReporter reporter;
public void set_builder(Gtk.Builder builder) {
this.builder = builder;
......
......@@ -76,6 +76,7 @@ public class AlienDatabaseImportJob : BatchImportJob {
}
public override bool determine_file_size(out uint64 filesize, out File file) {
file = null;
filesize = this.filesize;
return true;
......
......@@ -148,6 +148,8 @@ public class CameraTable {
debug("USB ESP: current_camera_count=%d port=%s", current_camera_count, port);
full_port = null;
// if GPhoto detects one camera, and USB reports one camera, all is swell
if (current_camera_count == 1 && usb_cameras.length == 1) {
full_port = usb_cameras[0];
......
......@@ -100,8 +100,11 @@ namespace GPhoto {
public bool get_info(Context context, Camera camera, string folder, string filename,
out CameraFileInfo info) throws Error {
if (folder.length > MAX_BASEDIR_LENGTH || filename.length > MAX_FILENAME_LENGTH)