[Patch] Interactive search (aka typeahead) enhancement patch



The patch aims to add the imo remaining nautilus search bits, an
explanation of the patch and its motivation is in bugzilla comment [1],
the patch has an strange issue with the gtktreeview typeahead that only
works for the first time.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=325086

? depcomp
? stamp-h1
? cut-n-paste-code/gsequence/.deps
? cut-n-paste-code/gsequence/.libs
? cut-n-paste-code/gsequence/gsequence.lo
? cut-n-paste-code/gsequence/libgsequence.la
? cut-n-paste-code/libegg/.deps
? cut-n-paste-code/libegg/.libs
? cut-n-paste-code/libegg/egg-recent-item.lo
? cut-n-paste-code/libegg/egg-recent-model.lo
? cut-n-paste-code/libegg/eggtreemultidnd.lo
? cut-n-paste-code/libegg/libegg.la
? libbackground/.deps
? libbackground/.libs
? libbackground/applier.lo
? libbackground/libbackground.la
? libbackground/preferences.lo
? libnautilus-private/.nautilus-icon-container.c.swp
? po/.intltool-merge-cache
? src/.nautilus-spatial-window.c.swp
? src/.nautilus-spatial-window.h.swp
? src/file-manager/.fm-list-view.c.swp
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.406
diff -p -u -r1.406 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	12 Dec 2005 16:59:10 -0000	1.406
+++ libnautilus-private/nautilus-icon-container.c	19 Jan 2006 22:38:49 -0000
@@ -53,6 +53,7 @@
 #include <libgnome/gnome-i18n.h>
 #include <libgnome/gnome-macros.h>
 #include <stdio.h>
+#define _GNU_SOURCE
 #include <string.h>
 
 #define TAB_NAVIGATION_DISABLED
@@ -147,6 +148,8 @@ typedef struct {
 	char *action_descriptions[LAST_ACTION];
 } NautilusIconContainerAccessiblePrivate;
 
+char *strcasestr (const char *haystack, const char *needle);
+
 static GType         nautilus_icon_container_accessible_get_type (void);
 
 static void          activate_selected_items                        (NautilusIconContainer *container);
@@ -3861,8 +3864,7 @@ nautilus_icon_container_search_iter (Nau
 			continue;
 		}
 		
-		if (strncmp (case_normalized_key, case_normalized_name,
-			     strlen (case_normalized_key)) == 0) {
+		if (strcasestr (case_normalized_name, case_normalized_key)) {
 			count++;
 		}
 
Index: src/nautilus-spatial-window-ui.xml
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window-ui.xml,v
retrieving revision 1.16
diff -p -u -r1.16 nautilus-spatial-window-ui.xml
--- src/nautilus-spatial-window-ui.xml	12 Dec 2005 16:59:11 -0000	1.16
+++ src/nautilus-spatial-window-ui.xml	19 Jan 2006 22:38:49 -0000
@@ -10,6 +10,11 @@
 			<menuitem name="Close All Folders" action="Close All Folders"/>
 		</placeholder>
 	</menu>
+	<menu action="Edit">
+		<placeholder name="Select Items">
+			<menuitem name="Find" action="Interactive Search"/>
+		</placeholder>
+	</menu>
         <placeholder name="Other Menus">
 	        <menu action="Places">
 		      <menuitem name="Home" action="Home"/>
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.454
diff -p -u -r1.454 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	12 Dec 2005 16:59:11 -0000	1.454
+++ src/nautilus-spatial-window.c	19 Jan 2006 22:38:50 -0000
@@ -28,6 +28,8 @@
 /* nautilus-window.c: Implementation of the main window object */
 
 #include <config.h>
+#include "file-manager/fm-list-view.h"
+#include "file-manager/fm-icon-view.h"
 #include "nautilus-spatial-window.h"
 #include "nautilus-window-private.h"
 #include "nautilus-window-bookmarks.h"
@@ -319,6 +321,33 @@ action_close_all_folders_callback (GtkAc
 	nautilus_application_close_all_spatial_windows ();
 }
 
+void
+action_interactive_search_spatial_callback (GtkAction *action,
+					    gpointer   user_data)
+{	
+	NautilusWindow *window;
+	window = NAUTILUS_WINDOW (user_data);
+
+	if (FM_IS_ICON_VIEW (window->content_view)) {
+		NautilusIconContainer  *icon_container;
+		gboolean ret;
+		icon_container = NAUTILUS_ICON_CONTAINER (GTK_BIN (FM_ICON_VIEW (window->content_view))->child);
+		
+		ret = EEL_CALL_METHOD_WITH_RETURN_VALUE
+		(NAUTILUS_ICON_CONTAINER_CLASS, icon_container,
+		 start_interactive_search, (icon_container));
+
+	} else if (FM_IS_LIST_VIEW (window->content_view)) {
+		FMListView *listview;
+		listview = FM_LIST_VIEW (window->content_view);
+		
+		EEL_CALL_METHOD
+		(FM_LIST_VIEW_CLASS, listview,
+		 starti_interactive_search, (listview));
+	}
+	
+}
+
 static void
 real_prompt_for_location (NautilusWindow *window,
 			  const char     *initial)
@@ -849,6 +878,9 @@ static const GtkActionEntry spatial_entr
   { "Search", "gtk-find", N_("_Search"), /* name, stock id, label */
     "<control>F", N_("Search for files"),
     G_CALLBACK (action_search_callback) },
+  { "Interactive Search", GTK_STOCK_FIND, N_("_Find in this folder"),
+    "<control>G", N_("Find files in this folder"),
+    G_CALLBACK (action_interactive_search_spatial_callback) },
 };
 
 static void
Index: src/nautilus-spatial-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.h,v
retrieving revision 1.113
diff -p -u -r1.113 nautilus-spatial-window.h
--- src/nautilus-spatial-window.h	11 Jul 2005 10:23:57 -0000	1.113
+++ src/nautilus-spatial-window.h	19 Jan 2006 22:38:50 -0000
@@ -63,6 +63,8 @@ void             nautilus_spatial_window
 void             nautilus_spatial_window_save_show_hidden_files_mode	(NautilusSpatialWindow *window);
 void             nautilus_spatial_window_set_location_button		(NautilusSpatialWindow *window,
 									 const char            *location);
+void             action_interactive_search_spatial_callback		(GtkAction *action, 
+									 gpointer  user_data);
 
 
 #endif
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.263
diff -p -u -r1.263 fm-list-view.c
--- src/file-manager/fm-list-view.c	12 Dec 2005 16:59:11 -0000	1.263
+++ src/file-manager/fm-list-view.c	19 Jan 2006 22:38:53 -0000
@@ -28,6 +28,7 @@
 #include <config.h>
 #include "fm-list-view.h"
 
+#define _GNU_SOURCE
 #include <string.h>
 #include "fm-error-reporting.h"
 #include "fm-list-model.h"
@@ -135,6 +136,13 @@ static NautilusZoomLevel        default_
 static GList *                  default_visible_columns_auto_value;
 static GList *                  default_column_order_auto_value;
 
+char *strcasestr (const char *haystack, const char *needle);
+static gboolean interactive_search_equal_func (GtkTreeModel  *model,
+						gint 		column,
+						const gchar	*key,
+						GtkTreeIter	*iter,
+						gpointer	search_data);
+static void   fm_list_view_start_interactive_search	    (FMListView   *view);
 static GList *fm_list_view_get_selection                   (FMDirectoryView   *view);
 static GList *fm_list_view_get_selection_for_file_transfer (FMDirectoryView   *view);
 static void   fm_list_view_set_zoom_level                  (FMListView        *view,
@@ -236,6 +244,37 @@ button_event_modifies_selection (GdkEven
 	return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
 }
 
+static gboolean
+interactive_search_equal_func (GtkTreeModel  *model,
+				gint 		column,
+				const gchar	*key,
+				GtkTreeIter	*iter,
+				gpointer	search_data)
+{
+    gchar *list_key = NULL;
+    
+    gtk_tree_model_get (model, 	iter,
+    			column, &list_key,
+                    	-1);
+
+    return strcasestr (list_key, key) == NULL; 
+}
+
+static void
+fm_list_view_start_interactive_search (FMListView *view)
+{
+	GtkTreeView *tv;
+	gboolean ret;
+
+	tv = view->details->tree_view;
+
+	gtk_tree_view_set_search_equal_func (tv, interactive_search_equal_func, NULL, NULL);
+
+	ret = EEL_CALL_METHOD_WITH_RETURN_VALUE
+	(GTK_TREE_VIEW_CLASS, tv,
+	start_interactive_search, (tv));
+}
+
 static void
 fm_list_view_did_not_drag (FMListView *view,
 			   GdkEventButton *event)
@@ -2469,6 +2508,8 @@ fm_list_view_class_init (FMListViewClass
 	G_OBJECT_CLASS (class)->dispose = fm_list_view_dispose;
 	G_OBJECT_CLASS (class)->finalize = fm_list_view_finalize;
 
+	class->start_interactive_search = fm_list_view_start_interactive_search;
+	
 	fm_directory_view_class->add_file = fm_list_view_add_file;
 	fm_directory_view_class->begin_loading = fm_list_view_begin_loading;
 	fm_directory_view_class->bump_zoom_level = fm_list_view_bump_zoom_level;
Index: src/file-manager/fm-list-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.h,v
retrieving revision 1.12
diff -p -u -r1.12 fm-list-view.h
--- src/file-manager/fm-list-view.h	22 Nov 2004 15:24:38 -0000	1.12
+++ src/file-manager/fm-list-view.h	19 Jan 2006 22:38:53 -0000
@@ -46,6 +46,9 @@ typedef struct {
 
 typedef struct {
 	FMDirectoryViewClass parent_class;
+
+	/* Pops up the interactive search dialog */
+        void    (* start_interactive_search)       (FMListView *view);
 } FMListViewClass;
 
 GType fm_list_view_get_type (void);


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