Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gnome-commander
Commits
5eccc4a6
Commit
5eccc4a6
authored
May 14, 2021
by
Uwe Scholz
Browse files
Access time will be readable through defined method in glib-2.70
Migration time2string method to accept GDateTime objects
parent
a05b10f6
Changes
7
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
5eccc4a6
...
...
@@ -61,7 +61,12 @@ GTEST_REQ=1.7.0
AC_SUBST(GTEST_REQ)
dnl Check for glib
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= ${GLIB_REQ}])
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= ${GLIB_REQ}], have_glib_req=yes, have_glib_req=no)
if test "x$have_glib_req" = "xyes"; then
PKG_CHECK_MODULES(GLIB_2_70, glib-2.0 >= 2.70.0,
AC_DEFINE(GLIB_2_70, 1, [Defined to 1 if you have glib >= 2.70]),
have_glib_2_70=no)
fi
dnl Check for gobject
PKG_CHECK_MODULES([GOBJECT],[gobject-2.0])
...
...
src/dialogs/gnome-cmd-file-props-dialog.cc
View file @
5eccc4a6
...
...
@@ -454,12 +454,13 @@ static GtkWidget *create_properties_tab (GnomeCmdFilePropsDialogPrivate *data)
label
=
create_label
(
dialog
,
data
->
f
->
get_mdate
(
TRUE
));
table_add
(
table
,
label
,
1
,
y
++
,
GTK_FILL
);
#ifdef GLIB_2_70
label
=
create_bold_label
(
dialog
,
_
(
"Accessed:"
));
table_add
(
table
,
label
,
0
,
y
,
GTK_FILL
);
label
=
create_label
(
dialog
,
data
->
f
->
get_adate
(
TRUE
));
table_add
(
table
,
label
,
1
,
y
++
,
GTK_FILL
);
#endif
add_sep
(
table
,
y
++
);
...
...
src/gnome-cmd-file.cc
View file @
5eccc4a6
...
...
@@ -757,25 +757,26 @@ const gchar *GnomeCmdFile::get_group()
}
inline
const
gchar
*
date2string
(
time_t
date
,
gboolean
overide_disp_setting
)
inline
const
gchar
*
date2string
(
GDateTime
*
date
,
gboolean
overide_disp_setting
)
{
return
time2string
(
date
,
overide_disp_setting
?
"%c"
:
gnome_cmd_data
.
options
.
date_format
);
return
time2string
(
date
,
overide_disp_setting
?
"%c"
:
gnome_cmd_data
.
options
.
date_format
);
}
#ifdef GLIB_2_70
const
gchar
*
GnomeCmdFile
::
get_adate
(
gboolean
overide_disp_setting
)
{
g_return_val_if_fail
(
info
!=
nullptr
,
nullptr
);
return
date2string
(
info
->
atime
,
overide_disp_setting
);
return
date2string
(
g_file_info_get_access_date_time
(
gFileInfo
)
,
overide_disp_setting
);
}
#endif
const
gchar
*
GnomeCmdFile
::
get_mdate
(
gboolean
overide_disp_setting
)
{
g_return_val_if_fail
(
i
nfo
!=
nullptr
,
nullptr
);
g_return_val_if_fail
(
gFileI
nfo
!=
nullptr
,
nullptr
);
return
date2string
(
info
->
mtime
,
overide_disp_setting
);
return
date2string
(
g_file_info_get_modification_date_time
(
gFileInfo
)
,
overide_disp_setting
);
}
...
...
src/gnome-cmd-file.h
View file @
5eccc4a6
...
...
@@ -73,7 +73,9 @@ struct GnomeCmdFile
const
gchar
*
get_extension
();
const
gchar
*
get_owner
();
const
gchar
*
get_group
();
#ifdef GLIB_2_70
const
gchar
*
get_adate
(
gboolean
overide_disp_setting
);
#endif
const
gchar
*
get_mdate
(
gboolean
overide_disp_setting
);
const
gchar
*
get_size
();
guint64
get_tree_size
();
...
...
src/gnome-cmd-xfer.cc
View file @
5eccc4a6
...
...
@@ -145,12 +145,20 @@ create_xfer_data (GnomeVFSXferOptions xferOptions, GList *src_uri_list, GList *d
inline
gchar
*
file_details
(
const
gchar
*
text_uri
)
{
GnomeVFSFileInfo
*
info
=
gnome_vfs_file_info_new
();
GnomeVFSResult
result
=
gnome_vfs_get_file_info
(
text_uri
,
info
,
GNOME_VFS_FILE_INFO_FOLLOW_LINKS
);
gchar
*
size
=
create_nice_size_str
(
info
->
size
);
gchar
*
details
=
result
==
GNOME_VFS_OK
?
g_strdup_printf
(
"%s, %s"
,
size
,
time2string
(
info
->
mtime
,
gnome_cmd_data
.
options
.
date_format
))
:
g_strdup
(
""
);
gnome_vfs_file_info_unref
(
info
);
auto
gFileTmp
=
g_file_new_for_uri
(
text_uri
);
auto
gFileInfoTmp
=
g_file_query_info
(
gFileTmp
,
G_FILE_ATTRIBUTE_STANDARD_SIZE
","
G_FILE_ATTRIBUTE_TIME_MODIFIED
,
G_FILE_QUERY_INFO_NONE
,
nullptr
,
nullptr
);
gchar
*
size
=
create_nice_size_str
(
g_file_info_get_attribute_uint64
(
gFileInfoTmp
,
G_FILE_ATTRIBUTE_STANDARD_SIZE
));
gchar
*
details
=
gFileInfoTmp
!=
nullptr
?
g_strdup_printf
(
"%s, %s"
,
size
,
time2string
(
g_file_info_get_modification_date_time
(
gFileInfoTmp
),
gnome_cmd_data
.
options
.
date_format
))
:
g_strdup
(
""
);
g_free
(
size
);
g_object_unref
(
gFileInfoTmp
);
return
details
;
}
...
...
src/utils.cc
View file @
5eccc4a6
...
...
@@ -382,29 +382,19 @@ const gchar *size2string (guint64 size, GnomeCmdSizeDispMode size_disp_mode)
}
const
gchar
*
time2string
(
time_t
t
,
const
gchar
*
date_format
)
const
gchar
*
time2string
(
GDateTime
*
gDateTime
,
const
gchar
*
date_format
)
{
// NOTE: date_format is passed in current locale format
g_return_val_if_fail
(
gDateTime
!=
nullptr
,
nullptr
);
static
gchar
buf
[
64
];
struct
tm
lt
;
localtime_r
(
&
t
,
&
lt
);
#if defined (__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
strftime
(
buf
,
sizeof
(
buf
),
date_format
,
&
lt
);
#if defined (__GNUC__)
#pragma GCC diagnostic pop
#endif
auto
dateString
=
g_date_time_format
(
gDateTime
,
date_format
);
// convert formatted date from current locale to UTF8
gchar
*
loc_date
=
g_locale_to_utf8
(
buf
,
-
1
,
NULL
,
NULL
,
NULL
);
if
(
loc_date
)
strncpy
(
buf
,
loc_date
,
sizeof
(
buf
)
-
1
);
strncpy
(
buf
,
dateString
,
sizeof
(
buf
)
-
1
);
g_free
(
loc_
date
);
g_free
(
date
String
);
return
buf
;
}
...
...
src/utils.h
View file @
5eccc4a6
/**
* @file utils.h
* @file utils.h
* @copyright (C) 2001-2006 Marcus Bjurman\n
* @copyright (C) 2007-2012 Piotr Eljasiak\n
* @copyright (C) 2013-2021 Uwe Scholz\n
...
...
@@ -138,7 +138,7 @@ const gchar *perm2string (guint32 permissions, gchar *buf, guint max);
const
gchar
*
perm2textstring
(
guint32
permissions
,
gchar
*
buf
,
guint
max
);
const
gchar
*
perm2numstring
(
guint32
permissions
,
gchar
*
buf
,
guint
max
);
const
gchar
*
size2string
(
guint64
size
,
GnomeCmdSizeDispMode
size_disp_mode
);
const
gchar
*
time2string
(
time_t
t
,
const
gchar
*
date_format
);
const
gchar
*
time2string
(
GDateTime
*
gDateTime
,
const
gchar
*
date_format
);
void
clear_event_key
(
GdkEventKey
*
event
);
...
...
Mamoru TASAKA
@mtasaka
mentioned in merge request
!19 (merged)
·
Nov 18, 2021
mentioned in merge request
!19 (merged)
mentioned in merge request !19
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment