[PATCH] New incarnation of filtering mode patch



Hi!,
do you remember the cool filtering patch[1] from Diego and the thread[2]
about it ? well, I've been working on a new incarnation of it that
incorporates the right approach[3] we commented about on the thread. I
like very much the final result of this patch.

I made a small webpage with the patches and a cool screencast for those
who can't test the patch, see it here:
http://supertux.cenobioracing.com/nautilus.html

I made the screencast with the largest directory I had (/usr/bin 1353
files) so you see the good performance of this (the initial delay when
loading /usr/bin is not related to my patch :)..)

As Diego's patch, this works, at the moment, only in spatial window, if
people agreed on the patch then the navigation window would be the next.


[1]http://www.es.gnome.org/~diego/
[2]http://mail.gnome.org/archives/nautilus-list/2005-April/msg00136.html
[3]http://mail.gnome.org/archives/nautilus-list/2005-April/msg00208.html
diff -pruN nautilus/libnautilus-private/nautilus-file.c nautilus1/libnautilus-private/nautilus-file.c
--- nautilus/libnautilus-private/nautilus-file.c	2005-10-20 15:22:12.000000000 +0000
+++ nautilus1/libnautilus-private/nautilus-file.c	2005-11-07 00:16:39.000000000 +0000
@@ -2114,7 +2114,8 @@ compare_by_full_path (NautilusFile *file
 static int
 nautilus_file_compare_for_sort_internal (NautilusFile *file_1,
 					 NautilusFile *file_2,
-					 gboolean directories_first)
+					 gboolean directories_first,
+					 gboolean reversed)
 {
 	int compare;
 	GnomeVFSDrive *drive1, *drive2;
@@ -2122,6 +2123,19 @@ nautilus_file_compare_for_sort_internal 
 
 	gboolean is_directory_1, is_directory_2;
 
+	/* Findbar matched results are in the first positions (even with reversed)  */
+	if (file_1->details->matched != file_2->details->matched) {
+		if (file_1->details->matched)
+			compare = -1;
+		else
+			compare = 1;
+		
+		if (reversed)
+			compare *= -1;
+		
+		return compare;	
+	}
+	
 	if (directories_first) {
 		is_directory_1 = nautilus_file_is_directory (file_1);
 		is_directory_2 = nautilus_file_is_directory (file_2);
@@ -2199,7 +2213,7 @@ nautilus_file_compare_for_sort (Nautilus
 		return 0;
 	}
 	
-	result = nautilus_file_compare_for_sort_internal (file_1, file_2, directories_first);
+	result = nautilus_file_compare_for_sort_internal (file_1, file_2, directories_first, reversed);
 	
 	if (result == 0) {
 		switch (sort_type) {
@@ -2303,7 +2317,7 @@ nautilus_file_compare_for_sort_by_attrib
 	
 	/* it is a normal attribute, compare by strings */
 
-	result = nautilus_file_compare_for_sort_internal (file_1, file_2, directories_first);
+	result = nautilus_file_compare_for_sort_internal (file_1, file_2, directories_first, reversed);
 	
 	if (result == 0) {
 		char *value_1;
@@ -2367,6 +2381,11 @@ nautilus_file_is_backup_file (NautilusFi
 		(file->details->relative_uri);
 }
 
+gboolean nautilus_file_is_matched_file (NautilusFile *file)
+{
+	return file->details->matched;
+}
+
 static gboolean
 is_file_hidden (NautilusFile *file)
 {
diff -pruN nautilus/libnautilus-private/nautilus-file.h nautilus1/libnautilus-private/nautilus-file.h
--- nautilus/libnautilus-private/nautilus-file.h	2005-10-20 15:22:12.000000000 +0000
+++ nautilus1/libnautilus-private/nautilus-file.h	2005-11-07 00:16:39.000000000 +0000
@@ -305,6 +305,7 @@ int                     nautilus_file_co
 /* filtering functions for use by various directory views */
 gboolean                nautilus_file_is_hidden_file                    (NautilusFile                   *file);
 gboolean                nautilus_file_is_backup_file                    (NautilusFile                   *file);
+gboolean                nautilus_file_is_matched_file                   (NautilusFile                   *file);
 gboolean                nautilus_file_should_show                       (NautilusFile                   *file,
 									 gboolean                        show_hidden,
 									 gboolean                        show_backup);
diff -pruN nautilus/libnautilus-private/nautilus-file-private.h nautilus1/libnautilus-private/nautilus-file-private.h
--- nautilus/libnautilus-private/nautilus-file-private.h	2005-09-06 15:12:46.000000000 +0000
+++ nautilus1/libnautilus-private/nautilus-file-private.h	2005-11-07 00:16:39.000000000 +0000
@@ -147,6 +147,9 @@ struct NautilusFileDetails
 
 	/* TRUE if the file is open in a spatial window */
 	eel_boolean_bit has_open_window               : 1;
+	
+	/* Following used by find bar */
+	eel_boolean_bit matched                       : 1;
 };
 
 NautilusFile *nautilus_file_new_from_info                  (NautilusDirectory      *directory,
diff -pruN nautilus/libnautilus-private/nautilus-view.c nautilus1/libnautilus-private/nautilus-view.c
--- nautilus/libnautilus-private/nautilus-view.c	2005-05-17 13:27:29.000000000 +0000
+++ nautilus1/libnautilus-private/nautilus-view.c	2005-11-07 00:16:39.000000000 +0000
@@ -260,3 +260,13 @@ nautilus_view_pop_up_location_context_me
 		(* NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu) (view, event);
 	}
 }
+
+void
+nautilus_view_filter (NautilusView *view, const char *pattern, guint case_sensitive)
+{
+	g_return_if_fail (NAUTILUS_IS_VIEW (view));
+
+	if (NAUTILUS_VIEW_GET_IFACE (view)->filter != NULL) {
+		return (* NAUTILUS_VIEW_GET_IFACE (view)->filter) (view, pattern, case_sensitive);
+	}
+}
diff -pruN nautilus/libnautilus-private/nautilus-view.h nautilus1/libnautilus-private/nautilus-view.h
--- nautilus/libnautilus-private/nautilus-view.h	2005-05-17 13:27:29.000000000 +0000
+++ nautilus1/libnautilus-private/nautilus-view.h	2005-11-07 00:16:39.000000000 +0000
@@ -106,6 +106,10 @@ struct _NautilusViewIface 
         gboolean       (* can_zoom_in)	 	  (NautilusView          *view);
         gboolean       (* can_zoom_out)	 	  (NautilusView          *view);
 
+	void	       (* filter)		  (NautilusView		 *view,
+						   const char		 *pattern,
+						   const guint		  case_sensitive);
+
 	/* Request popup of context menu referring to the open location.
 	 * This is triggered in spatial windows by right-clicking the location button,
 	 * in navigational windows by right-clicking the "Location:" label in the
@@ -149,6 +153,10 @@ void              nautilus_view_restore_
 gboolean          nautilus_view_can_zoom_in                (NautilusView      *view);
 gboolean          nautilus_view_can_zoom_out               (NautilusView      *view);
 NautilusZoomLevel nautilus_view_get_zoom_level             (NautilusView      *view);
+void		  nautilus_view_filter			   (NautilusView      *view,
+							    const char	      *pattern,
+							    const guint	       case_sensitive);
+
 void              nautilus_view_pop_up_location_context_menu (NautilusView    *view,
 							      GdkEventButton  *event);
 
diff -pruN nautilus/src/file-manager/fm-directory-view.c nautilus1/src/file-manager/fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c	2005-10-21 14:44:50.000000000 +0000
+++ nautilus1/src/file-manager/fm-directory-view.c	2005-11-07 00:16:39.000000000 +0000
@@ -31,7 +31,10 @@
 #include <math.h>
 #include "fm-directory-view.h"
 #include "fm-list-view.h"
+#include "fm-list-model.h"
 #include "fm-desktop-icon-view.h"
+#define __USE_GNU
+#include <string.h>
 
 #include "fm-actions.h"
 #include "fm-error-reporting.h"
@@ -1627,6 +1630,8 @@ fm_directory_view_init_view_iface (Nauti
         iface->can_zoom_out = (gpointer)fm_directory_view_can_zoom_out;
 	iface->get_zoom_level = (gpointer)fm_directory_view_get_zoom_level;
 
+	iface->filter = (gpointer)fm_directory_view_filter;
+
 	iface->pop_up_location_context_menu = (gpointer)fm_directory_view_pop_up_location_context_menu;
 }
 
@@ -2900,6 +2905,86 @@ fm_directory_view_end_loading (FMDirecto
 }
 
 /**
+ * fm_directory_view_filter:
+ *
+ * Re-sorts the current view according to matched files and selects them.
+ **/
+
+void
+fm_directory_view_filter (FMDirectoryView *view, const char *pattern, guint case_sensitive)
+{
+	GList *files, *tmp, *files_matched = NULL;
+	char * (*filter_func) (const char *, const char *);
+
+	files = nautilus_directory_get_file_list (view->details->model);
+	fm_directory_view_set_selection (view, NULL);
+
+	if (case_sensitive)
+		filter_func = strstr;
+	else
+		filter_func = strcasestr;
+		
+	for (tmp = files; tmp; tmp = tmp->next) {
+		NautilusFile *file;
+		char *name;
+
+		file = NAUTILUS_FILE (tmp->data);
+		name = nautilus_file_get_display_name (file);
+
+		if (fm_directory_view_should_show_file (view, file)) {
+			if (filter_func (name, pattern)) {
+				file->details->matched = TRUE; 
+				files_matched = g_list_prepend (files_matched, file);
+			} else {
+				file->details->matched = FALSE;
+			}
+		}
+		
+		g_free(name);
+	}
+	
+	if (FM_IS_ICON_VIEW (view)) {
+		// Sort the icon view
+		NautilusIconContainer  *icon_container;
+		icon_container = NAUTILUS_ICON_CONTAINER (GTK_BIN (FM_ICON_VIEW (view))->child);
+		nautilus_icon_container_sort (icon_container);
+
+	} else if (FM_IS_LIST_VIEW (view)) {
+		// Sort the list view
+		fm_list_view_sort_model (FM_LIST_VIEW (view));
+	}
+
+	if (strcmp(pattern,""))
+		fm_directory_view_set_selection (view, files_matched);
+	else
+		schedule_update_status (view); //update status bar
+	
+	//Move scrollbar to begining of the view
+	GtkAdjustment *adj;
+	adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (view));
+	if (gtk_adjustment_get_value (adj) != 0) {
+		gtk_adjustment_set_value (adj, 0);
+		gtk_adjustment_value_changed (adj);
+	}
+	
+	g_list_free (files);
+	g_list_free (files_matched);
+}
+
+void
+fm_directory_view_clean_matched_files (NautilusView *view) {
+	GList *files, *tmp;
+	FMDirectoryView *dir_view;
+	dir_view = FM_DIRECTORY_VIEW (view);
+	files = nautilus_directory_get_file_list (dir_view->details->model);
+	for (tmp = files; tmp; tmp = tmp->next) {
+		if ((NAUTILUS_FILE (tmp->data))->details->matched)
+			(NAUTILUS_FILE (tmp->data))->details->matched = FALSE;
+	}
+	
+	g_list_free (files);
+}
+/**
  * fm_directory_view_bump_zoom_level:
  *
  * bump the current zoom level by invoking the relevant subclass through the slot
diff -pruN nautilus/src/file-manager/fm-directory-view.h nautilus1/src/file-manager/fm-directory-view.h
--- nautilus/src/file-manager/fm-directory-view.h	2005-07-05 12:23:35.000000000 +0000
+++ nautilus1/src/file-manager/fm-directory-view.h	2005-11-07 00:16:39.000000000 +0000
@@ -345,6 +345,12 @@ void                fm_directory_view_mo
 									int               x,
 									int               y,
 									FMDirectoryView  *view);
+void		    fm_directory_view_filter			       (FMDirectoryView  *view,
+									const char       *pattern,
+									const guint	  case_sensitive);
+
+void		    fm_directory_view_clean_matched_files	       (NautilusView *view);
+
 
 /* Wrappers for signal emitters. These are normally called 
  * only by FMDirectoryView itself. They have corresponding signals
diff -pruN nautilus/src/file-manager/fm-list-model.c nautilus1/src/file-manager/fm-list-model.c
--- nautilus/src/file-manager/fm-list-model.c	2005-10-17 17:43:57.000000000 +0000
+++ nautilus1/src/file-manager/fm-list-model.c	2005-11-07 00:16:39.000000000 +0000
@@ -641,6 +641,10 @@ fm_list_model_sort (FMListModel *model)
 	gtk_tree_path_free (path);
 }
 
+void fm_list_model_do_sort (FMListModel *model) {
+	fm_list_model_sort (model);
+}
+
 void
 fm_list_model_sort_files (FMListModel *model, GList **files)
 {
diff -pruN nautilus/src/file-manager/fm-list-model.h nautilus1/src/file-manager/fm-list-model.h
--- nautilus/src/file-manager/fm-list-model.h	2005-06-16 13:43:15.000000000 +0000
+++ nautilus1/src/file-manager/fm-list-model.h	2005-11-07 00:16:39.000000000 +0000
@@ -98,6 +98,8 @@ char    *fm_list_model_get_attribute_fro
 void     fm_list_model_sort_files (FMListModel *model,
 							  GList **files);
 
+void	fm_list_model_do_sort (FMListModel *model);
+
 NautilusZoomLevel fm_list_model_get_zoom_level_from_column_id (int               column);
 int               fm_list_model_get_column_id_from_zoom_level (NautilusZoomLevel zoom_level);
 NautilusZoomLevel fm_list_model_get_zoom_level_from_emblem_column_id (int               column);
diff -pruN nautilus/src/file-manager/fm-list-view.c nautilus1/src/file-manager/fm-list-view.c
--- nautilus/src/file-manager/fm-list-view.c	2005-10-19 18:03:24.000000000 +0000
+++ nautilus1/src/file-manager/fm-list-view.c	2005-11-07 00:16:39.000000000 +0000
@@ -2498,6 +2498,11 @@ fm_list_view_class_init (FMListViewClass
 					       (const GList **) &default_column_order_auto_value);
 }
 
+void fm_list_view_sort_model (FMListView *view)
+{	
+		fm_list_model_do_sort (view->details->model);
+}
+
 static const char *
 fm_list_view_get_id (NautilusView *view)
 {
diff -pruN nautilus/src/nautilus-spatial-window.c nautilus1/src/nautilus-spatial-window.c
--- nautilus/src/nautilus-spatial-window.c	2005-10-19 17:53:06.000000000 +0000
+++ nautilus1/src/nautilus-spatial-window.c	2005-11-07 00:16:39.000000000 +0000
@@ -92,12 +92,23 @@ struct _NautilusSpatialWindowDetails {
         GtkActionGroup *spatial_action_group; /* owned by ui_manager */
 	char *last_geometry;	
         guint save_geometry_timeout_id;	  
+	guint filter_timeout_id;
 	
 	GtkWidget *content_box;
 	GtkWidget *location_button;
 	GtkWidget *location_label;
 	GtkWidget *location_icon;
 
+	GtkWidget *filter_box;
+	GtkWidget *filter_entry;
+	GtkWidget *filter_label;
+	GtkWidget *filter_close_button;
+	GtkWidget *filter_case;
+	GtkWidget *filter_button;
+
+	guint      filter_bar_showing;
+	guint 	   filter_case_sensitive;
+
 	GnomeVFSURI *location;
 };
 
@@ -244,6 +255,7 @@ void
 nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window)
 {
 	NautilusWindow *parent;
+	NautilusFile *file;
 	char *scroll_string;
 
 	parent = NAUTILUS_WINDOW(window);
@@ -253,6 +265,13 @@ nautilus_spatial_window_save_scroll_posi
 	}
 	
 	scroll_string = nautilus_view_get_first_visible_file (parent->content_view);
+	file = nautilus_file_get (scroll_string);
+	if (NAUTILUS_IS_FILE(file)) {
+		if (nautilus_file_is_matched_file(file)) {
+			g_free (scroll_string);
+			scroll_string = g_strdup ("");
+		}
+	}
 	nautilus_file_set_metadata (parent->details->viewed_file,
 				    NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION,
 				    NULL,
@@ -305,6 +324,18 @@ action_close_all_folders_callback (GtkAc
 }
 
 static void
+action_filter_spatial_callback (GtkAction *action,
+				gpointer   user_data)
+{
+	NautilusSpatialWindow *window;
+	GtkToggleButton *button;
+
+	window = NAUTILUS_SPATIAL_WINDOW (user_data);
+	button = GTK_TOGGLE_BUTTON (window->details->filter_button);
+	gtk_toggle_button_set_active (button, !gtk_toggle_button_get_active (button));
+}
+
+static void
 real_prompt_for_location (NautilusWindow *window,
 			  const char     *initial)
 {
@@ -361,9 +392,18 @@ real_set_content_view_widget (NautilusWi
 static void
 real_window_close (NautilusWindow *window)
 {
+	NautilusSpatialWindow *spatial;
+
 	nautilus_spatial_window_save_geometry (NAUTILUS_SPATIAL_WINDOW (window));
 	nautilus_spatial_window_save_scroll_position (NAUTILUS_SPATIAL_WINDOW (window));
 	nautilus_spatial_window_save_show_hidden_files_mode (NAUTILUS_SPATIAL_WINDOW (window));
+
+	/* Remove findbar matched results rests */
+	spatial = NAUTILUS_SPATIAL_WINDOW (window);
+	if (spatial->details->filter_bar_showing == TRUE) {
+		if (strcmp(gtk_entry_get_text (GTK_ENTRY (spatial->details->filter_entry)),""))
+			fm_directory_view_clean_matched_files (window->content_view);
+	}
 }
 
 static void 
@@ -746,6 +786,94 @@ action_edit_bookmarks_callback (GtkActio
         nautilus_window_edit_bookmarks (NAUTILUS_WINDOW (user_data));
 }
 
+static void
+filter_entry_real_filter (NautilusSpatialWindow *window)
+{
+	NautilusWindow *parent;
+	const char     *pattern;
+	guint           case_sensitive;
+
+	parent = NAUTILUS_WINDOW (window);
+	pattern = gtk_entry_get_text (GTK_ENTRY (window->details->filter_entry));
+	case_sensitive = window->details->filter_case_sensitive;
+
+	nautilus_view_filter (parent->content_view, pattern, case_sensitive);
+}
+
+static gboolean
+filter_entry_timeout_cb (NautilusSpatialWindow *window)
+{
+	window->details->filter_timeout_id = 0;
+	filter_entry_real_filter (window);
+
+	return FALSE;
+}
+
+static void
+set_spatial_window_filter_timeout (int miliseconds, NautilusSpatialWindow *window)
+{
+	if (window->details->filter_timeout_id)
+		g_source_remove (window->details->filter_timeout_id);
+
+	window->details->filter_timeout_id =
+		g_timeout_add (miliseconds, (GSourceFunc) filter_entry_timeout_cb, window);
+}
+
+static void
+filter_entry_changed_cb (GtkEntry *entry, NautilusSpatialWindow *window)
+{
+	set_spatial_window_filter_timeout (300, window);
+}
+
+static void
+filter_case_changed_cb (GtkToggleButton *button, NautilusSpatialWindow *window)
+{
+	if (window->details->filter_case_sensitive == FALSE)
+		window->details->filter_case_sensitive = TRUE;
+	else
+		window->details->filter_case_sensitive = FALSE;
+	
+	set_spatial_window_filter_timeout (150, window);
+}
+
+static void
+filter_toggle_button_cb (GtkToggleButton *button, NautilusSpatialWindow *window)
+{
+	/* Don't show the filtering bar on the desktop */
+	if (NAUTILUS_IS_DESKTOP_WINDOW (window))
+	   return;
+
+	if (window->details->filter_bar_showing == FALSE) {
+	   gtk_widget_show (window->details->filter_box);
+	   gtk_widget_grab_focus (window->details->filter_entry);
+	   window->details->filter_bar_showing = TRUE;
+	} else {
+	   gtk_widget_hide (window->details->filter_box);
+	   gtk_widget_grab_focus (window->details->content_box);
+	   gtk_entry_set_text (GTK_ENTRY (window->details->filter_entry), "");
+	   window->details->filter_bar_showing = FALSE;
+	}
+}
+
+static void
+filter_close_button_clicked (GtkButton *button, NautilusSpatialWindow *window)
+{
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (window->details->filter_button), FALSE);
+}
+
+static gint
+filter_entry_key_press_cb (GtkWidget *widget, GdkEventKey *event, NautilusSpatialWindow *window)
+{
+	switch (event->keyval) {
+		case GDK_Return:
+ 		case GDK_KP_Enter:
+			set_spatial_window_filter_timeout (150, window);
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
 static const GtkActionEntry spatial_entries[] = {
   { SPATIAL_ACTION_PLACES, NULL, N_("_Places") },               /* name, stock id, label */
   { SPATIAL_ACTION_GO_TO_LOCATION, NULL, N_("Open _Location..."), /* name, stock id, label */
@@ -763,6 +891,9 @@ static const GtkActionEntry spatial_entr
   { "Edit Bookmarks", NULL, N_("_Edit Bookmarks"), /* name, stock id, label */
     "<control>b", N_("Display a window that allows editing the bookmarks in this menu"),
     G_CALLBACK (action_edit_bookmarks_callback) },
+  { "Filter", GTK_STOCK_FIND, N_("_Find"),
+  "<control>G", N_("Find files in this window"),
+  G_CALLBACK (action_filter_spatial_callback) },
 };
 
 static void
@@ -775,12 +906,15 @@ nautilus_spatial_window_instance_init (N
 	GtkUIManager *ui_manager;
 	GtkTargetList *targets;
 	const char *ui;
+	GtkWidget *filter_icon;
+	GtkAction *action;
+	GtkWidget *close_icon;
 	
 	window->details = g_new0 (NautilusSpatialWindowDetails, 1);
 	window->affect_spatial_window_on_next_location_change = TRUE;
 
 	window->details->content_box = 
-		gtk_hbox_new (FALSE, 0);
+		gtk_vbox_new (FALSE, 0);
 	gtk_table_attach (GTK_TABLE (NAUTILUS_WINDOW (window)->details->table),
 			  window->details->content_box,
 			  /* X direction */                   /* Y direction */
@@ -789,6 +923,7 @@ nautilus_spatial_window_instance_init (N
 			  0,                                  0);
 	gtk_widget_show (window->details->content_box);
 
+	/* Setup status bar */
 	window->details->location_button = gtk_button_new ();
 	g_signal_connect (window->details->location_button,
 			  "button-press-event",
@@ -854,7 +989,78 @@ nautilus_spatial_window_instance_init (N
 	gtk_action_group_add_actions (action_group, 
 				      spatial_entries, G_N_ELEMENTS (spatial_entries),
 				      window);
+
+	/* Find button */
+	window->details->filter_button = gtk_toggle_button_new ();
+	filter_icon = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
+	gtk_container_add (GTK_CONTAINER (window->details->filter_button),
+			   filter_icon);
+	g_signal_connect (window->details->filter_button, "toggled",
+			  G_CALLBACK (filter_toggle_button_cb),
+			  window);
+	gtk_widget_show (filter_icon);
+	
+	gtk_box_pack_start (GTK_BOX (NAUTILUS_WINDOW (window)->details->statusbar),
+			    window->details->filter_button, FALSE, TRUE, 3);//0
+	gtk_box_reorder_child (GTK_BOX (NAUTILUS_WINDOW (window)->details->statusbar),
+			       window->details->filter_button, 1);
+	gtk_widget_show (window->details->filter_button);
+	
+	/* Setup filter bar */
+	window->details->filter_bar_showing = FALSE;
+	window->details->filter_box = gtk_hbox_new (FALSE, 6);
+	gtk_container_set_border_width (GTK_CONTAINER (window->details->filter_box), 1);//3
+	gtk_box_pack_end (GTK_BOX (window->details->content_box),
+			  window->details->filter_box,
+			  FALSE, TRUE, 0);
+
+	/* Filter bar - Close button */
+	window->details->filter_close_button = gtk_button_new ();
+	close_icon =  gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+	gtk_button_set_relief (GTK_BUTTON (window->details->filter_close_button), GTK_RELIEF_NONE);
+	gtk_container_add (GTK_CONTAINER (window->details->filter_close_button), close_icon);
+	g_signal_connect (window->details->filter_close_button, "clicked",
+			  G_CALLBACK (filter_close_button_clicked),
+			  window);
+	gtk_widget_show (close_icon);
+
+	gtk_box_pack_start (GTK_BOX(window->details->filter_box),
+			  window->details->filter_close_button,
+			  FALSE, FALSE, 0);
+
+	/* Filter bar - Find label and text entry */
+	window->details->filter_label = gtk_label_new (_("Find:"));
+	gtk_box_pack_start (GTK_BOX (window->details->filter_box),
+			    window->details->filter_label,
+			    FALSE, FALSE, 3); //0
+	gtk_widget_show (window->details->filter_label);
+
+	window->details->filter_entry = gtk_entry_new ();
+	gtk_box_pack_start (GTK_BOX (window->details->filter_box),
+			    window->details->filter_entry,
+			    FALSE, FALSE, 0);
+	g_signal_connect (window->details->filter_entry, "changed",
+			  G_CALLBACK (filter_entry_changed_cb),
+			  window);
+	g_signal_connect (G_OBJECT (window->details->filter_entry), "key_press_event",
+			  G_CALLBACK (filter_entry_key_press_cb),
+			  window);
+	gtk_widget_show (window->details->filter_entry);
 	
+	/* Filter bar - Case checkbutton */
+	window->details->filter_case = gtk_check_button_new_with_label (_("Case sensitive"));
+	gtk_box_pack_start (GTK_BOX (window->details->filter_box), 
+			    window->details->filter_case,
+			    FALSE, FALSE, 0);
+	g_signal_connect (window->details->filter_case, "toggled",
+			  G_CALLBACK (filter_case_changed_cb),
+			  window);
+                                                            
+	gtk_widget_show (window->details->filter_case);
+	gtk_widget_show (window->details->filter_close_button);
+
+
+	/* Setup UI Manager */
 	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
 	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
 	g_object_unref (action_group); /* owned by ui manager */
diff -pruN nautilus/src/nautilus-spatial-window-ui.xml nautilus1/src/nautilus-spatial-window-ui.xml
--- nautilus/src/nautilus-spatial-window-ui.xml	2005-06-23 14:16:58.000000000 +0000
+++ nautilus1/src/nautilus-spatial-window-ui.xml	2005-11-07 00:16:40.000000000 +0000
@@ -10,6 +10,12 @@
 			<menuitem name="Close All Folders" action="Close All Folders"/>
 		</placeholder>
 	</menu>
+   <menu action="Edit">
+      <placeholder name="Select Items">
+         <menuitem name="Find" action="Filter"/>
+      </placeholder>
+   </menu>
+
         <placeholder name="Other Menus">
 	        <menu action="Places">
 		      <menuitem name="Home" action="Home"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]