Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
Files
Commits
98d22d4f
Commit
98d22d4f
authored
Jan 18, 2000
by
John Sullivan
Browse files
Added size & mod date columns to list view.
parent
e72fb15b
Changes
4
Hide whitespace changes
Inline
Side-by-side
ChangeLog-20000414
View file @
98d22d4f
2000-01-17 John Sullivan <sullivan@eazel.com>
First steps towards making the list view non-degenerate.
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-directory-view.c:
(nautilus_file_date_as_string): New function, returns string suitable
for displaying in a list view column.
(nautilus_file_size_as_string): New function, calls newly-publicized
gnome_vfs_file_size_to_string.
(display_selection_info): Now calls gnome_vfs_file_size_to_string
instead of redoing the string-creation code here.
* src/file-manager/fm-directory-view-list.c
(create_flist): Creates new columns for icon, size, and mod date.
(add_to_flist): Fills columns for size & mod date. Icon column
is empty for the moment. Columns do not yet sort.
2000-01-17 Andy Hertzfeld <andy@eazel.com>
*libnautilus/gnome-icon-container-dnd.c:
...
...
src/file-manager/fm-directory-view-list.c
View file @
98d22d4f
...
...
@@ -39,7 +39,7 @@ static FMDirectoryViewClass *parent_class = NULL;
/* forward declarations */
void
add_to_flist
(
FMIconCache
*
icon_manager
,
static
void
add_to_flist
(
FMIconCache
*
icon_manager
,
GtkFList
*
flist
,
GnomeVFSFileInfo
*
info
);
static
GtkFList
*
create_flist
(
FMDirectoryViewList
*
list_view
);
...
...
@@ -102,6 +102,15 @@ fm_directory_view_list_destroy (GtkObject *object)
NAUTILUS_CALL_PARENT_CLASS
(
GTK_OBJECT_CLASS
,
destroy
,
(
object
));
}
#define LIST_VIEW_COLUMN_ICON 0
#define LIST_VIEW_COLUMN_NAME 1
#define LIST_VIEW_COLUMN_SIZE 2
#define LIST_VIEW_COLUMN_DATE_MODIFIED 3
#define LIST_VIEW_COLUMN_COUNT 4
GtkWidget
*
fm_directory_view_list_new
(
void
)
{
...
...
@@ -114,14 +123,32 @@ create_flist (FMDirectoryViewList *list_view)
{
GtkFList
*
flist
;
gchar
*
titles
[]
=
{
"Name"
,
NULL
NULL
,
_
(
"Name"
),
_
(
"Size"
),
_
(
"Date Modified"
),
};
uint
widths
[]
=
{
20
,
/* Icon */
150
,
/* Name */
75
,
/* Size */
100
,
/* Modified */
};
int
i
;
g_return_val_if_fail
(
FM_IS_DIRECTORY_VIEW_LIST
(
list_view
),
NULL
);
flist
=
GTK_FLIST
(
gtk_flist_new_with_titles
(
2
,
titles
));
gtk_clist_set_column_width
(
GTK_CLIST
(
flist
),
0
,
150
);
/* FIXME */
flist
=
GTK_FLIST
(
gtk_flist_new_with_titles
(
LIST_VIEW_COLUMN_COUNT
,
titles
));
for
(
i
=
0
;
i
<
LIST_VIEW_COLUMN_COUNT
;
++
i
)
{
gtk_clist_set_column_width
(
GTK_CLIST
(
flist
),
i
,
widths
[
i
]);
}
gtk_clist_set_column_justification
(
GTK_CLIST
(
flist
),
LIST_VIEW_COLUMN_SIZE
,
GTK_JUSTIFY_RIGHT
);
GTK_WIDGET_SET_FLAGS
(
flist
,
GTK_CAN_FOCUS
);
gtk_signal_connect
(
GTK_OBJECT
(
flist
),
...
...
@@ -163,20 +190,47 @@ flist_selection_changed_cb (GtkFList *flist,
fm_directory_view_notify_selection_changed
(
FM_DIRECTORY_VIEW
(
data
));
}
void
static
void
add_to_flist
(
FMIconCache
*
icon_manager
,
GtkFList
*
flist
,
GnomeVFSFileInfo
*
info
)
{
GtkCList
*
clist
;
gchar
*
text
[
2
];
gchar
*
text
[
LIST_VIEW_COLUMN_COUNT
];
gchar
*
size_string
=
NULL
;
gchar
*
modified_string
=
NULL
;
text
[
0
]
=
info
->
name
;
text
[
1
]
=
NULL
;
/* FIXME: Icon column needs a pixmap */
text
[
LIST_VIEW_COLUMN_ICON
]
=
NULL
;
text
[
LIST_VIEW_COLUMN_NAME
]
=
info
->
name
;
if
(
info
->
type
==
GNOME_VFS_FILE_TYPE_DIRECTORY
)
{
text
[
LIST_VIEW_COLUMN_SIZE
]
=
"--"
;
}
else
{
size_string
=
nautilus_file_size_as_string
(
info
->
size
);
text
[
LIST_VIEW_COLUMN_SIZE
]
=
size_string
;
}
/* Note: There's also accessed time and changed time.
* Accessed time doesn't seem worth showing to the user.
* Changed time is only subtly different from modified time
* (changed time includes "metadata" changes like file permissions).
* We should not display both, but we might change our minds as to
* which one is better.
*/
modified_string
=
nautilus_file_date_as_string
(
info
->
mtime
);
text
[
LIST_VIEW_COLUMN_DATE_MODIFIED
]
=
modified_string
;
clist
=
GTK_CLIST
(
flist
);
gtk_clist_append
(
clist
,
text
);
gtk_clist_set_row_data
(
clist
,
clist
->
rows
-
1
,
info
);
g_free
(
size_string
);
g_free
(
modified_string
);
}
static
GtkFList
*
...
...
src/file-manager/fm-directory-view.c
View file @
98d22d4f
...
...
@@ -30,6 +30,7 @@
#include
"fm-public-api.h"
#include
<gnome.h>
#include
<libgnomevfs/gnome-vfs-utils.h>
#include
<libnautilus/libnautilus.h>
#include
<libnautilus/nautilus-gtk-macros.h>
...
...
@@ -258,37 +259,7 @@ display_selection_info (FMDirectoryView *view)
return
;
}
/* FIXME: The following should probably go into a separate module, as
we might have to do the same thing in other places as well. Also,
I am not sure this will be OK for all the languages. */
/* FIXME: gnome-vfs has an internal routine that also does this
(gnome_vfs_size_to_string())
*/
if
(
size
<
(
GnomeVFSFileSize
)
1e3
)
{
if
(
size
==
1
)
size_string
=
g_strdup
(
_
(
"1 byte"
));
else
size_string
=
g_strdup_printf
(
_
(
"%u bytes"
),
(
guint
)
size
);
}
else
{
gdouble
displayed_size
;
if
(
size
<
(
GnomeVFSFileSize
)
1e6
)
{
displayed_size
=
(
gdouble
)
size
/
1.0e3
;
size_string
=
g_strdup_printf
(
_
(
"%.1fK"
),
displayed_size
);
}
else
if
(
size
<
(
GnomeVFSFileSize
)
1e9
)
{
displayed_size
=
(
gdouble
)
size
/
1.0e6
;
size_string
=
g_strdup_printf
(
_
(
"%.1fM"
),
displayed_size
);
}
else
{
displayed_size
=
(
gdouble
)
size
/
1.0e9
;
size_string
=
g_strdup_printf
(
_
(
"%.1fG"
),
displayed_size
);
}
}
size_string
=
gnome_vfs_file_size_to_string
(
size
);
msg
=
g_strdup_printf
(
_
(
"%d %s selected -- %s"
),
count
,
(
count
==
1
)
?
_
(
"file"
)
:
_
(
"files"
),
size_string
);
...
...
@@ -833,3 +804,38 @@ fm_directory_view_sort (FMDirectoryView *view,
#undef ALLOC_RULES
}
/**
* nautilus_file_date_as_string:
*
* Get a user-displayable string representing a file date. The caller
* is responsible for g_free-ing this string.
* @bytes: The date of the file.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar
*
nautilus_file_date_as_string
(
time_t
date
)
{
/* Note that ctime is a funky function that returns a
* string that you're not supposed to free.
*/
return
g_strdup
(
ctime
(
&
date
));
}
/**
* nautilus_file_size_as_string:
*
* Get a user-displayable string representing a file size. The caller
* is responsible for g_free-ing this string.
* @bytes: The size of the file in bytes.
*
* Returns: Newly allocated string ready to display to the user.
*
**/
gchar
*
nautilus_file_size_as_string
(
GnomeVFSFileSize
bytes
)
{
return
gnome_vfs_file_size_to_string
(
bytes
);
}
src/file-manager/fm-directory-view.h
View file @
98d22d4f
...
...
@@ -134,4 +134,11 @@ void fm_directory_view_activate_entry (FMDirectoryView *view,
void
fm_directory_view_notify_selection_changed
(
FMDirectoryView
*
view
);
void
fm_directory_view_populate
(
FMDirectoryView
*
view
);
/* Utility functions for formatting file-related information.
* FIXME: Probably these should be moved to some appropriate place in libnautilus.
*/
gchar
*
nautilus_file_date_as_string
(
time_t
date
);
gchar
*
nautilus_file_size_as_string
(
GnomeVFSFileSize
bytes
);
#endif
/* __FM_DIRECTORY_VIEW_H__ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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