Commit 4356b97c authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Add get_item_count virtual method. Add item count and free space to status

2004-01-06  Alexander Larsson <alexl@redhat.com>

	* src/file-manager/fm-directory-view.[ch]:
	Add get_item_count virtual method.
	Add item count and free space to status bar

	* src/file-manager/fm-icon-view.c (fm_icon_view_get_item_count):
	* src/file-manager/fm-list-view.c (fm_list_view_get_item_count):
	Implement get_iem_count

	* src/file-manager/fm-list-model.[ch] (fm_list_model_get_length):
	Add new function.
parent 4b4a316a
2004-01-06 Alexander Larsson <alexl@redhat.com>
* src/file-manager/fm-directory-view.[ch]:
Add get_item_count virtual method.
Add item count and free space to status bar
* src/file-manager/fm-icon-view.c (fm_icon_view_get_item_count):
* src/file-manager/fm-list-view.c (fm_list_view_get_item_count):
Implement get_iem_count
* src/file-manager/fm-list-model.[ch] (fm_list_model_get_length):
Add new function.
2004-01-06 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/apps_nautilus_preferences.schemas.in:
......
......@@ -223,6 +223,7 @@ struct FMDirectoryViewDetails
guint display_selection_idle_id;
guint update_menus_timeout_id;
guint update_status_idle_id;
guint display_pending_idle_id;
......@@ -347,6 +348,8 @@ static void zoomable_zoom_to_fit_callback (BonoboZoomable
static void schedule_update_menus (FMDirectoryView *view);
static void schedule_update_menus_callback (gpointer callback_data);
static void remove_update_menus_timeout_callback (FMDirectoryView *view);
static void schedule_update_status (FMDirectoryView *view);
static void remove_update_status_idle_callback (FMDirectoryView *view);
static void schedule_idle_display_of_pending_files (FMDirectoryView *view);
static void unschedule_idle_display_of_pending_files (FMDirectoryView *view);
static void unschedule_display_of_pending_files (FMDirectoryView *view);
......@@ -378,6 +381,7 @@ EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, file_changed)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_background_widget)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_item_count)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, is_empty)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, reset_to_defaults)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, restore_default_zoom_level)
......@@ -1649,6 +1653,7 @@ fm_directory_view_finalize (GObject *object)
}
remove_update_menus_timeout_callback (view);
remove_update_status_idle_callback (view);
fm_directory_view_ignore_hidden_file_preferences (view);
......@@ -1692,7 +1697,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
GnomeVFSFileSize non_folder_size;
guint non_folder_count, folder_count, folder_item_count;
gboolean folder_item_count_known;
guint item_count;
guint file_item_count;
GList *p;
char *first_item_name;
char *non_folder_str;
......@@ -1719,8 +1724,8 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
file = p->data;
if (nautilus_file_is_directory (file)) {
folder_count++;
if (nautilus_file_get_directory_item_count (file, &item_count, NULL)) {
folder_item_count += item_count;
if (nautilus_file_get_directory_item_count (file, &file_item_count, NULL)) {
folder_item_count += file_item_count;
} else {
folder_item_count_known = FALSE;
}
......@@ -1807,7 +1812,23 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
}
if (folder_count == 0 && non_folder_count == 0) {
status_string = g_strdup ("");
char *free_space_str;
char *item_count_str;
guint item_count;
item_count = fm_directory_view_get_item_count (view);
item_count_str = g_strdup_printf (ngettext ("%u item", "%u items", item_count), item_count);
free_space_str = nautilus_file_get_volume_free_space (view->details->directory_as_file);
if (free_space_str != NULL) {
status_string = g_strdup_printf (_("%s, Free space: %s"), item_count_str, free_space_str);
g_free (free_space_str);
g_free (item_count_str);
} else {
status_string = item_count_str;
}
} else if (folder_count == 0) {
status_string = g_strdup (non_folder_str);
} else if (non_folder_count == 0) {
......@@ -1987,6 +2008,7 @@ done_loading (FMDirectoryView *view)
if (view->details->nautilus_view != NULL) {
nautilus_view_report_load_complete (view->details->nautilus_view);
schedule_update_menus (view);
schedule_update_status (view);
check_for_directory_hard_limit (view);
uris_selected = view->details->pending_uris_selected;
......@@ -2606,6 +2628,9 @@ files_added_callback (NautilusDirectory *directory,
view = FM_DIRECTORY_VIEW (callback_data);
queue_pending_files (view, files, &view->details->new_added_files);
/* The number of items could have changed */
schedule_update_status (view);
}
static void
......@@ -2618,6 +2643,9 @@ files_changed_callback (NautilusDirectory *directory,
view = FM_DIRECTORY_VIEW (callback_data);
queue_pending_files (view, files, &view->details->new_changed_files);
/* The free space or the number of items could have changed */
schedule_update_status (view);
/* A change in MIME type could affect the Open with menu, for
* one thing, so we need to update menus when files change.
*/
......@@ -2928,6 +2956,16 @@ fm_directory_view_get_selection (FMDirectoryView *view)
get_selection, (view));
}
guint
fm_directory_view_get_item_count (FMDirectoryView *view)
{
g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), 0);
return EEL_CALL_METHOD_WITH_RETURN_VALUE
(FM_DIRECTORY_VIEW_CLASS, view,
get_item_count, (view));
}
/**
* fm_directory_view_get_bonobo_ui_container:
*
......@@ -5778,6 +5816,47 @@ schedule_update_menus (FMDirectoryView *view)
}
}
static void
remove_update_status_idle_callback (FMDirectoryView *view)
{
if (view->details->update_status_idle_id != 0) {
g_source_remove (view->details->update_status_idle_id);
view->details->update_status_idle_id = 0;
}
}
static gboolean
update_status_idle_callback (gpointer data)
{
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
fm_directory_view_display_selection_info (view);
view->details->update_status_idle_id = 0;
return FALSE;
}
static void
schedule_update_status (FMDirectoryView *view)
{
g_assert (FM_IS_DIRECTORY_VIEW (view));
/* Make sure we haven't already destroyed it */
g_assert (view->details->nautilus_view != NULL);
if (view->details->loading) {
/* Don't update status bar while loading the dir */
return;
}
if (view->details->update_status_idle_id == 0) {
view->details->update_status_idle_id =
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE - 20,
update_status_idle_callback, view, NULL);
}
}
/**
* fm_directory_view_notify_selection_changed:
*
......@@ -6262,6 +6341,7 @@ file_changed_callback (NautilusFile *file, gpointer callback_data)
FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data);
schedule_update_menus (view);
schedule_update_status (view);
/* We might have different capabilities, so we need to update
relative icon emblems . (Writeable etc) */
......@@ -7167,6 +7247,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, file_changed);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_background_widget);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_selection);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_item_count);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, is_empty);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, reset_to_defaults);
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, restore_default_zoom_level);
......
......@@ -152,6 +152,8 @@ struct FMDirectoryViewClass {
/* Return an array of locations of selected icons in their view. */
GArray * (* get_selected_icon_locations) (FMDirectoryView *view);
guint (* get_item_count) (FMDirectoryView *view);
/* bump_zoom_level is a function pointer that subclasses must override
* to change the zoom level of an object. */
void (* bump_zoom_level) (FMDirectoryView *view,
......@@ -299,6 +301,7 @@ gboolean fm_directory_view_can_accept_item (Nautilus
void fm_directory_view_display_selection_info (FMDirectoryView *view);
GList * fm_directory_view_get_selection (FMDirectoryView *view);
void fm_directory_view_stop (FMDirectoryView *view);
guint fm_directory_view_get_item_count (FMDirectoryView *view);
gboolean fm_directory_view_can_zoom_in (FMDirectoryView *view);
gboolean fm_directory_view_can_zoom_out (FMDirectoryView *view);
GtkWidget * fm_directory_view_get_background_widget (FMDirectoryView *view);
......
......@@ -1357,6 +1357,33 @@ fm_icon_view_get_selection (FMDirectoryView *view)
return list;
}
static void
count_item (NautilusIconData *icon_data,
gpointer callback_data)
{
guint *count;
count = callback_data;
(*count)++;
}
static guint
fm_icon_view_get_item_count (FMDirectoryView *view)
{
guint count;
g_return_val_if_fail (FM_IS_ICON_VIEW (view), 0);
count = 0;
nautilus_icon_container_for_each
(get_icon_container (FM_ICON_VIEW (view)),
count_item, &count);
return count;
}
static void
set_sort_criterion_by_id (FMIconView *icon_view, const char *id)
{
......@@ -2750,6 +2777,7 @@ fm_icon_view_class_init (FMIconViewClass *klass)
fm_directory_view_class->get_background_widget = fm_icon_view_get_background_widget;
fm_directory_view_class->get_selected_icon_locations = fm_icon_view_get_selected_icon_locations;
fm_directory_view_class->get_selection = fm_icon_view_get_selection;
fm_directory_view_class->get_item_count = fm_icon_view_get_item_count;
fm_directory_view_class->is_empty = fm_icon_view_is_empty;
fm_directory_view_class->remove_file = fm_icon_view_remove_file;
fm_directory_view_class->reset_to_defaults = fm_icon_view_reset_to_defaults;
......
......@@ -674,6 +674,13 @@ fm_list_model_is_empty (FMListModel *model)
return (g_sequence_get_length (model->details->files) == 0);
}
guint
fm_list_model_get_length (FMListModel *model)
{
return g_sequence_get_length (model->details->files);
}
static void
fm_list_model_remove (FMListModel *model, GtkTreeIter *iter)
{
......
......@@ -71,6 +71,7 @@ void fm_list_model_add_file (FMListModel *
void fm_list_model_file_changed (FMListModel *model,
NautilusFile *file);
gboolean fm_list_model_is_empty (FMListModel *model);
guint fm_list_model_get_length (FMListModel *model);
void fm_list_model_remove_file (FMListModel *model,
NautilusFile *file);
void fm_list_model_clear (FMListModel *model);
......
......@@ -1013,6 +1013,15 @@ fm_list_view_get_selection (FMDirectoryView *view)
return list;
}
static guint
fm_list_view_get_item_count (FMDirectoryView *view)
{
g_return_val_if_fail (FM_IS_LIST_VIEW (view), 0);
return fm_list_model_get_length (FM_LIST_VIEW (view)->details->model);
}
static gboolean
fm_list_view_is_empty (FMDirectoryView *view)
{
......@@ -1526,6 +1535,7 @@ fm_list_view_class_init (FMListViewClass *class)
fm_directory_view_class->file_changed = fm_list_view_file_changed;
fm_directory_view_class->get_background_widget = fm_list_view_get_background_widget;
fm_directory_view_class->get_selection = fm_list_view_get_selection;
fm_directory_view_class->get_item_count = fm_list_view_get_item_count;
fm_directory_view_class->is_empty = fm_list_view_is_empty;
fm_directory_view_class->remove_file = fm_list_view_remove_file;
fm_directory_view_class->reset_to_defaults = fm_list_view_reset_to_defaults;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment