From d443a3c2509889533ca812c163056bace396b586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 14 Jun 2023 20:35:58 +0200 Subject: New upstream version 0.32.1 --- src/Properties.vala | 101 +++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 48 deletions(-) (limited to 'src/Properties.vala') diff --git a/src/Properties.vala b/src/Properties.vala index ad0a041..c0cf2fd 100644 --- a/src/Properties.vala +++ b/src/Properties.vala @@ -4,12 +4,16 @@ * See the COPYING file in this distribution. */ -private abstract class Properties : Gtk.Grid { - uint line_count = 0; +private abstract class Properties : Gtk.Box { + protected Gtk.Grid grid = new Gtk.Grid(); + protected uint line_count = 0; protected Properties() { - row_spacing = 6; - column_spacing = 12; + Object(orientation: Gtk.Orientation.VERTICAL, homogeneous : false); + + grid.row_spacing = 6; + grid.column_spacing = 12; + pack_start(grid, false, false, 0); } protected void add_line(string label_text, string info_text, bool multi_line = false, string? href = null) { @@ -62,18 +66,18 @@ private abstract class Properties : Gtk.Grid { info = (Gtk.Widget) info_label; } - attach(label, 0, (int) line_count, 1, 1); + grid.attach(label, 0, (int) line_count, 1, 1); if (multi_line) { - attach(info, 1, (int) line_count, 1, 3); + grid.attach(info, 1, (int) line_count, 1, 3); } else { - attach(info, 1, (int) line_count, 1, 1); + grid.attach(info, 1, (int) line_count, 1, 1); } line_count++; } - protected string get_prettyprint_time(Time time) { + protected string get_prettyprint_time(DateTime time) { string timestring = time.format(Resources.get_hh_mm_format_string()); if (timestring[0] == '0') @@ -82,7 +86,7 @@ private abstract class Properties : Gtk.Grid { return timestring; } - protected string get_prettyprint_time_with_seconds(Time time) { + protected string get_prettyprint_time_with_seconds(DateTime time) { string timestring = time.format(Resources.get_hh_mm_ss_format_string()); if (timestring[0] == '0') @@ -91,12 +95,12 @@ private abstract class Properties : Gtk.Grid { return timestring; } - protected string get_prettyprint_date(Time date) { + protected string get_prettyprint_date(DateTime date) { string date_string = null; - Time today = Time.local(time_t()); - if (date.day_of_year == today.day_of_year && date.year == today.year) { + var today = new DateTime.now_local(); + if (date.get_day_of_year() == today.get_day_of_year() && date.get_year() == today.get_year()) { date_string = _("Today"); - } else if (date.day_of_year == (today.day_of_year - 1) && date.year == today.year) { + } else if (date.get_day_of_year() == (today.get_day_of_year() - 1) && date.get_year() == today.get_year()) { date_string = _("Yesterday"); } else { date_string = format_local_date(date); @@ -140,9 +144,9 @@ private abstract class Properties : Gtk.Grid { } protected virtual void clear_properties() { - foreach (Gtk.Widget child in get_children()) - remove(child); - + foreach (Gtk.Widget child in grid.get_children()) + grid.remove(child); + line_count = 0; } @@ -159,8 +163,8 @@ private abstract class Properties : Gtk.Grid { private class BasicProperties : Properties { private string title; - private time_t start_time = time_t(); - private time_t end_time = time_t(); + private DateTime? start_time = new DateTime.now_utc(); + private DateTime? end_time = new DateTime.now_utc(); private Dimensions dimensions; private int photo_count; private int event_count; @@ -173,13 +177,14 @@ private class BasicProperties : Properties { private string raw_assoc; public BasicProperties() { + base(); } protected override void clear_properties() { base.clear_properties(); title = ""; - start_time = 0; - end_time = 0; + start_time = null; + end_time = null; dimensions = Dimensions(0,0); photo_count = -1; event_count = -1; @@ -269,20 +274,20 @@ private class BasicProperties : Properties { video_count = 0; foreach (DataView view in iter) { DataSource source = view.get_source(); - - if (source is PhotoSource || source is PhotoImportSource) { - time_t exposure_time = (source is PhotoSource) ? + + if (source is PhotoSource || source is PhotoImportSource) { + var exposure_time = (source is PhotoSource) ? ((PhotoSource) source).get_exposure_time() : ((PhotoImportSource) source).get_exposure_time(); - if (exposure_time != 0) { - if (start_time == 0 || exposure_time < start_time) + if (exposure_time != null) { + if (start_time == null || exposure_time.compare(start_time) < 0) start_time = exposure_time; - if (end_time == 0 || exposure_time > end_time) + if (end_time == null || exposure_time.compare(end_time) > 0) end_time = exposure_time; } - + photo_count++; } else if (source is EventSource) { EventSource event_source = (EventSource) source; @@ -290,14 +295,14 @@ private class BasicProperties : Properties { if (event_count == -1) event_count = 0; - if ((start_time == 0 || event_source.get_start_time() < start_time) && - event_source.get_start_time() != 0 ) { + if ((start_time == null || event_source.get_start_time().compare(start_time) < 0) && + event_source.get_start_time() != null ) { start_time = event_source.get_start_time(); } - if ((end_time == 0 || event_source.get_end_time() > end_time) && - event_source.get_end_time() != 0 ) { + if ((end_time == null || event_source.get_end_time().compare(end_time) > 0) && + event_source.get_end_time() != null ) { end_time = event_source.get_end_time(); - } else if (end_time == 0 || event_source.get_start_time() > end_time) { + } else if (end_time == null || event_source.get_start_time().compare(end_time) > 0) { end_time = event_source.get_start_time(); } @@ -310,15 +315,15 @@ private class BasicProperties : Properties { video_count += event_video_count; event_count++; } else if (source is VideoSource || source is VideoImportSource) { - time_t exposure_time = (source is VideoSource) ? + var exposure_time = (source is VideoSource) ? ((VideoSource) source).get_exposure_time() : ((VideoImportSource) source).get_exposure_time(); - if (exposure_time != 0) { - if (start_time == 0 || exposure_time < start_time) + if (exposure_time != null) { + if (start_time == null || exposure_time.compare(start_time) < 0) start_time = exposure_time; - if (end_time == 0 || exposure_time > end_time) + if (end_time == null || exposure_time.compare(end_time) > 0) end_time = exposure_time; } @@ -330,9 +335,9 @@ private class BasicProperties : Properties { protected override void get_properties(Page current_page) { base.get_properties(current_page); - if (end_time == 0) + if (end_time == null) end_time = start_time; - if (start_time == 0) + if (start_time == null) start_time = end_time; } @@ -373,11 +378,11 @@ private class BasicProperties : Properties { add_line("", video_num_string); } - if (start_time != 0) { - string start_date = get_prettyprint_date(Time.local(start_time)); - string start_time = get_prettyprint_time(Time.local(start_time)); - string end_date = get_prettyprint_date(Time.local(end_time)); - string end_time = get_prettyprint_time(Time.local(end_time)); + if (start_time != null) { + string start_date = get_prettyprint_date(start_time.to_local()); + string start_time = get_prettyprint_time(start_time.to_local()); + string end_date = get_prettyprint_date(end_time.to_local()); + string end_time = get_prettyprint_time(end_time.to_local()); if (start_date == end_date) { // display only one date if start and end are the same @@ -485,7 +490,7 @@ private class ExtendedProperties : Properties { public ExtendedProperties() { base(); - row_spacing = 6; + grid.row_spacing = 6; } // Event stuff @@ -574,9 +579,9 @@ private class ExtendedProperties : Properties { copyright = metadata.get_copyright(); software = metadata.get_software(); exposure_bias = metadata.get_exposure_bias(); - time_t exposure_time_obj = metadata.get_exposure_date_time().get_timestamp(); - exposure_date = get_prettyprint_date(Time.local(exposure_time_obj)); - exposure_time = get_prettyprint_time_with_seconds(Time.local(exposure_time_obj)); + DateTime exposure_time_obj = metadata.get_exposure_date_time().get_timestamp(); + exposure_date = get_prettyprint_date(exposure_time_obj.to_local()); + exposure_time = get_prettyprint_time_with_seconds(exposure_time_obj.to_local()); comment = media.get_comment(); } else if (source is EventSource) { Event event = (Event) source; @@ -634,7 +639,7 @@ private class ExtendedProperties : Properties { add_line(_("GPS longitude:"), (gps_long != -1 && gps_long_ref != "" && gps_long_ref != null) ? "%f °%s".printf(gps_long, gps_long_ref) : NO_VALUE, false, osm_link); - add_line(_("Artist:"), (artist != "" && artist != null) ? artist : NO_VALUE); + add_line(_("Artist:"), (artist != "" && artist != null) ? Markup.escape_text(artist) : NO_VALUE); add_line(_("Copyright:"), (copyright != "" && copyright != null) ? copyright : NO_VALUE); -- cgit v1.2.3