Re: [Patch] Interactive search (aka typeahead) enhancement patch



On Fri, 2006-01-20 at 21:30 +0000, Nelson Benítez wrote:
> Nelson Benítez wrote:
> > 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
> 
> New patch, I could solve the strange issue I was having, see the
> bugzilla comment[2] for details, I have attach it also to this email.
> 
> [2] http://bugzilla.gnome.org/show_bug.cgi?id=325086#c3

This is sort of cool IMHO. What do other people think of it? Will people
be confused with this form of typeahead?

Sometimes when i switch from icon to list view the "normal" typeahead
seems to only match at the start of the name.

Comments on the code:

@@ -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++;
 		}


This is already case insensitive due to the case normalization!
strcasestr is a locale-specific function that is absolutely wrong to use
here.

 void
+action_interactive_search_spatial_callback (GtkAction *action,
+					    gpointer   user_data)

You shouldn't special case views like this in the generic code. If you
need to, add new view methods.

+  { "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) },

control G is typically "find next". I'm not sure if its the best to use
in this case.
 
+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; 
+}

strcasestr is a locale specific call, not utf8 call so its totally wrong here.
g_utf8_casefold is be a better approach.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a scrappy gay filmmaker with a mysterious suitcase handcuffed to his arm. 
She's a strong-willed bisexual vampire in the witness protection program. They 
fight crime! 




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