Re: Gtk-2 File Chooser Modification Time Display
- From: zentara@xxxxxxxxxxxxxx
- Date: Mon, 13 Feb 2006 12:05:54 GMT
On Sun, 12 Feb 2006 18:07:04 GMT, "Jonathan A." <invalid@xxxxxxxxxxx>
wrote:
On Sun, 12 Feb 2006 16:41:34 GMT, zentara@xxxxxxxxxxxxxx
<zentara@xxxxxxxxxxxxxx> appears to have said:
I asked about it on a Gtk2 maillist and will see what they say.
Great. I thought about subscribing to the "gtk-list" mailing list just
to ask this, and decided to try simply posting here first and see if
someone knew a simple answer I'd missed.
For what it's worth, if you are capable of compiling your own
Gtk+ c libs (there are various considerations, like version level
mis-matches), you could probably patch the file responsible for
that date string.
I compile my gtk libs locally anyhow, so that's no biggie, if it comes
to that. I've already patched the filechooser to always show the "browse
for other folders" option in the "save as..." dialog.
It's in the Gtk+ sources, in a file called
gtkfilechooserdefault.c
Just open it, and search for the word "Yesterday", and you will
find the section of code which sets this. There is a string default
formatted with %x, and I'm not familiar enough with c, to know the
various ramifications of changing it.
Me either... but I'll try anything once. Twice, if I like it. :)
Well I experimented with setting the format string from %x to %c,
which should show all file mtime info, but I was always getting
00:00 for HOURS:MINUTES. I looked into the function which
is in GLib, that they used to set the date, and it appears to me that
it ignores hours and minutes. BUT good news.....I managed to go
back to plain old stftime, and below is a sub which works.
No gaurantees as to what hidden ramifications it may have, as
filechooser interacts with other objects, but it seems to work
OK so far for me. So here is the modified sub, which returns
a nice sortable time string for all files
/* Tree column data callback for the file list; fetches the mtime of a
file */
static void
list_mtime_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data)
{
GtkFileChooserDefault *impl;
const GtkFileInfo *info;
GtkFileTime time_mtime;
char buf[216];
struct tm *cal_time;
gboolean sensitive = TRUE;
impl = data;
info = get_list_file_info (impl, iter);
if (!info)
{
g_object_set (cell,
"text", "",
"sensitive", TRUE,
NULL);
return;
}
time_mtime = gtk_file_info_get_modification_time (info);
if (time_mtime == 0)
strcpy (buf, _("Unknown"));
else
{
cal_time = localtime(&time_mtime);
char *format;
/* format = "%y/%m/%d(%a) %H:%M"; Any other date */
format = "%F %T";
/* if (g_date_strftime(buf, sizeof (buf), format, &mtime) == 0)
strcpy (buf, _("Unknown"));
*/
strftime(buf, sizeof buf, format , cal_time);
}
Good Luck. I'm using Gtk+-2.8.11
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
.
- Follow-Ups:
- Re: Gtk-2 File Chooser Modification Time Display
- From: Jonathan A.
- Re: Gtk-2 File Chooser Modification Time Display
- References:
- Gtk-2 File Chooser Modification Time Display
- From: Jonathan A.
- Re: Gtk-2 File Chooser Modification Time Display
- From: zentara
- Re: Gtk-2 File Chooser Modification Time Display
- From: Jonathan A.
- Gtk-2 File Chooser Modification Time Display
- Prev by Date: Where is Process Table Structure file in Kernel 2.6.12.1
- Next by Date: Re: Can anybody point to a tutorial on modules?
- Previous by thread: Re: Gtk-2 File Chooser Modification Time Display
- Next by thread: Re: Gtk-2 File Chooser Modification Time Display
- Index(es):
Relevant Pages
|