summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2023-01-04 14:37:26 -0800
committerAntónio Fernandes <antoniof@gnome.org>2023-01-09 10:46:41 +0000
commitc69f87524b336f998146d12c1063916e85e90eb6 (patch)
treeecd0d6fb409dd68317c2edc71ef1b852d6321dc1
parent30e82424ad01ecbd847b129722f9d383021cba29 (diff)
downloadnautilus-c69f87524b336f998146d12c1063916e85e90eb6.tar.gz
general: Replace deprecated GTimeVal with GDateTime
-rw-r--r--src/nautilus-file-undo-operations.c31
-rw-r--r--src/nautilus-file.c7
-rw-r--r--src/nautilus-search-engine-tracker.c18
3 files changed, 27 insertions, 29 deletions
diff --git a/src/nautilus-file-undo-operations.c b/src/nautilus-file-undo-operations.c
index d915dcce4..5eac275fc 100644
--- a/src/nautilus-file-undo-operations.c
+++ b/src/nautilus-file-undo-operations.c
@@ -1645,8 +1645,7 @@ trash_redo_func_callback (GHashTable *debuting_uris,
{
NautilusFileUndoInfoTrash *self = user_data;
GHashTable *new_trashed_files;
- GTimeVal current_time;
- gsize updated_trash_time;
+ gint64 updated_trash_time;
GFile *file;
GList *keys, *l;
@@ -1654,18 +1653,19 @@ trash_redo_func_callback (GHashTable *debuting_uris,
{
new_trashed_files =
g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
- g_object_unref, NULL);
+ g_object_unref, g_free);
keys = g_hash_table_get_keys (self->trashed);
- g_get_current_time (&current_time);
- updated_trash_time = current_time.tv_sec;
+ /* Convert from microseconds to seconds */
+ updated_trash_time = g_get_real_time () / 1000000;
for (l = keys; l != NULL; l = l->next)
{
file = l->data;
g_hash_table_insert (new_trashed_files,
- g_object_ref (file), GSIZE_TO_POINTER (updated_trash_time));
+ g_object_ref (file),
+ g_memdup2 (&updated_trash_time, sizeof (updated_trash_time)));
}
g_list_free (keys);
@@ -1726,7 +1726,8 @@ trash_retrieve_files_to_restore_thread (GTask *task,
GFileInfo *info;
gpointer lookupvalue;
GFile *item;
- glong trash_time, orig_trash_time;
+ gint64 orig_trash_time;
+ gint64 trash_time;
const char *origpath;
GFile *origfile;
@@ -1742,7 +1743,7 @@ trash_retrieve_files_to_restore_thread (GTask *task,
{
GDateTime *date;
- orig_trash_time = GPOINTER_TO_SIZE (lookupvalue);
+ orig_trash_time = *((guint64 *) lookupvalue);
trash_time = 0;
date = g_file_info_get_deletion_date (info);
if (date)
@@ -1850,7 +1851,7 @@ static void
nautilus_file_undo_info_trash_init (NautilusFileUndoInfoTrash *self)
{
self->trashed = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
- g_object_unref, NULL);
+ g_object_unref, g_free);
}
static void
@@ -1888,13 +1889,11 @@ void
nautilus_file_undo_info_trash_add_file (NautilusFileUndoInfoTrash *self,
GFile *file)
{
- GTimeVal current_time;
- gsize orig_trash_time;
-
- g_get_current_time (&current_time);
- orig_trash_time = current_time.tv_sec;
-
- g_hash_table_insert (self->trashed, g_object_ref (file), GSIZE_TO_POINTER (orig_trash_time));
+ /* Convert from microseconds to seconds */
+ gint64 orig_trash_time = g_get_real_time () / 1000000;
+ g_hash_table_insert (self->trashed,
+ g_object_ref (file),
+ g_memdup2 (&orig_trash_time, sizeof (orig_trash_time)));
}
GList *
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 73f868709..58139c93c 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -2465,7 +2465,6 @@ update_info_internal (NautilusFile *file,
time_t atime, mtime, btime;
time_t trash_time;
time_t recency;
- GTimeVal g_trash_time;
const char *time_string;
const char *symlink_name, *mime_type, *selinux_context, *name, *thumbnail_path;
GFileType file_type;
@@ -2891,8 +2890,10 @@ update_info_internal (NautilusFile *file,
time_string = g_file_info_get_attribute_string (info, "trash::deletion-date");
if (time_string != NULL)
{
- g_time_val_from_iso8601 (time_string, &g_trash_time);
- trash_time = g_trash_time.tv_sec;
+ g_autoptr (GTimeZone) tz = g_time_zone_new_local ();
+ g_autoptr (GDateTime) date_time = g_date_time_new_from_iso8601 (time_string, tz);
+
+ trash_time = date_time != NULL ? g_date_time_to_unix (date_time) : 0;
}
if (file->details->trash_time != trash_time)
{
diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c
index b4ae92ad4..51917216b 100644
--- a/src/nautilus-search-engine-tracker.c
+++ b/src/nautilus-search-engine-tracker.c
@@ -181,7 +181,8 @@ cursor_callback (GObject *object,
const char *atime_str;
const char *ctime_str;
const gchar *snippet;
- GTimeVal tv;
+ GDateTime *date;
+ g_autoptr (GTimeZone) tz = g_time_zone_new_local ();
gdouble rank, match;
gboolean success;
gchar *basename;
@@ -231,10 +232,9 @@ cursor_callback (GObject *object,
}
}
- if (g_time_val_from_iso8601 (mtime_str, &tv))
+ date = g_date_time_new_from_iso8601 (mtime_str, tz);
+ if (date != NULL)
{
- GDateTime *date;
- date = g_date_time_new_from_timeval_local (&tv);
nautilus_search_hit_set_modification_time (hit, date);
g_date_time_unref (date);
}
@@ -242,10 +242,9 @@ cursor_callback (GObject *object,
{
g_warning ("unable to parse mtime: %s", mtime_str);
}
- if (g_time_val_from_iso8601 (atime_str, &tv))
+ date = g_date_time_new_from_iso8601 (atime_str, tz);
+ if (date != NULL)
{
- GDateTime *date;
- date = g_date_time_new_from_timeval_local (&tv);
nautilus_search_hit_set_access_time (hit, date);
g_date_time_unref (date);
}
@@ -253,10 +252,9 @@ cursor_callback (GObject *object,
{
g_warning ("unable to parse atime: %s", atime_str);
}
- if (g_time_val_from_iso8601 (ctime_str, &tv))
+ date = g_date_time_new_from_iso8601 (ctime_str, tz);
+ if (date != NULL)
{
- GDateTime *date;
- date = g_date_time_new_from_timeval_local (&tv);
nautilus_search_hit_set_creation_time (hit, date);
g_date_time_unref (date);
}