mate-desktop / atril

A document viewer for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
198 stars 62 forks source link

Preserve compatibility with older GLib versions #544

Closed vvillenave closed 2 years ago

vvillenave commented 2 years ago

This is a rather non-invasive change, that will
be easy to remove whenever we go ahead and
stop supporting older systems.

vvillenave commented 2 years ago

@rbuj This is partly inspired by our discussion on mate-desktop/mate-control-center#667;
if you’re willing to allow conditionals, then it would be quite useful to gain
backward compatibility older systems here as well...
(WRT to accessibility in particular, Atril has become much more useful than Evince!)

rbuj commented 2 years ago

You can use only the static method when glib < 2.62.0

diff --git a/configure.ac b/configure.ac
index c25f2e8..d8815a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,7 +91,7 @@ GLIB_GSETTINGS

 dnl Specify required versions of dependencies
 CAIRO_REQUIRED=1.14.0
-GLIB_REQUIRED=2.62.0
+GLIB_REQUIRED=2.54.0
 GTK_REQUIRED=3.22.0
 WEBKIT_REQUIRED=2.6.0
 LIBSECRET_REQUIRED=0.5
diff --git a/cut-n-paste/smclient b/cut-n-paste/smclient
index 54fff1b..f3091f9 160000
--- a/cut-n-paste/smclient
+++ b/cut-n-paste/smclient
@@ -1 +1 @@
-Subproject commit 54fff1b15efa5c88d4bb19ebbae9476a03f9db32
+Subproject commit f3091f9a5400a4cdfae909058b5597115bb21e80
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 79afaa3..97ccca3 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2174,6 +2174,17 @@ show_loading_progress (EvWindow *ev_window)
        return FALSE;
 }

+#if !GLIB_CHECK_VERSION(2, 62, 0)
+static GDateTime *
+_g_file_info_get_modification_date_time (GFileInfo *info)
+{
+       GTimeVal mtime;
+
+       g_file_info_get_modification_time (info, &mtime);
+       return g_date_time_new_from_timeval_utc (&mtime);
+}
+#endif
+
 static void
 ev_window_load_remote_failed (EvWindow *ev_window,
                              GError   *error)
@@ -2200,7 +2211,11 @@ set_uri_mtime (GFile        *source,
        info = g_file_query_info_finish (source, async_result, NULL);
        if (info) {
                GDateTime *mtime;
+#if GLIB_CHECK_VERSION(2, 62, 0)
                mtime = g_file_info_get_modification_date_time (info);
+#else
+               mtime = _g_file_info_get_modification_date_time (info);
+#endif
                if (mtime) {
                        utime = g_date_time_to_unix (mtime);
                        g_date_time_unref (mtime);
@@ -2615,7 +2630,11 @@ query_remote_uri_mtime_cb (GFile        *remote,
                return;
        }

+#if GLIB_CHECK_VERSION(2, 62, 0)
        mtime = g_file_info_get_modification_date_time (info);
+#else
+       mtime = _g_file_info_get_modification_date_time (info);
+#endif
        utime = g_date_time_to_unix (mtime);
        g_date_time_unref (mtime);
cwendling commented 2 years ago

Or the even less disruptive:

diff --git a/configure.ac b/configure.ac
index c25f2e8..d8815a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,7 +91,7 @@ GLIB_GSETTINGS

 dnl Specify required versions of dependencies
 CAIRO_REQUIRED=1.14.0
-GLIB_REQUIRED=2.62.0
+GLIB_REQUIRED=2.54.0
 GTK_REQUIRED=3.22.0
 WEBKIT_REQUIRED=2.6.0
 LIBSECRET_REQUIRED=0.5
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 79afaa3..97ccca3 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2174,6 +2174,19 @@ show_loading_progress (EvWindow *ev_window)
        return FALSE;
 }

+#if !GLIB_CHECK_VERSION(2, 62, 0)
+/* Non-year-2038-proof compatibility with GLib < 2.62 */
+static GDateTime *
+_g_file_info_get_modification_date_time (GFileInfo *info)
+{
+       GTimeVal mtime;
+
+       g_file_info_get_modification_time (info, &mtime);
+       return g_date_time_new_from_timeval_utc (&mtime);
+}
+#define g_file_info_get_modification_date_time _g_file_info_get_modification_date_time
+#endif
+
 static void
 ev_window_load_remote_failed (EvWindow *ev_window,
                              GError   *error)
@@ -2200,7 +2211,11 @@ set_uri_mtime (GFile        *source,

which should work the same.

vvillenave commented 2 years ago

which should work the same.

Thanks! Good idea.