Skip to content
Commits on Source (3)
......@@ -105,22 +105,28 @@ namespace GQPE {
/**
* The image width.
*/
public int width { get; private set; }
public int width { get { return _get_width(); } }
private int _width;
/**
* The image height.
*/
public int height { get; private set; }
public int height { get { return _get_height(); } }
private int _height;
/**
* The image file size.
*/
public int size { get; private set; }
public int size { get { return _get_size(); } }
private int _size;
/**
* The image file date and time.
*/
public GLib.DateTime file_datetime { get; private set; }
public GLib.DateTime file_datetime {
get { return _get_file_datetime(); }
}
private GLib.DateTime _file_datetime;
/**
* Wether the photograph has geolocation.
......@@ -140,7 +146,8 @@ namespace GQPE {
metadata = new GExiv2.Metadata();
metadata.open_path(file.get_path());
get_metadata();
get_filedata();
_width = _height = _size = -1;
_file_datetime = null;
this.notify.connect ((s, p) => modified = true);
}
......@@ -495,18 +502,51 @@ namespace GQPE {
return d;
}
private int _get_width() {
if (_width == -1)
get_image_size();
return _width;
}
private int _get_height() {
if (_height == -1)
get_image_size();
return _height;
}
private int _get_size() {
if (_size == -1)
get_file_data();
return _size;
}
private unowned GLib.DateTime _get_file_datetime() {
if (_file_datetime == null)
get_file_data();
return _file_datetime;
}
/* Gets the image size. */
private void get_image_size() {
try {
var pb = new Gdk.Pixbuf.from_file(path);
_width = pb.width;
_height = pb.height;
} catch (GLib.Error e) {
GLib.warning(_("Error getting image size: %s"), e.message);
}
}
/* Gets the file data. */
private void get_filedata() throws GLib.Error {
var pb = new Gdk.Pixbuf.from_file(path);
width = pb.width;
height = pb.height;
private void get_file_data() {
Posix.Stat buf;
if (Posix.stat(path, out buf) != 0)
throw new GLib.Error(GLib.Quark.from_string("gqpe"), 0,
_("Cannot get file status: %s"), path);
size = (int)buf.st_size;
if (Posix.stat(path, out buf) != 0) {
GLib.warning(_("Error getting file status: %s"), path);
return;
}
_size = (int)buf.st_size;
long t = (long)buf.st_mtime;
file_datetime = new GLib.DateTime.from_unix_local(t);
_file_datetime = new GLib.DateTime.from_unix_local(t);
}
}
}
......@@ -226,7 +226,7 @@ namespace GQPE {
public static void error(string format, ...) {
var full_format = format + "\n";
var list = va_list();
stdout.vprintf(full_format, list);
stderr.vprintf(full_format, list);
GLib.Process.exit(1);
}
......@@ -279,7 +279,7 @@ namespace GQPE {
*/
public static Gee.SortedSet<Photograph>
load_photos_array(string[] args, int offset,
ProgressMessage messenger) {
ProgressMessage? messenger = null) {
messenger(ProgressState.INIT, 0);
int c = 0;
var photos = new Gee.TreeSet<Photograph>();
......@@ -288,7 +288,8 @@ namespace GQPE {
try {
var photo = new Photograph(file);
photos.add(photo);
messenger(ProgressState.ADVANCE, c++);
if (messenger != null)
messenger(ProgressState.ADVANCE, c++);
} catch (GLib.Error e) {
GLib.warning(_("Error processing %s: %s. Skipping."),
args[i], e.message);
......@@ -344,5 +345,33 @@ namespace GQPE {
(int)(pixbuf.height * scale),
Gdk.InterpType.HYPER);
}
/**
* Loads the data from a file.
* @param file the file to load.
* @return the data from a file, or ''null'' if it cannot be loaded.
*/
public static uint8[]? load_file_data(GLib.File file) {
try {
var bytes = file.load_bytes();
return bytes.get_data();
} catch (GLib.Error error) {
stderr.printf("%s\n", error.message);
return null;
}
}
/**
* Prints an error message, shows how to ask for help, and exits.
* @param format the format.
*/
[PrintfFormat]
public static void use(string format, ...) {
var full_format = format + "\n";
var list = va_list();
stderr.vprintf(full_format, list);
error(_("Run ‘%s --help’ for a list of options"),
GLib.Environment.get_prgname());
}
}
}
......@@ -36,6 +36,8 @@ gdkpixbuf = dependency('gdk-pixbuf-2.0')
gtk = dependency('gtk+-3.0')
sqlite3 = dependency('sqlite3')
json = dependency('json-glib-1.0')
soup = dependency('libsoup-2.4')
secret = dependency('libsecret-1')
xsltproc = find_program('xsltproc', required: false)
......@@ -163,6 +165,25 @@ executable('gqpe-shotwell', gqpeshotwell_sources,
include_directories: [ gqpelib_includes ],
install: true, link_with: [ gqpelib ])
gqpegaleria_sources = [
'src/galeria.vala'
]
gqpegaleria_dependencies = [
gee,
gexiv2,
gdk,
gdkpixbuf,
json,
math,
soup
]
executable('gqpe-galeria', gqpegaleria_sources,
dependencies: gqpegaleria_dependencies,
include_directories: [ gqpelib_includes ],
install: true, link_with: [ gqpelib ])
gresources = gnome.compile_resources(
'gresources', 'data/gqpe.gresource.xml',
source_dir: 'data',
......
This diff is collapsed.