mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
Show the time of last change in the file chooser, for files modified today
2007-06-26 Emmanuele Bassi <ebassi@gnome.org> * gtk/gtkfilechooserdefault.c (list_mtime_data_func): Show the time of last change in the file chooser, for files modified today or yesterday. (#324543) * configure.in: Check for localtime_r(). svn path=/trunk/; revision=18248
This commit is contained in:
parent
0aa5be0dec
commit
1bf057fa95
@ -1,3 +1,11 @@
|
|||||||
|
2007-06-26 Emmanuele Bassi <ebassi@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdefault.c (list_mtime_data_func): Show
|
||||||
|
the time of last change in the file chooser, for files
|
||||||
|
modified today or yesterday. (#324543)
|
||||||
|
|
||||||
|
* configure.in: Check for localtime_r().
|
||||||
|
|
||||||
2007-06-26 Cody Russell <bratsche@gnome.org>
|
2007-06-26 Cody Russell <bratsche@gnome.org>
|
||||||
|
|
||||||
* modules/engines/ms-windows/xp_theme.[ch]
|
* modules/engines/ms-windows/xp_theme.[ch]
|
||||||
|
@ -410,6 +410,7 @@ fi
|
|||||||
AC_SUBST(REBUILD)
|
AC_SUBST(REBUILD)
|
||||||
|
|
||||||
AC_CHECK_FUNCS(lstat mkstemp flockfile getc_unlocked)
|
AC_CHECK_FUNCS(lstat mkstemp flockfile getc_unlocked)
|
||||||
|
AC_CHECK_FUNCS(localtime_r)
|
||||||
|
|
||||||
# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
|
# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
|
||||||
AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
|
AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
|
||||||
|
@ -10884,9 +10884,7 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
|||||||
{
|
{
|
||||||
GtkFileChooserDefault *impl;
|
GtkFileChooserDefault *impl;
|
||||||
GtkFileTime time_mtime;
|
GtkFileTime time_mtime;
|
||||||
GDate mtime, now;
|
gchar *date_str = NULL;
|
||||||
int days_diff;
|
|
||||||
char buf[256];
|
|
||||||
gboolean sensitive = TRUE;
|
gboolean sensitive = TRUE;
|
||||||
|
|
||||||
impl = data;
|
impl = data;
|
||||||
@ -10954,39 +10952,65 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
|||||||
sensitive = gtk_file_info_get_is_folder (info);
|
sensitive = gtk_file_info_get_is_folder (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_mtime == 0)
|
if (G_UNLIKELY (time_mtime == 0))
|
||||||
strcpy (buf, _("Unknown"));
|
date_str = g_strdup (_("Unknown"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
GDate mtime, now;
|
||||||
|
gint days_diff;
|
||||||
|
struct tm tm_mtime;
|
||||||
time_t time_now;
|
time_t time_now;
|
||||||
|
const gchar *format;
|
||||||
|
gchar buf[256];
|
||||||
|
|
||||||
|
#ifdef HAVE_LOCALTIME_R
|
||||||
|
localtime_r ((time_t *) &time_mtime, &tm_mtime);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
struct tm *ptm = localtime ((time_t *) &time_mtime);
|
||||||
|
|
||||||
|
if (!ptm)
|
||||||
|
{
|
||||||
|
date_str = g_strdup (_("Unknown"));
|
||||||
|
g_warning ("ptm != NULL failed");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memcpy ((void *) &tm, (void *) ptm, sizeof (struct tm));
|
||||||
|
}
|
||||||
|
#endif /* HAVE_LOCALTIME_R */
|
||||||
|
|
||||||
g_date_set_time_t (&mtime, time_mtime);
|
g_date_set_time_t (&mtime, time_mtime);
|
||||||
time_now = time (NULL);
|
time_now = time (NULL);
|
||||||
g_date_set_time_t (&now, time_now);
|
g_date_set_time_t (&now, time_now);
|
||||||
|
|
||||||
days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
|
days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
|
||||||
|
|
||||||
|
/* Translators: %H means "hours" and %M means "minutes" */
|
||||||
if (days_diff == 0)
|
if (days_diff == 0)
|
||||||
strcpy (buf, _("Today"));
|
format = _("Today at %H:%M");
|
||||||
else if (days_diff == 1)
|
else if (days_diff == 1)
|
||||||
strcpy (buf, _("Yesterday"));
|
format = _("Yesterday at %H:%M");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *format;
|
|
||||||
|
|
||||||
if (days_diff > 1 && days_diff < 7)
|
if (days_diff > 1 && days_diff < 7)
|
||||||
format = "%A"; /* Days from last week */
|
format = "%A"; /* Days from last week */
|
||||||
else
|
else
|
||||||
format = "%x"; /* Any other date */
|
format = "%x"; /* Any other date */
|
||||||
|
|
||||||
if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
|
|
||||||
strcpy (buf, _("Unknown"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strftime (buf, sizeof (buf), format, &tm_mtime) != 0)
|
||||||
|
date_str = g_strdup (buf);
|
||||||
|
else
|
||||||
|
date_str = g_strdup (_("Unknown"));
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
g_object_set (cell,
|
g_object_set (cell,
|
||||||
"text", buf,
|
"text", date_str,
|
||||||
"sensitive", sensitive,
|
"sensitive", sensitive,
|
||||||
NULL);
|
NULL);
|
||||||
|
g_free (date_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
Loading…
Reference in New Issue
Block a user