summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-05-10 19:36:29 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-06-16 19:53:18 +0200
commit7ce1a66e8b52e4f6f03a57f08973c750f6bc5ead (patch)
tree8699f9012e3b09cc4bd4382f77b74cdacd09df96
parent43ee3b27f218ab513a11a253b4b8161eeec9b0df (diff)
downloadpluma-7ce1a66e8b52e4f6f03a57f08973c750f6bc5ead.tar.bz2
pluma-7ce1a66e8b52e4f6f03a57f08973c750f6bc5ead.tar.xz
Remove warning ‘GTimeVal’ is deprecated
-rw-r--r--pluma/pluma-app.c8
-rw-r--r--pluma/pluma-document-saver.c2
-rw-r--r--pluma/pluma-document-saver.h4
-rw-r--r--pluma/pluma-document.c76
-rw-r--r--pluma/pluma-gio-document-loader.c1
-rw-r--r--pluma/pluma-gio-document-saver.c33
6 files changed, 76 insertions, 48 deletions
diff --git a/pluma/pluma-app.c b/pluma/pluma-app.c
index 1cffa77f..c9d2e614 100644
--- a/pluma/pluma-app.c
+++ b/pluma/pluma-app.c
@@ -448,14 +448,10 @@ window_destroy (PlumaWindow *window,
static gchar *
gen_role (void)
{
- GTimeVal result;
static gint serial;
- g_get_current_time (&result);
-
- return g_strdup_printf ("pluma-window-%ld-%ld-%d-%s",
- result.tv_sec,
- result.tv_usec,
+ return g_strdup_printf ("pluma-window-%" G_GINT64_FORMAT "-%d-%s",
+ g_get_real_time (),
serial++,
g_get_host_name ());
}
diff --git a/pluma/pluma-document-saver.c b/pluma/pluma-document-saver.c
index 5b2df113..645daf41 100644
--- a/pluma/pluma-document-saver.c
+++ b/pluma/pluma-document-saver.c
@@ -293,7 +293,7 @@ pluma_document_saver_saving (PlumaDocumentSaver *saver,
void
pluma_document_saver_save (PlumaDocumentSaver *saver,
- GTimeVal *old_mtime)
+ gint64 *old_mtime)
{
pluma_debug (DEBUG_SAVER);
diff --git a/pluma/pluma-document-saver.h b/pluma/pluma-document-saver.h
index a64cdadc..27859039 100644
--- a/pluma/pluma-document-saver.h
+++ b/pluma/pluma-document-saver.h
@@ -85,7 +85,7 @@ struct _PlumaDocumentSaverClass
/* VTable */
void (* save) (PlumaDocumentSaver *saver,
- GTimeVal *old_mtime);
+ gint64 *old_mtime);
goffset (* get_file_size) (PlumaDocumentSaver *saver);
goffset (* get_bytes_written) (PlumaDocumentSaver *saver);
};
@@ -106,7 +106,7 @@ void pluma_document_saver_saving (PlumaDocumentSaver *saver,
gboolean completed,
GError *error);
void pluma_document_saver_save (PlumaDocumentSaver *saver,
- GTimeVal *old_mtime);
+ gint64 *old_mtime);
#if 0
void pluma_document_saver_cancel (PlumaDocumentSaver *saver);
diff --git a/pluma/pluma-document.c b/pluma/pluma-document.c
index 21a2c68b..0e877668 100644
--- a/pluma/pluma-document.c
+++ b/pluma/pluma-document.c
@@ -109,8 +109,8 @@ struct _PlumaDocumentPrivate
gchar *content_type;
- GTimeVal mtime;
- GTimeVal time_of_last_save_or_load;
+ gint64 mtime;
+ gint64 time_of_last_save_or_load;
guint search_flags;
gchar *search_text;
@@ -939,10 +939,9 @@ pluma_document_init (PlumaDocument *doc)
doc->priv->dispose_has_run = FALSE;
- doc->priv->mtime.tv_sec = 0;
- doc->priv->mtime.tv_usec = 0;
+ doc->priv->mtime = 0;
- g_get_current_time (&doc->priv->time_of_last_save_or_load);
+ doc->priv->time_of_last_save_or_load = g_get_real_time ();
doc->priv->encoding = pluma_encoding_get_utf8 ();
@@ -1270,10 +1269,11 @@ _pluma_document_check_externally_modified (PlumaDocument *doc)
gfile = g_file_new_for_uri (doc->priv->uri);
info = g_file_query_info (gfile,
- G_FILE_ATTRIBUTE_TIME_MODIFIED "," \
- G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
- G_FILE_QUERY_INFO_NONE,
- NULL, NULL);
+ G_FILE_ATTRIBUTE_TIME_MODIFIED "," \
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC "," \
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
g_object_unref (gfile);
if (info != NULL)
@@ -1291,14 +1291,20 @@ _pluma_document_check_externally_modified (PlumaDocument *doc)
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
{
- GTimeVal timeval;
+ guint64 timeval;
- g_file_info_get_modification_time (info, &timeval);
+ timeval = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED) * G_USEC_PER_SEC;
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC))
+ {
+ guint32 usec;
+
+ usec = g_file_info_get_attribute_uint32 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
+ timeval += (guint64) usec;
+ }
g_object_unref (info);
- return (timeval.tv_sec > doc->priv->mtime.tv_sec) ||
- (timeval.tv_sec == doc->priv->mtime.tv_sec &&
- timeval.tv_usec > doc->priv->mtime.tv_usec);
+ return (((gint64) timeval) > doc->priv->mtime);
}
}
@@ -1330,7 +1336,7 @@ document_loader_loaded (PlumaDocumentLoader *loader,
GFileInfo *info;
const gchar *content_type = NULL;
gboolean read_only = FALSE;
- GTimeVal mtime = {0, 0};
+ guint64 mtime = 0;
info = pluma_document_loader_get_info (loader);
@@ -1341,18 +1347,28 @@ document_loader_loaded (PlumaDocumentLoader *loader,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
- g_file_info_get_modification_time (info, &mtime);
+ mtime = g_file_info_get_attribute_uint64 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED) * G_USEC_PER_SEC;
+
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC))
+ {
+ guint32 usec;
+
+ usec = g_file_info_get_attribute_uint32 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
+ mtime += (guint64) usec;
+ }
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
read_only = !g_file_info_get_attribute_boolean (info,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
}
- doc->priv->mtime = mtime;
+ doc->priv->mtime = (gint64) mtime;
set_readonly (doc, read_only);
- g_get_current_time (&doc->priv->time_of_last_save_or_load);
+ doc->priv->time_of_last_save_or_load = g_get_real_time ();
set_encoding (doc,
pluma_document_loader_get_encoding (loader),
@@ -1545,7 +1561,7 @@ document_saver_saving (PlumaDocumentSaver *saver,
{
const gchar *uri;
const gchar *content_type = NULL;
- GTimeVal mtime = {0, 0};
+ guint64 mtime = 0;
GFileInfo *info;
uri = pluma_document_saver_get_uri (saver);
@@ -1560,13 +1576,23 @@ document_saver_saving (PlumaDocumentSaver *saver,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
- g_file_info_get_modification_time (info, &mtime);
+ mtime = g_file_info_get_attribute_uint64 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED) * G_USEC_PER_SEC;
+
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC))
+ {
+ guint32 usec;
+
+ usec = g_file_info_get_attribute_uint32 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
+ mtime += (guint64) usec;
+ }
}
set_content_type (doc, content_type);
- doc->priv->mtime = mtime;
+ doc->priv->mtime = (gint64) mtime;
- g_get_current_time (&doc->priv->time_of_last_save_or_load);
+ doc->priv->time_of_last_save_or_load = g_get_real_time ();
_pluma_document_set_readonly (doc, FALSE);
@@ -2314,15 +2340,11 @@ pluma_document_get_encoding (PlumaDocument *doc)
glong
_pluma_document_get_seconds_since_last_save_or_load (PlumaDocument *doc)
{
- GTimeVal current_time;
-
pluma_debug (DEBUG_DOCUMENT);
g_return_val_if_fail (PLUMA_IS_DOCUMENT (doc), -1);
- g_get_current_time (&current_time);
-
- return (current_time.tv_sec - doc->priv->time_of_last_save_or_load.tv_sec);
+ return ((g_get_real_time () - doc->priv->time_of_last_save_or_load) / G_USEC_PER_SEC);
}
static void
diff --git a/pluma/pluma-gio-document-loader.c b/pluma/pluma-gio-document-loader.c
index 24c065b4..0891af7e 100644
--- a/pluma/pluma-gio-document-loader.c
+++ b/pluma/pluma-gio-document-loader.c
@@ -62,6 +62,7 @@ typedef struct
#define REMOTE_QUERY_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," \
G_FILE_ATTRIBUTE_STANDARD_TYPE "," \
G_FILE_ATTRIBUTE_TIME_MODIFIED "," \
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC "," \
G_FILE_ATTRIBUTE_STANDARD_SIZE "," \
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "," \
PLUMA_METADATA_ATTRIBUTE_ENCODING
diff --git a/pluma/pluma-gio-document-saver.c b/pluma/pluma-gio-document-saver.c
index 3ba86fe7..ac1d9805 100644
--- a/pluma/pluma-gio-document-saver.c
+++ b/pluma/pluma-gio-document-saver.c
@@ -55,10 +55,11 @@ typedef struct
} AsyncData;
#define REMOTE_QUERY_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," \
- G_FILE_ATTRIBUTE_TIME_MODIFIED
+ G_FILE_ATTRIBUTE_TIME_MODIFIED "," \
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC
-static void pluma_gio_document_saver_save (PlumaDocumentSaver *saver,
- GTimeVal *old_mtime);
+static void pluma_gio_document_saver_save (PlumaDocumentSaver *saver,
+ gint64 *old_mtime);
static goffset pluma_gio_document_saver_get_file_size (PlumaDocumentSaver *saver);
static goffset pluma_gio_document_saver_get_bytes_written (PlumaDocumentSaver *saver);
@@ -67,7 +68,7 @@ static void check_modified_async (AsyncData *async);
struct _PlumaGioDocumentSaverPrivate
{
- GTimeVal old_mtime;
+ gint64 old_mtime;
goffset size;
goffset bytes_written;
@@ -673,16 +674,24 @@ check_modification_callback (GFile *source,
/* check if the mtime is > what we know about it (if we have it) */
if (info != NULL && g_file_info_has_attribute (info,
- G_FILE_ATTRIBUTE_TIME_MODIFIED))
+ G_FILE_ATTRIBUTE_TIME_MODIFIED))
{
- GTimeVal mtime;
- GTimeVal old_mtime;
+ guint64 mtime;
+ gint64 old_mtime;
+
+ mtime = g_file_info_get_attribute_uint64 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED) * G_USEC_PER_SEC;
+ if (g_file_info_has_attribute (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC))
+ {
+ guint32 usec = g_file_info_get_attribute_uint32 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
+ mtime += (guint64) usec;
+ }
- g_file_info_get_modification_time (info, &mtime);
old_mtime = gvsaver->priv->old_mtime;
- if ((old_mtime.tv_sec > 0 || old_mtime.tv_usec > 0) &&
- (mtime.tv_sec != old_mtime.tv_sec || mtime.tv_usec != old_mtime.tv_usec) &&
+ if ((old_mtime > 0 || ((gint64) mtime) > 0) && (((gint64) mtime) != old_mtime) &&
(PLUMA_DOCUMENT_SAVER (gvsaver)->flags & PLUMA_DOCUMENT_SAVE_IGNORE_MTIME) == 0)
{
pluma_debug_message (DEBUG_SAVER, "File is externally modified");
@@ -711,7 +720,7 @@ check_modified_async (AsyncData *async)
pluma_debug_message (DEBUG_SAVER, "Check externally modified");
g_file_query_info_async (async->saver->priv->gfile,
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED "," G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_HIGH,
async->cancellable,
@@ -739,7 +748,7 @@ save_remote_file_real (PlumaGioDocumentSaver *gvsaver)
static void
pluma_gio_document_saver_save (PlumaDocumentSaver *saver,
- GTimeVal *old_mtime)
+ gint64 *old_mtime)
{
PlumaGioDocumentSaver *gvsaver = PLUMA_GIO_DOCUMENT_SAVER (saver);