249
251
private Gee.Set<string>? mimes;
252
private Gtk.Box info_vbox;
253
private Gtk.Grid information;
251
254
private Gtk.Widget header_title;
252
255
private Gtk.Label type_label;
253
256
private Gtk.Label size_label;
341
344
if (info.size > 0) {
342
var info_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
345
info_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
343
346
construct_info_panel (info_vbox, info);
344
347
add_section (stack, _("General"), PanelType.INFO.to_string (), info_vbox);
435
438
size_warning_image.hide ();
437
440
foreach (GOF.File gof in files) {
441
if (gof.is_root_network_folder ()) {
442
size_label.label = _("unknown");
438
445
if (gof.is_directory) {
440
447
var d = new Marlin.DeepCount (gof.location);
662
/* get image size in pixels */
663
var mime = file.icon.to_string ();
664
if ("image" in mime) {
667
if (view.is_in_recent ())
668
path = (file.get_display_target_uri ()).substring (7, -1).replace ("%20", " ");
670
path = file.location.get_path ();
673
Gdk.Pixbuf pixbuf = new Gdk.Pixbuf.from_file (path);
674
var width = pixbuf.get_width ().to_string ();
675
var height = pixbuf.get_height ().to_string ();
676
info.add (new Pair<string, string> (_("Size:"), width +" × " + height + " px"));
678
warning ("Error: %s\n", e.message);
669
/* get image size in pixels using an asynchronous method to stop the interface blocking on
671
if ("image" in ftype) {
672
string resolution_value = "";
673
if (file.width > 0) { /* resolution has already been determined */
674
resolution_value = goffile.width.to_string () +" × " + goffile.height.to_string () + " px";
676
resolution_value = _("loading ...");
677
/* Async function will update info when resolution determined */
678
get_resolution.begin (file, info);
680
info.add (new Pair<string, string> (resolution_key, resolution_value));
682
683
if (got_common_location ()) {
706
private async void get_resolution (GOF.File goffile, Gee.LinkedList<Pair<string, string>> info) {
707
GLib.FileInputStream? stream = null;
708
GLib.File file = goffile.location;
709
string resolution_value = _("Could not be determined");
712
stream = yield file.read_async (0, cancellable);
713
if (stream == null) {
714
error ("Could not read image file's size data");
716
var pixbuf = yield new Gdk.Pixbuf.from_stream_async (stream, cancellable);
717
goffile.width = pixbuf.get_width ();
718
goffile.height = pixbuf.get_height ();
719
resolution_value = goffile.width.to_string () +" × " + goffile.height.to_string () + " px";
722
warning ("Error loading image resolution in PropertiesWindow: %s", e.message);
726
} catch (GLib.Error e) {
727
debug ("Error closing stream in get_resolution: %s", e.message);
730
/* Cannot be sure which row the resolution line was added to the grid so we have to search for it */
731
Gtk.Widget? kw = null;
734
kw = information.get_child_at (0, row);
735
if (kw is Gtk.Label && (kw as Gtk.Label).label == resolution_key) {
736
Gtk.Widget vw = information.get_child_at (1, row);
737
if (vw is Gtk.Label) {
738
(vw as Gtk.Label).label = resolution_value;
743
} while (kw != null);
705
745
private void construct_info_panel (Gtk.Box box, Gee.LinkedList<Pair<string, string>> item_info) {
706
var information = new Gtk.Grid();
746
information = new Gtk.Grid();
707
747
information.column_spacing = 6;
708
748
information.row_spacing = 6;