[recipes/fix-compiler-warnings: 1/3] Fix deprecation warnings for use of GTimeVal



commit 6677b48bd2137ac80ecff33640645b00dbf59993
Author: Matthew Leeds <matthew leeds endlessm com>
Date:   Sun Mar 22 14:45:51 2020 -0700

    Fix deprecation warnings for use of GTimeVal
    
    Only 18 years left until this would have been an issue

 meson.build           |  6 +++---
 src/gr-image.c        | 15 ++++++---------
 src/gr-recipe-store.c | 15 ++++++---------
 3 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/meson.build b/meson.build
index 3b461c4..1286312 100644
--- a/meson.build
+++ b/meson.build
@@ -81,9 +81,9 @@ if get_option('canberra') != 'no'
 endif
 
 deps = [ dependency('gtk+-3.0', version : '>=3.22'),
-         dependency('glib-2.0'),
-         dependency('gio-2.0'),
-         dependency('gio-unix-2.0'),
+         dependency('glib-2.0', version : '>= 2.61.2'),
+         dependency('gio-2.0', version : '>= 2.61.2'),
+         dependency('gio-unix-2.0', version : '>= 2.61.2'),
          dependency('gmodule-export-2.0'),
          dependency('libsoup-2.4'),
          dependency('goa-1.0'),
diff --git a/src/gr-image.c b/src/gr-image.c
index 1f12815..4b1d084 100644
--- a/src/gr-image.c
+++ b/src/gr-image.c
@@ -235,17 +235,15 @@ should_try_load (const char *path)
                                   G_FILE_QUERY_INFO_NONE,
                                   NULL,
                                   NULL);
-        if (info) {
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
                 goffset size;
-                GTimeVal tv;
                 g_autoptr(GDateTime) now = NULL;
                 g_autoptr(GDateTime) mtime = NULL;
 
                 size = g_file_info_get_size (info);
-                g_file_info_get_modification_time (info, &tv);
-
                 now = g_date_time_new_now_utc ();
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+                mtime = g_file_info_get_modification_date_time (info);
 
                 if (size == 6) {
                         result = g_date_time_difference (now, mtime) > G_TIME_SPAN_DAY;
@@ -297,13 +295,12 @@ set_modified_request (SoupMessage *msg,
                                   G_FILE_QUERY_INFO_NONE,
                                   NULL,
                                   NULL);
-        if (info) {
-                GTimeVal tv;
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
                 g_autoptr(GDateTime) mtime = NULL;
                 g_autofree char *mod_date = NULL;
 
-                g_file_info_get_modification_time (info, &tv);
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+                mtime = g_file_info_get_modification_date_time (info);
                 mod_date = g_date_time_format (mtime, "%a, %d %b %Y %H:%M:%S %Z");
                 soup_message_headers_append (msg->request_headers, "If-Modified-Since", mod_date);
         }
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index c7f4e84..3c6d7ca 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -991,15 +991,13 @@ should_try_load (const char *path)
                                   G_FILE_QUERY_INFO_NONE,
                                   NULL,
                                   NULL);
-        if (info) {
-                GTimeVal tv;
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
                 g_autoptr(GDateTime) now = NULL;
                 g_autoptr(GDateTime) mtime = NULL;
 
-                g_file_info_get_modification_time (info, &tv);
-
                 now = g_date_time_new_now_utc ();
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+                mtime = g_file_info_get_modification_date_time (info);
 
                 result = g_date_time_difference (now, mtime) > G_TIME_SPAN_DAY;
                 g_debug ("Cached file for %s is %s",
@@ -1016,7 +1014,6 @@ set_modified_request (SoupMessage *msg,
 {
         g_autoptr(GFile) file = NULL;
         g_autoptr(GFileInfo) info = NULL;
-        GTimeVal tv;
         g_autoptr(GDateTime) mtime = NULL;
         g_autofree char *mod_date = NULL;
 
@@ -1027,9 +1024,9 @@ set_modified_request (SoupMessage *msg,
                                   NULL,
                                   NULL);
 
-        if (info) {
-                g_file_info_get_modification_time (info, &tv);
-                mtime = g_date_time_new_from_timeval_utc (&tv);
+        if (info &&
+            g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) {
+                mtime = g_file_info_get_modification_date_time (info);
                 mod_date = g_date_time_format (mtime, "%a, %d %b %Y %H:%M:%S %Z");
                 soup_message_headers_append (msg->request_headers, "If-Modified-Since", mod_date);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]