recentmanager: add 64-bit _unix() time getters
This commit is contained in:
parent
8c3081232b
commit
9cdebc8291
5 changed files with 106 additions and 10 deletions
|
|
@ -3630,10 +3630,14 @@ gtk_recent_info_get_display_name
|
|||
gtk_recent_info_get_description
|
||||
gtk_recent_info_get_mime_type
|
||||
gtk_recent_info_get_added
|
||||
gtk_recent_info_get_added_unix
|
||||
gtk_recent_info_get_modified
|
||||
gtk_recent_info_get_modified_unix
|
||||
gtk_recent_info_get_visited
|
||||
gtk_recent_info_get_visited_unix
|
||||
gtk_recent_info_get_private_hint
|
||||
gtk_recent_info_get_application_info
|
||||
gtk_recent_info_get_application_info_unix
|
||||
gtk_recent_info_get_applications G_GNUC_MALLOC
|
||||
gtk_recent_info_last_application G_GNUC_MALLOC
|
||||
gtk_recent_info_has_application
|
||||
|
|
|
|||
|
|
@ -306,8 +306,8 @@ sort_recent_items_mru (GtkRecentInfo *a,
|
|||
|
||||
/* compared, not subtracted: the difference of two times does not fit
|
||||
* into the gint returned when they are more than 68 years apart */
|
||||
time_a = _gtk_recent_info_get_modified_time (a);
|
||||
time_b = _gtk_recent_info_get_modified_time (b);
|
||||
time_a = gtk_recent_info_get_modified_unix (a);
|
||||
time_b = gtk_recent_info_get_modified_unix (b);
|
||||
|
||||
return time_b < time_a ? -1 : (time_b > time_a ? 1 : 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ void _gtk_recent_chooser_set_delegate (GtkRecentChooser *receiver,
|
|||
|
||||
GQuark _gtk_recent_chooser_delegate_get_quark (void);
|
||||
|
||||
gint64 _gtk_recent_info_get_modified_time (GtkRecentInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RECENT_CHOOSER_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include <gio/gio.h>
|
||||
|
||||
#include "gtkrecentmanager.h"
|
||||
#include "gtkrecentchooserutils.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkstock.h"
|
||||
#include "gtkicontheme.h"
|
||||
|
|
@ -2069,17 +2068,66 @@ gtk_recent_info_get_visited (GtkRecentInfo *info)
|
|||
return recent_time_to_time_t (info->visited);
|
||||
}
|
||||
|
||||
/* The time of the last change as kept, in 64 bits, for sorting inside
|
||||
* GTK+; gtk_recent_info_get_modified() gives a time_t, which may be 32
|
||||
* bits. */
|
||||
/**
|
||||
* gtk_recent_info_get_added_unix:
|
||||
* @info: a #GtkRecentInfo
|
||||
*
|
||||
* Like gtk_recent_info_get_added(), as 64-bit seconds: a #time_t of 32
|
||||
* bits ends in 2038.
|
||||
*
|
||||
* Return value: the number of seconds elapsed from 1970-01-01 UTC when
|
||||
* the resource was added to the list, or -1 on failure.
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
gint64
|
||||
_gtk_recent_info_get_modified_time (GtkRecentInfo *info)
|
||||
gtk_recent_info_get_added_unix (GtkRecentInfo *info)
|
||||
{
|
||||
g_return_val_if_fail (info != NULL, -1);
|
||||
|
||||
return info->added;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_recent_info_get_modified_unix:
|
||||
* @info: a #GtkRecentInfo
|
||||
*
|
||||
* Like gtk_recent_info_get_modified(), as 64-bit seconds: a #time_t of
|
||||
* 32 bits ends in 2038.
|
||||
*
|
||||
* Return value: the number of seconds elapsed from 1970-01-01 UTC when
|
||||
* the resource was last modified, or -1 on failure.
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
gint64
|
||||
gtk_recent_info_get_modified_unix (GtkRecentInfo *info)
|
||||
{
|
||||
g_return_val_if_fail (info != NULL, -1);
|
||||
|
||||
return info->modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_recent_info_get_visited_unix:
|
||||
* @info: a #GtkRecentInfo
|
||||
*
|
||||
* Like gtk_recent_info_get_visited(), as 64-bit seconds: a #time_t of
|
||||
* 32 bits ends in 2038.
|
||||
*
|
||||
* Return value: the number of seconds elapsed from 1970-01-01 UTC when
|
||||
* the resource was last visited, or -1 on failure.
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
gint64
|
||||
gtk_recent_info_get_visited_unix (GtkRecentInfo *info)
|
||||
{
|
||||
g_return_val_if_fail (info != NULL, -1);
|
||||
|
||||
return info->visited;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_recent_info_get_private_hint:
|
||||
* @info: a #GtkRecentInfo
|
||||
|
|
@ -2157,6 +2205,44 @@ gtk_recent_info_get_application_info (GtkRecentInfo *info,
|
|||
const gchar **app_exec,
|
||||
guint *count,
|
||||
time_t *time_)
|
||||
{
|
||||
gint64 stamp;
|
||||
|
||||
if (!gtk_recent_info_get_application_info_unix (info, app_name, app_exec,
|
||||
count, &stamp))
|
||||
return FALSE;
|
||||
|
||||
if (time_)
|
||||
*time_ = recent_time_to_time_t (stamp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_recent_info_get_application_info_unix:
|
||||
* @info: a #GtkRecentInfo
|
||||
* @app_name: the name of the application that has registered this item
|
||||
* @app_exec: (transfer none) (out): return location for the string containing the command line
|
||||
* @count: (out): return location for the number of times this item was registered
|
||||
* @time_: (out): return location for the timestamp this item was last registered
|
||||
* for this application, in seconds from 1970-01-01 UTC
|
||||
*
|
||||
* Like gtk_recent_info_get_application_info(), with the time as 64-bit
|
||||
* seconds: a #time_t of 32 bits ends in 2038.
|
||||
*
|
||||
* Return value: %TRUE if an application with @app_name has registered this
|
||||
* resource inside the recently used list, or %FALSE otherwise. The
|
||||
* @app_exec string is owned by the #GtkRecentInfo and should not be
|
||||
* modified or freed
|
||||
*
|
||||
* Since: 2.24
|
||||
*/
|
||||
gboolean
|
||||
gtk_recent_info_get_application_info_unix (GtkRecentInfo *info,
|
||||
const gchar *app_name,
|
||||
const gchar **app_exec,
|
||||
guint *count,
|
||||
gint64 *time_)
|
||||
{
|
||||
RecentAppInfo *ai;
|
||||
|
||||
|
|
@ -2181,7 +2267,7 @@ gtk_recent_info_get_application_info (GtkRecentInfo *info,
|
|||
*count = ai->count;
|
||||
|
||||
if (time_)
|
||||
*time_ = recent_time_to_time_t (ai->stamp);
|
||||
*time_ = ai->stamp;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,12 +183,20 @@ const gchar * gtk_recent_info_get_mime_type (GtkRecentInfo *info
|
|||
time_t gtk_recent_info_get_added (GtkRecentInfo *info);
|
||||
time_t gtk_recent_info_get_modified (GtkRecentInfo *info);
|
||||
time_t gtk_recent_info_get_visited (GtkRecentInfo *info);
|
||||
gint64 gtk_recent_info_get_added_unix (GtkRecentInfo *info);
|
||||
gint64 gtk_recent_info_get_modified_unix (GtkRecentInfo *info);
|
||||
gint64 gtk_recent_info_get_visited_unix (GtkRecentInfo *info);
|
||||
gboolean gtk_recent_info_get_private_hint (GtkRecentInfo *info);
|
||||
gboolean gtk_recent_info_get_application_info (GtkRecentInfo *info,
|
||||
const gchar *app_name,
|
||||
const gchar **app_exec,
|
||||
guint *count,
|
||||
time_t *time_);
|
||||
gboolean gtk_recent_info_get_application_info_unix (GtkRecentInfo *info,
|
||||
const gchar *app_name,
|
||||
const gchar **app_exec,
|
||||
guint *count,
|
||||
gint64 *time_);
|
||||
gchar ** gtk_recent_info_get_applications (GtkRecentInfo *info,
|
||||
gsize *length) G_GNUC_MALLOC;
|
||||
gchar * gtk_recent_info_last_application (GtkRecentInfo *info) G_GNUC_MALLOC;
|
||||
|
|
|
|||
Loading…
Reference in a new issue