diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-01-14 02:04:00 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-01-14 02:04:00 +0000 |
commit | 38e733fe7d7ebfc8e182bc6d9d48258567819f73 (patch) | |
tree | b1fa25c66b27248f56b4c896f9583d6810926f1a | |
parent | fa043157af5843987d18560f1f03b0ee2b693305 (diff) | |
download | nautilus-38e733fe7d7ebfc8e182bc6d9d48258567819f73.tar.gz |
Lots more work pushing code from FMDirectoryView into subclasses. Almost
done now!
-rw-r--r-- | ChangeLog-20000414 | 90 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view-icons.c | 219 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view-list.c | 80 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.c | 372 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.h | 56 |
5 files changed, 474 insertions, 343 deletions
diff --git a/ChangeLog-20000414 b/ChangeLog-20000414 index b5d28ba38..faa2a99ba 100644 --- a/ChangeLog-20000414 +++ b/ChangeLog-20000414 @@ -1,5 +1,95 @@ 2000-01-13 John Sullivan <sullivan@eazel.com> + More work pushing code from FMDirectoryView into subclasses. + Almost done now. + + * src/file-manager/fm-directory-view.h: + Removed enum _FMDirectoryViewMode and its typedef. + Removed field entries_to_display. + Removed transition section holding function prototypes that + were on their way into subclasses. + (fm_directory_view_is_valid_mode): Removed. + (fm_directory_view_get_mode): Removed. + (fm_directory_view_set_mode): Removed. + + (fm_directory_view_begin_adding_entries): New function & signal. + (fm_directory_view_add_entry): New function & signal. + (fm_directory_view_done_adding_entries): New function & signal. + (fm_directory_view_done_sorting_entries): New function & signal. + (fm_directory_view_begin_loading): New function & signal. + + (fm_directory_view_display_selection_info): Newly exposed function. + + *src/file-manager/fm-directory-view.c: + Removed some now-unnecessary #includes. + Added constants for new signals to enum. + Removed global variable for icon cache in favor of already-extant + fm_get_current_icon_cache(). + Removed all references to entries_to_display. + (display_selection_info): Renamed to + fm_directory_view_display_selection_info now that it's public. + (view_has_icon_container): Removed. + (get_icon_container): Moved into subclass FMDirectoryViewIcons. + (add_to_icon_container): Moved into subclass FMDirectoryViewIcons. + (load_icon_container): Moved into subclass FMDirectoryViewIcons. + (display_icons_not_in_layout): Moved into subclass FMDirectoryViewIcons. + (setup_base_uri): Moved into subclass FMDirectoryViewIcons (and renamed + to set_up_base_uri). + (view_has_flist): Removed. + (get_flist): Moved into subclass FMDirectoryViewList. + (add_to_flist): Moved into subclass FMDirectoryViewList. + (class_init): Signal initialization code for begin_adding_entries, + add_entry, done_adding_entries, done_sorting_entries, and begin_loading. + (init): Removed mode-setting line. + (display_pending_entries): Replaced the bulk of this function with three + new signals: begin_adding_entries, add_entry, done_adding_entries. The + loop structure and GnomeVFSFileInfo retrieving part remains. + (directory_load_cb): Deployed new signal begin_loading where setup_base_uri + used to be. + (fm_directory_view_is_valid_mode): Removed. + (fm_directory_view_get_mode): Removed. + (fm_directory_view_set_mode): Removed. + (fm_directory_view_begin_adding_entries): New function, emits signal. + (fm_directory_view_add_entry): New function, emits signal. + (fm_directory_view_done_adding_entries): New function, emits signal. + (fm_directory_view_done_sorting_entries): New function, emits signal. + (fm_directory_view_begin_loading): New function, emits signal. + (fm_directory_view_sort): Replaced some icon-container-specific + code with fm_directory_view_done_sorting_entries(). + + *src/file-manager/fm-directory-view-icons.c: + (fm_directory_view_icons_initialize_class): Wired up signal handlers + for add_entry, done_adding_entries, done_sorting_entries, and begin_loading. + (fm_directory_view_icons_initialize): Removed set_mode call. + (display_icons_not_in_layout): Moved here from superclass FMDirectoryView. + (get_icon_container): Moved here from superclass FMDirectoryView. + (add_to_icon_container): Moved here from superclass FMDirectoryView. + (load_icon_container): Moved here from superclass FMDirectoryView. + (set_up_base_uri): Moved here from superclass FMDirectoryView. + (fm_directory_view_icons_add_entry): New signal handler function, code + taken and simplified from superclass FMDirectoryView. + (fm_directory_view_icons_done_adding_entries): New signal handler + function, code taken and simplified from superclass FMDirectoryView. + (fm_directory_view_icons_done_sorting_entries): New signal handler + function, code taken and simplified from superclass FMDirectoryView. + (fm_directory_view_icons_begin_loading): New signal handler function, + code taken and simplified from superclass FMDirectoryView. + + *src/file-manager/fm-directory-view-list.c: + (fm_directory_view_list_initialize_class): Wired up signal handlers + for begin_adding_entries, add_entry, and done_adding_entries + (fm_directory_view_list_initialize): Removed set_mode call. + (get_flist): Moved here from superclass FMDirectoryView. + (add_to_flist): Moved here from superclass FMDirectoryView. + (fm_directory_view_list_begin_adding_entries): New signal handler + function, code taken and simplified from superclass FMDirectoryView. + (fm_directory_view_list_add_entry): New signal handler function, code + taken and simplified from superclass FMDirectoryView. + (fm_directory_view_list_done_adding_entries): New signal handler + function, code taken and simplified from superclass FMDirectoryView. + +2000-01-13 John Sullivan <sullivan@eazel.com> + * libnautilus/nautilus-gtk-macros.h: Defined macros for use when a signal must be overridden by subclasses. * src/file-manager/fm-directory-view.c: Deployed these diff --git a/src/file-manager/fm-directory-view-icons.c b/src/file-manager/fm-directory-view-icons.c index 993008f03..40914b117 100644 --- a/src/file-manager/fm-directory-view-icons.c +++ b/src/file-manager/fm-directory-view-icons.c @@ -32,21 +32,41 @@ #include "fm-directory-view.h" #include "fm-directory-view-icons.h" +#include "fm-icon-cache.h" static FMDirectoryViewClass *parent_class = NULL; /* forward declarations */ static GnomeIconContainer *create_icon_container (FMDirectoryViewIcons *view); -static gint display_icon_container_selection_info_idle_cb (gpointer data); -static void fm_directory_view_icons_clear (FMDirectoryView *view); -static void icon_container_activate_cb (GnomeIconContainer *icon_container, - const gchar *name, - gpointer icon_data, - gpointer data); -static void icon_container_selection_changed_cb (GnomeIconContainer *container, - gpointer data); - +static gint display_icon_container_selection_info_idle_cb + (gpointer data); +static void display_icons_not_in_layout (FMDirectoryView *view); +static void fm_directory_view_icons_add_entry (FMDirectoryView *view, + GnomeVFSFileInfo *info); +static void fm_directory_view_icons_done_adding_entries + (FMDirectoryView *view); +static void fm_directory_view_icons_done_sorting_entries + (FMDirectoryView *view); +static void fm_directory_view_icons_begin_loading + (FMDirectoryView *view); +static void fm_directory_view_icons_clear (FMDirectoryView *view); +static void icon_container_activate_cb (GnomeIconContainer *icon_container, + const gchar *name, + gpointer icon_data, + gpointer data); +static void icon_container_selection_changed_cb (GnomeIconContainer *container, + gpointer data); + +static GnomeIconContainer *get_icon_container (FMDirectoryView *view); +static void add_to_icon_container (FMDirectoryView *view, + FMIconCache *icon_manager, + GnomeIconContainer *icon_container, + GnomeVFSFileInfo *info, + gboolean with_layout); +static void load_icon_container (FMDirectoryView *view, + GnomeIconContainer *icon_container); +static void set_up_base_uri (FMDirectoryView *view); /* GtkObject methods. */ @@ -70,7 +90,17 @@ fm_directory_view_icons_initialize_class (gpointer klass) parent_class = gtk_type_class (gtk_type_parent(object_class->type)); object_class->destroy = fm_directory_view_icons_destroy; - fm_directory_view_class->clear = fm_directory_view_icons_clear; + + fm_directory_view_class->clear + = fm_directory_view_icons_clear; + fm_directory_view_class->add_entry + = fm_directory_view_icons_add_entry; + fm_directory_view_class->done_adding_entries + = fm_directory_view_icons_done_adding_entries; + fm_directory_view_class->done_sorting_entries + = fm_directory_view_icons_done_sorting_entries; + fm_directory_view_class->begin_loading + = fm_directory_view_icons_begin_loading; } static void @@ -79,12 +109,8 @@ fm_directory_view_icons_initialize (gpointer object, gpointer klass) GnomeIconContainer *icon_container; g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (object)); - - /* FIXME: eventually get rid of set_mode call entirely. */ - fm_directory_view_set_mode (FM_DIRECTORY_VIEW (object), - FM_DIRECTORY_VIEW_MODE_ICONS); - - g_assert (GTK_BIN (object)->child == NULL); + g_return_if_fail (GTK_BIN (object)->child == NULL); + icon_container = create_icon_container (object); gnome_icon_container_set_icon_mode (icon_container, GNOME_ICON_CONTAINER_NORMAL_ICONS); @@ -134,7 +160,7 @@ display_icon_container_selection_info_idle_cb (gpointer data) icon_container = get_icon_container (view); selection = gnome_icon_container_get_selection (icon_container); - display_selection_info (view, selection); + fm_directory_view_display_selection_info (view, selection); g_list_free (selection); view->display_selection_idle_id = 0; @@ -143,6 +169,124 @@ display_icon_container_selection_info_idle_cb (gpointer data) } static void +display_icons_not_in_layout (FMDirectoryView *view) +{ + FMIconCache *icon_manager; + GnomeIconContainer *icon_container; + GList *p; + + if (view->icons_not_in_layout == NULL) + return; + + icon_manager = fm_get_current_icon_cache(); + + icon_container = get_icon_container (view); + g_return_if_fail (icon_container != NULL); + + /* FIXME: This will block if there are many files. */ + + for (p = view->icons_not_in_layout; p != NULL; p = p->next) { + GnomeVFSFileInfo *info; + + info = p->data; + add_to_icon_container (view, icon_manager, + icon_container, info, FALSE); + } + + g_list_free (view->icons_not_in_layout); + view->icons_not_in_layout = NULL; +} + + +static GnomeIconContainer * +get_icon_container (FMDirectoryView *view) +{ + g_return_val_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (view), NULL); + g_return_val_if_fail (GNOME_IS_ICON_CONTAINER (GTK_BIN (view)->child), NULL); + + return GNOME_ICON_CONTAINER (GTK_BIN (view)->child); +} + +static void +add_to_icon_container (FMDirectoryView *view, + FMIconCache *icon_manager, + GnomeIconContainer *icon_container, + GnomeVFSFileInfo *info, + gboolean with_layout) +{ + GdkPixbuf *image; + + g_return_if_fail(info); + + image = fm_icon_cache_get_icon (icon_manager, info); + + if (! with_layout || view->icon_layout == NULL) { + gnome_icon_container_add_pixbuf_auto (icon_container, + image, + info->name, + info); + } else { + gboolean result; + + result = gnome_icon_container_add_pixbuf_with_layout + (icon_container, image, info->name, info, + view->icon_layout); + if (! result) + view->icons_not_in_layout = g_list_prepend + (view->icons_not_in_layout, info); + } +} + +static void +load_icon_container (FMDirectoryView *view, + GnomeIconContainer *icon_container) +{ + gnome_icon_container_clear (icon_container); + + if (view->directory_list != NULL) { + GnomeVFSDirectoryListPosition *position; + FMIconCache *icon_manager; + + icon_manager = fm_get_current_icon_cache(); + + position = gnome_vfs_directory_list_get_first_position + (view->directory_list); + + while (position != view->current_position) { + GnomeVFSFileInfo *info; + + info = gnome_vfs_directory_list_get + (view->directory_list, position); + + g_return_if_fail(info); + add_to_icon_container (view, icon_manager, + icon_container, info, TRUE); + + position = gnome_vfs_directory_list_position_next + (position); + } + } + +} + +/* Set up the base URI for Drag & Drop operations. */ +static void +set_up_base_uri (FMDirectoryView *view) +{ + gchar *txt_uri; + + g_return_if_fail (get_icon_container(view) != NULL); + + txt_uri = gnome_vfs_uri_to_string (view->uri, 0); + if (txt_uri == NULL) + return; + + gnome_icon_container_set_base_uri (get_icon_container (view), txt_uri); + + g_free (txt_uri); +} + +static void fm_directory_view_icons_clear (FMDirectoryView *view) { g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (view)); @@ -150,6 +294,47 @@ fm_directory_view_icons_clear (FMDirectoryView *view) gnome_icon_container_clear (get_icon_container (view)); } +static void +fm_directory_view_icons_add_entry (FMDirectoryView *view, GnomeVFSFileInfo *info) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (view)); + + add_to_icon_container (view, + fm_get_current_icon_cache(), + get_icon_container (view), + info, + TRUE); +} + +static void +fm_directory_view_icons_done_adding_entries (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (view)); + + display_icons_not_in_layout (view); +} + +static void +fm_directory_view_icons_done_sorting_entries (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (view)); + + /* This will make sure icons are re-laid out according to the new + order. */ + if (view->icon_layout != NULL) + view->icon_layout = NULL; + + load_icon_container (view, get_icon_container (view)); +} + +static void +fm_directory_view_icons_begin_loading (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_ICONS (view)); + + set_up_base_uri (view); +} + /* WARNING WARNING WARNING diff --git a/src/file-manager/fm-directory-view-list.c b/src/file-manager/fm-directory-view-list.c index 2e9d1e460..4ba949ec9 100644 --- a/src/file-manager/fm-directory-view-list.c +++ b/src/file-manager/fm-directory-view-list.c @@ -40,11 +40,22 @@ static FMDirectoryViewClass *parent_class = NULL; /* forward declarations */ static GtkFList *create_flist (FMDirectoryViewList *view); +static GtkFList *get_flist (FMDirectoryViewList *view); +void add_to_flist (FMIconCache *icon_manager, + GtkFList *flist, + GnomeVFSFileInfo *info); static gint display_flist_selection_info_idle_cb (gpointer data); static void flist_activate_cb (GtkFList *flist, gpointer entry_data, gpointer data); static void flist_selection_changed_cb (GtkFList *flist, gpointer data); +static void fm_directory_view_list_begin_adding_entries + (FMDirectoryView *view); +static void fm_directory_view_list_add_entry + (FMDirectoryView *view, + GnomeVFSFileInfo *info); +static void fm_directory_view_list_done_adding_entries + (FMDirectoryView *view); static void fm_directory_view_list_clear (FMDirectoryView *view); @@ -71,19 +82,19 @@ fm_directory_view_list_initialize_class (gpointer klass) parent_class = gtk_type_class (gtk_type_parent(object_class->type)); object_class->destroy = fm_directory_view_list_destroy; + fm_directory_view_class->clear = fm_directory_view_list_clear; + fm_directory_view_class->begin_adding_entries = fm_directory_view_list_begin_adding_entries; + fm_directory_view_class->add_entry = fm_directory_view_list_add_entry; + fm_directory_view_class->done_adding_entries = fm_directory_view_list_done_adding_entries; } static void fm_directory_view_list_initialize (gpointer object, gpointer klass) { g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (object)); - - /* FIXME: eventually get rid of set_mode call entirely. */ - fm_directory_view_set_mode (FM_DIRECTORY_VIEW (object), - FM_DIRECTORY_VIEW_MODE_DETAILED); - - g_assert (GTK_BIN (object)->child == NULL); + g_return_if_fail (GTK_BIN (object)->child == NULL); + create_flist (object); } @@ -158,11 +169,13 @@ display_flist_selection_info_idle_cb (gpointer data) GtkFList *flist; GList *selection; + g_return_val_if_fail (FM_IS_DIRECTORY_VIEW_LIST (data), FALSE); + view = FM_DIRECTORY_VIEW (data); - flist = get_flist (view); + flist = get_flist (FM_DIRECTORY_VIEW_LIST (view)); selection = gtk_flist_get_selection (flist); - display_selection_info (view, selection); + fm_directory_view_display_selection_info (view, selection); g_list_free (selection); view->display_selection_idle_id = 0; @@ -206,11 +219,60 @@ flist_selection_changed_cb (GtkFList *flist, view); } +void +add_to_flist (FMIconCache *icon_manager, + GtkFList *flist, + GnomeVFSFileInfo *info) +{ + GtkCList *clist; + gchar *text[2]; + + text[0] = info->name; + text[1] = NULL; + + clist = GTK_CLIST (flist); + gtk_clist_append (clist, text); + gtk_clist_set_row_data (clist, clist->rows - 1, info); +} + +static GtkFList * +get_flist (FMDirectoryViewList *view) +{ + g_return_val_if_fail (FM_IS_DIRECTORY_VIEW_LIST (view), NULL); + g_return_val_if_fail (GTK_IS_FLIST (GTK_BIN (view)->child), NULL); + + return GTK_FLIST (GTK_BIN (view)->child); +} + static void fm_directory_view_list_clear (FMDirectoryView *view) { g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (view)); - gtk_clist_clear(GTK_CLIST(get_flist(view))); + gtk_clist_clear (GTK_CLIST (get_flist (FM_DIRECTORY_VIEW_LIST (view)))); +} + +static void +fm_directory_view_list_begin_adding_entries (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (view)); + + gtk_clist_freeze (GTK_CLIST (get_flist (FM_DIRECTORY_VIEW_LIST (view)))); +} + +static void +fm_directory_view_list_add_entry (FMDirectoryView *view, GnomeVFSFileInfo *info) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (view)); + + add_to_flist (fm_get_current_icon_cache(), get_flist (FM_DIRECTORY_VIEW_LIST (view)), info); +} + +static void +fm_directory_view_list_done_adding_entries (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (view)); + + gtk_clist_thaw (GTK_CLIST (get_flist (FM_DIRECTORY_VIEW_LIST (view)))); } diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 55aac7fd2..8ba3aa086 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -29,37 +29,33 @@ #include <gnome.h> #include <libnautilus/libnautilus.h> -#include <libnautilus/gnome-icon-container.h> -#include <libnautilus/gtkflist.h> #include <libnautilus/nautilus-gtk-macros.h> #include "fm-directory-view.h" -#include "fm-icon-cache.h" #include "fm-public-api.h" #define FM_DEBUG(x) g_message x -#define WITH_LAYOUT TRUE #define DISPLAY_TIMEOUT_INTERVAL 500 #define ENTRIES_PER_CB 1 enum { + ADD_ENTRY, + BEGIN_ADDING_ENTRIES, CLEAR, + DONE_ADDING_ENTRIES, + DONE_SORTING_ENTRIES, + BEGIN_LOADING, LAST_SIGNAL }; static guint fm_directory_view_signals[LAST_SIGNAL] = { 0 }; static GtkScrolledWindowClass *parent_class = NULL; -/* FIXME this no longer has any reason to be global, - given fm_get_current_icon_cache() -*/ -static FMIconCache *icm = NULL; - void -display_selection_info (FMDirectoryView *view, - GList *selection) +fm_directory_view_display_selection_info (FMDirectoryView *view, + GList *selection) { GnomeVFSFileSize size; guint count; @@ -127,132 +123,6 @@ display_selection_info (FMDirectoryView *view, } -/* GnomeIconContainer handling. */ - -static gboolean -view_has_icon_container (FMDirectoryView *view) -{ - return (view->mode == FM_DIRECTORY_VIEW_MODE_ICONS - || view->mode == FM_DIRECTORY_VIEW_MODE_SMALLICONS); -} - -GnomeIconContainer * -get_icon_container (FMDirectoryView *view) -{ - GtkBin *bin; - - g_return_val_if_fail (view_has_icon_container (view), NULL); - - bin = GTK_BIN (view); - - if (bin->child == NULL) - return NULL; /* Avoid GTK+ complaints. */ - else - return GNOME_ICON_CONTAINER (bin->child); -} - -static void -add_to_icon_container (FMDirectoryView *view, - FMIconCache *icon_manager, - GnomeIconContainer *icon_container, - GnomeVFSFileInfo *info, - gboolean with_layout) -{ - GdkPixbuf *image; - - g_return_if_fail(info); - - image = fm_icon_cache_get_icon (icon_manager, info); - - if (! with_layout || view->icon_layout == NULL) { - gnome_icon_container_add_pixbuf_auto (icon_container, - image, - info->name, - info); - } else { - gboolean result; - - result = gnome_icon_container_add_pixbuf_with_layout - (icon_container, image, info->name, info, - view->icon_layout); - if (! result) - view->icons_not_in_layout = g_list_prepend - (view->icons_not_in_layout, info); - } -} - -void -load_icon_container (FMDirectoryView *view, - GnomeIconContainer *icon_container) -{ - gnome_icon_container_clear (icon_container); - - if (view->directory_list != NULL) { - GnomeVFSDirectoryListPosition *position; - - if (!icm) - icm = fm_get_current_icon_cache(); - - position = gnome_vfs_directory_list_get_first_position - (view->directory_list); - - while (position != view->current_position) { - GnomeVFSFileInfo *info; - - info = gnome_vfs_directory_list_get - (view->directory_list, position); - - g_return_if_fail(info); - add_to_icon_container (view, icm, - icon_container, info, WITH_LAYOUT); - - position = gnome_vfs_directory_list_position_next - (position); - } - } - -} - - -/* GtkFList handling. */ - -static gboolean -view_has_flist (FMDirectoryView *view) -{ - return (view->mode == FM_DIRECTORY_VIEW_MODE_DETAILED - || view->mode == FM_DIRECTORY_VIEW_MODE_CUSTOM); -} - -GtkFList * -get_flist (FMDirectoryView *view) -{ - GtkBin *bin; - - g_return_val_if_fail (view_has_flist (view), NULL); - - bin = GTK_BIN (view); - - if (bin->child == NULL) - return NULL; /* Avoid GTK+ complaints. */ - else - return GTK_FLIST (bin->child); -} - -void -add_to_flist (FMIconCache *icon_manager, - GtkFList *flist, - GnomeVFSFileInfo *info) -{ - GtkCList *clist; - gchar *text[2]; - - text[0] = info->name; - text[1] = NULL; - - clist = GTK_CLIST (flist); - gtk_clist_append (clist, text); - gtk_clist_set_row_data (clist, clist->rows - 1, info); -} static void notify_location_change_cb (NautilusViewFrame *view_frame, Nautilus_NavigationInfo *nav_context, FMDirectoryView *directory_view) @@ -304,6 +174,7 @@ destroy (GtkObject *object) } +NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_entry); NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear); static void @@ -323,24 +194,60 @@ class_init (FMDirectoryViewClass *class) GTK_SIGNAL_OFFSET (FMDirectoryViewClass, clear), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + fm_directory_view_signals[BEGIN_ADDING_ENTRIES] = + gtk_signal_new ("begin_adding_entries", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FMDirectoryViewClass, begin_adding_entries), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + fm_directory_view_signals[ADD_ENTRY] = + gtk_signal_new ("add_entry", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FMDirectoryViewClass, add_entry), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + fm_directory_view_signals[DONE_ADDING_ENTRIES] = + gtk_signal_new ("done_adding_entries", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FMDirectoryViewClass, done_adding_entries), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + fm_directory_view_signals[DONE_SORTING_ENTRIES] = + gtk_signal_new ("done_sorting_entries", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FMDirectoryViewClass, done_sorting_entries), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + fm_directory_view_signals[BEGIN_LOADING] = + gtk_signal_new ("begin_loading", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FMDirectoryViewClass, begin_loading), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (FM_DIRECTORY_VIEW_CLASS, class, fm_directory_view, + add_entry); + NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (FM_DIRECTORY_VIEW_CLASS, + class, + fm_directory_view, clear); } static void init (FMDirectoryView *directory_view) { - directory_view->mode = FM_DIRECTORY_VIEW_MODE_NONE; - directory_view->uri = NULL; directory_view->vfs_async_handle = NULL; directory_view->directory_list = NULL; directory_view->current_position = GNOME_VFS_DIRECTORY_LIST_POSITION_NONE; - directory_view->entries_to_display = 0; directory_view->display_timeout_id = 0; @@ -405,7 +312,6 @@ stop_load (FMDirectoryView *view, gboolean error) } view->current_position = GNOME_VFS_DIRECTORY_LIST_POSITION_NONE; - view->entries_to_display = 0; view->directory_list = NULL; memset(&pri, 0, sizeof(pri)); @@ -420,89 +326,22 @@ stop_load (FMDirectoryView *view, gboolean error) static void display_pending_entries (FMDirectoryView *view) { - FMIconCache *icon_manager; - GnomeIconContainer *icon_container; - GtkFList *flist; - guint i; + fm_directory_view_begin_adding_entries (view); - FM_DEBUG (("Adding %d entries.", view->entries_to_display)); - - if(!icm) - icm = fm_get_current_icon_cache(); - icon_manager = icm; - - if (view_has_icon_container (view)) { - icon_container = get_icon_container (view); - flist = NULL; - } else { - icon_container = NULL; - flist = get_flist (view); - gtk_clist_freeze (GTK_CLIST (flist)); - } - - for (i = 0; i < view->entries_to_display - && view->current_position != GNOME_VFS_DIRECTORY_LIST_POSITION_NONE; i++) { + while (view->current_position != GNOME_VFS_DIRECTORY_LIST_POSITION_NONE) + { GnomeVFSFileInfo *info; info = gnome_vfs_directory_list_get (view->directory_list, view->current_position); - if (icon_container != NULL) - add_to_icon_container (view, icon_manager, - icon_container, info, WITH_LAYOUT); - else - add_to_flist (icon_manager, flist, info); + fm_directory_view_add_entry (view, info); view->current_position = gnome_vfs_directory_list_position_next (view->current_position); } - if (i != view->entries_to_display) - g_warning("BROKEN! we thought we had %d items, actually had %d", - view->entries_to_display, i); - - if (flist != NULL) - gtk_clist_thaw (GTK_CLIST (flist)); - - view->entries_to_display = 0; - - FM_DEBUG (("Done.")); -} - -static void -display_icons_not_in_layout (FMDirectoryView *view) -{ - FMIconCache *icon_manager; - GnomeIconContainer *icon_container; - GList *p; - - if (view->icons_not_in_layout == NULL) - return; - - FM_DEBUG (("Adding entries not in layout.")); - - if (!icm) - icm = fm_get_current_icon_cache(); - icon_manager = icm; - - icon_container = get_icon_container (view); - g_return_if_fail (icon_container != NULL); - - /* FIXME: This will block if there are many files. */ - - for (p = view->icons_not_in_layout; p != NULL; p = p->next) { - GnomeVFSFileInfo *info; - - info = p->data; - add_to_icon_container (view, icon_manager, - icon_container, info, FALSE); - FM_DEBUG (("Adding `%s'", info->name)); - } - - FM_DEBUG (("Done with entries not in layout.")); - - g_list_free (view->icons_not_in_layout); - view->icons_not_in_layout = NULL; + fm_directory_view_done_adding_entries (view); } static gboolean @@ -522,27 +361,6 @@ display_timeout_cb (gpointer data) } -/* Set up the base URI for Drag & Drop operations. */ -static void -setup_base_uri (FMDirectoryView *view) -{ - GnomeIconContainer *icon_container; - gchar *txt_uri; - - txt_uri = gnome_vfs_uri_to_string (view->uri, 0); - if (txt_uri == NULL) - return; - - if (view_has_icon_container (view)) - { - icon_container = get_icon_container (view); - if (icon_container != NULL) - gnome_icon_container_set_base_uri (icon_container, txt_uri); - } - - g_free (txt_uri); -} - static void directory_load_cb (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, @@ -559,14 +377,14 @@ directory_load_cb (GnomeVFSAsyncHandle *handle, if (view->directory_list == NULL) { if (result == GNOME_VFS_OK || result == GNOME_VFS_ERROR_EOF) { - setup_base_uri (view); + fm_directory_view_begin_loading (view); + view->directory_list = list; - /* FIXME just to make sure. But these should be + /* FIXME just to make sure. But this should be already set somewhere else. */ view->current_position = GNOME_VFS_DIRECTORY_LIST_POSITION_NONE; - view->entries_to_display = 0; if (result != GNOME_VFS_ERROR_EOF) view->display_timeout_id @@ -582,15 +400,12 @@ directory_load_cb (GnomeVFSAsyncHandle *handle, } } - if(!view->current_position && list) + if(view->current_position == GNOME_VFS_DIRECTORY_LIST_POSITION_NONE && list) view->current_position = gnome_vfs_directory_list_get_position (list); - view->entries_to_display += entries_read; - if (result == GNOME_VFS_ERROR_EOF) { display_pending_entries (view); - display_icons_not_in_layout (view); stop_load (view, FALSE); /* gtk_signal_emit (GTK_OBJECT (view), signals[LOAD_DONE]); */ } else if (result != GNOME_VFS_OK) { @@ -602,21 +417,6 @@ directory_load_cb (GnomeVFSAsyncHandle *handle, } -gboolean -fm_directory_view_is_valid_mode (FMDirectoryViewMode mode) -{ - switch (mode) { - case FM_DIRECTORY_VIEW_MODE_ICONS: - case FM_DIRECTORY_VIEW_MODE_SMALLICONS: - case FM_DIRECTORY_VIEW_MODE_DETAILED: - case FM_DIRECTORY_VIEW_MODE_CUSTOM: - return TRUE; - case FM_DIRECTORY_VIEW_MODE_NONE: - default: - return FALSE; - } -} - GtkType fm_directory_view_get_type (void) { @@ -648,37 +448,53 @@ fm_directory_view_new (void) return gtk_widget_new(fm_directory_view_get_type (), NULL); } -FMDirectoryViewMode -fm_directory_view_get_mode (FMDirectoryView *view) + +void +fm_directory_view_clear (FMDirectoryView *view) { - g_return_val_if_fail (view != NULL, FM_DIRECTORY_VIEW_MODE_ICONS); - g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), - FM_DIRECTORY_VIEW_MODE_ICONS); + g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); - return view->mode; + gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[CLEAR]); } void -fm_directory_view_set_mode (FMDirectoryView *view, - FMDirectoryViewMode new_mode) +fm_directory_view_begin_adding_entries (FMDirectoryView *view) { - g_return_if_fail (view != NULL); g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); - if (view->mode == new_mode) - return; + gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[BEGIN_ADDING_ENTRIES]); +} + +void +fm_directory_view_add_entry (FMDirectoryView *view, GnomeVFSFileInfo *info) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); - view->mode = new_mode; + gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[ADD_ENTRY], info); } - void -fm_directory_view_clear (FMDirectoryView *view) +fm_directory_view_done_adding_entries (FMDirectoryView *view) { g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); - g_print ("called fm_directory_view_clear"); - gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[CLEAR]); + gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[DONE_ADDING_ENTRIES]); +} + +void +fm_directory_view_done_sorting_entries (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); + + gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[DONE_SORTING_ENTRIES]); +} + +void +fm_directory_view_begin_loading (FMDirectoryView *view) +{ + g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); + + gtk_signal_emit (GTK_OBJECT (view), fm_directory_view_signals[BEGIN_LOADING]); } void @@ -740,7 +556,6 @@ fm_directory_view_stop (FMDirectoryView *view) return; display_pending_entries (view); - display_icons_not_in_layout (view); stop_load (view, FALSE); } @@ -750,7 +565,6 @@ fm_directory_view_sort (FMDirectoryView *view, FMDirectoryViewSortType sort_type) { GnomeVFSDirectorySortRule *rules; - GnomeIconContainer *icon_container; #define ALLOC_RULES(n) alloca ((n) * sizeof (GnomeVFSDirectorySortRule)) @@ -790,15 +604,7 @@ fm_directory_view_sort (FMDirectoryView *view, FM_DEBUG (("Sorting.")); gnome_vfs_directory_list_sort (view->directory_list, FALSE, rules); - /* This will make sure icons are re-laid out according to the new - order. */ - if (view->icon_layout != NULL) - view->icon_layout = NULL; - - /* FIXME FIXME FIXME */ - icon_container = get_icon_container (view); - if (icon_container != NULL) - load_icon_container (view, icon_container); + fm_directory_view_done_sorting_entries(view); #undef ALLOC_RULES } diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h index 954cf4bae..22bb23ac3 100644 --- a/src/file-manager/fm-directory-view.h +++ b/src/file-manager/fm-directory-view.h @@ -31,15 +31,6 @@ #include <libnautilus/gtkscrollframe.h> -enum _FMDirectoryViewMode { - FM_DIRECTORY_VIEW_MODE_NONE, /* Internal */ - FM_DIRECTORY_VIEW_MODE_ICONS, - FM_DIRECTORY_VIEW_MODE_SMALLICONS, - FM_DIRECTORY_VIEW_MODE_DETAILED, - FM_DIRECTORY_VIEW_MODE_CUSTOM -}; -typedef enum _FMDirectoryViewMode FMDirectoryViewMode; - enum _FMDirectoryViewSortType { FM_DIRECTORY_VIEW_SORT_BYNAME, FM_DIRECTORY_VIEW_SORT_BYSIZE, @@ -60,13 +51,10 @@ typedef struct _FMDirectoryViewClass FMDirectoryViewClass; struct _FMDirectoryView { GtkScrolledWindow scroll_frame; - FMDirectoryViewMode mode; - NautilusContentViewFrame *view_frame; GnomeVFSDirectoryList *directory_list; GnomeVFSDirectoryListPosition current_position; - guint entries_to_display; guint display_timeout_id; @@ -85,22 +73,34 @@ struct _FMDirectoryViewClass { GtkScrolledWindowClass parent_class; void (* clear) (FMDirectoryView *view); + void (* begin_adding_entries) (FMDirectoryView *view); + void (* add_entry) (FMDirectoryView *view, GnomeVFSFileInfo *info); + void (* done_adding_entries) (FMDirectoryView *view); + void (* done_sorting_entries) (FMDirectoryView *view); + void (* begin_loading) (FMDirectoryView *view); }; -gboolean fm_directory_view_is_valid_mode - (FMDirectoryViewMode mode); GtkType fm_directory_view_get_type (void); GtkWidget *fm_directory_view_new (void); -void fm_directory_view_set_mode (FMDirectoryView *view, - FMDirectoryViewMode mode); -FMDirectoryViewMode - fm_directory_view_get_mode (FMDirectoryView *view); void fm_directory_view_load_uri (FMDirectoryView *view, const char *uri); void fm_directory_view_clear (FMDirectoryView *view); -void fm_directory_view_stop (FMDirectoryView *view); +void fm_directory_view_begin_adding_entries + (FMDirectoryView *view); +void fm_directory_view_add_entry + (FMDirectoryView *view, GnomeVFSFileInfo *info); +void fm_directory_view_done_adding_entries + (FMDirectoryView *view); + +void fm_directory_view_done_sorting_entries + (FMDirectoryView *view); + +void fm_directory_view_begin_loading + (FMDirectoryView *view); + +void fm_directory_view_stop (FMDirectoryView *view); void fm_directory_view_sort (FMDirectoryView *view, FMDirectoryViewSortType sort_type); @@ -110,22 +110,10 @@ NautilusContentViewFrame * -/* Private transition section: These are here only while I'm in the process - * of moving code into the subclasses. sullivan@eazel.com 1/11/2000 - */ - -#include <libnautilus/gtkflist.h> -#include "fm-icon-cache.h" - -void add_to_flist (FMIconCache *icon_manager, - GtkFList *flist, - GnomeVFSFileInfo *info); -void display_selection_info (FMDirectoryView *view, GList *selection); -GtkFList *get_flist (FMDirectoryView *view); -GnomeIconContainer *get_icon_container (FMDirectoryView *view); -void load_icon_container (FMDirectoryView *view, GnomeIconContainer *icon_container); +/* display_selection_info is used by subclasses. No one else should call it. */ +void fm_directory_view_display_selection_info + (FMDirectoryView *view, GList *selection); -/* End of private transition section */ #endif /* __FM_DIRECTORY_VIEW_H__ */ |