Commit 8f1491ea authored by John Sullivan's avatar John Sullivan

Some changes towards fixing the architecture for sorting in directory views.

parent 920e9eb8
2000-01-26 John Sullivan <sullivan@eazel.com>
A few changes in the direction of improving the directory
view sorting architecture. No visible effects yet.
* src/file-manager/fm-directory-view-icons.c:
(create_icon_container): Took out useless call to
fm_directory_view_populate().
* src/file-manager/fm-directory-view-list.c:
(fm_directory_view_list_sort_items): New function, extracted
from column_clicked_cb, that does the actual sorting.
(column_clicked_cb): Replaced actual sorting code with
call to new fm_directory_view_list_sort_items; retained
setup code.
(create_flist): Took out useless call to
fm_directory_view_populate().
* src/file-manager/fm-directory-view.h:
(fm_directory_view_populate): Removed this call from public API.
* src/file-manager/fm-directory-view.c:
(fm_directory_view_populate): Made static and renamed to
..._repopulate now that I better understand its use. Soon it will
go away entirely.
2000-01-26 Andy Hertzfeld <andy@eazel.com>
* libnautilus/gnome-icon-container-dnd.c:
......
......@@ -192,8 +192,6 @@ create_icon_container (FMDirectoryViewIcons *icon_view)
gtk_container_add (GTK_CONTAINER (icon_view), GTK_WIDGET (icon_container));
gtk_widget_show (GTK_WIDGET (icon_container));
fm_directory_view_populate (FM_DIRECTORY_VIEW (icon_view));
return icon_container;
}
......
......@@ -88,6 +88,9 @@ static void fm_directory_view_list_initialize_class (gpointer klass);
static void fm_directory_view_list_destroy (GtkObject *object);
static void fm_directory_view_list_done_adding_entries
(FMDirectoryView *view);
static void fm_directory_view_list_sort_items (FMDirectoryViewList *list_view,
int column,
gboolean reversed);
static GtkFList *get_flist (FMDirectoryViewList *list_view);
static GtkWidget *get_sort_indicator (GtkFList *flist,
gint column,
......@@ -157,6 +160,8 @@ fm_directory_view_list_initialize (gpointer object, gpointer klass)
list_view = FM_DIRECTORY_VIEW_LIST (object);
list_view->details = g_new0 (FMDirectoryViewListDetails, 1);
/* FIXME: These should be read from metadata */
list_view->details->sort_column = LIST_VIEW_COLUMN_NONE;
list_view->details->sort_reversed = FALSE;
list_view->details->icon_size = NAUTILUS_ICON_SIZE_SMALLER;
......@@ -176,55 +181,24 @@ static void
column_clicked_cb (GtkCList *clist, gint column, gpointer user_data)
{
FMDirectoryViewList *list_view;
FMDirectoryViewSortType sort_type;
GtkFList *flist;
gboolean reversed;
g_return_if_fail (GTK_IS_FLIST (clist));
g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (user_data));
g_return_if_fail (get_flist (FM_DIRECTORY_VIEW_LIST (user_data)) == GTK_FLIST (clist));
list_view = FM_DIRECTORY_VIEW_LIST (user_data);
sort_type = FM_DIRECTORY_VIEW_SORT_NONE;
flist = GTK_FLIST (clist);
switch (column)
{
case LIST_VIEW_COLUMN_ICON:
sort_type = FM_DIRECTORY_VIEW_SORT_BYTYPE;
break;
case LIST_VIEW_COLUMN_NAME:
sort_type = FM_DIRECTORY_VIEW_SORT_BYNAME;
break;
case LIST_VIEW_COLUMN_SIZE:
sort_type = FM_DIRECTORY_VIEW_SORT_BYSIZE;
break;
case LIST_VIEW_COLUMN_DATE_MODIFIED:
sort_type = FM_DIRECTORY_VIEW_SORT_BYMTIME;
break;
case LIST_VIEW_COLUMN_MIME_TYPE:
sort_type = FM_DIRECTORY_VIEW_SORT_BYTYPE;
break;
default: g_assert_not_reached();
}
hide_sort_indicator (flist, list_view->details->sort_column);
if (column == list_view->details->sort_column)
{
list_view->details->sort_reversed = !list_view->details->sort_reversed;
reversed = !list_view->details->sort_reversed;
}
else
{
list_view->details->sort_reversed = FALSE;
list_view->details->sort_column = column;
reversed = FALSE;
}
show_sort_indicator (flist, column, list_view->details->sort_reversed);
fm_directory_view_sort (FM_DIRECTORY_VIEW (list_view),
sort_type,
list_view->details->sort_reversed);
fm_directory_view_list_sort_items (list_view, column, reversed);
}
......@@ -354,19 +328,11 @@ create_flist (FMDirectoryViewList *list_view)
gtk_container_add (GTK_CONTAINER (list_view), GTK_WIDGET (flist));
gtk_widget_show (GTK_WIDGET (flist));
fm_directory_view_populate (FM_DIRECTORY_VIEW (list_view));
return flist;
}
/* FIXME - this code was cut and pasted from fm-directory-view-list.c */
static void
flist_activate_cb (GtkFList *flist,
gpointer entry_data,
......@@ -494,6 +460,52 @@ fm_directory_view_list_get_selection (FMDirectoryView *view)
return gtk_flist_get_selection (get_flist (FM_DIRECTORY_VIEW_LIST (view)));
}
static void
fm_directory_view_list_sort_items (FMDirectoryViewList *list_view,
int column,
gboolean reversed)
{
FMDirectoryViewSortType sort_type;
GtkFList *flist;
g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (list_view));
flist = get_flist (list_view);
switch (column)
{
case LIST_VIEW_COLUMN_ICON:
sort_type = FM_DIRECTORY_VIEW_SORT_BYTYPE;
break;
case LIST_VIEW_COLUMN_NAME:
sort_type = FM_DIRECTORY_VIEW_SORT_BYNAME;
break;
case LIST_VIEW_COLUMN_SIZE:
sort_type = FM_DIRECTORY_VIEW_SORT_BYSIZE;
break;
case LIST_VIEW_COLUMN_DATE_MODIFIED:
sort_type = FM_DIRECTORY_VIEW_SORT_BYMTIME;
break;
case LIST_VIEW_COLUMN_MIME_TYPE:
sort_type = FM_DIRECTORY_VIEW_SORT_BYTYPE;
break;
default:
g_assert_not_reached();
sort_type = FM_DIRECTORY_VIEW_SORT_NONE;
break;
}
hide_sort_indicator (flist, list_view->details->sort_column);
list_view->details->sort_column = column;
list_view->details->sort_reversed = reversed;
show_sort_indicator (flist, column, reversed);
fm_directory_view_sort (FM_DIRECTORY_VIEW (list_view),
sort_type,
reversed);
}
static void
fm_directory_view_list_background_changed_cb (NautilusBackground *background,
FMDirectoryViewList *list_view)
......
......@@ -92,6 +92,7 @@ static void stop_location_change_cb (NautilusViewFrame *view_frame,
static void notify_location_change_cb (NautilusViewFrame *view_frame,
Nautilus_NavigationInfo *nav_context,
FMDirectoryView *directory_view);
static void fm_directory_view_repopulate (FMDirectoryView *view);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_entry)
......@@ -359,15 +360,15 @@ stop_load (FMDirectoryView *view, gboolean error)
/**
* fm_directory_view_populate:
* fm_directory_view_repopulate:
*
* Fill view with entries for current location, after emptying any old contents.
* This is normally called only by FMDirectoryView and subclasses.
* Fill view with already-discovered entries for current location, after emptying
* any old contents. This is normally called only by FMDirectoryView.
* @view: FMDirectoryView to fill.
*
**/
void
fm_directory_view_populate (FMDirectoryView *view)
static void
fm_directory_view_repopulate (FMDirectoryView *view)
{
g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
......@@ -967,7 +968,7 @@ fm_directory_view_sort (FMDirectoryView *view,
gnome_vfs_directory_list_sort (view->details->directory_list, reverse_sort, rules);
fm_directory_view_populate (view);
fm_directory_view_repopulate (view);
#undef ALLOC_RULES
}
......@@ -137,7 +137,6 @@ void fm_directory_view_begin_loading (FMDirector
void fm_directory_view_activate_entry (FMDirectoryView *view,
NautilusFile *file);
void fm_directory_view_notify_selection_changed (FMDirectoryView *view);
void fm_directory_view_populate (FMDirectoryView *view);
NautilusDirectory * fm_directory_view_get_model (FMDirectoryView *view);
void fm_directory_view_popup_background_context_menu (FMDirectoryView *view);
void fm_directory_view_popup_item_context_menu (FMDirectoryView *view,
......
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